From 5db19d426953b5c15672c80b4481ab6614746ec4 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Sun, 17 Mar 2013 21:47:12 -0400 Subject: [PATCH] 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 --- dom/bindings/BindingUtils.h | 19 +++++++++++++++++++ dom/bindings/Codegen.py | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index 7b2b4d5accc2..71fac771893b 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -1667,6 +1667,25 @@ bool NativeToString(JSContext* cx, JSObject* wrapper, JSObject* obj, const char* pre, const char* post, JS::Value* v); +HAS_MEMBER(JSBindingFinalized) + +template::Value> +struct JSBindingFinalized +{ + static void Finalized(T* self) + { + } +}; + +template +struct JSBindingFinalized +{ + static void Finalized(T* self) + { + self->JSBindingFinalized(); + } +}; + nsresult ReparentWrapper(JSContext* aCx, JSObject* aObj); diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 5650f3abd658..35d52f8523d9 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -919,7 +919,8 @@ def finalizeHook(descriptor, hookName, context): if descriptor.customFinalize: finalize = "self->%s(%s);" % (hookName, context) 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: finalize += "self->Release();" elif descriptor.nativeOwnership == 'nsisupports':