Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Specialize |nsCOMPtr| for |nsISupports| (i.e., |nsCOMPtr<nsISupports>…
Browse files Browse the repository at this point in the history
…|). The specialization _does_not_ have the invariant that |nsCOMPtr<T>| has of always pointing to the COM-correct interface. An |nsCOMPtr<nsISupports>| essentially means "a pointer to _any_ [XP]COM interface". This change allows dougt to fix his M11 bug. a=chofmann, r={danm, hyatt}
  • Loading branch information
scc%netscape.com committed Nov 8, 1999
1 parent fe19761 commit 50bb3ff
Show file tree
Hide file tree
Showing 4 changed files with 740 additions and 514 deletions.
43 changes: 3 additions & 40 deletions xpcom/base/nsCOMPtr.cpp
Expand Up @@ -18,10 +18,10 @@
* Rights Reserved.
*
* Contributor(s):
* Scott Collins <scc@netscape.com>
*/

#include "nsCOMPtr.h"
// #include "nsIWeakReference.h"

nsresult
nsQueryInterface::operator()( const nsIID& aIID, void** answer ) const
Expand Down Expand Up @@ -59,50 +59,13 @@ void
nsCOMPtr_base::assign_from_helper( const nsCOMPtr_helper& helper, const nsIID& iid )
{
nsISupports* newRawPtr;
if ( !NS_SUCCEEDED( helper(iid, NSCAP_REINTERPRET_CAST(void**, &newRawPtr)) ) )
if ( !NS_SUCCEEDED( helper(iid, NS_REINTERPRET_CAST(void**, &newRawPtr)) ) )
newRawPtr = 0;
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
mRawPtr = newRawPtr;
}


#if 0
void
nsCOMPtr_base::assign_with_QueryInterface( nsISupports* rawPtr, const nsIID& iid, nsresult* result )
{
nsresult status = NS_ERROR_NULL_POINTER;
if ( !rawPtr || !NS_SUCCEEDED( status = rawPtr->QueryInterface(iid, NSCAP_REINTERPRET_CAST(void**, &rawPtr)) ) )
rawPtr = 0;

if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);

mRawPtr = rawPtr;

if ( result )
*result = status;
}

void
nsCOMPtr_base::assign_with_QueryReferent( nsIWeakReference* weakPtr, const nsIID& iid, nsresult* result )
{
nsresult status = NS_ERROR_NULL_POINTER;

nsISupports* rawPtr;
if ( !weakPtr || !NS_SUCCEEDED( status = weakPtr->QueryReferent(iid, NSCAP_REINTERPRET_CAST(void**, &rawPtr)) ) )
rawPtr = 0;

if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);

mRawPtr = rawPtr;

if ( result )
*result = status;
}
#endif

void**
nsCOMPtr_base::begin_assignment()
{
Expand All @@ -112,5 +75,5 @@ nsCOMPtr_base::begin_assignment()
mRawPtr = 0;
}

return NSCAP_REINTERPRET_CAST(void**, &mRawPtr);
return NS_REINTERPRET_CAST(void**, &mRawPtr);
}

0 comments on commit 50bb3ff

Please sign in to comment.