mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1188696 - Remove the XPCOM dependencies in nsRefPtr.h. r=froydnj
This commit is contained in:
parent
9fa2417770
commit
ec207ee3d4
@ -8,9 +8,8 @@
|
||||
#define nsRefPtr_h
|
||||
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@ -216,7 +215,7 @@ public:
|
||||
// parameters where aRhs bay be a T** or an I** where I is a base class
|
||||
// of T.
|
||||
{
|
||||
NS_ASSERTION(aRhs, "Null pointer passed to forget!");
|
||||
MOZ_ASSERT(aRhs, "Null pointer passed to forget!");
|
||||
*aRhs = mRawPtr;
|
||||
mRawPtr = 0;
|
||||
}
|
||||
@ -247,8 +246,8 @@ public:
|
||||
T*
|
||||
operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
|
||||
{
|
||||
NS_PRECONDITION(mRawPtr != 0,
|
||||
"You can't dereference a NULL nsRefPtr with operator->().");
|
||||
MOZ_ASSERT(mRawPtr != 0,
|
||||
"You can't dereference a NULL nsRefPtr with operator->().");
|
||||
return get();
|
||||
}
|
||||
|
||||
@ -260,8 +259,8 @@ public:
|
||||
U&
|
||||
operator->*(U V::* aMember)
|
||||
{
|
||||
NS_PRECONDITION(mRawPtr != 0,
|
||||
"You can't dereference a NULL nsRefPtr with operator->*().");
|
||||
MOZ_ASSERT(mRawPtr != 0,
|
||||
"You can't dereference a NULL nsRefPtr with operator->*().");
|
||||
return get()->*aMember;
|
||||
}
|
||||
#endif
|
||||
@ -286,8 +285,8 @@ public:
|
||||
T&
|
||||
operator*() const
|
||||
{
|
||||
NS_PRECONDITION(mRawPtr != 0,
|
||||
"You can't dereference a NULL nsRefPtr with operator*().");
|
||||
MOZ_ASSERT(mRawPtr != 0,
|
||||
"You can't dereference a NULL nsRefPtr with operator*().");
|
||||
return *get();
|
||||
}
|
||||
|
||||
@ -299,28 +298,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
nsRefPtr<T>::nsRefPtr(const nsCOMPtr_helper& aHelper)
|
||||
{
|
||||
void* newRawPtr;
|
||||
if (NS_FAILED(aHelper(NS_GET_TEMPLATE_IID(T), &newRawPtr))) {
|
||||
newRawPtr = 0;
|
||||
}
|
||||
mRawPtr = static_cast<T*>(newRawPtr);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
nsRefPtr<T>&
|
||||
nsRefPtr<T>::operator=(const nsCOMPtr_helper& aHelper)
|
||||
{
|
||||
void* newRawPtr;
|
||||
if (NS_FAILED(aHelper(NS_GET_TEMPLATE_IID(T), &newRawPtr))) {
|
||||
newRawPtr = 0;
|
||||
}
|
||||
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
|
||||
return *this;
|
||||
}
|
||||
|
||||
class nsCycleCollectionTraversalCallback;
|
||||
template <typename T>
|
||||
void
|
||||
@ -532,14 +509,6 @@ operator!=(::detail::nsRefPtrZero* aLhs, const nsRefPtr<T>& aRhs)
|
||||
return reinterpret_cast<const void*>(aLhs) != static_cast<const void*>(aRhs.get());
|
||||
}
|
||||
|
||||
|
||||
template <class SourceType, class DestinationType>
|
||||
inline nsresult
|
||||
CallQueryInterface(nsRefPtr<SourceType>& aSourcePtr, DestinationType** aDestPtr)
|
||||
{
|
||||
return CallQueryInterface(aSourcePtr.get(), aDestPtr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
template <class T>
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "nsDebug.h" // for |NS_ASSERTION|
|
||||
#include "nsISupportsUtils.h" // for |nsresult|, |NS_ADDREF|, |NS_GET_TEMPLATE_IID| et al
|
||||
#include "nsRefPtr.h"
|
||||
|
||||
#include "nsCycleCollectionNoteChild.h"
|
||||
|
||||
@ -1377,4 +1378,27 @@ CallQueryInterface(nsCOMPtr<SourceType>& aSourcePtr, DestinationType** aDestPtr)
|
||||
return CallQueryInterface(aSourcePtr.get(), aDestPtr);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
nsRefPtr<T>::nsRefPtr(const nsCOMPtr_helper& aHelper)
|
||||
{
|
||||
void* newRawPtr;
|
||||
if (NS_FAILED(aHelper(NS_GET_TEMPLATE_IID(T), &newRawPtr))) {
|
||||
newRawPtr = 0;
|
||||
}
|
||||
mRawPtr = static_cast<T*>(newRawPtr);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
nsRefPtr<T>&
|
||||
nsRefPtr<T>::operator=(const nsCOMPtr_helper& aHelper)
|
||||
{
|
||||
void* newRawPtr;
|
||||
if (NS_FAILED(aHelper(NS_GET_TEMPLATE_IID(T), &newRawPtr))) {
|
||||
newRawPtr = 0;
|
||||
}
|
||||
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#endif // !defined(nsCOMPtr_h___)
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsError.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsRefPtr.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
/**
|
||||
@ -134,4 +135,11 @@ CallQueryInterface(T* aSource, DestinationType** aDestination)
|
||||
reinterpret_cast<void**>(aDestination));
|
||||
}
|
||||
|
||||
template <class SourceType, class DestinationType>
|
||||
inline nsresult
|
||||
CallQueryInterface(nsRefPtr<SourceType>& aSourcePtr, DestinationType** aDestPtr)
|
||||
{
|
||||
return CallQueryInterface(aSourcePtr.get(), aDestPtr);
|
||||
}
|
||||
|
||||
#endif /* __nsISupportsUtils_h */
|
||||
|
Loading…
Reference in New Issue
Block a user