1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsCycleCollectionParticipant.h"
10 #ifdef MOZILLA_INTERNAL_API
13 #include "nsStringAPI.h"
17 nsScriptObjectTracer::NoteJSChild(void *aScriptThing
, const char *name
,
20 nsCycleCollectionTraversalCallback
*cb
=
21 static_cast<nsCycleCollectionTraversalCallback
*>(aClosure
);
22 NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb
, name
);
23 cb
->NoteJSChild(aScriptThing
);
27 nsXPCOMCycleCollectionParticipant::RootImpl(void *p
)
29 nsISupports
*s
= static_cast<nsISupports
*>(p
);
35 nsXPCOMCycleCollectionParticipant::UnrootImpl(void *p
)
37 nsISupports
*s
= static_cast<nsISupports
*>(p
);
42 // We define a default trace function because some participants don't need
43 // to trace anything, so it is okay for them not to define one.
45 nsXPCOMCycleCollectionParticipant::TraceImpl(void *p
, const TraceCallbacks
&cb
,
51 nsXPCOMCycleCollectionParticipant::CheckForRightISupports(nsISupports
*s
)
54 s
->QueryInterface(NS_GET_IID(nsCycleCollectionISupports
),
55 reinterpret_cast<void**>(&foo
));
60 CycleCollectionNoteEdgeNameImpl(nsCycleCollectionTraversalCallback
& aCallback
,
64 nsAutoCString
arrayEdgeName(aName
);
65 if (aFlags
& CycleCollectionEdgeNameArrayFlag
) {
66 arrayEdgeName
.AppendLiteral("[i]");
68 aCallback
.NoteNextEdgeName(arrayEdgeName
.get());
72 TraceCallbackFunc::Trace(JS::Heap
<JS::Value
>* p
, const char* name
, void* closure
) const
74 mCallback(JSVAL_TO_TRACEABLE(p
->get()), name
, closure
);
78 TraceCallbackFunc::Trace(JS::Heap
<jsid
>* p
, const char* name
, void* closure
) const
80 void *thing
= JSID_TO_GCTHING(*p
);
82 mCallback(thing
, name
, closure
);
87 TraceCallbackFunc::Trace(JS::Heap
<JSObject
*>* p
, const char* name
, void* closure
) const
89 mCallback(*p
, name
, closure
);
93 TraceCallbackFunc::Trace(JS::Heap
<JSString
*>* p
, const char* name
, void* closure
) const
95 mCallback(*p
, name
, closure
);
99 TraceCallbackFunc::Trace(JS::Heap
<JSScript
*>* p
, const char* name
, void* closure
) const
101 mCallback(p
->get(), name
, closure
);