mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Make define_constants unsafe
This commit is contained in:
parent
d29f61af31
commit
fa17814f12
1 changed files with 8 additions and 10 deletions
|
@ -70,13 +70,12 @@ pub type NonNullJSNative =
|
||||||
|
|
||||||
/// Defines constants on `obj`.
|
/// Defines constants on `obj`.
|
||||||
/// Fails on JSAPI failure.
|
/// Fails on JSAPI failure.
|
||||||
fn define_constants(
|
unsafe fn define_constants(
|
||||||
cx: *mut JSContext,
|
cx: *mut JSContext,
|
||||||
obj: HandleObject,
|
obj: HandleObject,
|
||||||
constants: &[ConstantSpec]) {
|
constants: &[ConstantSpec]) {
|
||||||
for spec in constants {
|
for spec in constants {
|
||||||
rooted!(in(cx) let value = spec.get_value());
|
rooted!(in(cx) let value = spec.get_value());
|
||||||
unsafe {
|
|
||||||
assert!(JS_DefineProperty(cx,
|
assert!(JS_DefineProperty(cx,
|
||||||
obj,
|
obj,
|
||||||
spec.name.as_ptr() as *const libc::c_char,
|
spec.name.as_ptr() as *const libc::c_char,
|
||||||
|
@ -86,7 +85,6 @@ fn define_constants(
|
||||||
None));
|
None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
unsafe extern "C" fn fun_to_string_hook(cx: *mut JSContext,
|
unsafe extern "C" fn fun_to_string_hook(cx: *mut JSContext,
|
||||||
obj: HandleObject,
|
obj: HandleObject,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue