From 06474b13ccb5949c62e8d237ce67e1952bb3db23 Mon Sep 17 00:00:00 2001 From: "benjamin%smedbergs.us" Date: Wed, 19 Apr 2006 16:29:31 +0000 Subject: [PATCH] Bug 305949 - Fix various XPCOM macros in preparation for stopping exporting nonfrozen XPCOM functions, r=darin sr=bryner --- xpcom/ds/nsHashPropertyBag.h | 4 ++- xpcom/ds/nsSupportsArray.h | 7 ++-- xpcom/glue/nsQuickSort.h | 2 +- xpcom/glue/nsTHashtable.cpp | 2 +- xpcom/glue/nsTHashtable.h | 2 +- xpcom/glue/nsWeakReference.cpp | 47 +++++++++++++++++++++++++++ xpcom/glue/nsWeakReference.h | 59 +++------------------------------- xpcom/io/nsFastLoadFile.cpp | 4 +-- xpcom/io/nsFastLoadFile.h | 4 +-- 9 files changed, 64 insertions(+), 67 deletions(-) diff --git a/xpcom/ds/nsHashPropertyBag.h b/xpcom/ds/nsHashPropertyBag.h index dffe7eab442..12d4f5c3da4 100755 --- a/xpcom/ds/nsHashPropertyBag.h +++ b/xpcom/ds/nsHashPropertyBag.h @@ -49,8 +49,10 @@ #include "nsIWritablePropertyBag2.h" #include "nsInterfaceHashtable.h" +// Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration +// controls member method visibility. #undef IMETHOD_VISIBILITY -#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT +#define IMETHOD_VISIBILITY class NS_COM nsHashPropertyBag : public nsIWritablePropertyBag , public nsIWritablePropertyBag2 diff --git a/xpcom/ds/nsSupportsArray.h b/xpcom/ds/nsSupportsArray.h index 0f9c960198e..07f3abd8c96 100644 --- a/xpcom/ds/nsSupportsArray.h +++ b/xpcom/ds/nsSupportsArray.h @@ -44,8 +44,10 @@ static const PRUint32 kAutoArraySize = 8; +// Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration +// controls member method visibility. #undef IMETHOD_VISIBILITY -#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT +#define IMETHOD_VISIBILITY class NS_COM nsSupportsArray : public nsISupportsArray { public: @@ -166,7 +168,4 @@ private: nsSupportsArray(const nsISupportsArray& other); }; -#undef IMETHOD_VISIBILITY -#define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN - #endif // nsSupportsArray_h__ diff --git a/xpcom/glue/nsQuickSort.h b/xpcom/glue/nsQuickSort.h index f828c2d7930..8cc95593095 100644 --- a/xpcom/glue/nsQuickSort.h +++ b/xpcom/glue/nsQuickSort.h @@ -60,7 +60,7 @@ PR_BEGIN_EXTERN_C * + greater than zero if the second element should be before the first * 5. extra data to pass to comparison function */ -void NS_COM_GLUE NS_QuickSort(void *, unsigned int, unsigned int, +NS_COM_GLUE void NS_QuickSort(void *, unsigned int, unsigned int, int (*)(const void *, const void *, void *), void *); diff --git a/xpcom/glue/nsTHashtable.cpp b/xpcom/glue/nsTHashtable.cpp index 05507633b4d..02e9da0e199 100644 --- a/xpcom/glue/nsTHashtable.cpp +++ b/xpcom/glue/nsTHashtable.cpp @@ -97,7 +97,7 @@ HashCString(const char *str) return code; } -PR_IMPLEMENT(PLDHashOperator) +PLDHashOperator PL_DHashStubEnumRemove(PLDHashTable *table, PLDHashEntryHdr *entry, PRUint32 ordinal, diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index 1e55ada62c3..6955905fa1f 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -44,7 +44,7 @@ #include NEW_H // helper function for nsTHashtable::Clear() -PR_EXTERN(PLDHashOperator) PR_CALLBACK +NS_COM_GLUE PLDHashOperator PL_DHashStubEnumRemove(PLDHashTable *table, PLDHashEntryHdr *entry, PRUint32 ordinal, diff --git a/xpcom/glue/nsWeakReference.cpp b/xpcom/glue/nsWeakReference.cpp index 89565e8191e..a62d2a3fc56 100644 --- a/xpcom/glue/nsWeakReference.cpp +++ b/xpcom/glue/nsWeakReference.cpp @@ -43,6 +43,42 @@ #include "nsWeakReference.h" #include "nsCOMPtr.h" +class nsWeakReference : public nsIWeakReference + { + public: + // nsISupports... + NS_DECL_ISUPPORTS + + // nsIWeakReference... + NS_DECL_NSIWEAKREFERENCE + + private: + friend class nsSupportsWeakReference; + + nsWeakReference( nsSupportsWeakReference* referent ) + : mReferent(referent) + // ...I can only be constructed by an |nsSupportsWeakReference| + { + // nothing else to do here + } + + ~nsWeakReference() + // ...I will only be destroyed by calling |delete| myself. + { + if ( mReferent ) + mReferent->NoticeProxyDestruction(); + } + + void + NoticeReferentDestruction() + // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor. + { + mReferent = 0; + } + + nsSupportsWeakReference* mReferent; + }; + nsresult nsQueryReferent::operator()( const nsIID& aIID, void** answer ) const { @@ -114,3 +150,14 @@ nsWeakReference::QueryReferent( const nsIID& aIID, void** aInstancePtr ) { return mReferent ? mReferent->QueryInterface(aIID, aInstancePtr) : NS_ERROR_NULL_POINTER; } + +void +nsSupportsWeakReference::ClearWeakReferences() + { + if ( mProxy ) + { + mProxy->NoticeReferentDestruction(); + mProxy = 0; + } + } + diff --git a/xpcom/glue/nsWeakReference.h b/xpcom/glue/nsWeakReference.h index 92476ea2c95..ac81097e905 100644 --- a/xpcom/glue/nsWeakReference.h +++ b/xpcom/glue/nsWeakReference.h @@ -47,8 +47,10 @@ class nsWeakReference; +// Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration +// controls member method visibility. #undef IMETHOD_VISIBILITY -#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT +#define IMETHOD_VISIBILITY class NS_COM_GLUE nsSupportsWeakReference : public nsISupportsWeakReference { @@ -78,66 +80,13 @@ class NS_COM_GLUE nsSupportsWeakReference : public nsISupportsWeakReference protected: - inline void ClearWeakReferences(); + void ClearWeakReferences(); PRBool HasWeakReferences() const {return mProxy != 0;} }; #undef IMETHOD_VISIBILITY #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN -class NS_COM_GLUE nsWeakReference : public nsIWeakReference - { - public: - // nsISupports... - NS_DECL_ISUPPORTS - - // nsIWeakReference... - NS_DECL_NSIWEAKREFERENCE - - private: - friend class nsSupportsWeakReference; - - nsWeakReference( nsSupportsWeakReference* referent ) - : mReferent(referent) - // ...I can only be constructed by an |nsSupportsWeakReference| - { - // nothing else to do here - } - - ~nsWeakReference() - // ...I will only be destroyed by calling |delete| myself. - { - if ( mReferent ) - mReferent->NoticeProxyDestruction(); - } - - void - NoticeReferentDestruction() - // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor. - { - mReferent = 0; - } - - nsSupportsWeakReference* mReferent; - }; - -inline -void -nsSupportsWeakReference::ClearWeakReferences() - /* - Usually being called from |nsSupportsWeakReference::~nsSupportsWeakReference| - will be good enough, but you may have a case where you need to call disconnect - your weak references in an outer destructor (to prevent some client holding a - weak reference from re-entering your destructor). - */ - { - if ( mProxy ) - { - mProxy->NoticeReferentDestruction(); - mProxy = 0; - } - } - inline nsSupportsWeakReference::~nsSupportsWeakReference() { diff --git a/xpcom/io/nsFastLoadFile.cpp b/xpcom/io/nsFastLoadFile.cpp index 9e6593838ce..243e63c5af3 100644 --- a/xpcom/io/nsFastLoadFile.cpp +++ b/xpcom/io/nsFastLoadFile.cpp @@ -104,7 +104,7 @@ static void trace_mux(char mode, const char *format, ...) #define FLETCHER_ACCUMULATE(A,B,U) ONES_COMPLEMENT_ACCUMULATE(A, U); \ ONES_COMPLEMENT_ACCUMULATE(B, A) -PR_IMPLEMENT(PRUint32) +PRUint32 NS_AccumulateFastLoadChecksum(PRUint32 *aChecksum, const PRUint8* aBuffer, PRUint32 aLength, @@ -225,7 +225,7 @@ NS_AccumulateFastLoadChecksum(PRUint32 *aChecksum, return aLength; } -PR_IMPLEMENT(PRUint32) +PRUint32 NS_AddFastLoadChecksums(PRUint32 sum1, PRUint32 sum2, PRUint32 sum2ByteCount) { PRUint32 A1 = sum1 & 0xffff; diff --git a/xpcom/io/nsFastLoadFile.h b/xpcom/io/nsFastLoadFile.h index da8d304fc8a..a63f5b41f7e 100644 --- a/xpcom/io/nsFastLoadFile.h +++ b/xpcom/io/nsFastLoadFile.h @@ -178,13 +178,13 @@ typedef PRUint32 NSFastLoadOID; // nsFastLoadFooter::mObjectMap index * * After this, if NS_SUCCEEDED(rv), checksum contains a valid FastLoad sum. */ -PR_EXTERN(PRUint32) +NS_COM PRUint32 NS_AccumulateFastLoadChecksum(PRUint32 *aChecksum, const PRUint8* aBuffer, PRUint32 aLength, PRBool aLastBuffer); -PR_EXTERN(PRUint32) +NS_COM PRUint32 NS_AddFastLoadChecksums(PRUint32 sum1, PRUint32 sum2, PRUint32 sum2ByteCount); /**