diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index a6f03f5c430..b833d431f7f 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2531,15 +2531,10 @@ assert!(!prototype_proto.ptr.is_null());""" % getPrototypeProto)] properties = {"id": name} for arrayName in self.properties.arrayNames(): array = getattr(self.properties, arrayName) - if arrayName == "consts": - if array.length(): - properties[arrayName] = array.variableName() - else: - properties[arrayName] = "&[]" - elif array.length(): - properties[arrayName] = "Some(%s)" % array.variableName() + if array.length(): + properties[arrayName] = array.variableName() else: - properties[arrayName] = "None" + properties[arrayName] = "&[]" code.append(CGGeneric(""" let mut prototype = RootedObject::new(cx, ptr::null_mut()); diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs index 9ce31b8bd36..f1e6a886eb7 100644 --- a/components/script/dom/bindings/interface.rs +++ b/components/script/dom/bindings/interface.rs @@ -227,8 +227,8 @@ pub unsafe fn create_interface_prototype_object( cx: *mut JSContext, proto: HandleObject, class: &'static JSClass, - regular_methods: Option<&'static [Prefable]>, - regular_properties: Option<&'static [Prefable]>, + regular_methods: &'static [Prefable], + regular_properties: &'static [Prefable], constants: &'static [Prefable], rval: MutableHandleObject) { create_object(cx, proto, class, regular_methods, regular_properties, constants, rval); @@ -240,8 +240,8 @@ pub unsafe fn create_noncallback_interface_object( receiver: HandleObject, proto: HandleObject, class: &'static NonCallbackInterfaceObjectClass, - static_methods: Option<&'static [Prefable]>, - static_properties: Option<&'static [Prefable]>, + static_methods: &'static [Prefable], + static_properties: &'static [Prefable], constants: &'static [Prefable], interface_prototype_object: HandleObject, name: &'static [u8], @@ -354,36 +354,34 @@ unsafe fn create_object( cx: *mut JSContext, proto: HandleObject, class: &'static JSClass, - methods: Option<&'static [Prefable]>, - properties: Option<&'static [Prefable]>, + methods: &'static [Prefable], + properties: &'static [Prefable], constants: &'static [Prefable], rval: MutableHandleObject) { rval.set(JS_NewObjectWithUniqueType(cx, class, proto)); assert!(!rval.ptr.is_null()); - if let Some(methods) = methods { - define_prefable_methods(cx, rval.handle(), methods); - } - if let Some(properties) = properties { - define_prefable_properties(cx, rval.handle(), properties); - } + define_prefable_methods(cx, rval.handle(), methods); + define_prefable_properties(cx, rval.handle(), properties); for prefable in constants { define_constants(cx, rval.handle(), prefable.specs()); } } /// Conditionally define methods on an object. -pub unsafe fn define_prefable_methods(cx: *mut JSContext, - obj: HandleObject, - methods: &'static [Prefable]) { +pub unsafe fn define_prefable_methods( + cx: *mut JSContext, + obj: HandleObject, + methods: &'static [Prefable]) { for prefable in methods { define_methods(cx, obj, prefable.specs()).unwrap(); } } /// Conditionally define properties on an object. -pub unsafe fn define_prefable_properties(cx: *mut JSContext, - obj: HandleObject, - properties: &'static [Prefable]) { +pub unsafe fn define_prefable_properties( + cx: *mut JSContext, + obj: HandleObject, + properties: &'static [Prefable]) { for prefable in properties { define_properties(cx, obj, prefable.specs()).unwrap(); }