diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-06-21 12:43:35 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-06-22 13:25:18 +0200 |
commit | 4964d2792e981476349f0aa5d3c12995a7838d80 (patch) | |
tree | 57adf17c36b56675da683600d41a3dafab72a2d5 /src/components/script/dom/bindings/utils.rs | |
parent | 886d401ff0bdbceaec528fb40b6eb719f7857e86 (diff) | |
download | servo-4964d2792e981476349f0aa5d3c12995a7838d80.tar.gz servo-4964d2792e981476349f0aa5d3c12995a7838d80.zip |
Pass the NativeProperties struct to CreateInterfaceObjects2.
This will simplify adding more kinds of properties, such as static attributes.
Diffstat (limited to 'src/components/script/dom/bindings/utils.rs')
-rw-r--r-- | src/components/script/dom/bindings/utils.rs | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index 106353e228d..d9be42433d9 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -230,13 +230,9 @@ pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiv protoClass: &'static JSClass, constructor: Option<(NonNullJSNative, &'static str, u32)>, domClass: *DOMClass, - methods: Option<&'static [JSFunctionSpec]>, - properties: Option<&'static [JSPropertySpec]>, - constants: Option<&'static [ConstantSpec]>, - staticMethods: Option<&'static [JSFunctionSpec]>) -> *mut JSObject { + members: &'static NativeProperties) -> *mut JSObject { let proto = CreateInterfacePrototypeObject(cx, global, protoProto, - protoClass, methods, - properties, constants); + protoClass, members); unsafe { JS_SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT, @@ -248,7 +244,7 @@ pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiv name.to_c_str().with_ref(|s| { CreateInterfaceObject(cx, global, receiver, native, nargs, proto, - staticMethods, constants, s) + members, s) }) }, None => (), @@ -260,8 +256,7 @@ pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiv fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject, constructorNative: NonNullJSNative, ctorNargs: u32, proto: *mut JSObject, - staticMethods: Option<&'static [JSFunctionSpec]>, - constants: Option<&'static [ConstantSpec]>, + members: &'static NativeProperties, name: *libc::c_char) { unsafe { let fun = JS_NewFunction(cx, Some(constructorNative), ctorNargs, @@ -271,12 +266,12 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m let constructor = JS_GetFunctionObject(fun); assert!(constructor.is_not_null()); - match staticMethods { + match members.staticMethods { Some(staticMethods) => DefineMethods(cx, constructor, staticMethods), _ => (), } - match constants { + match members.consts { Some(constants) => DefineConstants(cx, constructor, constants), _ => (), } @@ -330,24 +325,22 @@ fn DefineProperties(cx: *mut JSContext, obj: *mut JSObject, properties: &'static fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject, parentProto: *mut JSObject, protoClass: &'static JSClass, - methods: Option<&'static [JSFunctionSpec]>, - properties: Option<&'static [JSPropertySpec]>, - constants: Option<&'static [ConstantSpec]>) -> *mut JSObject { + members: &'static NativeProperties) -> *mut JSObject { unsafe { let ourProto = JS_NewObjectWithUniqueType(cx, protoClass, parentProto, global); assert!(ourProto.is_not_null()); - match methods { + match members.methods { Some(methods) => DefineMethods(cx, ourProto, methods), _ => (), } - match properties { + match members.attrs { Some(properties) => DefineProperties(cx, ourProto, properties), _ => (), } - match constants { + match members.consts { Some(constants) => DefineConstants(cx, ourProto, constants), _ => (), } |