Make define_constants unsafe

This commit is contained in:
Anthony Ramine 2016-08-24 18:00:24 +02:00
parent d29f61af31
commit fa17814f12

View file

@ -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,
@ -85,7 +84,6 @@ fn define_constants(
None, None,
None)); None));
} }
}
} }
unsafe extern "C" fn fun_to_string_hook(cx: *mut JSContext, unsafe extern "C" fn fun_to_string_hook(cx: *mut JSContext,