diff --git a/xpcom/base/nsCOMPtr.h b/xpcom/base/nsCOMPtr.h index 24bde5d2fc52..ddd635399f7a 100644 --- a/xpcom/base/nsCOMPtr.h +++ b/xpcom/base/nsCOMPtr.h @@ -33,29 +33,29 @@ #endif /* - Public things defined in this file: + Public things defined in this file: - T* rawTptr; - class nsCOMPtr nsCOMPtr smartTptr; + T* rawTptr; + class nsCOMPtr nsCOMPtr smartTptr; - null_nsCOMPtr() smartTptr = null_nsCOMPtr(); + null_nsCOMPtr() smartTptr = null_nsCOMPtr(); - do_QueryInterface( nsISupports* ) smartTptr = do_QueryInterface(other_ptr); - do_QueryInterface( nsISupports*, nsresult* ) smartTptr = do_QueryInterface(other_ptr, &status); + do_QueryInterface( nsISupports* ) smartTptr = do_QueryInterface(other_ptr); + do_QueryInterface( nsISupports*, nsresult* ) smartTptr = do_QueryInterface(other_ptr, &status); - dont_QueryInterface( T* ) smartTptr = dont_QueryInterface(rawTptr); + dont_QueryInterface( T* ) smartTptr = dont_QueryInterface(rawTptr); - getter_AddRefs( nsCOMPtr& ) - getter_AddRefs( T* ) - dont_AddRef( T* ) + getter_AddRefs( nsCOMPtr& ) + getter_AddRefs( T* ) + dont_AddRef( T* ) - CallQueryInterface( nsISupports*, T** ) - CallQueryInterface( nsISupports*, nsCOMPtr* ) + CallQueryInterface( nsISupports*, T** ) + CallQueryInterface( nsISupports*, nsCOMPtr* ) */ /* - Having problems? - + Having problems? + See the User Manual at: , or @@ -88,30 +88,30 @@ myself for Mac and Windows. */ - // under Metrowerks (Mac), we don't have autoconf yet + // under Metrowerks (Mac), we don't have autoconf yet #ifdef __MWERKS__ - #define HAVE_CPP_USING - #define HAVE_CPP_EXPLICIT - #define HAVE_CPP_NEW_CASTS - #define HAVE_CPP_BOOL + #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 + // under VC++ (Windows), we don't have autoconf yet #ifdef _MSC_VER - #define HAVE_CPP_EXPLICIT - #define HAVE_CPP_USING - #define HAVE_CPP_NEW_CASTS + #define HAVE_CPP_EXPLICIT + #define HAVE_CPP_USING + #define HAVE_CPP_NEW_CASTS #if (_MSC_VER<1100) - // before 5.0, VC++ couldn't handle explicit + // before 5.0, VC++ couldn't handle explicit #undef HAVE_CPP_EXPLICIT #elif (_MSC_VER==1100) // VC++5.0 has an internal compiler error (sometimes) without this #undef HAVE_CPP_USING #endif - #define NSCAP_FEATURE_INLINE_STARTASSIGNMENT - // under VC++, we win by inlining StartAssignment + #define NSCAP_FEATURE_INLINE_STARTASSIGNMENT + // under VC++, we win by inlining StartAssignment #endif #define NSCAP_FEATURE_ALLOW_RAW_POINTERS @@ -119,26 +119,26 @@ #define NSCAP_FEATURE_FACTOR_DESTRUCTOR - /* - If the compiler doesn't support |explicit|, we'll just make it go away, trusting - that the builds under compilers that do have it will keep us on the straight and narrow. - */ + /* + If the compiler doesn't support |explicit|, we'll just make it go away, trusting + that the builds under compilers that do have it will keep us on the straight and narrow. + */ #ifndef HAVE_CPP_EXPLICIT #define explicit #endif #ifdef HAVE_CPP_BOOL - typedef bool NSCAP_BOOL; + typedef bool NSCAP_BOOL; #else - typedef PRBool NSCAP_BOOL; + typedef PRBool NSCAP_BOOL; #endif #ifdef HAVE_CPP_NEW_CASTS - #define NSCAP_STATIC_CAST(T,x) static_cast(x) - #define NSCAP_REINTERPRET_CAST(T,x) reinterpret_cast(x) + #define NSCAP_STATIC_CAST(T,x) static_cast(x) + #define NSCAP_REINTERPRET_CAST(T,x) reinterpret_cast(x) #else - #define NSCAP_STATIC_CAST(T,x) ((T)(x)) - #define NSCAP_REINTERPRET_CAST(T,x) ((T)(x)) + #define NSCAP_STATIC_CAST(T,x) ((T)(x)) + #define NSCAP_REINTERPRET_CAST(T,x) ((T)(x)) #endif #ifdef NSCAP_FEATURE_DEBUG_MACROS @@ -182,7 +182,7 @@ class nsDerivedSafe : public T NS_IMETHOD_(nsrefcnt) Release(void); #endif - void operator delete( void*, size_t ); // NOT TO BE IMPLEMENTED + void operator delete( void*, size_t ); // NOT TO BE IMPLEMENTED // declaring |operator delete| private makes calling delete on an interface pointer a compile error nsDerivedSafe& operator=( const nsDerivedSafe& ); // NOT TO BE IMPLEMENTED @@ -214,7 +214,7 @@ struct nsDontQueryInterface /* ... - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |dont_QueryInterface()| instead. + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |dont_QueryInterface()| instead. */ { explicit @@ -242,7 +242,7 @@ struct nsQueryInterface /* ... - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |do_QueryInterface()| instead. + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |do_QueryInterface()| instead. */ { explicit @@ -266,22 +266,22 @@ do_QueryInterface( nsISupports* aRawPtr, nsresult* error = 0 ) #ifdef NSCAP_FEATURE_ALLOW_RAW_POINTERS - #define null_nsCOMPtr() (0) + #define null_nsCOMPtr() (0) #else - inline - const nsQueryInterface - null_nsCOMPtr() - /* - You can use this to assign |NULL| into an |nsCOMPtr|, e.g., + inline + const nsQueryInterface + null_nsCOMPtr() + /* + You can use this to assign |NULL| into an |nsCOMPtr|, e.g., - myPtr = null_nsCOMPtr(); - */ - { - typedef nsISupports* nsISupports_Ptr; - return nsQueryInterface(nsISupports_Ptr(0)); - } + myPtr = null_nsCOMPtr(); + */ + { + typedef nsISupports* nsISupports_Ptr; + return nsQueryInterface(nsISupports_Ptr(0)); + } #endif @@ -295,8 +295,8 @@ struct nsDontAddRef machinery of |getter_AddRefs| in the argument list to functions that |AddRef| their results before returning them to the caller. - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| or - |dont_AddRef()| instead. + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| or + |dont_AddRef()| instead. See also |getter_AddRefs()|, |dont_AddRef()|, and |class nsGetterAddRefs|. */ @@ -319,9 +319,9 @@ getter_AddRefs( T* aRawPtr ) ...makes typing easier, because it deduces the template type, e.g., you write |dont_AddRef(fooP)| instead of |nsDontAddRef(fooP)|. */ - { - return nsDontAddRef(aRawPtr); - } + { + return nsDontAddRef(aRawPtr); + } template inline @@ -334,9 +334,9 @@ dont_AddRef( T* aRawPtr ) class nsCOMPtr_base - /* - ...factors implementation for all template versions of |nsCOMPtr|. - */ + /* + ...factors implementation for all template versions of |nsCOMPtr|. + */ { public: @@ -347,7 +347,7 @@ class nsCOMPtr_base } #ifdef NSCAP_FEATURE_FACTOR_DESTRUCTOR - NS_EXPORT ~nsCOMPtr_base(); + NS_EXPORT ~nsCOMPtr_base(); #endif #if 0 @@ -378,11 +378,11 @@ class nsCOMPtr : private nsCOMPtr_base typedef T element_type; #ifndef NSCAP_FEATURE_FACTOR_DESTRUCTOR - ~nsCOMPtr() - { - if ( mRawPtr ) - NSCAP_RELEASE(mRawPtr); - } + ~nsCOMPtr() + { + if ( mRawPtr ) + NSCAP_RELEASE(mRawPtr); + } #endif nsCOMPtr() @@ -418,12 +418,12 @@ class nsCOMPtr : private nsCOMPtr_base } #ifdef NSCAP_FEATURE_ALLOW_RAW_POINTERS - nsCOMPtr( T* aRawPtr ) - : nsCOMPtr_base(aRawPtr) - { - if ( mRawPtr ) - NSCAP_ADDREF(mRawPtr); - } + nsCOMPtr( T* aRawPtr ) + : nsCOMPtr_base(aRawPtr) + { + if ( mRawPtr ) + NSCAP_ADDREF(mRawPtr); + } nsCOMPtr& operator=( T* rhs ) @@ -512,10 +512,10 @@ class nsCOMPtr : private nsCOMPtr_base #ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT return NSCAP_REINTERPRET_CAST(T**, begin_assignment()); #else - if ( mRawPtr ) - NSCAP_RELEASE(mRawPtr); - mRawPtr = 0; - return NSCAP_REINTERPRET_CAST(T**, &mRawPtr); + if ( mRawPtr ) + NSCAP_RELEASE(mRawPtr); + mRawPtr = 0; + return NSCAP_REINTERPRET_CAST(T**, &mRawPtr); #endif } }; @@ -532,7 +532,7 @@ class nsGetterAddRefs nsCOMPtr fooP; ...->QueryInterface(iid, getter_AddRefs(fooP)) - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| instead. + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| instead. When initialized with a |nsCOMPtr|, as in the example above, it returns a |void**| (or |T**| if needed) that the outer call (|QueryInterface| in this @@ -586,92 +586,92 @@ template inline NSCAP_BOOL operator==( const nsCOMPtr& lhs, const nsCOMPtr& rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs.get()); - } + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator==( const nsCOMPtr& lhs, const U* rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs); - } + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs); + } template inline NSCAP_BOOL operator==( const U* lhs, const nsCOMPtr& rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get()); - } + { + return NSCAP_STATIC_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator==( const nsCOMPtr& lhs, int rhs ) - // specifically to allow |smartPtr == 0| - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_REINTERPRET_CAST(const void*, rhs); - } + // specifically to allow |smartPtr == 0| + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_REINTERPRET_CAST(const void*, rhs); + } template inline NSCAP_BOOL operator==( int lhs, const nsCOMPtr& rhs ) - // specifically to allow |0 == smartPtr| - { - return NSCAP_REINTERPRET_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get()); - } + // specifically to allow |0 == smartPtr| + { + return NSCAP_REINTERPRET_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator!=( const nsCOMPtr& lhs, const nsCOMPtr& rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs.get()); - } + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator!=( const nsCOMPtr& lhs, const U* rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs); - } + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs); + } template inline NSCAP_BOOL operator!=( const U* lhs, const nsCOMPtr& rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get()); - } + { + return NSCAP_STATIC_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator!=( const nsCOMPtr& lhs, int rhs ) - // specifically to allow |smartPtr != 0| - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_REINTERPRET_CAST(const void*, rhs); - } + // specifically to allow |smartPtr != 0| + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_REINTERPRET_CAST(const void*, rhs); + } template inline NSCAP_BOOL operator!=( int lhs, const nsCOMPtr& rhs ) - // specifically to allow |0 != smartPtr| - { - return NSCAP_REINTERPRET_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get()); - } + // specifically to allow |0 != smartPtr| + { + return NSCAP_REINTERPRET_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get()); + } inline NSCAP_BOOL SameCOMIdentity( nsISupports* lhs, nsISupports* rhs ) - { - return nsCOMPtr( do_QueryInterface(lhs) ) == nsCOMPtr( do_QueryInterface(rhs) ); - } + { + return nsCOMPtr( do_QueryInterface(lhs) ) == nsCOMPtr( do_QueryInterface(rhs) ); + } #endif // defined(NSCAP_FEATURE_ALLOW_COMPARISONS) @@ -680,13 +680,13 @@ template inline nsresult CallQueryInterface( nsISupports* aSource, nsCOMPtr* aDestination ) - // a type-safe shortcut for calling the |QueryInterface()| member function - { - NS_PRECONDITION(aSource, "null parameter"); - NS_PRECONDITION(aDestination, "null parameter"); + // a type-safe shortcut for calling the |QueryInterface()| member function + { + NS_PRECONDITION(aSource, "null parameter"); + NS_PRECONDITION(aDestination, "null parameter"); - return aSource->QueryInterface(DestinationType::GetIID(), (void**)getter_AddRefs(*aDestination)); - } + return aSource->QueryInterface(DestinationType::GetIID(), (void**)getter_AddRefs(*aDestination)); + } #endif // !defined(nsCOMPtr_h___) diff --git a/xpcom/glue/nsCOMPtr.h b/xpcom/glue/nsCOMPtr.h index 24bde5d2fc52..ddd635399f7a 100644 --- a/xpcom/glue/nsCOMPtr.h +++ b/xpcom/glue/nsCOMPtr.h @@ -33,29 +33,29 @@ #endif /* - Public things defined in this file: + Public things defined in this file: - T* rawTptr; - class nsCOMPtr nsCOMPtr smartTptr; + T* rawTptr; + class nsCOMPtr nsCOMPtr smartTptr; - null_nsCOMPtr() smartTptr = null_nsCOMPtr(); + null_nsCOMPtr() smartTptr = null_nsCOMPtr(); - do_QueryInterface( nsISupports* ) smartTptr = do_QueryInterface(other_ptr); - do_QueryInterface( nsISupports*, nsresult* ) smartTptr = do_QueryInterface(other_ptr, &status); + do_QueryInterface( nsISupports* ) smartTptr = do_QueryInterface(other_ptr); + do_QueryInterface( nsISupports*, nsresult* ) smartTptr = do_QueryInterface(other_ptr, &status); - dont_QueryInterface( T* ) smartTptr = dont_QueryInterface(rawTptr); + dont_QueryInterface( T* ) smartTptr = dont_QueryInterface(rawTptr); - getter_AddRefs( nsCOMPtr& ) - getter_AddRefs( T* ) - dont_AddRef( T* ) + getter_AddRefs( nsCOMPtr& ) + getter_AddRefs( T* ) + dont_AddRef( T* ) - CallQueryInterface( nsISupports*, T** ) - CallQueryInterface( nsISupports*, nsCOMPtr* ) + CallQueryInterface( nsISupports*, T** ) + CallQueryInterface( nsISupports*, nsCOMPtr* ) */ /* - Having problems? - + Having problems? + See the User Manual at: , or @@ -88,30 +88,30 @@ myself for Mac and Windows. */ - // under Metrowerks (Mac), we don't have autoconf yet + // under Metrowerks (Mac), we don't have autoconf yet #ifdef __MWERKS__ - #define HAVE_CPP_USING - #define HAVE_CPP_EXPLICIT - #define HAVE_CPP_NEW_CASTS - #define HAVE_CPP_BOOL + #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 + // under VC++ (Windows), we don't have autoconf yet #ifdef _MSC_VER - #define HAVE_CPP_EXPLICIT - #define HAVE_CPP_USING - #define HAVE_CPP_NEW_CASTS + #define HAVE_CPP_EXPLICIT + #define HAVE_CPP_USING + #define HAVE_CPP_NEW_CASTS #if (_MSC_VER<1100) - // before 5.0, VC++ couldn't handle explicit + // before 5.0, VC++ couldn't handle explicit #undef HAVE_CPP_EXPLICIT #elif (_MSC_VER==1100) // VC++5.0 has an internal compiler error (sometimes) without this #undef HAVE_CPP_USING #endif - #define NSCAP_FEATURE_INLINE_STARTASSIGNMENT - // under VC++, we win by inlining StartAssignment + #define NSCAP_FEATURE_INLINE_STARTASSIGNMENT + // under VC++, we win by inlining StartAssignment #endif #define NSCAP_FEATURE_ALLOW_RAW_POINTERS @@ -119,26 +119,26 @@ #define NSCAP_FEATURE_FACTOR_DESTRUCTOR - /* - If the compiler doesn't support |explicit|, we'll just make it go away, trusting - that the builds under compilers that do have it will keep us on the straight and narrow. - */ + /* + If the compiler doesn't support |explicit|, we'll just make it go away, trusting + that the builds under compilers that do have it will keep us on the straight and narrow. + */ #ifndef HAVE_CPP_EXPLICIT #define explicit #endif #ifdef HAVE_CPP_BOOL - typedef bool NSCAP_BOOL; + typedef bool NSCAP_BOOL; #else - typedef PRBool NSCAP_BOOL; + typedef PRBool NSCAP_BOOL; #endif #ifdef HAVE_CPP_NEW_CASTS - #define NSCAP_STATIC_CAST(T,x) static_cast(x) - #define NSCAP_REINTERPRET_CAST(T,x) reinterpret_cast(x) + #define NSCAP_STATIC_CAST(T,x) static_cast(x) + #define NSCAP_REINTERPRET_CAST(T,x) reinterpret_cast(x) #else - #define NSCAP_STATIC_CAST(T,x) ((T)(x)) - #define NSCAP_REINTERPRET_CAST(T,x) ((T)(x)) + #define NSCAP_STATIC_CAST(T,x) ((T)(x)) + #define NSCAP_REINTERPRET_CAST(T,x) ((T)(x)) #endif #ifdef NSCAP_FEATURE_DEBUG_MACROS @@ -182,7 +182,7 @@ class nsDerivedSafe : public T NS_IMETHOD_(nsrefcnt) Release(void); #endif - void operator delete( void*, size_t ); // NOT TO BE IMPLEMENTED + void operator delete( void*, size_t ); // NOT TO BE IMPLEMENTED // declaring |operator delete| private makes calling delete on an interface pointer a compile error nsDerivedSafe& operator=( const nsDerivedSafe& ); // NOT TO BE IMPLEMENTED @@ -214,7 +214,7 @@ struct nsDontQueryInterface /* ... - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |dont_QueryInterface()| instead. + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |dont_QueryInterface()| instead. */ { explicit @@ -242,7 +242,7 @@ struct nsQueryInterface /* ... - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |do_QueryInterface()| instead. + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |do_QueryInterface()| instead. */ { explicit @@ -266,22 +266,22 @@ do_QueryInterface( nsISupports* aRawPtr, nsresult* error = 0 ) #ifdef NSCAP_FEATURE_ALLOW_RAW_POINTERS - #define null_nsCOMPtr() (0) + #define null_nsCOMPtr() (0) #else - inline - const nsQueryInterface - null_nsCOMPtr() - /* - You can use this to assign |NULL| into an |nsCOMPtr|, e.g., + inline + const nsQueryInterface + null_nsCOMPtr() + /* + You can use this to assign |NULL| into an |nsCOMPtr|, e.g., - myPtr = null_nsCOMPtr(); - */ - { - typedef nsISupports* nsISupports_Ptr; - return nsQueryInterface(nsISupports_Ptr(0)); - } + myPtr = null_nsCOMPtr(); + */ + { + typedef nsISupports* nsISupports_Ptr; + return nsQueryInterface(nsISupports_Ptr(0)); + } #endif @@ -295,8 +295,8 @@ struct nsDontAddRef machinery of |getter_AddRefs| in the argument list to functions that |AddRef| their results before returning them to the caller. - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| or - |dont_AddRef()| instead. + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| or + |dont_AddRef()| instead. See also |getter_AddRefs()|, |dont_AddRef()|, and |class nsGetterAddRefs|. */ @@ -319,9 +319,9 @@ getter_AddRefs( T* aRawPtr ) ...makes typing easier, because it deduces the template type, e.g., you write |dont_AddRef(fooP)| instead of |nsDontAddRef(fooP)|. */ - { - return nsDontAddRef(aRawPtr); - } + { + return nsDontAddRef(aRawPtr); + } template inline @@ -334,9 +334,9 @@ dont_AddRef( T* aRawPtr ) class nsCOMPtr_base - /* - ...factors implementation for all template versions of |nsCOMPtr|. - */ + /* + ...factors implementation for all template versions of |nsCOMPtr|. + */ { public: @@ -347,7 +347,7 @@ class nsCOMPtr_base } #ifdef NSCAP_FEATURE_FACTOR_DESTRUCTOR - NS_EXPORT ~nsCOMPtr_base(); + NS_EXPORT ~nsCOMPtr_base(); #endif #if 0 @@ -378,11 +378,11 @@ class nsCOMPtr : private nsCOMPtr_base typedef T element_type; #ifndef NSCAP_FEATURE_FACTOR_DESTRUCTOR - ~nsCOMPtr() - { - if ( mRawPtr ) - NSCAP_RELEASE(mRawPtr); - } + ~nsCOMPtr() + { + if ( mRawPtr ) + NSCAP_RELEASE(mRawPtr); + } #endif nsCOMPtr() @@ -418,12 +418,12 @@ class nsCOMPtr : private nsCOMPtr_base } #ifdef NSCAP_FEATURE_ALLOW_RAW_POINTERS - nsCOMPtr( T* aRawPtr ) - : nsCOMPtr_base(aRawPtr) - { - if ( mRawPtr ) - NSCAP_ADDREF(mRawPtr); - } + nsCOMPtr( T* aRawPtr ) + : nsCOMPtr_base(aRawPtr) + { + if ( mRawPtr ) + NSCAP_ADDREF(mRawPtr); + } nsCOMPtr& operator=( T* rhs ) @@ -512,10 +512,10 @@ class nsCOMPtr : private nsCOMPtr_base #ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT return NSCAP_REINTERPRET_CAST(T**, begin_assignment()); #else - if ( mRawPtr ) - NSCAP_RELEASE(mRawPtr); - mRawPtr = 0; - return NSCAP_REINTERPRET_CAST(T**, &mRawPtr); + if ( mRawPtr ) + NSCAP_RELEASE(mRawPtr); + mRawPtr = 0; + return NSCAP_REINTERPRET_CAST(T**, &mRawPtr); #endif } }; @@ -532,7 +532,7 @@ class nsGetterAddRefs nsCOMPtr fooP; ...->QueryInterface(iid, getter_AddRefs(fooP)) - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| instead. + DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| instead. When initialized with a |nsCOMPtr|, as in the example above, it returns a |void**| (or |T**| if needed) that the outer call (|QueryInterface| in this @@ -586,92 +586,92 @@ template inline NSCAP_BOOL operator==( const nsCOMPtr& lhs, const nsCOMPtr& rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs.get()); - } + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator==( const nsCOMPtr& lhs, const U* rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs); - } + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_STATIC_CAST(const void*, rhs); + } template inline NSCAP_BOOL operator==( const U* lhs, const nsCOMPtr& rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get()); - } + { + return NSCAP_STATIC_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator==( const nsCOMPtr& lhs, int rhs ) - // specifically to allow |smartPtr == 0| - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_REINTERPRET_CAST(const void*, rhs); - } + // specifically to allow |smartPtr == 0| + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) == NSCAP_REINTERPRET_CAST(const void*, rhs); + } template inline NSCAP_BOOL operator==( int lhs, const nsCOMPtr& rhs ) - // specifically to allow |0 == smartPtr| - { - return NSCAP_REINTERPRET_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get()); - } + // specifically to allow |0 == smartPtr| + { + return NSCAP_REINTERPRET_CAST(const void*, lhs) == NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator!=( const nsCOMPtr& lhs, const nsCOMPtr& rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs.get()); - } + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator!=( const nsCOMPtr& lhs, const U* rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs); - } + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_STATIC_CAST(const void*, rhs); + } template inline NSCAP_BOOL operator!=( const U* lhs, const nsCOMPtr& rhs ) - { - return NSCAP_STATIC_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get()); - } + { + return NSCAP_STATIC_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get()); + } template inline NSCAP_BOOL operator!=( const nsCOMPtr& lhs, int rhs ) - // specifically to allow |smartPtr != 0| - { - return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_REINTERPRET_CAST(const void*, rhs); - } + // specifically to allow |smartPtr != 0| + { + return NSCAP_STATIC_CAST(const void*, lhs.get()) != NSCAP_REINTERPRET_CAST(const void*, rhs); + } template inline NSCAP_BOOL operator!=( int lhs, const nsCOMPtr& rhs ) - // specifically to allow |0 != smartPtr| - { - return NSCAP_REINTERPRET_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get()); - } + // specifically to allow |0 != smartPtr| + { + return NSCAP_REINTERPRET_CAST(const void*, lhs) != NSCAP_STATIC_CAST(const void*, rhs.get()); + } inline NSCAP_BOOL SameCOMIdentity( nsISupports* lhs, nsISupports* rhs ) - { - return nsCOMPtr( do_QueryInterface(lhs) ) == nsCOMPtr( do_QueryInterface(rhs) ); - } + { + return nsCOMPtr( do_QueryInterface(lhs) ) == nsCOMPtr( do_QueryInterface(rhs) ); + } #endif // defined(NSCAP_FEATURE_ALLOW_COMPARISONS) @@ -680,13 +680,13 @@ template inline nsresult CallQueryInterface( nsISupports* aSource, nsCOMPtr* aDestination ) - // a type-safe shortcut for calling the |QueryInterface()| member function - { - NS_PRECONDITION(aSource, "null parameter"); - NS_PRECONDITION(aDestination, "null parameter"); + // a type-safe shortcut for calling the |QueryInterface()| member function + { + NS_PRECONDITION(aSource, "null parameter"); + NS_PRECONDITION(aDestination, "null parameter"); - return aSource->QueryInterface(DestinationType::GetIID(), (void**)getter_AddRefs(*aDestination)); - } + return aSource->QueryInterface(DestinationType::GetIID(), (void**)getter_AddRefs(*aDestination)); + } #endif // !defined(nsCOMPtr_h___)