Bug 731746 part 4. When wrapping a JS-implemented webidl object, define the new object as a property on the implementing object. r=mccr8

This commit is contained in:
Boris Zbarsky 2013-04-24 22:44:28 -04:00
parent de9b7862dc
commit c6af618fd5

View File

@ -8459,7 +8459,20 @@ class CGJSImplClass(CGBindingImplClass):
extradefinitions=extradefinitions)
def getWrapObjectBody(self):
return "return %sBinding::Wrap(aCx, aScope, this);" % self.descriptor.name
return ("JS::Rooted<JSObject*> obj(aCx, %sBinding::Wrap(aCx, aScope, this));\n"
"if (!obj) {\n"
" return nullptr;\n"
"}\n"
"\n"
"// Now define it on our chrome object\n"
"JSAutoCompartment ac(aCx, mImpl->Callback());\n"
"if (!JS_WrapObject(aCx, obj.address())) {\n"
" return nullptr;\n"
"}\n"
'if (!JS_DefineProperty(aCx, mImpl->Callback(), "__DOM_IMPL__", JS::ObjectValue(*obj), nullptr, nullptr, 0)) {\n'
" return nullptr;\n"
"}\n"
"return obj;" % self.descriptor.name)
def getGetParentObjectReturnType(self):
return "nsISupports*"