use SafeJSContext

This commit is contained in:
Kagami Sascha Rosylight 2019-07-25 11:14:21 +09:00
parent caf7a2488e
commit 87cc409579
2 changed files with 4 additions and 5 deletions

View file

@ -2887,7 +2887,7 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
Generate the CollectJSONAttributes method for an interface descriptor Generate the CollectJSONAttributes method for an interface descriptor
""" """
def __init__(self, descriptor, toJSONMethod): def __init__(self, descriptor, toJSONMethod):
args = [Argument('*mut JSContext', 'cx'), args = [Argument('SafeJSContext', 'cx'),
Argument('HandleObject', 'obj'), Argument('HandleObject', 'obj'),
Argument('*const %s' % descriptor.concreteType, 'this'), Argument('*const %s' % descriptor.concreteType, 'this'),
Argument('&RootedGuard<*mut JSObject>', 'result')] Argument('&RootedGuard<*mut JSObject>', 'result')]
@ -2903,11 +2903,11 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
name = m.identifier.name name = m.identifier.name
getAndDefine = fill( getAndDefine = fill(
""" """
rooted!(in(cx) let mut temp = UndefinedValue()); rooted!(in(*cx) let mut temp = UndefinedValue());
if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) { if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) {
return false; return false;
} }
if !JS_DefineProperty(cx, result.handle().into(), if !JS_DefineProperty(*cx, result.handle().into(),
${nameAsArray} as *const u8 as *const libc::c_char, ${nameAsArray} as *const u8 as *const libc::c_char,
temp.handle(), JSPROP_ENUMERATE as u32) { temp.handle(), JSPROP_ENUMERATE as u32) {
return false; return false;
@ -3667,7 +3667,7 @@ class CGDefaultToJSONMethod(CGSpecializedMethod):
def definition_body(self): def definition_body(self):
ret = dedent(""" ret = dedent("""
rooted!(in(cx) let result = JS_NewPlainObject(cx)); rooted!(in(*cx) let result = JS_NewPlainObject(*cx));
if result.is_null() { if result.is_null() {
return false; return false;
} }

View file

@ -14,7 +14,6 @@ use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString; use crate::dom::bindings::str::DOMString;
use crate::dom::globalscope::GlobalScope; use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window; use crate::dom::window::Window;
use crate::script_runtime::JSContext;
use dom_struct::dom_struct; use dom_struct::dom_struct;
#[dom_struct] #[dom_struct]