-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Wow! Re-enabled initialization/assignment from raw COM interface pointers, only this time it means the same as |dont_QueryInterface|. Which is what people want and expect. Re-enabled comparisons between |nsCOMPtr|s and raw COM interface pointers; and it means what people expect: are these two 4-byte values equal/not-equal. Added a function for comparing two pointers (either can be raw or nsCOMPtr) called |SameCOMIdentity|, which provides the other kind of comparison. No current functionality has changed. Everything you're doing now is still legal and valid. These changes only bring some additional options. -----BEGIN PGP SIGNATURE----- Version: PGP Personal Privacy 6.0.2 Comment: get my key at <http://www.meer.net/ScottCollins/#key> iQA/AwUBNzAeufGmojMuVn+fEQInWgCfUVK/7xfd/pdhAmyIe4HhynKsuucAn20t MRtmNY4e2MAdwClvhR65a5Yv =elb3 -----END PGP SIGNATURE----- git-svn-id: svn://10.0.0.236/trunk@30401 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -93,6 +93,7 @@
|
||||
#define HAVE_CPP_USING
|
||||
#define HAVE_CPP_EXPLICIT
|
||||
#define HAVE_CPP_NEW_CASTS
|
||||
#define HAVE_CPP_BOOL
|
||||
#endif
|
||||
|
||||
// under VC++ (Windows), we don't have autoconf yet
|
||||
@@ -113,6 +114,9 @@
|
||||
// under VC++, we win by inlining StartAssignment
|
||||
#endif
|
||||
|
||||
#define NSCAP_FEATURE_ALLOW_RAW_POINTERS
|
||||
#define NSCAP_FEATURE_ALLOW_COMPARISONS
|
||||
|
||||
|
||||
/*
|
||||
If the compiler doesn't support |explicit|, we'll just make it go away, trusting
|
||||
@@ -122,9 +126,17 @@
|
||||
#define explicit
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CPP_BOOL
|
||||
typedef bool NSCAP_BOOL;
|
||||
#else
|
||||
typedef PRBool NSCAP_BOOL;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CPP_NEW_CASTS
|
||||
#define NSCAP_STATIC_CAST(T,x) static_cast<T>(x)
|
||||
#define NSCAP_REINTERPRET_CAST(T,x) reinterpret_cast<T>(x)
|
||||
#else
|
||||
#define NSCAP_STATIC_CAST(T,x) ((T)(x))
|
||||
#define NSCAP_REINTERPRET_CAST(T,x) ((T)(x))
|
||||
#endif
|
||||
|
||||
@@ -383,6 +395,22 @@ class nsCOMPtr : private nsCOMPtr_base
|
||||
NSCAP_ADDREF(mRawPtr);
|
||||
}
|
||||
|
||||
#ifdef NSCAP_FEATURE_ALLOW_RAW_POINTERS
|
||||
nsCOMPtr( T* aRawPtr )
|
||||
: nsCOMPtr_base(aRawPtr)
|
||||
{
|
||||
if ( mRawPtr )
|
||||
NSCAP_ADDREF(mRawPtr);
|
||||
}
|
||||
|
||||
nsCOMPtr<T>&
|
||||
operator=( T* rhs )
|
||||
{
|
||||
assign_with_AddRef(rhs);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<T>&
|
||||
operator=( const nsQueryInterface& rhs )
|
||||
{
|
||||
@@ -530,6 +558,70 @@ getter_AddRefs( nsCOMPtr<T>& aSmartPtr )
|
||||
}
|
||||
|
||||
|
||||
#ifdef NSCAP_FEATURE_ALLOW_COMPARISONS
|
||||
|
||||
/*
|
||||
Note: can't enable this till I find a suitable replacement for |bool|.
|
||||
*/
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const nsCOMPtr<T>& lhs, const nsCOMPtr<U>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const nsCOMPtr<T>& lhs, const U* rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs);
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const U* lhs, const nsCOMPtr<T>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const nsCOMPtr<T>& lhs, const nsCOMPtr<U>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const nsCOMPtr<T>& lhs, const U* rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs);
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const U* lhs, const nsCOMPtr<T>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
SameCOMIdentity( nsISupports* lhs, nsISupports* rhs )
|
||||
{
|
||||
return nsCOMPtr<nsISupports>( do_QueryInterface(lhs) ) == nsCOMPtr<nsISupports>( do_QueryInterface(rhs) );
|
||||
}
|
||||
|
||||
#endif // defined(NSCAP_FEATURE_ALLOW_COMPARISONS)
|
||||
|
||||
|
||||
|
||||
template <class SourceType, class DestinationType>
|
||||
inline
|
||||
|
||||
@@ -93,6 +93,7 @@
|
||||
#define HAVE_CPP_USING
|
||||
#define HAVE_CPP_EXPLICIT
|
||||
#define HAVE_CPP_NEW_CASTS
|
||||
#define HAVE_CPP_BOOL
|
||||
#endif
|
||||
|
||||
// under VC++ (Windows), we don't have autoconf yet
|
||||
@@ -113,6 +114,9 @@
|
||||
// under VC++, we win by inlining StartAssignment
|
||||
#endif
|
||||
|
||||
#define NSCAP_FEATURE_ALLOW_RAW_POINTERS
|
||||
#define NSCAP_FEATURE_ALLOW_COMPARISONS
|
||||
|
||||
|
||||
/*
|
||||
If the compiler doesn't support |explicit|, we'll just make it go away, trusting
|
||||
@@ -122,9 +126,17 @@
|
||||
#define explicit
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CPP_BOOL
|
||||
typedef bool NSCAP_BOOL;
|
||||
#else
|
||||
typedef PRBool NSCAP_BOOL;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CPP_NEW_CASTS
|
||||
#define NSCAP_STATIC_CAST(T,x) static_cast<T>(x)
|
||||
#define NSCAP_REINTERPRET_CAST(T,x) reinterpret_cast<T>(x)
|
||||
#else
|
||||
#define NSCAP_STATIC_CAST(T,x) ((T)(x))
|
||||
#define NSCAP_REINTERPRET_CAST(T,x) ((T)(x))
|
||||
#endif
|
||||
|
||||
@@ -383,6 +395,22 @@ class nsCOMPtr : private nsCOMPtr_base
|
||||
NSCAP_ADDREF(mRawPtr);
|
||||
}
|
||||
|
||||
#ifdef NSCAP_FEATURE_ALLOW_RAW_POINTERS
|
||||
nsCOMPtr( T* aRawPtr )
|
||||
: nsCOMPtr_base(aRawPtr)
|
||||
{
|
||||
if ( mRawPtr )
|
||||
NSCAP_ADDREF(mRawPtr);
|
||||
}
|
||||
|
||||
nsCOMPtr<T>&
|
||||
operator=( T* rhs )
|
||||
{
|
||||
assign_with_AddRef(rhs);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<T>&
|
||||
operator=( const nsQueryInterface& rhs )
|
||||
{
|
||||
@@ -530,6 +558,70 @@ getter_AddRefs( nsCOMPtr<T>& aSmartPtr )
|
||||
}
|
||||
|
||||
|
||||
#ifdef NSCAP_FEATURE_ALLOW_COMPARISONS
|
||||
|
||||
/*
|
||||
Note: can't enable this till I find a suitable replacement for |bool|.
|
||||
*/
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const nsCOMPtr<T>& lhs, const nsCOMPtr<U>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const nsCOMPtr<T>& lhs, const U* rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs);
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const U* lhs, const nsCOMPtr<T>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const nsCOMPtr<T>& lhs, const nsCOMPtr<U>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const nsCOMPtr<T>& lhs, const U* rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs);
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const U* lhs, const nsCOMPtr<T>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
SameCOMIdentity( nsISupports* lhs, nsISupports* rhs )
|
||||
{
|
||||
return nsCOMPtr<nsISupports>( do_QueryInterface(lhs) ) == nsCOMPtr<nsISupports>( do_QueryInterface(rhs) );
|
||||
}
|
||||
|
||||
#endif // defined(NSCAP_FEATURE_ALLOW_COMPARISONS)
|
||||
|
||||
|
||||
|
||||
template <class SourceType, class DestinationType>
|
||||
inline
|
||||
|
||||
@@ -93,6 +93,7 @@
|
||||
#define HAVE_CPP_USING
|
||||
#define HAVE_CPP_EXPLICIT
|
||||
#define HAVE_CPP_NEW_CASTS
|
||||
#define HAVE_CPP_BOOL
|
||||
#endif
|
||||
|
||||
// under VC++ (Windows), we don't have autoconf yet
|
||||
@@ -113,6 +114,9 @@
|
||||
// under VC++, we win by inlining StartAssignment
|
||||
#endif
|
||||
|
||||
#define NSCAP_FEATURE_ALLOW_RAW_POINTERS
|
||||
#define NSCAP_FEATURE_ALLOW_COMPARISONS
|
||||
|
||||
|
||||
/*
|
||||
If the compiler doesn't support |explicit|, we'll just make it go away, trusting
|
||||
@@ -122,9 +126,17 @@
|
||||
#define explicit
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CPP_BOOL
|
||||
typedef bool NSCAP_BOOL;
|
||||
#else
|
||||
typedef PRBool NSCAP_BOOL;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CPP_NEW_CASTS
|
||||
#define NSCAP_STATIC_CAST(T,x) static_cast<T>(x)
|
||||
#define NSCAP_REINTERPRET_CAST(T,x) reinterpret_cast<T>(x)
|
||||
#else
|
||||
#define NSCAP_STATIC_CAST(T,x) ((T)(x))
|
||||
#define NSCAP_REINTERPRET_CAST(T,x) ((T)(x))
|
||||
#endif
|
||||
|
||||
@@ -383,6 +395,22 @@ class nsCOMPtr : private nsCOMPtr_base
|
||||
NSCAP_ADDREF(mRawPtr);
|
||||
}
|
||||
|
||||
#ifdef NSCAP_FEATURE_ALLOW_RAW_POINTERS
|
||||
nsCOMPtr( T* aRawPtr )
|
||||
: nsCOMPtr_base(aRawPtr)
|
||||
{
|
||||
if ( mRawPtr )
|
||||
NSCAP_ADDREF(mRawPtr);
|
||||
}
|
||||
|
||||
nsCOMPtr<T>&
|
||||
operator=( T* rhs )
|
||||
{
|
||||
assign_with_AddRef(rhs);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<T>&
|
||||
operator=( const nsQueryInterface& rhs )
|
||||
{
|
||||
@@ -530,6 +558,70 @@ getter_AddRefs( nsCOMPtr<T>& aSmartPtr )
|
||||
}
|
||||
|
||||
|
||||
#ifdef NSCAP_FEATURE_ALLOW_COMPARISONS
|
||||
|
||||
/*
|
||||
Note: can't enable this till I find a suitable replacement for |bool|.
|
||||
*/
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const nsCOMPtr<T>& lhs, const nsCOMPtr<U>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const nsCOMPtr<T>& lhs, const U* rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs);
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator==( const U* lhs, const nsCOMPtr<T>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const nsCOMPtr<T>& lhs, const nsCOMPtr<U>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const nsCOMPtr<T>& lhs, const U* rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs);
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
operator!=( const U* lhs, const nsCOMPtr<T>& rhs )
|
||||
{
|
||||
return NSCAP_STATIC_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get());
|
||||
}
|
||||
|
||||
inline
|
||||
NSCAP_BOOL
|
||||
SameCOMIdentity( nsISupports* lhs, nsISupports* rhs )
|
||||
{
|
||||
return nsCOMPtr<nsISupports>( do_QueryInterface(lhs) ) == nsCOMPtr<nsISupports>( do_QueryInterface(rhs) );
|
||||
}
|
||||
|
||||
#endif // defined(NSCAP_FEATURE_ALLOW_COMPARISONS)
|
||||
|
||||
|
||||
|
||||
template <class SourceType, class DestinationType>
|
||||
inline
|
||||
|
||||
Reference in New Issue
Block a user