Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions
nsIWeakReferenceUtils.h File Reference
#include "nsCOMPtr.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

protocol  NS_COM_GLUE

Typedefs

typedef nsCOMPtr
< nsIWeakReference
nsWeakPtr

Functions

template<class T , class DestinationType >
nsresult CallQueryReferent (T *aSource, DestinationType **aDestination)
const nsQueryReferent do_QueryReferent (nsIWeakReference *aRawPtr, nsresult *error=0)
NS_COM_GLUE nsIWeakReferenceNS_GetWeakReference (nsISupports *, nsresult *aResult=0)
 Deprecated, use |do_GetWeakReference| instead.
already_AddRefed
< nsIWeakReference
do_GetWeakReference (nsISupports *aRawPtr, nsresult *error=0)
 |do_GetWeakReference| is a convenience function that bundles up all the work needed to get a weak reference to an arbitrary object, i.e., the |QueryInterface|, test, and call through to |GetWeakReference|, and put it into your |nsCOMPtr|.
void do_GetWeakReference (nsIWeakReference *aRawPtr, nsresult *error=0)
template<class T >
void do_GetWeakReference (already_AddRefed< T > &)
template<class T >
void do_GetWeakReference (already_AddRefed< T > &, nsresult *)

Typedef Documentation

Definition at line 46 of file nsIWeakReferenceUtils.h.


Function Documentation

template<class T , class DestinationType >
nsresult CallQueryReferent ( T aSource,
DestinationType **  aDestination 
) [inline]

Definition at line 57 of file nsIWeakReferenceUtils.h.

  {
    NS_PRECONDITION(aSource, "null parameter");
    NS_PRECONDITION(aDestination, "null parameter");

    return aSource->QueryReferent(NS_GET_IID(DestinationType),
                                  NS_REINTERPRET_CAST(void**, aDestination));
  }

Here is the caller graph for this function:

already_AddRefed<nsIWeakReference> do_GetWeakReference ( nsISupports *  aRawPtr,
nsresult error = 0 
) [inline]

|do_GetWeakReference| is a convenience function that bundles up all the work needed to get a weak reference to an arbitrary object, i.e., the |QueryInterface|, test, and call through to |GetWeakReference|, and put it into your |nsCOMPtr|.

It is specifically designed to cooperate with |nsCOMPtr| (or |nsWeakPtr|) like so: |nsWeakPtr myWeakPtr = do_GetWeakReference(aPtr);|.

Definition at line 108 of file nsIWeakReferenceUtils.h.

  {
    return NS_GetWeakReference(aRawPtr, error);
  }

Here is the call graph for this function:

void do_GetWeakReference ( nsIWeakReference aRawPtr,
nsresult error = 0 
) [inline]

Definition at line 115 of file nsIWeakReferenceUtils.h.

  {
    // This signature exists soley to _stop_ you from doing a bad thing.
    //  Saying |do_GetWeakReference()| on a weak reference itself,
    //  is very likely to be a programmer error.
  }
template<class T >
void do_GetWeakReference ( already_AddRefed< T > &  ) [inline]

Definition at line 125 of file nsIWeakReferenceUtils.h.

  {
    // This signature exists soley to _stop_ you from doing the bad thing.
    //  Saying |do_GetWeakReference()| on a pointer that is not otherwise owned by
    //  someone else is an automatic leak.  See <http://bugzilla.mozilla.org/show_bug.cgi?id=8221>.
  }
template<class T >
void do_GetWeakReference ( already_AddRefed< T > &  ,
nsresult  
) [inline]

Definition at line 135 of file nsIWeakReferenceUtils.h.

  {
    // This signature exists soley to _stop_ you from doing the bad thing.
    //  Saying |do_GetWeakReference()| on a pointer that is not otherwise owned by
    //  someone else is an automatic leak.  See <http://bugzilla.mozilla.org/show_bug.cgi?id=8221>.
  }
const nsQueryReferent do_QueryReferent ( nsIWeakReference aRawPtr,
nsresult error = 0 
) [inline]

Definition at line 86 of file nsIWeakReferenceUtils.h.

  {
    return nsQueryReferent(aRawPtr, error);
  }
NS_COM_GLUE nsIWeakReference* NS_GetWeakReference ( nsISupports *  ,
nsresult aResult = 0 
)

Deprecated, use |do_GetWeakReference| instead.

Definition at line 64 of file nsWeakReference.cpp.

  {
    nsresult status;

    nsIWeakReference* result = nsnull;

    if ( aInstancePtr )
      {
        nsCOMPtr<nsISupportsWeakReference> factoryPtr = do_QueryInterface(aInstancePtr, &status);
        NS_ASSERTION(factoryPtr, "Oops!  You're asking for a weak reference to an object that doesn't support that.");
        if ( factoryPtr )
          {
            status = factoryPtr->GetWeakReference(&result);
          }
        // else, |status| has already been set by |do_QueryInterface|
      }
    else
      status = NS_ERROR_NULL_POINTER;

    if ( aErrorPtr )
      *aErrorPtr = status;
    return result;
  }

Here is the call graph for this function:

Here is the caller graph for this function: