Return a Temporary from *Binding::Wrap.

Returning a JS<T> is GC-unsafe.

This commit also includes some cleanup around Node and Document reflection.
This commit is contained in:
Ms2ger 2014-07-10 16:40:41 +02:00
parent 360d5d01d8
commit 439bc78cab
5 changed files with 16 additions and 28 deletions

View file

@ -1792,7 +1792,7 @@ class CGWrapMethod(CGAbstractMethod):
else:
args = [Argument('*mut JSContext', 'aCx'),
Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)]
retval = 'JS<%s>' % descriptor.concreteType
retval = 'Temporary<%s>' % descriptor.concreteType
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True)
def definition_body(self):
@ -1809,7 +1809,7 @@ assert!(proto.is_not_null());
raw.reflector().set_jsobject(obj);
return raw;""" % CreateBindingJSObject(self.descriptor, "scope"))
Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor, "scope"))
else:
return CGGeneric("""\
%s
@ -1818,7 +1818,8 @@ with_compartment(aCx, obj, || {
JS_SetPrototype(aCx, obj, proto);
});
raw.reflector().set_jsobject(obj);
return raw;""" % CreateBindingJSObject(self.descriptor))
Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor))
class CGIDLInterface(CGThing):