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 1525a3c559
commit 863f9e1027
21 changed files with 26 additions and 61 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

@@ -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

@@ -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)
{
}