mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Store a slice in ConstantSpec, rather than a raw pointer.
This commit is contained in:
parent
ba68203ebf
commit
d882bb7cc0
2 changed files with 5 additions and 6 deletions
|
@ -192,7 +192,7 @@ pub enum ConstantVal {
|
|||
|
||||
#[deriving(Clone)]
|
||||
pub struct ConstantSpec {
|
||||
pub name: *libc::c_char,
|
||||
pub name: &'static [u8],
|
||||
pub value: ConstantVal
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,6 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m
|
|||
|
||||
fn DefineConstants(cx: *mut JSContext, obj: *mut JSObject, constants: &'static [ConstantSpec]) -> bool {
|
||||
constants.iter().all(|spec| {
|
||||
assert!(spec.name.is_not_null());
|
||||
let jsval = match spec.value {
|
||||
NullVal => NullValue(),
|
||||
IntVal(i) => Int32Value(i),
|
||||
|
@ -323,7 +322,8 @@ fn DefineConstants(cx: *mut JSContext, obj: *mut JSObject, constants: &'static [
|
|||
VoidVal => UndefinedValue(),
|
||||
};
|
||||
unsafe {
|
||||
JS_DefineProperty(cx, obj, spec.name, jsval, None, None,
|
||||
JS_DefineProperty(cx, obj, spec.name.as_ptr() as *libc::c_char,
|
||||
jsval, None, None,
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY |
|
||||
JSPROP_PERMANENT) != 0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue