зеркало из https://github.com/mozilla/gecko-dev.git
bug 819215 - make NS_IMPL_CYCLE_COLLECTION_XXXCLASS unnecessary r=smaug, mccr8
This commit is contained in:
Родитель
13fbb0d64c
Коммит
0179193261
|
@ -2618,8 +2618,15 @@ public:
|
|||
static NS_METHOD RootImpl(void *p) { return NS_OK; }
|
||||
static NS_METHOD UnlinkImpl(void *p);
|
||||
static NS_METHOD UnrootImpl(void *p) { return NS_OK; }
|
||||
static nsXPCOMCycleCollectionParticipant* GetParticipant()
|
||||
{
|
||||
static const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)>
|
||||
::Type participant =
|
||||
{ NS_IMPL_CYCLE_COLLECTION_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)) };
|
||||
return NS_PARTICIPANT_AS(nsXPCOMCycleCollectionParticipant,
|
||||
&participant);
|
||||
}
|
||||
};
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_DECL_CYCLE_COLLECTION_UNMARK_PURPLE_STUB(XPCWrappedNative)
|
||||
|
||||
nsIPrincipal* GetObjectPrincipal() const;
|
||||
|
|
|
@ -88,8 +88,16 @@ public: \
|
|||
{ \
|
||||
return p->InnerObject(); \
|
||||
} \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
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); \
|
||||
} \
|
||||
};
|
||||
|
||||
// Put this in your class's constructor:
|
||||
#define NS_INIT_AGGREGATED(outer) \
|
||||
|
|
|
@ -41,7 +41,7 @@ CycleCollectionNoteEdgeName(nsCycleCollectionTraversalCallback& aCallback,
|
|||
_cycleCollectorGlobal
|
||||
|
||||
#define NS_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
_class::NS_CYCLE_COLLECTION_INNERNAME.GetParticipant()
|
||||
_class::NS_CYCLE_COLLECTION_INNERCLASS::GetParticipant()
|
||||
|
||||
template <typename T>
|
||||
nsISupports* ToSupports(T* p, typename T::NS_CYCLE_COLLECTION_INNERCLASS* dummy = 0)
|
||||
|
|
|
@ -495,10 +495,6 @@ T* DowncastCCParticipant(void *p)
|
|||
// Helpers for implementing a concrete nsCycleCollectionParticipant
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE \
|
||||
static const CCParticipantVTable<NS_CYCLE_COLLECTION_INNERCLASS>::Type \
|
||||
NS_CYCLE_COLLECTION_INNERNAME;
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base) \
|
||||
public: \
|
||||
static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, \
|
||||
|
@ -523,13 +519,26 @@ public: \
|
|||
NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base) \
|
||||
static NS_METHOD UnlinkImpl(void *p);
|
||||
|
||||
#define NS_PARTICIPANT_AS(type, participant) \
|
||||
const_cast<type*>(reinterpret_cast<const type*>(participant))
|
||||
|
||||
#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); \
|
||||
}
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(_class, _base) \
|
||||
class NS_CYCLE_COLLECTION_INNERCLASS \
|
||||
: public nsXPCOMCycleCollectionParticipant \
|
||||
{ \
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_CLASS(_class) \
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(_class, _class)
|
||||
|
@ -544,8 +553,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS
|
|||
static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed); \
|
||||
static NS_METHOD_(bool) CanSkipInCCImpl(void *p); \
|
||||
static NS_METHOD_(bool) CanSkipThisImpl(void *p); \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(_class) \
|
||||
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS_AMBIGUOUS(_class, _class)
|
||||
|
@ -556,8 +565,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS \
|
|||
{ \
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
|
||||
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback cb, void *closure); \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _base) \
|
||||
class NS_CYCLE_COLLECTION_INNERCLASS \
|
||||
|
@ -569,8 +578,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS
|
|||
static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed); \
|
||||
static NS_METHOD_(bool) CanSkipInCCImpl(void *p); \
|
||||
static NS_METHOD_(bool) CanSkipThisImpl(void *p); \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(_class) \
|
||||
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _class)
|
||||
|
@ -586,8 +595,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS
|
|||
static NS_METHOD_(bool) CanSkipImpl(void *p, bool aRemovingAllowed); \
|
||||
static NS_METHOD_(bool) CanSkipInCCImpl(void *p); \
|
||||
static NS_METHOD_(bool) CanSkipThisImpl(void *p); \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(_class) \
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _class)
|
||||
|
@ -613,8 +622,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS \
|
|||
{ \
|
||||
public: \
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(_class, \
|
||||
_base_class) \
|
||||
|
@ -623,8 +632,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS \
|
|||
{ \
|
||||
public: \
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, _base_class) \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(_class, \
|
||||
_base_class) \
|
||||
|
@ -633,8 +642,8 @@ class NS_CYCLE_COLLECTION_INNERCLASS \
|
|||
{ \
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
|
||||
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback cb, void *closure); \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
NS_IMPL_GET_XPCOM_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
||||
};
|
||||
|
||||
/**
|
||||
* This implements a stub UnmarkIfPurple function for classes that want to be
|
||||
|
@ -696,28 +705,18 @@ struct Skippable
|
|||
// Cycle collector participant implementations.
|
||||
|
||||
// A native class is non-nsISupports and uses nsCycleCollectingAutoRefCnt.
|
||||
#define NS_IMPL_CYCLE_COLLECTION_NATIVE_CLASS(_class) \
|
||||
const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \
|
||||
::Type _class::NS_CYCLE_COLLECTION_INNERNAME = \
|
||||
{ NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) };
|
||||
#define NS_IMPL_CYCLE_COLLECTION_NATIVE_CLASS(_class)
|
||||
|
||||
// For native classes containing JS pointers.
|
||||
#define NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(_class) \
|
||||
const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \
|
||||
::Type _class::NS_CYCLE_COLLECTION_INNERNAME = \
|
||||
{ NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) };
|
||||
#define NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(_class)
|
||||
|
||||
// A legacy native class is non-nsISupports, but does not use
|
||||
// nsCycleCollectingAutoRefCnt. This should be avoided because it can
|
||||
// cause leaks.
|
||||
#define NS_IMPL_CYCLE_COLLECTION_LEGACY_NATIVE_CLASS(_class) \
|
||||
NS_IMPL_CYCLE_COLLECTION_NATIVE_CLASS(_class)
|
||||
#define NS_IMPL_CYCLE_COLLECTION_LEGACY_NATIVE_CLASS(_class)
|
||||
|
||||
// For nsISupports classes.
|
||||
#define NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
|
||||
const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \
|
||||
::Type _class::NS_CYCLE_COLLECTION_INNERNAME = \
|
||||
{ NS_IMPL_CYCLE_COLLECTION_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) };
|
||||
#define NS_IMPL_CYCLE_COLLECTION_CLASS(_class)
|
||||
|
||||
|
||||
// Cycle collector participant declarations.
|
||||
|
@ -747,8 +746,16 @@ struct Skippable
|
|||
{ \
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_UNMARK_IF_PURPLE(_class) \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
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); \
|
||||
} \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(_class) \
|
||||
class NS_CYCLE_COLLECTION_INNERCLASS \
|
||||
|
@ -758,8 +765,16 @@ struct Skippable
|
|||
NS_DECL_CYCLE_COLLECTION_NATIVE_UNMARK_IF_PURPLE(_class) \
|
||||
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback cb, \
|
||||
void *closure); \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
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); \
|
||||
} \
|
||||
};
|
||||
|
||||
#define NS_DECL_CYCLE_COLLECTION_LEGACY_NATIVE_CLASS(_class) \
|
||||
class NS_CYCLE_COLLECTION_INNERCLASS \
|
||||
|
@ -767,8 +782,16 @@ struct Skippable
|
|||
{ \
|
||||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \
|
||||
NS_DECL_CYCLE_COLLECTION_STUB_UNMARK_IF_PURPLE(_class) \
|
||||
}; \
|
||||
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
||||
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); \
|
||||
} \
|
||||
};
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(_class, _root_function) \
|
||||
NS_METHOD \
|
||||
|
|
|
@ -339,7 +339,7 @@ public:
|
|||
NS_ASSERT_OWNINGTHREAD_AND_NOT_CCTHREAD(_class); \
|
||||
nsrefcnt count = \
|
||||
mRefCnt.decr(static_cast<void*>(this), \
|
||||
_class::NS_CYCLE_COLLECTION_INNERNAME.GetParticipant()); \
|
||||
_class::NS_CYCLE_COLLECTION_INNERCLASS::GetParticipant()); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
if (count == 0) { \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
|
|
Загрузка…
Ссылка в новой задаче