Remove the pointless terminator from ConstantSpec slices.

This commit is contained in:
Ms2ger 2014-06-06 14:10:41 +02:00
parent 0c54cd1634
commit ba68203ebf
2 changed files with 10 additions and 16 deletions

View file

@ -1073,7 +1073,7 @@ class PropertyDefiner:
specTemplate is a template for each entry of the spec array
specTerminator is a terminator for the spec array (inserted at the end
of the array)
of the array), or None
specType is the actual typename of our spec
@ -1086,7 +1086,8 @@ class PropertyDefiner:
for member in array:
specs.append(specTemplate % getDataTuple(member))
specs.append(specTerminator)
if specTerminator:
specs.append(specTerminator)
return (("static %s: [%s, ..%i] = [\n" +
",\n".join(specs) + "\n" +
@ -1254,7 +1255,7 @@ class ConstDefiner(PropertyDefiner):
return decls + self.generatePrefableArray(
array, name,
' ConstantSpec { name: &%s_name as *u8 as *libc::c_char, value: %s }',
' ConstantSpec { name: 0 as *libc::c_char, value: VoidVal }',
None,
'ConstantSpec',
specData)

View file

@ -312,10 +312,8 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m
}
fn DefineConstants(cx: *mut JSContext, obj: *mut JSObject, constants: &'static [ConstantSpec]) -> bool {
for spec in constants.iter() {
if spec.name.is_null() {
return true;
}
constants.iter().all(|spec| {
assert!(spec.name.is_not_null());
let jsval = match spec.value {
NullVal => NullValue(),
IntVal(i) => Int32Value(i),
@ -325,16 +323,11 @@ fn DefineConstants(cx: *mut JSContext, obj: *mut JSObject, constants: &'static [
VoidVal => UndefinedValue(),
};
unsafe {
if JS_DefineProperty(cx, obj, spec.name,
jsval, None,
None,
JSPROP_ENUMERATE | JSPROP_READONLY |
JSPROP_PERMANENT) == 0 {
return false;
}
JS_DefineProperty(cx, obj, spec.name, jsval, None, None,
JSPROP_ENUMERATE | JSPROP_READONLY |
JSPROP_PERMANENT) != 0
}
}
fail!();
})
}
fn DefineMethods(cx: *mut JSContext, obj: *mut JSObject, methods: &'static [JSFunctionSpec]) -> bool {