mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 812617 - Provide a JSBindingFinalized hook for the native classes using Web IDL bindings to know when their JS wrapper has been finalized; r=bzbarsky
--HG-- extra : rebase_source : bb5059a170f3c2f4aa977190fceea421b41b5e58
This commit is contained in:
parent
a3fa501952
commit
5db19d4269
@ -1667,6 +1667,25 @@ bool
|
|||||||
NativeToString(JSContext* cx, JSObject* wrapper, JSObject* obj, const char* pre,
|
NativeToString(JSContext* cx, JSObject* wrapper, JSObject* obj, const char* pre,
|
||||||
const char* post, JS::Value* v);
|
const char* post, JS::Value* v);
|
||||||
|
|
||||||
|
HAS_MEMBER(JSBindingFinalized)
|
||||||
|
|
||||||
|
template<class T, bool hasCallback=HasJSBindingFinalizedMember<T>::Value>
|
||||||
|
struct JSBindingFinalized
|
||||||
|
{
|
||||||
|
static void Finalized(T* self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct JSBindingFinalized<T, true>
|
||||||
|
{
|
||||||
|
static void Finalized(T* self)
|
||||||
|
{
|
||||||
|
self->JSBindingFinalized();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
ReparentWrapper(JSContext* aCx, JSObject* aObj);
|
ReparentWrapper(JSContext* aCx, JSObject* aObj);
|
||||||
|
|
||||||
|
@ -919,7 +919,8 @@ def finalizeHook(descriptor, hookName, context):
|
|||||||
if descriptor.customFinalize:
|
if descriptor.customFinalize:
|
||||||
finalize = "self->%s(%s);" % (hookName, context)
|
finalize = "self->%s(%s);" % (hookName, context)
|
||||||
else:
|
else:
|
||||||
finalize = "ClearWrapper(self, self);\n" if descriptor.wrapperCache else ""
|
finalize = "JSBindingFinalized<%s>::Finalized(self);\n" % descriptor.nativeType
|
||||||
|
finalize += "ClearWrapper(self, self);\n" if descriptor.wrapperCache else ""
|
||||||
if descriptor.workers:
|
if descriptor.workers:
|
||||||
finalize += "self->Release();"
|
finalize += "self->Release();"
|
||||||
elif descriptor.nativeOwnership == 'nsisupports':
|
elif descriptor.nativeOwnership == 'nsisupports':
|
||||||
|
Loading…
Reference in New Issue
Block a user