mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
DefineDOMInterfaceMethod now takes a SafeJSContext instead of a JSContext
as first argument.
This commit is contained in:
parent
aa0e4f5c76
commit
6e4caf1153
3 changed files with 9 additions and 8 deletions
|
@ -47,7 +47,7 @@ fn main() {
|
||||||
let mut phf = File::create(&phf).unwrap();
|
let mut phf = File::create(&phf).unwrap();
|
||||||
write!(
|
write!(
|
||||||
&mut phf,
|
&mut phf,
|
||||||
"pub static MAP: phf::Map<&'static [u8], unsafe fn(*mut JSContext, HandleObject)> = "
|
"pub static MAP: phf::Map<&'static [u8], unsafe fn(JSContext, HandleObject)> = "
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
map.build(&mut phf).unwrap();
|
map.build(&mut phf).unwrap();
|
||||||
|
|
|
@ -3268,7 +3268,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
assert descriptor.interface.hasInterfaceObject()
|
assert descriptor.interface.hasInterfaceObject()
|
||||||
args = [
|
args = [
|
||||||
Argument('*mut JSContext', 'cx'),
|
Argument('SafeJSContext', 'cx'),
|
||||||
Argument('HandleObject', 'global'),
|
Argument('HandleObject', 'global'),
|
||||||
]
|
]
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface',
|
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface',
|
||||||
|
@ -3285,12 +3285,12 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
return CGGeneric("""\
|
return CGGeneric("""\
|
||||||
assert!(!global.get().is_null());
|
assert!(!global.get().is_null());
|
||||||
|
|
||||||
if !ConstructorEnabled(SafeJSContext::from_ptr(cx), global) {
|
if !ConstructorEnabled(cx, global) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rooted!(in(cx) let mut proto = ptr::null_mut::<JSObject>());
|
rooted!(in(*cx) let mut proto = ptr::null_mut::<JSObject>());
|
||||||
%s(SafeJSContext::from_ptr(cx), global, proto.handle_mut());
|
%s(cx, global, proto.handle_mut());
|
||||||
assert!(!proto.is_null());""" % (function,))
|
assert!(!proto.is_null());""" % (function,))
|
||||||
|
|
||||||
|
|
||||||
|
@ -7312,7 +7312,7 @@ class GlobalGenRoots():
|
||||||
def InterfaceObjectMap(config):
|
def InterfaceObjectMap(config):
|
||||||
mods = [
|
mods = [
|
||||||
"crate::dom::bindings::codegen",
|
"crate::dom::bindings::codegen",
|
||||||
"js::jsapi::JSContext",
|
"crate::script_runtime::JSContext",
|
||||||
"js::rust::HandleObject",
|
"js::rust::HandleObject",
|
||||||
"phf",
|
"phf",
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::dom::bindings::inheritance::TopTypeId;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::bindings::trace::trace_object;
|
use crate::dom::bindings::trace::trace_object;
|
||||||
use crate::dom::windowproxy;
|
use crate::dom::windowproxy;
|
||||||
|
use crate::script_runtime::JSContext as SafeJSContext;
|
||||||
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
|
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
|
||||||
use js::glue::{GetCrossCompartmentWrapper, JS_GetReservedSlot, WrapperNew};
|
use js::glue::{GetCrossCompartmentWrapper, JS_GetReservedSlot, WrapperNew};
|
||||||
use js::glue::{UnwrapObjectDynamic, RUST_JSID_TO_INT, RUST_JSID_TO_STRING};
|
use js::glue::{UnwrapObjectDynamic, RUST_JSID_TO_INT, RUST_JSID_TO_STRING};
|
||||||
|
@ -353,7 +354,7 @@ pub unsafe extern "C" fn enumerate_global(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for init_fun in InterfaceObjectMap::MAP.values() {
|
for init_fun in InterfaceObjectMap::MAP.values() {
|
||||||
init_fun(cx, Handle::from_raw(obj));
|
init_fun(SafeJSContext::from_ptr(cx), Handle::from_raw(obj));
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -388,7 +389,7 @@ pub unsafe extern "C" fn resolve_global(
|
||||||
let bytes = slice::from_raw_parts(ptr, length as usize);
|
let bytes = slice::from_raw_parts(ptr, length as usize);
|
||||||
|
|
||||||
if let Some(init_fun) = InterfaceObjectMap::MAP.get(bytes) {
|
if let Some(init_fun) = InterfaceObjectMap::MAP.get(bytes) {
|
||||||
init_fun(cx, Handle::from_raw(obj));
|
init_fun(SafeJSContext::from_ptr(cx), Handle::from_raw(obj));
|
||||||
*rval = true;
|
*rval = true;
|
||||||
} else {
|
} else {
|
||||||
*rval = false;
|
*rval = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue