mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +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,21 +70,19 @@ pub type NonNullJSNative =
|
|||
|
||||
/// Defines constants on `obj`.
|
||||
/// Fails on JSAPI failure.
|
||||
fn define_constants(
|
||||
unsafe fn define_constants(
|
||||
cx: *mut JSContext,
|
||||
obj: HandleObject,
|
||||
constants: &[ConstantSpec]) {
|
||||
for spec in constants {
|
||||
rooted!(in(cx) let value = spec.get_value());
|
||||
unsafe {
|
||||
assert!(JS_DefineProperty(cx,
|
||||
obj,
|
||||
spec.name.as_ptr() as *const libc::c_char,
|
||||
value.handle(),
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT,
|
||||
None,
|
||||
None));
|
||||
}
|
||||
assert!(JS_DefineProperty(cx,
|
||||
obj,
|
||||
spec.name.as_ptr() as *const libc::c_char,
|
||||
value.handle(),
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT,
|
||||
None,
|
||||
None));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue