Bug 209852. Remove |dont_QueryInterface|.

r=dbaron, sr=jag
This commit is contained in:
caillon%returnzero.com 2003-06-21 00:15:41 +00:00
parent 008f94e6a2
commit 4cc64cee34
34 changed files with 49 additions and 84 deletions

View File

@ -803,7 +803,7 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
nsresult rv = NS_OK;
NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER);
mDeviceContext = dont_QueryInterface(aDeviceContext);
mDeviceContext = aDeviceContext;
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
// Clear PrintPreview Alternate Device

View File

@ -4929,7 +4929,7 @@ nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOf
nsresult result = NS_OK;
nsCOMPtr<nsIDOMNode> node = dont_QueryInterface(aNode);
nsCOMPtr<nsIDOMNode> node = aNode;
if (!node)
return NS_ERROR_NULL_POINTER;

View File

@ -4209,7 +4209,7 @@ nsXULElement::GetParentTree(nsIDOMXULMultiSelectControlElement** aTreeElement)
PRBool
nsXULElement::IsAncestor(nsIDOMNode* aParentNode, nsIDOMNode* aChildNode)
{
nsCOMPtr<nsIDOMNode> parent = dont_QueryInterface(aChildNode);
nsCOMPtr<nsIDOMNode> parent = aChildNode;
while (parent && (parent != aParentNode)) {
nsCOMPtr<nsIDOMNode> newParent;
parent->GetParentNode(getter_AddRefs(newParent));

View File

@ -1208,7 +1208,7 @@ XULContentSinkImpl::GetTopNameSpace(nsCOMPtr<nsINameSpace>* aNameSpace)
if (count == 0)
return NS_ERROR_UNEXPECTED;
*aNameSpace = dont_QueryInterface(NS_REINTERPRET_CAST(nsINameSpace*, mNameSpaceStack[count - 1]));
*aNameSpace = NS_REINTERPRET_CAST(nsINameSpace*, mNameSpaceStack[count - 1]);
return NS_OK;
}

View File

@ -1822,7 +1822,7 @@ nsXULDocument::GetTooltipNode(nsIDOMNode** aNode)
NS_IMETHODIMP
nsXULDocument::SetTooltipNode(nsIDOMNode* aNode)
{
mTooltipNode = dont_QueryInterface(aNode);
mTooltipNode = aNode;
return NS_OK;
}
@ -2695,7 +2695,7 @@ PRBool
nsXULDocument::ContextStack::IsInsideXULTemplate()
{
if (mDepth) {
nsCOMPtr<nsIContent> element = dont_QueryInterface(mTop->mElement);
nsCOMPtr<nsIContent> element = mTop->mElement;
while (element) {
PRInt32 nameSpaceID;
element->GetNameSpaceID(&nameSpaceID);

View File

@ -94,7 +94,7 @@ IsElementInBuilder(nsIContent *aContent, nsIXULTemplateBuilder *aBuilder)
if (! xuldoc)
return PR_FALSE;
nsCOMPtr<nsIContent> content = dont_QueryInterface(aContent);
nsCOMPtr<nsIContent> content = aContent;
do {
nsCOMPtr<nsIXULTemplateBuilder> builder;
xuldoc->GetTemplateBuilderFor(content, getter_AddRefs(builder));

View File

@ -311,7 +311,7 @@ nsresult InitializeWindowCreator()
WindowCreator *creatorCallback = new WindowCreator();
if (creatorCallback)
{
nsCOMPtr<nsIWindowCreator> windowCreator(dont_QueryInterface(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)));
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback));
if (windowCreator)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));

View File

@ -269,7 +269,7 @@ nsresult InitializeWindowCreator()
WindowCreator *creatorCallback = new WindowCreator();
if (creatorCallback)
{
nsCOMPtr<nsIWindowCreator> windowCreator(dont_QueryInterface(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)));
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback));
if (windowCreator)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));

View File

@ -293,7 +293,7 @@ nsresult InitializeWindowCreator()
WindowCreator *creatorCallback = new WindowCreator();
if (creatorCallback)
{
nsCOMPtr<nsIWindowCreator> windowCreator(dont_QueryInterface(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)));
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback));
if (windowCreator)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));

View File

@ -481,7 +481,7 @@ nsresult InitializeWindowCreator(WebShellInitContext * initContext)
gCreatorCallback = new WindowCreator(initContext);
if (gCreatorCallback)
{
nsCOMPtr<nsIWindowCreator> windowCreator(dont_QueryInterface(NS_STATIC_CAST(nsIWindowCreator *, gCreatorCallback)));
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, gCreatorCallback));
if (windowCreator)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));

View File

@ -803,7 +803,7 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
nsresult rv = NS_OK;
NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER);
mDeviceContext = dont_QueryInterface(aDeviceContext);
mDeviceContext = aDeviceContext;
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
// Clear PrintPreview Alternate Device

View File

@ -4929,7 +4929,7 @@ nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOf
nsresult result = NS_OK;
nsCOMPtr<nsIDOMNode> node = dont_QueryInterface(aNode);
nsCOMPtr<nsIDOMNode> node = aNode;
if (!node)
return NS_ERROR_NULL_POINTER;

View File

@ -1659,7 +1659,7 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent)
}
// Get our own content node and hold on to it to keep it from going away.
nsCOMPtr<nsIContent> content = dont_QueryInterface(mContent);
nsCOMPtr<nsIContent> content = mContent;
// Deselect ourselves.
SelectMenu(PR_FALSE);

View File

@ -104,9 +104,9 @@ nsCopyMessageStreamListener::~nsCopyMessageStreamListener()
NS_IMETHODIMP nsCopyMessageStreamListener::Init(nsIMsgFolder *srcFolder, nsICopyMessageListener *destination, nsISupports *listenerData)
{
mSrcFolder = dont_QueryInterface(srcFolder);
mDestination = dont_QueryInterface(destination);
mListenerData = dont_QueryInterface(listenerData);
mSrcFolder = srcFolder;
mDestination = destination;
mListenerData = listenerData;
return NS_OK;
}

View File

@ -184,7 +184,7 @@ nsMsgAccount::SetIncomingServer(nsIMsgIncomingServer * aIncomingServer)
m_prefs->SetCharPref(serverPrefName.get(), key);
}
m_incomingServer = dont_QueryInterface(aIncomingServer);
m_incomingServer = aIncomingServer;
nsCOMPtr<nsIMsgAccountManager> accountManager =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
@ -295,7 +295,7 @@ nsMsgAccount::SetDefaultIdentity(nsIMsgIdentity * aDefaultIdentity)
if (m_identities->IndexOf(aDefaultIdentity) == -1)
return NS_ERROR_UNEXPECTED;
m_defaultIdentity = dont_QueryInterface(aDefaultIdentity);
m_defaultIdentity = aDefaultIdentity;
return NS_OK;
}

View File

@ -879,8 +879,8 @@ nsMsgAccountManagerDataSource::createServerResources(nsISupports *element,
nsresult rv;
// get parameters out of the data argument
serverCreationParams *params = (serverCreationParams*)data;
nsCOMPtr<nsISupportsArray> servers = dont_QueryInterface(params->serverArray);
nsCOMPtr<nsIRDFService> rdf = dont_QueryInterface(params->rdfService);
nsCOMPtr<nsISupportsArray> servers = params->serverArray;
nsCOMPtr<nsIRDFService> rdf = params->rdfService;
// the server itself is in the element argument
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(element, &rv);

View File

@ -491,13 +491,13 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
nsresult nsMsgProtocol::SetUrl(nsIURI * aURL)
{
m_url = dont_QueryInterface(aURL);
m_url = aURL;
return NS_OK;
}
NS_IMETHODIMP nsMsgProtocol::SetLoadGroup(nsILoadGroup * aLoadGroup)
{
m_loadGroup = dont_QueryInterface(aLoadGroup);
m_loadGroup = aLoadGroup;
return NS_OK;
}

View File

@ -571,7 +571,7 @@ NS_IMETHODIMP nsSmtpUrl::SetPostMessageFile(nsIFileSpec * aFileSpec)
{
nsresult rv = NS_OK;
if (aFileSpec)
m_fileName = dont_QueryInterface(aFileSpec);
m_fileName = aFileSpec;
else
rv = NS_ERROR_NULL_POINTER;
@ -607,7 +607,7 @@ nsSmtpUrl::SetSenderIdentity(nsIMsgIdentity * aSenderIdentity)
{
NS_ENSURE_ARG_POINTER(aSenderIdentity);
m_senderIdentity = dont_QueryInterface(aSenderIdentity);
m_senderIdentity = aSenderIdentity;
return NS_OK;
}

View File

@ -478,7 +478,7 @@ nsresult nsImapProtocol::Initialize(nsIImapHostSessionList * aHostSessionList, n
NS_ADDREF(m_flagState);
m_sinkEventQueue = dont_QueryInterface(aSinkEventQueue);
m_sinkEventQueue = aSinkEventQueue;
m_hostSessionList = aHostSessionList; // no ref count...host session list has life time > connection
m_parser.SetHostSessionList(aHostSessionList);
m_parser.SetFlagState(m_flagState);
@ -7666,7 +7666,7 @@ NS_IMETHODIMP nsImapMockChannel::GetChannelContext(nsISupports **aChannelContex
NS_IMETHODIMP nsImapMockChannel::SetLoadGroup(nsILoadGroup * aLoadGroup)
{
m_loadGroup = dont_QueryInterface(aLoadGroup);
m_loadGroup = aLoadGroup;
return NS_OK;
}

View File

@ -1231,7 +1231,7 @@ NS_IMETHODIMP nsImapUrl::GetMockChannel(nsIImapMockChannel ** aChannel)
NS_IMETHODIMP nsImapUrl::SetMockChannel(nsIImapMockChannel * aChannel)
{
nsresult rv = NS_OK;
m_mockChannel = dont_QueryInterface(aChannel);
m_mockChannel = aChannel;
return rv;
}
@ -1369,7 +1369,7 @@ NS_IMETHODIMP nsImapUrl::SetMsgLoadingFromCache(PRBool loadingFromCache)
NS_IMETHODIMP nsImapUrl::SetMessageFile(nsIFileSpec * aFileSpec)
{
m_messageFileSpec = dont_QueryInterface(aFileSpec);
m_messageFileSpec = aFileSpec;
return NS_OK;
}

View File

@ -174,7 +174,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsMsgMailNewsUrl)
nsresult nsMailboxUrl::SetMailboxParser(nsIStreamListener * aMailboxParser)
{
if (aMailboxParser)
m_mailboxParser = dont_QueryInterface(aMailboxParser);
m_mailboxParser = aMailboxParser;
return NS_OK;
}
@ -190,7 +190,7 @@ nsresult nsMailboxUrl::GetMailboxParser(nsIStreamListener ** aConsumer)
nsresult nsMailboxUrl::SetMailboxCopyHandler(nsIStreamListener * aMailboxCopyHandler)
{
if (aMailboxCopyHandler)
m_mailboxCopyHandler = dont_QueryInterface(aMailboxCopyHandler);
m_mailboxCopyHandler = aMailboxCopyHandler;
return NS_OK;
}
@ -324,7 +324,7 @@ nsMailboxUrl::SetOriginalSpec(const char *aSpec)
NS_IMETHODIMP nsMailboxUrl::SetMessageFile(nsIFileSpec * aFileSpec)
{
m_messageFileSpec = dont_QueryInterface(aFileSpec);
m_messageFileSpec = aFileSpec;
return NS_OK;
}

View File

@ -608,7 +608,7 @@ PRInt32 nsParseMailMessageState::ParseFolderLine(const char *line, PRUint32 line
NS_IMETHODIMP nsParseMailMessageState::SetMailDB(nsIMsgDatabase *mailDB)
{
m_mailDB = dont_QueryInterface(mailDB);
m_mailDB = mailDB;
return NS_OK;
}

View File

@ -177,7 +177,7 @@ public:
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIDBCHANGELISTENER
void SetDB (nsIMsgDatabase *mailDB) {m_mailDB = dont_QueryInterface(mailDB); }
void SetDB (nsIMsgDatabase *mailDB) {m_mailDB = mailDB; }
// message socket libnet callbacks, which come through folder pane
virtual int ProcessMailboxInputStream(nsIURI* aURL, nsIInputStream *aIStream, PRUint32 aLength);

View File

@ -65,7 +65,7 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsPop3URL, nsMsgMailNewsUrl, nsIPop3URL)
nsresult nsPop3URL::SetPop3Sink(nsIPop3Sink* aPop3Sink)
{
if (aPop3Sink)
m_pop3Sink = dont_QueryInterface(aPop3Sink);
m_pop3Sink = aPop3Sink;
return NS_OK;
}

View File

@ -229,7 +229,7 @@ NS_IMPL_GETSET(nsNntpUrl, CanonicalLineEnding, PRBool, m_canonicalLineEnding);
NS_IMETHODIMP nsNntpUrl::SetMessageFile(nsIFileSpec * aFileSpec)
{
m_messageFileSpec = dont_QueryInterface(aFileSpec);
m_messageFileSpec = aFileSpec;
return NS_OK;
}

View File

@ -466,8 +466,7 @@ CompositeArcsInOutEnumeratorImpl::Destroy()
{
// Keep the datasource alive for the duration of the stack
// frame so its allocator stays valid.
nsCOMPtr<nsIRDFCompositeDataSource> kungFuDeathGrip =
dont_QueryInterface(mCompositeDataSource);
nsCOMPtr<nsIRDFCompositeDataSource> kungFuDeathGrip = mCompositeDataSource;
nsFixedSizeAllocator& pool = mCompositeDataSource->mAllocator;
this->~CompositeArcsInOutEnumeratorImpl();
@ -597,8 +596,7 @@ CompositeAssertionEnumeratorImpl::Destroy()
{
// Keep the datasource alive for the duration of the stack
// frame so its allocator stays valid.
nsCOMPtr<nsIRDFCompositeDataSource> kungFuDeathGrip =
dont_QueryInterface(mCompositeDataSource);
nsCOMPtr<nsIRDFCompositeDataSource> kungFuDeathGrip = mCompositeDataSource;
nsFixedSizeAllocator& pool = mCompositeDataSource->mAllocator;
this->~CompositeAssertionEnumeratorImpl();

View File

@ -107,10 +107,10 @@ nsIRDFContainerUtils* ContainerEnumeratorImpl::gRDFC;
ContainerEnumeratorImpl::ContainerEnumeratorImpl(nsIRDFDataSource* aDataSource,
nsIRDFResource* aContainer)
: mNextIndex(1)
: mDataSource(aDataSource),
mContainer(aContainer),
mNextIndex(1)
{
mDataSource = dont_QueryInterface(aDataSource);
mContainer = dont_QueryInterface(aContainer);
}
nsresult

View File

@ -456,8 +456,7 @@ public:
Destroy(InMemoryAssertionEnumeratorImpl* aEnumerator) {
// Keep the datasource alive for the duration of the stack
// frame so its allocator stays valid.
nsCOMPtr<nsIRDFDataSource> kungFuDeathGrip =
dont_QueryInterface(aEnumerator->mDataSource);
nsCOMPtr<nsIRDFDataSource> kungFuDeathGrip = aEnumerator->mDataSource;
// Grab the pool from the datasource; since we keep the
// datasource alive, this has to be safe.
@ -662,8 +661,7 @@ public:
Destroy(InMemoryArcsEnumeratorImpl* aEnumerator) {
// Keep the datasource alive for the duration of the stack
// frame so its allocator stays valid.
nsCOMPtr<nsIRDFDataSource> kungFuDeathGrip =
dont_QueryInterface(aEnumerator->mDataSource);
nsCOMPtr<nsIRDFDataSource> kungFuDeathGrip = aEnumerator->mDataSource;
// Grab the pool from the datasource; since we keep the
// datasource alive, this has to be safe.

View File

@ -726,7 +726,7 @@ NS_IMETHODIMP
RDFContentSinkImpl::SetDataSource(nsIRDFDataSource* aDataSource)
{
NS_PRECONDITION(aDataSource != nsnull, "SetDataSource null ptr");
mDataSource = dont_QueryInterface(aDataSource);
mDataSource = aDataSource;
NS_ASSERTION(mDataSource != nsnull,"Couldn't QI RDF DataSource");
return NS_OK;
}

View File

@ -340,7 +340,7 @@ nsViewerApp::InitializeWindowCreator()
// create an nsWindowCreator and give it to the WindowWatcher service
nsWindowCreator *creatorCallback = new nsWindowCreator(this);
if (creatorCallback) {
nsCOMPtr<nsIWindowCreator> windowCreator(dont_QueryInterface(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)));
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback));
if (windowCreator) {
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
if (wwatch) {

View File

@ -305,25 +305,6 @@ dont_AddRef( const already_AddRefed<T> aAlreadyAddRefedPtr )
/*
There used to be machinery to allow |dont_QueryInterface()| to work, but
since it is now equivalent to using a raw pointer ... all that machinery
has gone away. For pointer arguments, the following definition should
optimize away. This is better than using a |#define| because it is
scoped.
*/
template <class T>
inline
T*
dont_QueryInterface( T* expr )
{
return expr;
}
class nsCOMPtr_helper
/*
An |nsCOMPtr_helper| transforms commonly called getters into typesafe forms

View File

@ -1415,7 +1415,7 @@ nsLocalFile::GetNativeTarget(nsACString &_retval)
nsresult rv;
PRBool isSymlink;
nsCOMPtr<nsIFile> self(dont_QueryInterface(this));
nsCOMPtr<nsIFile> self(this);
nsCOMPtr<nsIFile> parent;
while (NS_SUCCEEDED(rv = self->GetParent(getter_AddRefs(parent)))) {
NS_ASSERTION(parent != nsnull, "no parent?!");

View File

@ -507,7 +507,7 @@ main()
#if 1
cout << endl << "### Test 11.5: can you compare a |nsCOMPtr| with a raw interface pointer [==]?" << endl;
if ( nsCOMPtr<IFoo>( dont_QueryInterface(raw_foo2p) ) == foo2p )
if ( nsCOMPtr<IFoo>( raw_foo2p ) == foo2p )
cout << "raw_foo2p == foo2p" << endl;
else
cout << "raw_foo2p != foo2p" << endl;
@ -619,18 +619,6 @@ main()
cout << "### End Test 23" << endl;
{
cout << endl << "### setup for Test 24" << endl;
nsCOMPtr<IFoo> fooP;
IFoo* rawFooP = new IFoo;
cout << "### Test 24: is |QueryInterface| _not_ called when explicitly barred?" << endl;
fooP = dont_QueryInterface(rawFooP);
cout << "### cleanup for Test 24" << endl;
}
cout << "### End Test 24" << endl;
{
nsCOMPtr<IFoo> fooP;
@ -648,7 +636,7 @@ main()
}
cout << endl << "### Test 25: will a static |nsCOMPtr| |Release| before program termination?" << endl;
cout << endl << "### Test 24: will a static |nsCOMPtr| |Release| before program termination?" << endl;
gFoop = do_QueryInterface(new IFoo);
cout << "<<main()" << endl;

View File

@ -176,7 +176,7 @@ NS_NewRelatedLinksStreamListener(nsIRDFDataSource* aDataSource,
RelatedLinksStreamListener::RelatedLinksStreamListener(nsIRDFDataSource *aDataSource)
: mDataSource(dont_QueryInterface(aDataSource))
: mDataSource(aDataSource)
{
}