diff options
author | Pale Moon <git-repo@palemoon.org> | 2016-03-14 12:31:06 +0100 |
---|---|---|
committer | Pale Moon <git-repo@palemoon.org> | 2016-03-14 12:31:06 +0100 |
commit | 0914637e0eb33101b4d8ca481e945ac92777b19d (patch) | |
tree | 17af240cd0c888663c2de790e5c914fa0820743e /xpcom | |
parent | ebcf789fcd6ec36d38a27cdeeb0427d9cc5c84b2 (diff) | |
download | palemoon-gre-0914637e0eb33101b4d8ca481e945ac92777b19d.tar.gz |
Reinstate static initializers for CC-able objects.
Diffstat (limited to 'xpcom')
-rw-r--r-- | xpcom/base/CycleCollectedJSRuntime.cpp | 55 | ||||
-rw-r--r-- | xpcom/base/CycleCollectedJSRuntime.h | 35 | ||||
-rw-r--r-- | xpcom/base/nsAgg.h | 31 | ||||
-rw-r--r-- | xpcom/ds/nsArray.cpp | 2 | ||||
-rw-r--r-- | xpcom/glue/nsCycleCollectionParticipant.cpp | 12 | ||||
-rw-r--r-- | xpcom/glue/nsCycleCollectionParticipant.h | 440 |
6 files changed, 208 insertions, 367 deletions
diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index 1ae9c541f..812844663 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -240,23 +240,22 @@ private: class JSContextParticipant : public nsCycleCollectionParticipant { public: - static NS_METHOD RootImpl(void *n) + NS_IMETHOD Root(void *n) { return NS_OK; } - static NS_METHOD UnlinkImpl(void *n) + NS_IMETHOD Unlink(void *n) { return NS_OK; } - static NS_METHOD UnrootImpl(void *n) + NS_IMETHOD Unroot(void *n) { return NS_OK; } - static NS_METHOD_(void) DeleteCycleCollectableImpl(void *n) + NS_IMETHOD_(void) DeleteCycleCollectable(void *n) { } - static NS_METHOD TraverseImpl(JSContextParticipant *that, void *n, - nsCycleCollectionTraversalCallback &cb) + NS_IMETHOD Traverse(void *n, nsCycleCollectionTraversalCallback &cb) { JSContext *cx = static_cast<JSContext*>(n); @@ -277,11 +276,7 @@ public: } }; -static const CCParticipantVTable<JSContextParticipant>::Type -JSContext_cycleCollectorGlobal = -{ - NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(JSContextParticipant) -}; +static JSContextParticipant JSContext_cycleCollectorGlobal; struct Closure { @@ -319,12 +314,11 @@ NoteJSHolder(void *holder, nsScriptObjectTracer *&tracer, void *arg) return PL_DHASH_NEXT; } -NS_METHOD -JSGCThingParticipant::TraverseImpl(JSGCThingParticipant* that, void* p, - nsCycleCollectionTraversalCallback& cb) +NS_IMETHODIMP +JSGCThingParticipant::Traverse(void* p, nsCycleCollectionTraversalCallback& cb) { CycleCollectedJSRuntime* runtime = reinterpret_cast<CycleCollectedJSRuntime*> - (reinterpret_cast<char*>(that) - + (reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSRuntime, mGCThingCycleCollectorGlobal)); runtime->TraverseGCThing(CycleCollectedJSRuntime::TRAVERSE_FULL, @@ -334,18 +328,13 @@ JSGCThingParticipant::TraverseImpl(JSGCThingParticipant* that, void* p, // NB: This is only used to initialize the participant in // CycleCollectedJSRuntime. It should never be used directly. -static const CCParticipantVTable<JSGCThingParticipant>::Type -sGCThingCycleCollectorGlobal = -{ - NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(JSGCThingParticipant) -}; +static JSGCThingParticipant sGCThingCycleCollectorGlobal; -NS_METHOD -JSZoneParticipant::TraverseImpl(JSZoneParticipant* that, void* p, - nsCycleCollectionTraversalCallback& cb) +NS_IMETHODIMP +JSZoneParticipant::Traverse(void* p, nsCycleCollectionTraversalCallback& cb) { CycleCollectedJSRuntime* runtime = reinterpret_cast<CycleCollectedJSRuntime*> - (reinterpret_cast<char*>(that) - + (reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSRuntime, mJSZoneCycleCollectorGlobal)); MOZ_ASSERT(!cb.WantAllTraces()); @@ -442,10 +431,7 @@ NoteJSChildGrayWrapperShim(void* aData, void* aThing) // NB: This is only used to initialize the participant in // CycleCollectedJSRuntime. It should never be used directly. -static const CCParticipantVTable<JSZoneParticipant>::Type -sJSZoneCycleCollectorGlobal = { - NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(JSZoneParticipant) -}; +static const JSZoneParticipant sJSZoneCycleCollectorGlobal; CycleCollectedJSRuntime::CycleCollectedJSRuntime(uint32_t aMaxbytes, JSUseHelperThreads aUseHelperThreads, @@ -792,7 +778,6 @@ CycleCollectedJSRuntime::TraceNativeGrayRoots(JSTracer* aTracer) void CycleCollectedJSRuntime::AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer) { - MOZ_ASSERT(aTracer->Trace, "AddJSHolder needs a non-null Trace function"); bool wasEmpty = mJSHolders.Count() == 0; mJSHolders.Put(aHolder, aTracer); if (wasEmpty && mJSHolders.Count() == 1) { @@ -836,7 +821,7 @@ void CycleCollectedJSRuntime::AssertNoObjectsToTrace(void* aPossibleJSHolder) { nsScriptObjectTracer* tracer = mJSHolders.Get(aPossibleJSHolder); - if (tracer && tracer->Trace) { + if (tracer) { tracer->Trace(aPossibleJSHolder, TraceCallbackFunc(AssertNoGcThing), nullptr); } } @@ -846,19 +831,19 @@ CycleCollectedJSRuntime::AssertNoObjectsToTrace(void* aPossibleJSHolder) nsCycleCollectionParticipant* CycleCollectedJSRuntime::JSContextParticipant() { - return JSContext_cycleCollectorGlobal.GetParticipant(); + return &JSContext_cycleCollectorGlobal; } nsCycleCollectionParticipant* -CycleCollectedJSRuntime::GCThingParticipant() const +CycleCollectedJSRuntime::GCThingParticipant() { - return mGCThingCycleCollectorGlobal.GetParticipant(); + return &mGCThingCycleCollectorGlobal; } nsCycleCollectionParticipant* -CycleCollectedJSRuntime::ZoneParticipant() const +CycleCollectedJSRuntime::ZoneParticipant() { - return mJSZoneCycleCollectorGlobal.GetParticipant(); + return &mJSZoneCycleCollectorGlobal; } bool diff --git a/xpcom/base/CycleCollectedJSRuntime.h b/xpcom/base/CycleCollectedJSRuntime.h index 191eef79b..997418382 100644 --- a/xpcom/base/CycleCollectedJSRuntime.h +++ b/xpcom/base/CycleCollectedJSRuntime.h @@ -22,54 +22,53 @@ namespace mozilla { class JSGCThingParticipant: public nsCycleCollectionParticipant { public: - static NS_METHOD RootImpl(void *n) + NS_IMETHOD Root(void *n) { return NS_OK; } - static NS_METHOD UnlinkImpl(void *n) + NS_IMETHOD Unlink(void *n) { return NS_OK; } - static NS_METHOD UnrootImpl(void *n) + NS_IMETHOD Unroot(void *n) { return NS_OK; } - static NS_METHOD_(void) DeleteCycleCollectableImpl(void *n) + NS_IMETHOD_(void) DeleteCycleCollectable(void *n) { } - static NS_METHOD TraverseImpl(JSGCThingParticipant *that, void *n, - nsCycleCollectionTraversalCallback &cb); + NS_IMETHOD Traverse(void *n, nsCycleCollectionTraversalCallback &cb); }; class JSZoneParticipant : public nsCycleCollectionParticipant { public: - - static NS_METHOD RootImpl(void *p) + MOZ_CONSTEXPR JSZoneParticipant(): nsCycleCollectionParticipant() {} + + NS_IMETHOD Root(void *p) { return NS_OK; } - static NS_METHOD UnlinkImpl(void *p) + NS_IMETHOD Unlink(void *p) { return NS_OK; } - static NS_METHOD UnrootImpl(void *p) + NS_IMETHOD Unroot(void *p) { return NS_OK; } - static NS_METHOD_(void) DeleteCycleCollectableImpl(void *n) + NS_IMETHOD_(void) DeleteCycleCollectable(void *n) { } - static NS_METHOD TraverseImpl(JSZoneParticipant *that, void *p, - nsCycleCollectionTraversalCallback &cb); + NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb); }; class CycleCollectedJSRuntime @@ -158,8 +157,8 @@ public: // This returns the singleton nsCycleCollectionParticipant for JSContexts. static nsCycleCollectionParticipant* JSContextParticipant(); - nsCycleCollectionParticipant* GCThingParticipant() const; - nsCycleCollectionParticipant* ZoneParticipant() const; + nsCycleCollectionParticipant* GCThingParticipant(); + nsCycleCollectionParticipant* ZoneParticipant(); bool NotifyLeaveMainThread() const; void NotifyEnterCycleCollectionThread() const; @@ -175,11 +174,9 @@ public: virtual void PrepareForCollection() {} private: - typedef const CCParticipantVTable<JSGCThingParticipant>::Type GCThingParticipantVTable; - const GCThingParticipantVTable mGCThingCycleCollectorGlobal; + JSGCThingParticipant mGCThingCycleCollectorGlobal; - typedef const CCParticipantVTable<JSZoneParticipant>::Type JSZoneParticipantVTable; - const JSZoneParticipantVTable mJSZoneCycleCollectorGlobal; + JSZoneParticipant mJSZoneCycleCollectorGlobal; JSRuntime* mJSRuntime; diff --git a/xpcom/base/nsAgg.h b/xpcom/base/nsAgg.h index c37bfe687..ca7d6f4fa 100644 --- a/xpcom/base/nsAgg.h +++ b/xpcom/base/nsAgg.h @@ -72,11 +72,9 @@ class NS_CYCLE_COLLECTION_INNERCLASS \ : public nsXPCOMCycleCollectionParticipant \ { \ public: \ - static NS_METHOD UnlinkImpl(void *p); \ - static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_INNERCLASS *that, \ - void *p, \ - nsCycleCollectionTraversalCallback &cb); \ - static NS_METHOD_(void) DeleteCycleCollectableImpl(void* p) \ + NS_IMETHOD Unlink(void *p); \ + NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb); \ + NS_IMETHOD_(void) DeleteCycleCollectable(void* p) \ { \ NS_CYCLE_COLLECTION_CLASSNAME(_class):: \ Downcast(static_cast<nsISupports*>(p))->DeleteCycleCollectable(); \ @@ -89,16 +87,12 @@ public: \ { \ return p->InnerObject(); \ } \ - static nsXPCOMCycleCollectionParticipant* GetParticipant() \ - { \ - static const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \ - ::Type participant = { \ - NS_IMPL_CYCLE_COLLECTION_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) \ - }; \ - return NS_PARTICIPANT_AS(nsXPCOMCycleCollectionParticipant, \ - &participant); \ - } \ -}; + static nsXPCOMCycleCollectionParticipant* GetParticipant() \ + { \ + return &_class::NS_CYCLE_COLLECTION_INNERNAME; \ + } \ +}; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; // Put this in your class's constructor: #define NS_INIT_AGGREGATED(outer) \ @@ -276,10 +270,9 @@ _class::AggregatedQueryInterface(REFNSIID aIID, void** aInstancePtr) \ else #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_AGGREGATED(_class) \ - NS_METHOD \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraverseImpl \ - (NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, \ - void *p, nsCycleCollectionTraversalCallback &cb) \ + NS_IMETHODIMP \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::Traverse \ + (void *p, nsCycleCollectionTraversalCallback &cb) \ { \ nsISupports *s = static_cast<nsISupports*>(p); \ MOZ_ASSERT(CheckForRightISupports(s), \ diff --git a/xpcom/ds/nsArray.cpp b/xpcom/ds/nsArray.cpp index 6e7992cb7..164bef3ce 100644 --- a/xpcom/ds/nsArray.cpp +++ b/xpcom/ds/nsArray.cpp @@ -39,6 +39,8 @@ nsArray::~nsArray() NS_IMPL_ADDREF(nsArray) NS_IMPL_RELEASE(nsArray) +NS_IMPL_CYCLE_COLLECTION_CLASS(nsArrayCC) + NS_IMPL_CYCLE_COLLECTING_ADDREF(nsArrayCC) NS_IMPL_CYCLE_COLLECTING_RELEASE(nsArrayCC) diff --git a/xpcom/glue/nsCycleCollectionParticipant.cpp b/xpcom/glue/nsCycleCollectionParticipant.cpp index 13fe4bc73..109851755 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.cpp +++ b/xpcom/glue/nsCycleCollectionParticipant.cpp @@ -23,16 +23,16 @@ nsScriptObjectTracer::NoteJSChild(void *aScriptThing, const char *name, cb->NoteJSChild(aScriptThing); } -nsresult -nsXPCOMCycleCollectionParticipant::RootImpl(void *p) +NS_IMETHODIMP +nsXPCOMCycleCollectionParticipant::Root(void *p) { nsISupports *s = static_cast<nsISupports*>(p); NS_ADDREF(s); return NS_OK; } -nsresult -nsXPCOMCycleCollectionParticipant::UnrootImpl(void *p) +NS_IMETHODIMP +nsXPCOMCycleCollectionParticipant::Unroot(void *p) { nsISupports *s = static_cast<nsISupports*>(p); NS_RELEASE(s); @@ -42,8 +42,8 @@ nsXPCOMCycleCollectionParticipant::UnrootImpl(void *p) // We define a default trace function because some participants don't need // to trace anything, so it is okay for them not to define one. NS_IMETHODIMP_(void) -nsXPCOMCycleCollectionParticipant::TraceImpl(void *p, const TraceCallbacks &cb, - void *closure) +nsXPCOMCycleCollectionParticipant::Trace(void *p, const TraceCallbacks &cb, + void *closure) { } diff --git a/xpcom/glue/nsCycleCollectionParticipant.h b/xpcom/glue/nsCycleCollectionParticipant.h index 10bb8d2db..e27703b42 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.h +++ b/xpcom/glue/nsCycleCollectionParticipant.h @@ -44,13 +44,6 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionISupports, NS_CYCLECOLLECTIONISUPPORTS_IID) -/** - * Forward declarations - */ -class nsCycleCollectionParticipant; -class nsScriptObjectTracer; -class nsXPCOMCycleCollectionParticipant; - namespace JS { template <class T> class Heap; } /* namespace JS */ @@ -90,159 +83,29 @@ struct TraceCallbackFunc : public TraceCallbacks }; /** - * VTables - * - * When using global scope static initialization for simple types with virtual - * member functions, GCC creates static initializer functions. In order to - * avoid this from happening, cycle collection participants are defined as - * function tables. - * - * The Traverse function may require calling another function from the cycle - * collection participant function table, so a pointer to the function table - * is given to it. Using member function pointers would be less awkward, but - * in MSVC, the size of such a member function pointer depends on the class - * the function is member of. This makes it hard to make them compatible with - * a generic function table. Moreover, static initialization of the function - * table then uses a static initializer function. - * - * Finally, it is not possible to use an initializer list for non-aggregate - * types. Separate types are thus required for static initialization. For - * convenience and to avoid repetitions that could lead to discrepancies, - * function table members for sub-types are declared independently, and - * different aggregate types are defined for static initialization. - */ - -/* Base functions for nsCycleCollectionParticipant */ -template <typename T> -struct nsCycleCollectionParticipantVTableCommon -{ - nsresult (NS_STDCALL *TraverseReal) - (T *that, void *p, nsCycleCollectionTraversalCallback &cb); - - nsresult (NS_STDCALL *Root)(void *p); - nsresult (NS_STDCALL *Unlink)(void *p); - nsresult (NS_STDCALL *Unroot)(void *p); - - bool (NS_STDCALL *CanSkipReal)(void *p, bool aRemovingAllowed); - bool (NS_STDCALL *CanSkipInCCReal)(void *p); - bool (NS_STDCALL *CanSkipThisReal)(void *p); - - void (NS_STDCALL *DeleteCycleCollectable)(void*); -}; - -typedef nsCycleCollectionParticipantVTableCommon<nsCycleCollectionParticipant> - nsCycleCollectionParticipantVTable; - -/* Additional functions for nsScriptObjectTracer */ -struct nsScriptObjectTracerVTable -{ - void (NS_STDCALL *Trace)(void *p, const TraceCallbacks &cb, void *closure); -}; - -/** - * Types for static initialization - * - * Considering T, the cycle collection participant class, subclass of either - * nsCycleCollectionParticipant, nsScriptObjectTracer or - * nsXPCOMCycleCollectionParticipant, static initialization goes as follows: - * - * CCParticipantVTable<T>::type T::_cycleCollectorGlobal = {{...} ...}; - * - * CCParticipantVTable<T>::type automatically defines the right type considering - * what particular cycle collection participant class T derives from. - * - * The NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(classname), - * NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(classname), and - * NS_IMPL_CYCLE_COLLECTION_VTABLE(classname) macros may be used as helpers - * for static initialization: - * - * CCParticipantVTable<T>::type T::_cycleCollectorGlobal = { - * NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(classname); - * }; - */ - -enum nsCycleCollectionParticipantType -{ - eInvalid, - eCycleCollectionParticipant, - eScriptObjectTracer, - eXPCOMCycleCollectionParticipant -}; - -template <typename T, enum nsCycleCollectionParticipantType ParticipantType> -struct CCParticipantVTableImpl { }; - -/* CCParticipantVTable for nsCycleCollectionParticipant */ -template <typename T> -struct CCParticipantVTableImpl<T, eCycleCollectionParticipant> -{ - nsCycleCollectionParticipant *GetParticipant() const - { - return const_cast<nsCycleCollectionParticipant *> - (reinterpret_cast<const nsCycleCollectionParticipant *>(this)); - } - nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant; -}; - -/* CCParticipantVTable for nsScriptObjectTracer */ -template <typename T> -struct CCParticipantVTableImpl<T, eScriptObjectTracer> -{ - nsScriptObjectTracer *GetParticipant() const - { - return const_cast<nsScriptObjectTracer *> - (reinterpret_cast<const nsScriptObjectTracer *>(this)); - } - nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant; - nsScriptObjectTracerVTable scriptObjectTracer; -}; - -/* CCParticipantVTable for nsXPCOMCycleCollectionParticipant */ -template <typename T> -struct CCParticipantVTableImpl<T, eXPCOMCycleCollectionParticipant> -{ - nsXPCOMCycleCollectionParticipant *GetParticipant() const - { - return const_cast<nsXPCOMCycleCollectionParticipant *> - (reinterpret_cast<const nsXPCOMCycleCollectionParticipant *>(this)); - } - nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant; - nsScriptObjectTracerVTable scriptObjectTracer; -}; - -template <typename T> -struct CCParticipantVTable -{ - static const enum nsCycleCollectionParticipantType ParticipantType = - mozilla::IsBaseOf<nsXPCOMCycleCollectionParticipant, T>::value ? eXPCOMCycleCollectionParticipant : - mozilla::IsBaseOf<nsScriptObjectTracer, T>::value ? eScriptObjectTracer : - mozilla::IsBaseOf<nsCycleCollectionParticipant, T>::value ? eCycleCollectionParticipant : - eInvalid; - typedef CCParticipantVTableImpl<T, ParticipantType> Type; -}; - -/** * Participant implementation classes */ -class nsCycleCollectionParticipant : public nsCycleCollectionParticipantVTable +class NS_NO_VTABLE nsCycleCollectionParticipant { public: - static const bool isSkippable = false; + MOZ_CONSTEXPR nsCycleCollectionParticipant() : mMightSkip(false) {} + MOZ_CONSTEXPR nsCycleCollectionParticipant(bool aSkip) : mMightSkip(aSkip) {} NS_DECLARE_STATIC_IID_ACCESSOR(NS_CYCLECOLLECTIONPARTICIPANT_IID) - // Helper function to avoid painful syntax for member function call using - // the VTable entry. - NS_METHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb) { - return TraverseReal(this, p, cb); - } + NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb) = 0; + + NS_IMETHOD Root(void *p) = 0; + NS_IMETHOD Unlink(void *p) = 0; + NS_IMETHOD Unroot(void *p) = 0; + // If CanSkip returns true, p is removed from the purple buffer during // a call to nsCycleCollector_forgetSkippable(). // Note, calling CanSkip may remove objects from the purple buffer! // If aRemovingAllowed is true, p can be removed from the purple buffer. bool CanSkip(void *p, bool aRemovingAllowed) { - return CanSkipReal ? CanSkipReal(p, aRemovingAllowed) : false; + return mMightSkip ? CanSkipReal(p, aRemovingAllowed) : false; } // If CanSkipInCC returns true, p is skipped when selecting roots for the @@ -250,7 +113,7 @@ public: // Note, calling CanSkipInCC may remove other objects from the purple buffer! bool CanSkipInCC(void *p) { - return CanSkipInCCReal ? CanSkipInCCReal(p) : false; + return mMightSkip ? CanSkipInCCReal(p) : false; } // If CanSkipThis returns true, p is not added to the graph. @@ -258,28 +121,57 @@ public: // change the state of any objects! bool CanSkipThis(void *p) { - return CanSkipThisReal ? CanSkipThisReal(p) : false; + return mMightSkip ? CanSkipThisReal(p) : false; + } + + NS_IMETHOD_(void) DeleteCycleCollectable(void *n) = 0; + +protected: + NS_IMETHOD_(bool) CanSkipReal(void *p, bool aRemovingAllowed) + { + NS_ASSERTION(false, "Forgot to implement CanSkipReal?"); + return false; + } + NS_IMETHOD_(bool) CanSkipInCCReal(void *p) + { + NS_ASSERTION(false, "Forgot to implement CanSkipInCCReal?"); + return false; + } + NS_IMETHOD_(bool) CanSkipThisReal(void *p) + { + NS_ASSERTION(false, "Forgot to implement CanSkipThisReal?"); + return false; } + +private: + const bool mMightSkip; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionParticipant, NS_CYCLECOLLECTIONPARTICIPANT_IID) -class nsScriptObjectTracer - : public nsCycleCollectionParticipant, public nsScriptObjectTracerVTable +class NS_NO_VTABLE nsScriptObjectTracer : public nsCycleCollectionParticipant { public: + MOZ_CONSTEXPR nsScriptObjectTracer() : nsCycleCollectionParticipant(false) {} + MOZ_CONSTEXPR nsScriptObjectTracer(bool aSkip) : nsCycleCollectionParticipant(aSkip) {} + + NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure) = 0; + static void NS_COM_GLUE NoteJSChild(void *aScriptThing, const char *name, void *aClosure); }; -class nsXPCOMCycleCollectionParticipant : public nsScriptObjectTracer +class NS_NO_VTABLE nsXPCOMCycleCollectionParticipant : public nsScriptObjectTracer { public: - static NS_METHOD RootImpl(void *p); - static NS_METHOD UnrootImpl(void *p); + MOZ_CONSTEXPR nsXPCOMCycleCollectionParticipant() : nsScriptObjectTracer(false) {} + MOZ_CONSTEXPR nsXPCOMCycleCollectionParticipant(bool aSkip) : nsScriptObjectTracer(aSkip) {} - static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure); + NS_IMETHOD Root(void *p); + NS_IMETHOD Unroot(void *p); + + NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure); static bool CheckForRightISupports(nsISupports *s); }; @@ -382,8 +274,8 @@ T* DowncastCCParticipant(void *p) /////////////////////////////////////////////////////////////////////////////// #define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(_class) \ - NS_METHOD_(bool) \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipImpl(void *p, \ + NS_IMETHODIMP_(bool) \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipReal(void *p, \ bool aRemovingAllowed) \ { \ _class *tmp = DowncastCCParticipant<_class >(p); @@ -394,8 +286,8 @@ T* DowncastCCParticipant(void *p) } #define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(_class) \ - NS_METHOD_(bool) \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipInCCImpl(void *p) \ + NS_IMETHODIMP_(bool) \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipInCCReal(void *p) \ { \ _class *tmp = DowncastCCParticipant<_class >(p); @@ -405,8 +297,8 @@ T* DowncastCCParticipant(void *p) } #define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(_class) \ - NS_METHOD_(bool) \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipThisImpl(void *p) \ + NS_IMETHODIMP_(bool) \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipThisReal(void *p) \ { \ _class *tmp = DowncastCCParticipant<_class >(p); @@ -426,15 +318,15 @@ T* DowncastCCParticipant(void *p) /////////////////////////////////////////////////////////////////////////////// #define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ - NS_METHOD \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnlinkImpl(void *p) \ + NS_IMETHODIMP \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unlink(void *p) \ { \ _class *tmp = DowncastCCParticipant<_class >(p); #define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ nsISupports *s = static_cast<nsISupports*>(p); \ - NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::UnlinkImpl(s); + NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Unlink(s); #define NS_IMPL_CYCLE_COLLECTION_UNLINK(_field) \ ImplCycleCollectionUnlink(tmp->_field); @@ -446,7 +338,7 @@ T* DowncastCCParticipant(void *p) #define NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(_base_class) \ nsISupports *s = static_cast<nsISupports*>(p); \ - NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::UnlinkImpl(s); \ + NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Unlink(s); \ (void)tmp; \ return NS_OK; \ } @@ -464,10 +356,9 @@ T* DowncastCCParticipant(void *p) cb.DescribeRefCountedNode(_refcnt, #_class); #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \ - NS_METHOD \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraverseImpl \ - (NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, void *p,\ - nsCycleCollectionTraversalCallback &cb) \ + NS_IMETHODIMP \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::Traverse \ + (void *p, nsCycleCollectionTraversalCallback &cb) \ { \ _class *tmp = DowncastCCParticipant<_class >(p); @@ -482,7 +373,7 @@ T* DowncastCCParticipant(void *p) #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base_class) \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \ nsISupports *s = static_cast<nsISupports*>(p); \ - if (NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::TraverseImpl(that, s, cb) \ + if (NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Traverse(s, cb) \ == NS_SUCCESS_INTERRUPTED_TRAVERSE) { \ return NS_SUCCESS_INTERRUPTED_TRAVERSE; \ } @@ -496,7 +387,7 @@ T* DowncastCCParticipant(void *p) #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS \ { \ TraceCallbackFunc noteJsChild(&nsScriptObjectTracer::NoteJSChild); \ - that->Trace(p, noteJsChild, &cb); \ + Trace(p, noteJsChild, &cb); \ } #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END \ @@ -510,18 +401,16 @@ T* DowncastCCParticipant(void *p) #define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_class) \ void \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraceImpl(void *p, \ - const TraceCallbacks &aCallbacks, \ - void *aClosure) \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \ + const TraceCallbacks &aCallbacks, \ + void *aClosure) \ { \ _class *tmp = DowncastCCParticipant<_class >(p); #define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(_class, _base_class) \ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_class) \ nsISupports *s = static_cast<nsISupports*>(p); \ - NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::TraceImpl(s, \ - aCallbacks, \ - aClosure); + NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Trace(s, aCallbacks, aClosure); #define NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(_field) \ if (tmp->_field) \ @@ -545,9 +434,8 @@ T* DowncastCCParticipant(void *p) #define NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base) \ public: \ - static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, \ - void *p, nsCycleCollectionTraversalCallback &cb); \ - static NS_METHOD_(void) DeleteCycleCollectableImpl(void* p) \ + NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb); \ + NS_IMETHOD_(void) DeleteCycleCollectable(void *p) \ { \ DowncastCCParticipant<_class>(p)->DeleteCycleCollectable(); \ } \ @@ -565,7 +453,7 @@ public: \ #define NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \ NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base) \ - static NS_METHOD UnlinkImpl(void *p); + NS_IMETHOD Unlink(void *p); #define NS_PARTICIPANT_AS(type, participant) \ const_cast<type*>(reinterpret_cast<const type*>(participant)) @@ -573,11 +461,7 @@ public: \ #define NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ static nsXPCOMCycleCollectionParticipant* GetParticipant() \ { \ - static const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \ - ::Type p = { \ - NS_IMPL_CYCLE_COLLECTION_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) \ - }; \ - return NS_PARTICIPANT_AS(nsXPCOMCycleCollectionParticipant, &p); \ + return &_class::NS_CYCLE_COLLECTION_INNERNAME; \ } /** @@ -599,6 +483,7 @@ class NS_CYCLE_COLLECTION_INNERCLASS \ NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \ NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ }; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; \ NOT_INHERITED_CANT_OVERRIDE #define NS_DECL_CYCLE_COLLECTION_CLASS(_class) \ @@ -609,13 +494,17 @@ class NS_CYCLE_COLLECTION_INNERCLASS \ class NS_CYCLE_COLLECTION_INNERCLASS \ : public nsXPCOMCycleCollectionParticipant \ { \ +public: \ + MOZ_CONSTEXPR NS_CYCLE_COLLECTION_INNERCLASS () \ + : nsXPCOMCycleCollectionParticipant(true) {} \ +private: \ NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \ - static const bool isSkippable = true; \ - static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed); \ - static NS_METHOD_(bool) CanSkipInCCImpl(void *p); \ - static NS_METHOD_(bool) CanSkipThisImpl(void *p); \ - NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ -}; \ + NS_IMETHOD_(bool) CanSkipReal(void *p, bool aRemovingAllowed); \ + NS_IMETHOD_(bool) CanSkipInCCReal(void *p); \ + NS_IMETHOD_(bool) CanSkipThisReal(void *p); \ + NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ +}; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; \ NOT_INHERITED_CANT_OVERRIDE #define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(_class) \ @@ -626,23 +515,28 @@ class NS_CYCLE_COLLECTION_INNERCLASS : public nsXPCOMCycleCollectionParticipant \ { \ NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \ - static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure); \ + NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure); \ NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ }; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; \ NOT_INHERITED_CANT_OVERRIDE #define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _base) \ class NS_CYCLE_COLLECTION_INNERCLASS \ : public nsXPCOMCycleCollectionParticipant \ { \ +public: \ + MOZ_CONSTEXPR NS_CYCLE_COLLECTION_INNERCLASS () \ + : nsXPCOMCycleCollectionParticipant(true) {} \ +private: \ NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \ - static const bool isSkippable = true; \ - static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure); \ - static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed); \ - static NS_METHOD_(bool) CanSkipInCCImpl(void *p); \ - static NS_METHOD_(bool) CanSkipThisImpl(void *p); \ + NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure); \ + NS_IMETHOD_(bool) CanSkipReal(void *p, bool aRemovingAllowed); \ + NS_IMETHOD_(bool) CanSkipInCCReal(void *p); \ + NS_IMETHOD_(bool) CanSkipThisReal(void *p); \ NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ }; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; \ NOT_INHERITED_CANT_OVERRIDE #define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(_class) \ @@ -654,13 +548,13 @@ class NS_CYCLE_COLLECTION_INNERCLASS : public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \ { \ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \ - static const bool isSkippable = true; \ - static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure); \ - static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed); \ - static NS_METHOD_(bool) CanSkipInCCImpl(void *p); \ - static NS_METHOD_(bool) CanSkipThisImpl(void *p); \ + NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure); \ + NS_IMETHOD_(bool) CanSkipReal(void *p, bool aRemovingAllowed); \ + NS_IMETHOD_(bool) CanSkipInCCReal(void *p); \ + NS_IMETHOD_(bool) CanSkipThisReal(void *p); \ NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ -}; +}; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; #define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(_class) \ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _class) @@ -668,8 +562,7 @@ class NS_CYCLE_COLLECTION_INNERCLASS #define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, \ _base_class) \ public: \ - static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, \ - void *p, nsCycleCollectionTraversalCallback &cb); \ + NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb); \ static _class* Downcast(nsISupports* s) \ { \ return static_cast<_class*>(static_cast<_base_class*>( \ @@ -678,7 +571,7 @@ public: \ #define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, _base_class) \ - static NS_METHOD UnlinkImpl(void *p); + NS_IMETHOD Unlink(void *p); #define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(_class, _base_class) \ class NS_CYCLE_COLLECTION_INNERCLASS \ @@ -687,7 +580,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS \ public: \ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \ NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ -}; +}; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; #define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(_class, \ _base_class) \ @@ -697,7 +591,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS \ public: \ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, _base_class) \ NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ -}; +}; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; #define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(_class, \ _base_class) \ @@ -705,68 +600,22 @@ class NS_CYCLE_COLLECTION_INNERCLASS : public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \ { \ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \ - static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, void *closure); \ + NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure); \ NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \ -}; - -/** - * Dummy class with a definition for CanSkip* function members, but no - * implementation. - * Implementation was added to please Win PGO. (See bug 765159) - */ -struct SkippableDummy -{ - static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed) { return false; } - static NS_METHOD_(bool) CanSkipInCCImpl(void *p) { return false; } - static NS_METHOD_(bool) CanSkipThisImpl(void *p) { return false; } -}; - -/** - * Skippable<T> defines a class that always has definitions for CanSkip* - * function members, so that T::isSkippable ? &Skippable<T>::CanSkip* : NULL - * can compile when T::isSkippable is false and T doesn't have CanSkip* - * definitions (which, as not being skippable, it's not supposed to have). - */ -template <class T> -struct Skippable - : public mozilla::Conditional<T::isSkippable, T, SkippableDummy>::Type -{ }; - - -// VTables for the cycle collector participant implementations. - -#define NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(_class) \ - { \ - &_class::TraverseImpl, \ - &_class::RootImpl, \ - &_class::UnlinkImpl, \ - &_class::UnrootImpl, \ - _class::isSkippable ? &Skippable<_class>::CanSkipImpl : NULL, \ - _class::isSkippable ? &Skippable<_class>::CanSkipInCCImpl : NULL, \ - _class::isSkippable ? &Skippable<_class>::CanSkipThisImpl : NULL, \ - &_class::DeleteCycleCollectableImpl \ - } - -#define NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(_class) \ - NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(_class), \ - { &_class::TraceImpl } - -#define NS_IMPL_CYCLE_COLLECTION_VTABLE(_class) \ - NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(_class) - +}; \ +static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; // Cycle collector participant declarations. #define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \ public: \ - static NS_METHOD RootImpl(void *n); \ - static NS_METHOD UnlinkImpl(void *n); \ - static NS_METHOD UnrootImpl(void *n); \ - static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, \ - void *n, nsCycleCollectionTraversalCallback &cb); \ - static NS_METHOD_(void) DeleteCycleCollectableImpl(void* p) \ + NS_IMETHOD Root(void *n); \ + NS_IMETHOD Unlink(void *n); \ + NS_IMETHOD Unroot(void *n); \ + NS_IMETHOD Traverse(void *n, nsCycleCollectionTraversalCallback &cb); \ + NS_IMETHOD_(void) DeleteCycleCollectable(void *n) \ { \ - DowncastCCParticipant<_class>(p)->DeleteCycleCollectable(); \ + DowncastCCParticipant<_class>(n)->DeleteCycleCollectable(); \ } #define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(_class) \ @@ -777,17 +626,13 @@ struct Skippable class NS_CYCLE_COLLECTION_INNERCLASS \ : public nsCycleCollectionParticipant \ { \ - NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \ - static nsCycleCollectionParticipant* GetParticipant() \ - { \ - static const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \ - ::Type p = { \ - NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE( \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)) \ - }; \ - return NS_PARTICIPANT_AS(nsCycleCollectionParticipant, &p); \ + NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \ + static nsCycleCollectionParticipant* GetParticipant() \ + { \ + return &_class::NS_CYCLE_COLLECTION_INNERNAME; \ } \ - }; + }; \ + static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; #define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(_class) \ void DeleteCycleCollectable(void) \ @@ -798,22 +643,17 @@ struct Skippable : public nsScriptObjectTracer \ { \ NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \ - static NS_METHOD_(void) TraceImpl(void *p, const TraceCallbacks &cb, \ - void *closure); \ + NS_IMETHOD_(void) Trace(void *p, const TraceCallbacks &cb, void *closure); \ static nsScriptObjectTracer* GetParticipant() \ { \ - static const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \ - ::Type participant = { \ - NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE( \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)) \ - }; \ - return NS_PARTICIPANT_AS(nsScriptObjectTracer, &participant); \ - } \ - }; + return &_class::NS_CYCLE_COLLECTION_INNERNAME; \ + } \ + }; \ + static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME; #define NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(_class, _root_function) \ - NS_METHOD \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::RootImpl(void *p) \ + NS_IMETHODIMP \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::Root(void *p) \ { \ _class *tmp = static_cast<_class*>(p); \ tmp->_root_function(); \ @@ -821,8 +661,8 @@ struct Skippable } #define NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(_class, _unroot_function) \ - NS_METHOD \ - NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnrootImpl(void *p) \ + NS_IMETHODIMP \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unroot(void *p) \ { \ _class *tmp = static_cast<_class*>(p); \ tmp->_unroot_function(); \ @@ -832,7 +672,11 @@ struct Skippable // NS_IMPL_CYCLE_COLLECTION_0 is not defined because most of the time it doesn't // make sense to add something to the CC that doesn't traverse to anything. +#define NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ + _class::NS_CYCLE_COLLECTION_INNERCLASS _class::NS_CYCLE_COLLECTION_INNERNAME; + #define NS_IMPL_CYCLE_COLLECTION_1(_class, _f) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_END \ @@ -841,6 +685,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_2(_class, _f1, _f2) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -851,6 +696,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_3(_class, _f1, _f2, _f3) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -863,6 +709,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_4(_class, _f1, _f2, _f3, _f4) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -877,6 +724,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_5(_class, _f1, _f2, _f3, _f4, _f5) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -893,6 +741,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_6(_class, _f1, _f2, _f3, _f4, _f5, _f6) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -911,6 +760,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_7(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -931,6 +781,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_8(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -953,6 +804,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_9(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -977,6 +829,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_10(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9, _f10) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1004,6 +857,7 @@ struct Skippable #define NS_IMPL_CYCLE_COLLECTION_17(_class, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9, \ _f10, _f11, _f12, _f13, _f14, _f15, _f16, _f17) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1044,6 +898,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_1(_class, _base, _f1) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_END \ @@ -1052,6 +907,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_2(_class, _base, _f1, _f2) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1062,6 +918,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_3(_class, _base, _f1, _f2, _f3) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1074,6 +931,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_4(_class, _base, _f1, _f2, _f3, _f4) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1088,6 +946,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_5(_class, _base, _f1, _f2, _f3, _f4, _f5) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1104,6 +963,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_6(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1122,6 +982,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_7(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6, _f7) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1142,6 +1003,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_8(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1164,6 +1026,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_9(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ @@ -1188,6 +1051,7 @@ struct Skippable NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_IMPL_CYCLE_COLLECTION_INHERITED_10(_class, _base, _f1, _f2, _f3, _f4, _f5, _f6, _f7, _f8, _f9, _f10) \ + NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f1) \ NS_IMPL_CYCLE_COLLECTION_UNLINK(_f2) \ |