2012-05-18 12:29:38 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-01-05 01:31:26 +03:00
|
|
|
|
|
|
|
#ifndef nsCycleCollectionParticipant_h__
|
|
|
|
#define nsCycleCollectionParticipant_h__
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
#include "mozilla/TypeTraits.h"
|
2007-01-05 01:31:26 +03:00
|
|
|
#include "nsISupports.h"
|
|
|
|
|
|
|
|
#define NS_CYCLECOLLECTIONPARTICIPANT_IID \
|
2007-03-16 15:52:47 +03:00
|
|
|
{ \
|
2007-08-06 18:34:02 +04:00
|
|
|
0x9674489b, \
|
|
|
|
0x1f6f, \
|
|
|
|
0x4550, \
|
|
|
|
{ 0xa7, 0x30, 0xcc, 0xae, 0xdd, 0x10, 0x4c, 0xf9 } \
|
2007-01-05 01:31:26 +03:00
|
|
|
}
|
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
/**
|
|
|
|
* Special IID to get at the base nsISupports for a class. Usually this is the
|
|
|
|
* canonical nsISupports pointer, but in the case of tearoffs for example it is
|
|
|
|
* the base nsISupports pointer of the tearoff. This allow the cycle collector
|
|
|
|
* to have separate nsCycleCollectionParticipant's for tearoffs or aggregated
|
|
|
|
* classes.
|
|
|
|
*/
|
|
|
|
#define NS_CYCLECOLLECTIONISUPPORTS_IID \
|
|
|
|
{ \
|
|
|
|
0xc61eac14, \
|
|
|
|
0x5f7a, \
|
|
|
|
0x4481, \
|
|
|
|
{ 0x96, 0x5e, 0x7e, 0xaa, 0x6e, 0xff, 0xa8, 0x5f } \
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Just holds the IID so NS_GET_IID works.
|
|
|
|
*/
|
2007-08-06 18:34:02 +04:00
|
|
|
class nsCycleCollectionISupports
|
2007-02-18 17:38:04 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CYCLECOLLECTIONISUPPORTS_IID)
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionISupports,
|
|
|
|
NS_CYCLECOLLECTIONISUPPORTS_IID)
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
/**
|
|
|
|
* Forward declarations
|
|
|
|
*/
|
2007-05-25 14:57:38 +04:00
|
|
|
class nsCycleCollectionParticipant;
|
2012-06-04 10:30:26 +04:00
|
|
|
class nsScriptObjectTracer;
|
|
|
|
class nsXPCOMCycleCollectionParticipant;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback definitions
|
|
|
|
*/
|
|
|
|
typedef void
|
|
|
|
(* TraceCallback)(void *p, const char *name, void *closure);
|
2007-05-24 18:10:02 +04:00
|
|
|
|
2007-08-06 18:34:02 +04:00
|
|
|
class NS_NO_VTABLE nsCycleCollectionTraversalCallback
|
2007-01-05 01:31:26 +03:00
|
|
|
{
|
2007-08-06 18:34:02 +04:00
|
|
|
public:
|
2011-06-24 01:10:52 +04:00
|
|
|
// You must call DescribeRefCountedNode() with an accurate
|
2007-11-02 01:51:57 +03:00
|
|
|
// refcount, otherwise cycle collection will fail, and probably crash.
|
2009-07-09 05:10:29 +04:00
|
|
|
// If the callback cares about objsz or objname, it should
|
|
|
|
// put WANT_DEBUG_INFO in mFlags.
|
2011-06-24 01:10:52 +04:00
|
|
|
NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refcount,
|
|
|
|
size_t objsz,
|
|
|
|
const char *objname) = 0;
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD_(void) DescribeGCedNode(bool ismarked,
|
2011-06-24 01:10:52 +04:00
|
|
|
size_t objsz,
|
|
|
|
const char *objname) = 0;
|
2012-05-03 23:28:11 +04:00
|
|
|
|
2007-11-02 01:51:57 +03:00
|
|
|
NS_IMETHOD_(void) NoteXPCOMRoot(nsISupports *root) = 0;
|
2012-05-03 23:28:11 +04:00
|
|
|
NS_IMETHOD_(void) NoteJSRoot(void *root) = 0;
|
|
|
|
NS_IMETHOD_(void) NoteNativeRoot(void *root, nsCycleCollectionParticipant *participant) = 0;
|
2012-05-03 23:28:10 +04:00
|
|
|
|
2007-08-06 18:34:02 +04:00
|
|
|
NS_IMETHOD_(void) NoteXPCOMChild(nsISupports *child) = 0;
|
2012-05-03 23:28:10 +04:00
|
|
|
NS_IMETHOD_(void) NoteJSChild(void *child) = 0;
|
2007-08-06 18:34:02 +04:00
|
|
|
NS_IMETHOD_(void) NoteNativeChild(void *child,
|
|
|
|
nsCycleCollectionParticipant *helper) = 0;
|
2009-07-09 05:10:29 +04:00
|
|
|
|
2008-03-18 02:11:08 +03:00
|
|
|
// Give a name to the edge associated with the next call to
|
2012-05-03 23:28:10 +04:00
|
|
|
// NoteXPCOMChild, NoteJSChild, or NoteNativeChild.
|
2009-07-09 05:10:29 +04:00
|
|
|
// Callbacks who care about this should set WANT_DEBUG_INFO in the
|
|
|
|
// flags.
|
2008-03-18 02:11:08 +03:00
|
|
|
NS_IMETHOD_(void) NoteNextEdgeName(const char* name) = 0;
|
2009-07-09 05:10:29 +04:00
|
|
|
|
2011-11-24 16:35:56 +04:00
|
|
|
NS_IMETHOD_(void) NoteWeakMapping(void *map, void *key, void *val) = 0;
|
|
|
|
|
2009-07-09 05:10:29 +04:00
|
|
|
enum {
|
|
|
|
// Values for flags:
|
|
|
|
|
2011-06-24 01:10:52 +04:00
|
|
|
// Caller should pass useful objsz and objname to
|
|
|
|
// DescribeRefCountedNode and DescribeGCedNode and should call
|
|
|
|
// NoteNextEdgeName.
|
2009-07-09 05:10:29 +04:00
|
|
|
WANT_DEBUG_INFO = (1<<0),
|
|
|
|
|
|
|
|
// Caller should not skip objects that we know will be
|
|
|
|
// uncollectable.
|
|
|
|
WANT_ALL_TRACES = (1<<1)
|
|
|
|
};
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t Flags() const { return mFlags; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool WantDebugInfo() const { return (mFlags & WANT_DEBUG_INFO) != 0; }
|
|
|
|
bool WantAllTraces() const { return (mFlags & WANT_ALL_TRACES) != 0; }
|
2009-07-09 05:10:29 +04:00
|
|
|
protected:
|
|
|
|
nsCycleCollectionTraversalCallback() : mFlags(0) {}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mFlags;
|
2007-05-24 18:10:02 +04:00
|
|
|
};
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
/**
|
|
|
|
* 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
|
2012-06-04 10:30:26 +04:00
|
|
|
{
|
2012-06-04 10:30:26 +04:00
|
|
|
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);
|
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
void (NS_STDCALL *UnmarkIfPurple)(void *p);
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
bool (NS_STDCALL *CanSkipReal)(void *p, bool aRemovingAllowed);
|
|
|
|
bool (NS_STDCALL *CanSkipInCCReal)(void *p);
|
|
|
|
bool (NS_STDCALL *CanSkipThisReal)(void *p);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef nsCycleCollectionParticipantVTableCommon<nsCycleCollectionParticipant>
|
|
|
|
nsCycleCollectionParticipantVTable;
|
|
|
|
|
|
|
|
/* Additional functions for nsScriptObjectTracer */
|
|
|
|
struct nsScriptObjectTracerVTable
|
|
|
|
{
|
|
|
|
void (NS_STDCALL *Trace)(void *p, TraceCallback 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);
|
|
|
|
* };
|
|
|
|
*/
|
2012-06-04 10:30:26 +04:00
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
enum nsCycleCollectionParticipantType
|
|
|
|
{
|
|
|
|
eInvalid,
|
|
|
|
eCycleCollectionParticipant,
|
|
|
|
eScriptObjectTracer,
|
|
|
|
eXPCOMCycleCollectionParticipant
|
|
|
|
};
|
2012-06-15 17:50:24 +04:00
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
template <typename T, enum nsCycleCollectionParticipantType ParticipantType>
|
|
|
|
struct CCParticipantVTableImpl { };
|
|
|
|
|
|
|
|
/* CCParticipantVTable for nsCycleCollectionParticipant */
|
|
|
|
template <typename T>
|
|
|
|
struct CCParticipantVTableImpl<T, eCycleCollectionParticipant>
|
|
|
|
{
|
2012-07-23 09:42:23 +04:00
|
|
|
nsCycleCollectionParticipant *GetParticipant() const
|
2012-06-04 10:30:26 +04:00
|
|
|
{
|
2012-07-23 09:42:23 +04:00
|
|
|
return const_cast<nsCycleCollectionParticipant *>
|
|
|
|
(reinterpret_cast<const nsCycleCollectionParticipant *>(this));
|
2012-06-04 10:30:26 +04:00
|
|
|
}
|
|
|
|
nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* CCParticipantVTable for nsScriptObjectTracer */
|
|
|
|
template <typename T>
|
|
|
|
struct CCParticipantVTableImpl<T, eScriptObjectTracer>
|
|
|
|
{
|
2012-07-23 09:42:23 +04:00
|
|
|
nsScriptObjectTracer *GetParticipant() const
|
2012-06-04 10:30:26 +04:00
|
|
|
{
|
2012-07-23 09:42:23 +04:00
|
|
|
return const_cast<nsScriptObjectTracer *>
|
|
|
|
(reinterpret_cast<const nsScriptObjectTracer *>(this));
|
2012-06-04 10:30:26 +04:00
|
|
|
}
|
|
|
|
nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant;
|
|
|
|
nsScriptObjectTracerVTable scriptObjectTracer;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* CCParticipantVTable for nsXPCOMCycleCollectionParticipant */
|
|
|
|
template <typename T>
|
|
|
|
struct CCParticipantVTableImpl<T, eXPCOMCycleCollectionParticipant>
|
|
|
|
{
|
2012-07-23 09:42:23 +04:00
|
|
|
nsXPCOMCycleCollectionParticipant *GetParticipant() const
|
2012-06-04 10:30:26 +04:00
|
|
|
{
|
2012-07-23 09:42:23 +04:00
|
|
|
return const_cast<nsXPCOMCycleCollectionParticipant *>
|
|
|
|
(reinterpret_cast<const nsXPCOMCycleCollectionParticipant *>(this));
|
2012-06-04 10:30:26 +04:00
|
|
|
}
|
|
|
|
nsCycleCollectionParticipantVTableCommon<T> cycleCollectionParticipant;
|
|
|
|
nsScriptObjectTracerVTable scriptObjectTracer;
|
|
|
|
};
|
2012-06-15 17:50:24 +04:00
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
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
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static const bool isSkippable = false;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2012-01-14 20:58:05 +04:00
|
|
|
// 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!
|
2012-02-14 00:59:14 +04:00
|
|
|
// If aRemovingAllowed is true, p can be removed from the purple buffer.
|
|
|
|
bool CanSkip(void *p, bool aRemovingAllowed)
|
2012-01-14 20:58:05 +04:00
|
|
|
{
|
2012-06-04 10:30:26 +04:00
|
|
|
return CanSkipReal ? CanSkipReal(p, aRemovingAllowed) : false;
|
2012-01-14 20:58:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If CanSkipInCC returns true, p is skipped when selecting roots for the
|
|
|
|
// cycle collector graph.
|
|
|
|
// Note, calling CanSkipInCC may remove other objects from the purple buffer!
|
|
|
|
bool CanSkipInCC(void *p)
|
|
|
|
{
|
2012-06-04 10:30:26 +04:00
|
|
|
return CanSkipInCCReal ? CanSkipInCCReal(p) : false;
|
2012-01-14 20:58:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If CanSkipThis returns true, p is not added to the graph.
|
|
|
|
// This method is called during cycle collection, so don't
|
|
|
|
// change the state of any objects!
|
|
|
|
bool CanSkipThis(void *p)
|
|
|
|
{
|
2012-06-04 10:30:26 +04:00
|
|
|
return CanSkipThisReal ? CanSkipThisReal(p) : false;
|
2012-01-14 20:58:05 +04:00
|
|
|
}
|
2007-01-05 01:31:26 +03:00
|
|
|
};
|
|
|
|
|
2012-01-17 20:32:19 +04:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionParticipant,
|
|
|
|
NS_CYCLECOLLECTIONPARTICIPANT_IID)
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
class nsScriptObjectTracer
|
|
|
|
: public nsCycleCollectionParticipant, public nsScriptObjectTracerVTable
|
2012-01-17 20:32:19 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-06-04 10:30:26 +04:00
|
|
|
static void NS_COM_GLUE NoteJSChild(void *aScriptThing, const char *name,
|
|
|
|
void *aClosure);
|
2012-01-17 20:32:19 +04:00
|
|
|
};
|
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
class nsXPCOMCycleCollectionParticipant : public nsScriptObjectTracer
|
2012-01-17 20:32:19 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD RootImpl(void *p);
|
|
|
|
static NS_METHOD UnrootImpl(void *p);
|
2012-01-17 20:32:19 +04:00
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback cb, void *closure);
|
2012-01-17 20:32:19 +04:00
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
static bool CheckForRightISupports(nsISupports *s);
|
2012-01-17 20:32:19 +04:00
|
|
|
};
|
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2007-05-24 18:10:02 +04:00
|
|
|
// Helpers for implementing a QI to nsXPCOMCycleCollectionParticipant
|
2007-01-05 01:31:26 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
cycleCollection
|
|
|
|
|
|
|
|
#define NS_CYCLE_COLLECTION_CLASSNAME(_class) \
|
|
|
|
_class::NS_CYCLE_COLLECTION_INNERCLASS
|
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_CYCLE_COLLECTION_INNERNAME \
|
|
|
|
_cycleCollectorGlobal
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
#define NS_CYCLE_COLLECTION_PARTICIPANT(_class) \
|
|
|
|
_class::NS_CYCLE_COLLECTION_INNERNAME.GetParticipant()
|
2007-01-05 01:31:26 +03:00
|
|
|
|
|
|
|
#define NS_IMPL_QUERY_CYCLE_COLLECTION(_class) \
|
2007-05-24 18:10:02 +04:00
|
|
|
if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) { \
|
2012-06-04 10:30:26 +04:00
|
|
|
*aInstancePtr = NS_CYCLE_COLLECTION_PARTICIPANT(_class); \
|
2007-05-24 18:10:02 +04:00
|
|
|
return NS_OK; \
|
2007-01-05 01:31:26 +03:00
|
|
|
} else
|
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
#define NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class) \
|
2010-11-12 01:52:30 +03:00
|
|
|
if ( aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ) { \
|
|
|
|
*aInstancePtr = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
|
|
|
return NS_OK; \
|
|
|
|
} else
|
2007-02-18 17:38:04 +03:00
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
#define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class) \
|
|
|
|
NS_IMPL_QUERY_CYCLE_COLLECTION(_class)
|
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
#define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class) \
|
|
|
|
NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class)
|
|
|
|
|
|
|
|
#define NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class) \
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class) \
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class)
|
|
|
|
|
2007-04-25 20:35:27 +04:00
|
|
|
#define NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(_class) \
|
|
|
|
NS_INTERFACE_MAP_BEGIN(_class) \
|
2007-08-21 02:55:06 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)
|
2007-04-25 20:35:27 +04:00
|
|
|
|
|
|
|
#define NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(_class) \
|
|
|
|
NS_INTERFACE_MAP_BEGIN(_class) \
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class)
|
2007-01-05 01:31:26 +03:00
|
|
|
|
2007-08-21 02:55:06 +04:00
|
|
|
#define NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(_class) \
|
|
|
|
if (rv == NS_OK) return rv; \
|
|
|
|
nsISupports* foundInterface; \
|
|
|
|
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)
|
|
|
|
|
|
|
|
#define NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(_class) \
|
|
|
|
NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
|
|
|
{ \
|
|
|
|
NS_PRECONDITION(aInstancePtr, "null out param"); \
|
|
|
|
\
|
|
|
|
if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) { \
|
2012-06-04 10:30:26 +04:00
|
|
|
*aInstancePtr = NS_CYCLE_COLLECTION_PARTICIPANT(_class); \
|
2007-08-21 02:55:06 +04:00
|
|
|
return NS_OK; \
|
|
|
|
} \
|
|
|
|
nsresult rv;
|
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_CYCLE_COLLECTION_UPCAST(obj, clazz) \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(clazz)::Upcast(obj)
|
2007-08-21 02:55:06 +04:00
|
|
|
|
2012-02-16 03:28:42 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helpers for implementing CanSkip methods
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-01-14 20:58:05 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD_(bool) \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipImpl(void *p, \
|
2012-02-14 00:59:14 +04:00
|
|
|
bool aRemovingAllowed) \
|
2012-01-14 20:58:05 +04:00
|
|
|
{ \
|
|
|
|
nsISupports *s = static_cast<nsISupports*>(p); \
|
|
|
|
NS_ASSERTION(CheckForRightISupports(s), \
|
|
|
|
"not the nsISupports pointer we expect"); \
|
|
|
|
_class *tmp = Downcast(s);
|
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END \
|
2012-02-16 03:28:42 +04:00
|
|
|
(void)tmp; \
|
2012-01-14 20:58:05 +04:00
|
|
|
return false; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD_(bool) \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipInCCImpl(void *p) \
|
2012-01-14 20:58:05 +04:00
|
|
|
{ \
|
|
|
|
nsISupports *s = static_cast<nsISupports*>(p); \
|
|
|
|
NS_ASSERTION(CheckForRightISupports(s), \
|
|
|
|
"not the nsISupports pointer we expect"); \
|
|
|
|
_class *tmp = Downcast(s);
|
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END \
|
2012-02-16 03:28:42 +04:00
|
|
|
(void)tmp; \
|
2012-01-14 20:58:05 +04:00
|
|
|
return false; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD_(bool) \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipThisImpl(void *p) \
|
2012-01-14 20:58:05 +04:00
|
|
|
{ \
|
|
|
|
nsISupports *s = static_cast<nsISupports*>(p); \
|
|
|
|
NS_ASSERTION(CheckForRightISupports(s), \
|
|
|
|
"not the nsISupports pointer we expect"); \
|
|
|
|
_class *tmp = Downcast(s);
|
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END \
|
2012-02-16 03:28:42 +04:00
|
|
|
(void)tmp; \
|
2012-01-14 20:58:05 +04:00
|
|
|
return false; \
|
|
|
|
}
|
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helpers for implementing nsCycleCollectionParticipant::Unlink
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnlinkImpl(void *p) \
|
2007-01-05 01:31:26 +03:00
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
nsISupports *s = static_cast<nsISupports*>(p); \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_ASSERTION(CheckForRightISupports(s), \
|
|
|
|
"not the nsISupports pointer we expect"); \
|
|
|
|
_class *tmp = Downcast(s);
|
2007-01-05 01:31:26 +03:00
|
|
|
|
2007-03-08 14:17:16 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(_class, _base_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnlinkImpl(void *p) \
|
2007-03-08 14:17:16 +03:00
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
nsISupports *s = static_cast<nsISupports*>(p); \
|
2007-03-08 14:17:16 +03:00
|
|
|
NS_ASSERTION(CheckForRightISupports(s), \
|
|
|
|
"not the nsISupports pointer we expect"); \
|
2007-07-11 12:46:44 +04:00
|
|
|
_class *tmp = static_cast<_class*>(Downcast(s)); \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::UnlinkImpl(s);
|
2007-03-08 14:17:16 +03:00
|
|
|
|
2007-05-24 18:10:02 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnlinkImpl(void *p) \
|
2007-05-24 18:10:02 +04:00
|
|
|
{ \
|
2007-07-08 11:08:04 +04:00
|
|
|
_class *tmp = static_cast<_class*>(p);
|
2007-05-24 18:10:02 +04:00
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_field) \
|
|
|
|
tmp->_field = NULL;
|
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(_field) \
|
|
|
|
tmp->_field.Clear();
|
|
|
|
|
2007-05-24 18:10:02 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(_field) \
|
|
|
|
tmp->_field.Clear();
|
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
2012-05-18 12:29:38 +04:00
|
|
|
(void)tmp; \
|
2007-01-05 01:31:26 +03:00
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
2007-02-18 23:05:32 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_0(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnlinkImpl(void *p) \
|
2007-02-18 23:05:32 +03:00
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
NS_ASSERTION(CheckForRightISupports(static_cast<nsISupports*>(p)), \
|
2007-02-18 23:05:32 +03:00
|
|
|
"not the nsISupports pointer we expect"); \
|
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
2007-05-24 18:10:02 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_NATIVE_0(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnlinkImpl(void *p) \
|
2007-05-24 18:10:02 +04:00
|
|
|
{ \
|
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helpers for implementing nsCycleCollectionParticipant::Traverse
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-05-07 22:19:36 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_DESCRIBE(_class, _refcnt) \
|
2011-06-24 01:10:52 +04:00
|
|
|
cb.DescribeRefCountedNode(_refcnt, sizeof(_class), #_class);
|
2007-01-05 01:31:26 +03:00
|
|
|
|
2009-02-27 17:48:26 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraverseImpl \
|
|
|
|
(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, void *p,\
|
2007-01-05 01:31:26 +03:00
|
|
|
nsCycleCollectionTraversalCallback &cb) \
|
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
nsISupports *s = static_cast<nsISupports*>(p); \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_ASSERTION(CheckForRightISupports(s), \
|
|
|
|
"not the nsISupports pointer we expect"); \
|
2009-02-27 17:48:26 +03:00
|
|
|
_class *tmp = static_cast<_class*>(Downcast(s));
|
2009-05-07 22:19:36 +04:00
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
2009-02-27 17:48:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(_class, tmp->mRefCnt.get())
|
2007-01-05 01:31:26 +03:00
|
|
|
|
2009-03-03 15:14:13 +03:00
|
|
|
// Base class' CC participant should return NS_SUCCESS_INTERRUPTED_TRAVERSE
|
|
|
|
// from Traverse if it wants derived classes to not traverse anything from
|
|
|
|
// their CC participant.
|
|
|
|
|
2007-03-08 14:17:16 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(_class, _base_class) \
|
2009-02-27 17:48:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
if (NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::TraverseImpl(that, s, cb) \
|
|
|
|
== NS_SUCCESS_INTERRUPTED_TRAVERSE) { \
|
2009-03-03 15:14:13 +03:00
|
|
|
return NS_SUCCESS_INTERRUPTED_TRAVERSE; \
|
|
|
|
}
|
2007-03-08 14:17:16 +03:00
|
|
|
|
2007-05-24 18:10:02 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_BEGIN(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraverseImpl \
|
|
|
|
(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, void *p,\
|
2007-05-24 18:10:02 +04:00
|
|
|
nsCycleCollectionTraversalCallback &cb) \
|
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
_class *tmp = static_cast<_class*>(p); \
|
2009-05-07 22:19:36 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(_class, tmp->mRefCnt.get())
|
2007-05-24 18:10:02 +04:00
|
|
|
|
2009-07-09 05:10:29 +04:00
|
|
|
#define NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(_cb, _name) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
if (NS_UNLIKELY((_cb).WantDebugInfo())) { \
|
|
|
|
(_cb).NoteNextEdgeName(_name); \
|
|
|
|
} \
|
|
|
|
PR_END_MACRO
|
2008-03-18 02:11:08 +03:00
|
|
|
|
2007-02-17 02:02:08 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(_field) \
|
2008-03-18 02:11:08 +03:00
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field); \
|
|
|
|
cb.NoteXPCOMChild(tmp->_field); \
|
|
|
|
PR_END_MACRO;
|
2007-02-17 02:02:08 +03:00
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_field) \
|
2008-03-18 02:11:08 +03:00
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field); \
|
|
|
|
cb.NoteXPCOMChild(tmp->_field.get()); \
|
|
|
|
PR_END_MACRO;
|
2007-01-05 01:31:26 +03:00
|
|
|
|
2007-03-08 14:17:16 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(_field, _base) \
|
2008-03-18 02:11:08 +03:00
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field); \
|
|
|
|
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(_base*, tmp->_field)); \
|
|
|
|
PR_END_MACRO;
|
2007-03-08 14:17:16 +03:00
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(_field) \
|
|
|
|
{ \
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t i; \
|
2008-03-18 02:11:08 +03:00
|
|
|
for (i = 0; i < tmp->_field.Count(); ++i) { \
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field "[i]"); \
|
2007-03-09 16:14:06 +03:00
|
|
|
cb.NoteXPCOMChild(tmp->_field[i]); \
|
2008-03-18 02:11:08 +03:00
|
|
|
} \
|
2007-01-05 01:31:26 +03:00
|
|
|
}
|
|
|
|
|
2008-03-18 02:11:08 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR(_ptr, _ptr_class, _name) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, _name); \
|
2012-06-04 10:30:26 +04:00
|
|
|
cb.NoteNativeChild(_ptr, NS_CYCLE_COLLECTION_PARTICIPANT(_ptr_class)); \
|
2008-03-18 02:11:08 +03:00
|
|
|
PR_END_MACRO;
|
2007-05-24 18:10:02 +04:00
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(_field, _field_class) \
|
2008-03-18 02:11:08 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR(tmp->_field, _field_class, \
|
|
|
|
#_field)
|
2007-05-24 18:10:02 +04:00
|
|
|
|
2008-03-18 02:11:08 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY(_array, _element_class, \
|
|
|
|
_name) \
|
2007-05-24 18:10:02 +04:00
|
|
|
{ \
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i, length = (_array).Length(); \
|
2007-05-24 18:10:02 +04:00
|
|
|
for (i = 0; i < length; ++i) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR((_array)[i], \
|
2008-03-18 02:11:08 +03:00
|
|
|
_element_class, \
|
|
|
|
_name "[i]"); \
|
2007-05-24 18:10:02 +04:00
|
|
|
}
|
|
|
|
|
2011-04-22 07:17:31 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(_field) \
|
|
|
|
{ \
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t i, length = tmp->_field.Length(); \
|
2011-04-22 07:17:31 +04:00
|
|
|
for (i = 0; i < length; ++i) { \
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, #_field "[i]"); \
|
|
|
|
cb.NoteXPCOMChild(tmp->_field[i].get()); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2007-05-24 18:10:02 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_MEMBER(_field, \
|
|
|
|
_element_class) \
|
2008-03-18 02:11:08 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY(tmp->_field, _element_class, \
|
|
|
|
#_field)
|
2007-05-24 18:10:02 +04:00
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS \
|
2012-06-04 10:30:26 +04:00
|
|
|
that->Trace(p, &nsScriptObjectTracer::NoteJSChild, &cb);
|
2007-10-29 16:45:07 +03:00
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END \
|
2012-07-11 08:26:56 +04:00
|
|
|
(void)tmp; \
|
2007-01-05 01:31:26 +03:00
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helpers for implementing nsScriptObjectTracer::Trace
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_class) \
|
|
|
|
void \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraceImpl(void *p, \
|
|
|
|
TraceCallback aCallback, \
|
|
|
|
void *aClosure) \
|
2007-10-29 16:45:07 +03:00
|
|
|
{ \
|
|
|
|
nsISupports *s = static_cast<nsISupports*>(p); \
|
|
|
|
NS_ASSERTION(CheckForRightISupports(s), \
|
|
|
|
"not the nsISupports pointer we expect"); \
|
|
|
|
_class *tmp = Downcast(s);
|
|
|
|
|
2011-05-24 05:09:28 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(_class, _base_class) \
|
|
|
|
void \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraceImpl(void *p, \
|
|
|
|
TraceCallback aCallback, \
|
|
|
|
void *aClosure) \
|
2011-05-24 05:09:28 +04:00
|
|
|
{ \
|
|
|
|
nsISupports *s = static_cast<nsISupports*>(p); \
|
|
|
|
NS_ASSERTION(CheckForRightISupports(s), \
|
|
|
|
"not the nsISupports pointer we expect"); \
|
|
|
|
_class *tmp = static_cast<_class*>(Downcast(s)); \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::TraceImpl(s, \
|
|
|
|
aCallback, \
|
|
|
|
aClosure);
|
2011-05-24 05:09:28 +04:00
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(_class) \
|
|
|
|
void \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::TraceImpl(void *p, \
|
|
|
|
TraceCallback aCallback, \
|
|
|
|
void *aClosure) \
|
2007-10-29 16:45:07 +03:00
|
|
|
{ \
|
|
|
|
_class *tmp = static_cast<_class*>(p);
|
|
|
|
|
2011-02-02 18:30:03 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(_object, _name) \
|
2012-05-03 23:28:10 +04:00
|
|
|
if (_object) \
|
|
|
|
aCallback(_object, _name, aClosure);
|
2007-10-29 16:45:07 +03:00
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(_field) \
|
2011-02-02 18:30:03 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->_field, #_field)
|
2007-10-29 16:45:07 +03:00
|
|
|
|
2012-06-11 03:44:50 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(_field) \
|
|
|
|
if (JSVAL_IS_TRACEABLE(tmp->_field)) { \
|
|
|
|
void *gcThing = JSVAL_TO_TRACEABLE(tmp->_field); \
|
|
|
|
aCallback(gcThing, #_field, aClosure); \
|
|
|
|
}
|
|
|
|
|
2009-07-17 00:06:26 +04:00
|
|
|
// NB: The (void)tmp; hack in the TRACE_END macro exists to support
|
|
|
|
// implementations that don't need to do anything in their Trace method.
|
|
|
|
// Without this hack, some compilers warn about the unused tmp local.
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_TRACE_END \
|
2009-07-17 00:06:26 +04:00
|
|
|
(void)tmp; \
|
2007-10-29 16:45:07 +03:00
|
|
|
}
|
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helpers for implementing a concrete nsCycleCollectionParticipant
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE \
|
2012-07-23 09:42:23 +04:00
|
|
|
static const CCParticipantVTable<NS_CYCLE_COLLECTION_INNERCLASS>::Type \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_CYCLE_COLLECTION_INNERNAME;
|
2007-10-29 16:45:07 +03:00
|
|
|
|
2008-01-10 17:10:03 +03:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base) \
|
2007-02-18 17:38:04 +03:00
|
|
|
public: \
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, \
|
|
|
|
void *p, nsCycleCollectionTraversalCallback &cb); \
|
2012-08-24 20:50:06 +04:00
|
|
|
static NS_METHOD_(void) UnmarkIfPurpleImpl(void *s) \
|
2007-03-16 15:52:47 +03:00
|
|
|
{ \
|
2012-08-24 20:50:06 +04:00
|
|
|
Downcast(static_cast<nsISupports *>(s))->UnmarkIfPurple(); \
|
2007-03-16 15:52:47 +03:00
|
|
|
} \
|
2007-02-18 17:38:04 +03:00
|
|
|
static _class* Downcast(nsISupports* s) \
|
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
return static_cast<_class*>(static_cast<_base*>(s)); \
|
2007-02-18 17:38:04 +03:00
|
|
|
} \
|
|
|
|
static nsISupports* Upcast(_class *p) \
|
|
|
|
{ \
|
|
|
|
return NS_ISUPPORTS_CAST(_base*, p); \
|
2007-10-29 16:45:07 +03:00
|
|
|
}
|
|
|
|
|
2008-01-10 17:10:03 +03:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base) \
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD UnlinkImpl(void *p);
|
2008-01-10 17:10:03 +03:00
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#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
|
2007-01-05 01:31:26 +03:00
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_CLASS(_class) \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(_class, _class)
|
|
|
|
|
2012-02-16 03:28:42 +04:00
|
|
|
// Cycle collector helper for ambiguous classes that can sometimes be skipped.
|
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS_AMBIGUOUS(_class, _base) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public nsXPCOMCycleCollectionParticipant \
|
|
|
|
{ \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
|
2012-06-04 10:30:26 +04:00
|
|
|
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); \
|
2012-02-16 03:28:42 +04:00
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
|
|
|
|
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(_class) \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS_AMBIGUOUS(_class, _class)
|
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _base) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public nsXPCOMCycleCollectionParticipant \
|
|
|
|
{ \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback cb, void *closure); \
|
2007-10-29 16:45:07 +03:00
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
|
|
|
|
2012-01-14 20:58:05 +04:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _base) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public nsXPCOMCycleCollectionParticipant \
|
|
|
|
{ \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_BODY(_class, _base) \
|
2012-06-04 10:30:26 +04:00
|
|
|
static const bool isSkippable = true; \
|
|
|
|
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback 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); \
|
2012-01-14 20:58:05 +04:00
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
|
|
|
|
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(_class) \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _class)
|
|
|
|
|
2012-01-24 02:06:58 +04:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(_class, \
|
|
|
|
_base_class) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \
|
|
|
|
{ \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
static const bool isSkippable = true; \
|
|
|
|
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback 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); \
|
2012-01-24 02:06:58 +04:00
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(_class) \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(_class, _class)
|
|
|
|
|
2009-05-13 00:20:42 +04:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, \
|
|
|
|
_base_class) \
|
2007-03-08 14:17:16 +03:00
|
|
|
public: \
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD TraverseImpl(NS_CYCLE_COLLECTION_CLASSNAME(_class) *that, \
|
|
|
|
void *p, nsCycleCollectionTraversalCallback &cb); \
|
2007-03-08 14:17:16 +03:00
|
|
|
static _class* Downcast(nsISupports* s) \
|
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
return static_cast<_class*>(static_cast<_base_class*>( \
|
2007-03-08 14:17:16 +03:00
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Downcast(s))); \
|
2009-05-13 00:20:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, _base_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD UnlinkImpl(void *p);
|
2009-05-13 00:20:42 +04:00
|
|
|
|
|
|
|
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(_class, _base_class) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \
|
|
|
|
{ \
|
|
|
|
public: \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
|
2007-10-29 16:45:07 +03:00
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
2007-03-08 14:17:16 +03:00
|
|
|
|
|
|
|
#define NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(_class, \
|
|
|
|
_base_class) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \
|
|
|
|
{ \
|
|
|
|
public: \
|
2009-05-13 00:20:42 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY_NO_UNLINK(_class, _base_class) \
|
2007-10-29 16:45:07 +03:00
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
2007-03-08 14:17:16 +03:00
|
|
|
|
2010-08-25 17:10:00 +04:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(_class, \
|
|
|
|
_base_class) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public NS_CYCLE_COLLECTION_CLASSNAME(_base_class) \
|
|
|
|
{ \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback cb, void *closure); \
|
2010-08-25 17:10:00 +04:00
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
|
|
|
|
2007-03-16 15:52:47 +03:00
|
|
|
/**
|
2012-03-26 20:57:29 +04:00
|
|
|
* This implements a stub UnmarkIfPurple function for classes that want to be
|
2007-03-16 15:52:47 +03:00
|
|
|
* traversed but whose AddRef/Release functions don't add/remove them to/from
|
|
|
|
* the purple buffer. If you're just using NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
* then you don't need this.
|
|
|
|
*/
|
|
|
|
#define NS_DECL_CYCLE_COLLECTION_UNMARK_PURPLE_STUB(_class) \
|
2012-03-26 20:57:29 +04:00
|
|
|
NS_IMETHODIMP_(void) UnmarkIfPurple() \
|
2007-03-16 15:52:47 +03:00
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
{ };
|
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
|
|
|
|
// VTables for the cycle collector participant implementations.
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(_class) \
|
|
|
|
{ \
|
|
|
|
&_class::TraverseImpl, \
|
|
|
|
&_class::RootImpl, \
|
|
|
|
&_class::UnlinkImpl, \
|
|
|
|
&_class::UnrootImpl, \
|
2012-08-24 20:50:06 +04:00
|
|
|
&_class::UnmarkIfPurpleImpl, \
|
2012-06-04 10:30:26 +04:00
|
|
|
_class::isSkippable ? &Skippable<_class>::CanSkipImpl : NULL, \
|
|
|
|
_class::isSkippable ? &Skippable<_class>::CanSkipInCCImpl : NULL, \
|
|
|
|
_class::isSkippable ? &Skippable<_class>::CanSkipThisImpl : NULL \
|
|
|
|
}
|
2012-08-24 20:50:06 +04:00
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
#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) \
|
2012-08-24 20:50:06 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(_class)
|
|
|
|
|
|
|
|
|
|
|
|
// Cycle collector participant implementations.
|
2012-06-04 10:30:26 +04:00
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
// A native class is non-nsISupports and uses nsCycleCollectingAutoRefCnt.
|
2012-06-04 10:30:26 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_NATIVE_CLASS(_class) \
|
2012-07-23 09:42:23 +04:00
|
|
|
const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \
|
2012-06-04 10:30:26 +04:00
|
|
|
::Type _class::NS_CYCLE_COLLECTION_INNERNAME = \
|
|
|
|
{ NS_IMPL_CYCLE_COLLECTION_NATIVE_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) };
|
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
// For native classes containing JS pointers.
|
2012-06-04 10:30:26 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(_class) \
|
2012-07-23 09:42:23 +04:00
|
|
|
const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \
|
2012-06-04 10:30:26 +04:00
|
|
|
::Type _class::NS_CYCLE_COLLECTION_INNERNAME = \
|
|
|
|
{ NS_IMPL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) };
|
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
// 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)
|
|
|
|
|
|
|
|
// For nsISupports classes.
|
2007-01-05 01:31:26 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
|
2012-07-23 09:42:23 +04:00
|
|
|
const CCParticipantVTable<NS_CYCLE_COLLECTION_CLASSNAME(_class)> \
|
2012-06-04 10:30:26 +04:00
|
|
|
::Type _class::NS_CYCLE_COLLECTION_INNERNAME = \
|
|
|
|
{ NS_IMPL_CYCLE_COLLECTION_VTABLE(NS_CYCLE_COLLECTION_CLASSNAME(_class)) };
|
2007-01-05 01:31:26 +03:00
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
|
|
|
|
// Cycle collector participant declarations.
|
|
|
|
|
2012-06-04 10:30:26 +04:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \
|
2007-10-28 15:49:30 +03:00
|
|
|
public: \
|
2012-06-04 10:30:26 +04:00
|
|
|
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);
|
2007-10-29 16:45:07 +03:00
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_NATIVE_UNMARK_IF_PURPLE(_class) \
|
|
|
|
static NS_METHOD_(void) UnmarkIfPurpleImpl(void *p) \
|
|
|
|
{ \
|
|
|
|
_class *tmp = static_cast<_class *>(p); \
|
|
|
|
if (NS_LIKELY(tmp->mRefCnt.IsPurple())) \
|
|
|
|
tmp->mRefCnt.unmarkPurple(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_DECL_CYCLE_COLLECTION_STUB_UNMARK_IF_PURPLE(_class) \
|
|
|
|
static NS_METHOD_(void) UnmarkIfPurpleImpl(void *p) {}
|
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(_class) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public nsCycleCollectionParticipant \
|
|
|
|
{ \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \
|
2012-08-24 20:50:06 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_UNMARK_IF_PURPLE(_class) \
|
2007-05-24 18:10:02 +04:00
|
|
|
}; \
|
2007-10-29 16:45:07 +03:00
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
2007-05-24 18:10:02 +04:00
|
|
|
|
2007-10-29 16:45:07 +03:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(_class) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public nsScriptObjectTracer \
|
|
|
|
{ \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \
|
2012-08-24 20:50:06 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_UNMARK_IF_PURPLE(_class) \
|
2012-06-04 10:30:26 +04:00
|
|
|
static NS_METHOD_(void) TraceImpl(void *p, TraceCallback cb, \
|
|
|
|
void *closure); \
|
2007-10-29 16:45:07 +03:00
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
2007-05-24 18:10:02 +04:00
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
#define NS_DECL_CYCLE_COLLECTION_LEGACY_NATIVE_CLASS(_class) \
|
|
|
|
class NS_CYCLE_COLLECTION_INNERCLASS \
|
|
|
|
: public nsCycleCollectionParticipant \
|
|
|
|
{ \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY(_class) \
|
|
|
|
NS_DECL_CYCLE_COLLECTION_STUB_UNMARK_IF_PURPLE(_class) \
|
|
|
|
}; \
|
|
|
|
NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
|
|
|
|
2007-05-24 18:10:02 +04:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(_class, _root_function) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::RootImpl(void *p) \
|
2007-05-24 18:10:02 +04:00
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
_class *tmp = static_cast<_class*>(p); \
|
2007-05-24 18:10:02 +04:00
|
|
|
tmp->_root_function(); \
|
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(_class, _unroot_function) \
|
2012-06-04 10:30:26 +04:00
|
|
|
NS_METHOD \
|
|
|
|
NS_CYCLE_COLLECTION_CLASSNAME(_class)::UnrootImpl(void *p) \
|
2007-05-24 18:10:02 +04:00
|
|
|
{ \
|
2007-07-11 12:46:44 +04:00
|
|
|
_class *tmp = static_cast<_class*>(p); \
|
2007-05-24 18:10:02 +04:00
|
|
|
tmp->_unroot_function(); \
|
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_0(_class) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
|
2008-03-14 19:23:31 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(_class) \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_1(_class, _f) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_2(_class, _f1, _f2) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2007-02-18 17:38:04 +03:00
|
|
|
#define NS_IMPL_CYCLE_COLLECTION_3(_class, _f1, _f2, _f3) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
2007-02-18 17:38:04 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
2007-01-05 01:31:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2009-06-12 04:46:46 +04:00
|
|
|
#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_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2010-06-02 22:33:47 +04:00
|
|
|
#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_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f5) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f5) \
|
|
|
|
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_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f5) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f6) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f5) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f6) \
|
|
|
|
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_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f5) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f6) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f7) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f5) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f6) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f7) \
|
|
|
|
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_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f5) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f6) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f7) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f8) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f5) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f6) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f7) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f8) \
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
#endif // nsCycleCollectionParticipant_h__
|