gecko-dev/xpcom/base/nsIWeakReference.idl

37 lines
1012 B
Plaintext

// nsIWeakReference.idl
#include "nsISupports.idl"
[scriptable, uuid(9188bc85-f92e-11d2-81ef-0060083a0bcf)]
interface nsIWeakReference : nsISupports
{
void QueryReference( in nsIIDRef uuid, [iid_is(uuid), retval] out nsQIResult result );
};
[scriptable, uuid(9188bc86-f92e-11d2-81ef-0060083a0bcf)]
interface nsISupportsWeakReference : nsISupports
{
void GetWeakReference( [retval] out nsIWeakReference result );
};
%{C++
// typedef nsCOMPtr<nsIWeakReference> nsWeakPtr;
// ...this definition had to be moved to nsWeakPtr.h to avoid circular includes, sorry
nsIWeakReference* NS_GetWeakReference( nsISupports* );
// ...convenience. Get a weak reference (if possible) without doing the query yourself
template <class T>
inline
nsresult
CallQueryReference( nsIWeakReference* aSource, T** aDestination )
{
NS_PRECONDITION(aSource, "null parameter");
NS_PRECONDITION(aDestination, "null parameter");
return aSource->QueryReference(nsCOMTypeInfo<T>::GetIID(), (void**)aDestination);
}
%}