From bfddd1ec53e44621a268922d5ddbde873f811b6c Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:27:31 +0100 Subject: [PATCH 01/19] Replace the 'GlobalStaticData' free function by a 'new' static member function. --- components/script/dom/bindings/utils.rs | 10 ++++++---- components/script/page.rs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 2819018cf27..df7afd7de09 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -55,10 +55,12 @@ pub struct GlobalStaticData { pub windowproxy_handler: WindowProxyHandler, } -/// Creates a new GlobalStaticData. -pub fn GlobalStaticData() -> GlobalStaticData { - GlobalStaticData { - windowproxy_handler: browsercontext::new_window_proxy_handler(), +impl GlobalStaticData { + /// Creates a new GlobalStaticData. + pub fn new() -> GlobalStaticData { + GlobalStaticData { + windowproxy_handler: browsercontext::new_window_proxy_handler(), + } } } diff --git a/components/script/page.rs b/components/script/page.rs index 2433f03f2c5..b9dce92fac5 100644 --- a/components/script/page.rs +++ b/components/script/page.rs @@ -133,7 +133,7 @@ impl Page { constellation_chan: ConstellationChan, js_context: Rc) -> Page { let js_info = JSPageInfo { - dom_static: GlobalStaticData(), + dom_static: GlobalStaticData::new(), js_context: js_context, }; let layout_rpc: Box = { From b4b59df5e4b04ea52858b1a5b3176e51d4f25501 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:29:07 +0100 Subject: [PATCH 02/19] Rename GetProtoOrIfaceArray to get_proto_or_iface_array. --- components/script/dom/bindings/codegen/CodegenRust.py | 4 ++-- components/script/dom/bindings/utils.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index c9ea798b1d9..526813cb8cc 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2034,7 +2034,7 @@ class CGGetPerInterfaceObject(CGAbstractMethod): assert!(((*JS_GetClass(aGlobal)).flags & JSCLASS_DOM_GLOBAL) != 0); /* Check to see whether the interface objects are already installed */ -let protoOrIfaceArray = GetProtoOrIfaceArray(aGlobal); +let protoOrIfaceArray = get_proto_or_iface_array(aGlobal); let cachedObject: *mut JSObject = *protoOrIfaceArray.offset(%s as int); if cachedObject.is_null() { let tmp: *mut JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver); @@ -4553,7 +4553,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::utils::{DOMClass}', 'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}', 'dom::bindings::utils::{FindEnumStringIndex, GetArrayIndexFromId}', - 'dom::bindings::utils::{GetPropertyOnPrototype, GetProtoOrIfaceArray}', + 'dom::bindings::utils::{GetPropertyOnPrototype, get_proto_or_iface_array}', 'dom::bindings::utils::HasPropertyOnPrototype', 'dom::bindings::utils::IsPlatformObject', 'dom::bindings::utils::{Reflectable}', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index df7afd7de09..3bc80172b90 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -154,7 +154,7 @@ unsafe impl Sync for DOMJSClass {} /// Returns the ProtoOrIfaceArray for the given global object. /// Fails if `global` is not a DOM global object. -pub fn GetProtoOrIfaceArray(global: *mut JSObject) -> *mut *mut JSObject { +pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut *mut JSObject { unsafe { assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0); JS_GetReservedSlot(global, DOM_PROTOTYPE_SLOT).to_private() as *mut *mut JSObject From 23813577d1414f8466bc0d4fd5e83948403bd934 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:41:30 +0100 Subject: [PATCH 03/19] Use snake case for the members of NativeProperties. Note that the codegen uses the names of the Python fields to initialize the Rust struct. --- .../script/dom/bindings/codegen/CodegenRust.py | 10 +++++----- components/script/dom/bindings/utils.rs | 16 ++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 526813cb8cc..6dc8ece7f55 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1905,10 +1905,10 @@ class CGAbstractExternMethod(CGAbstractMethod): class PropertyArrays(): def __init__(self, descriptor): - self.staticMethods = MethodDefiner(descriptor, "StaticMethods", - static=True) - self.staticAttrs = AttrDefiner(descriptor, "StaticAttributes", - static=True) + self.static_methods = MethodDefiner(descriptor, "StaticMethods", + static=True) + self.static_attrs = AttrDefiner(descriptor, "StaticAttributes", + static=True) self.methods = MethodDefiner(descriptor, "Methods", static=False) self.attrs = AttrDefiner(descriptor, "Attributes", static=False) self.consts = ConstDefiner(descriptor, "Constants") @@ -1916,7 +1916,7 @@ class PropertyArrays(): @staticmethod def arrayNames(): - return [ "staticMethods", "staticAttrs", "methods", "attrs", "consts" ] + return ["static_methods", "static_attrs", "methods", "attrs", "consts"] def variableNames(self): names = {} diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 3bc80172b90..8e5610d97d3 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -171,9 +171,9 @@ pub struct NativeProperties { /// Constants for the interface. pub consts: Option<&'static [ConstantSpec]>, /// Static methods for the interface. - pub staticMethods: Option<&'static [JSFunctionSpec]>, + pub static_methods: Option<&'static [JSFunctionSpec]>, /// Static attributes for the interface. - pub staticAttrs: Option<&'static [JSPropertySpec]>, + pub static_attrs: Option<&'static [JSPropertySpec]>, } unsafe impl Sync for NativeProperties {} @@ -226,13 +226,17 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m let constructor = JS_GetFunctionObject(fun); assert!(!constructor.is_null()); - match members.staticMethods { - Some(staticMethods) => DefineMethods(cx, constructor, staticMethods), + match members.static_methods { + Some(static_methods) => { + DefineMethods(cx, constructor, static_methods) + }, _ => (), } - match members.staticAttrs { - Some(staticProperties) => DefineProperties(cx, constructor, staticProperties), + match members.static_attrs { + Some(static_properties) => { + DefineProperties(cx, constructor, static_properties) + }, _ => (), } From d7af3da919f95e616b61626763981b6d180d7cbe Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:48:48 +0100 Subject: [PATCH 04/19] Rename CreateInterfaceObjects2 to do_create_interface_objects. --- .../script/dom/bindings/codegen/CodegenRust.py | 10 +++++----- components/script/dom/bindings/utils.rs | 14 ++++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 6dc8ece7f55..082ab972f5b 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2001,10 +2001,10 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): constructor = 'None' call = """\ -return CreateInterfaceObjects2(aCx, aGlobal, aReceiver, parentProto, - &PrototypeClass, %s, - %s, - &sNativeProperties);""" % (constructor, domClass) +return do_create_interface_objects(aCx, aGlobal, aReceiver, parentProto, + &PrototypeClass, %s, + %s, + &sNativeProperties);""" % (constructor, domClass) return CGList([ CGGeneric(getParentProto), @@ -4548,7 +4548,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::js::{JS, JSRef, Root, RootedReference, Temporary}', 'dom::bindings::js::{OptionalRootable, OptionalRootedRootable, ResultRootable}', 'dom::bindings::js::{OptionalRootedReference, OptionalOptionalRootedRootable}', - 'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}', + 'dom::bindings::utils::{CreateDOMGlobal, do_create_interface_objects}', 'dom::bindings::utils::ConstantSpec', 'dom::bindings::utils::{DOMClass}', 'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 8e5610d97d3..411f7dcda3a 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -184,12 +184,14 @@ pub type NonNullJSNative = /// Creates the *interface prototype object* and the *interface object* (if /// needed). /// Fails on JSAPI failure. -pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject, - protoProto: *mut JSObject, - protoClass: &'static JSClass, - constructor: Option<(NonNullJSNative, &'static str, u32)>, - domClass: *const DOMClass, - members: &'static NativeProperties) -> *mut JSObject { +pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject, + receiver: *mut JSObject, + protoProto: *mut JSObject, + protoClass: &'static JSClass, + constructor: Option<(NonNullJSNative, &'static str, u32)>, + domClass: *const DOMClass, + members: &'static NativeProperties) + -> *mut JSObject { let proto = CreateInterfacePrototypeObject(cx, global, protoProto, protoClass, members); From 38baa130d8ae1a024f09c92d60bf827de47d3cb2 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:51:56 +0100 Subject: [PATCH 05/19] Use snake case for the arguments to do_create_interface_objects. --- components/script/dom/bindings/utils.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 411f7dcda3a..d657e7b2c2a 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -186,18 +186,18 @@ pub type NonNullJSNative = /// Fails on JSAPI failure. pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject, - protoProto: *mut JSObject, - protoClass: &'static JSClass, + proto_proto: *mut JSObject, + proto_class: &'static JSClass, constructor: Option<(NonNullJSNative, &'static str, u32)>, - domClass: *const DOMClass, + dom_class: *const DOMClass, members: &'static NativeProperties) -> *mut JSObject { - let proto = CreateInterfacePrototypeObject(cx, global, protoProto, - protoClass, members); + let proto = CreateInterfacePrototypeObject(cx, global, proto_proto, + proto_class, members); unsafe { JS_SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT, - PrivateValue(domClass as *const libc::c_void)); + PrivateValue(dom_class as *const libc::c_void)); } match constructor { From 47cd2d7eb4943ca9396e90f1f898b8d59d6694de Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:53:22 +0100 Subject: [PATCH 06/19] Rename CreateInterfaceObject to create_interface_object. --- components/script/dom/bindings/utils.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index d657e7b2c2a..f1e6d42f8d8 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -203,9 +203,9 @@ pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject, match constructor { Some((native, name, nargs)) => { let s = CString::from_slice(name.as_bytes()); - CreateInterfaceObject(cx, global, receiver, - native, nargs, proto, - members, s.as_ptr()) + create_interface_object(cx, global, receiver, + native, nargs, proto, + members, s.as_ptr()) }, None => (), } @@ -215,11 +215,12 @@ pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject, /// Creates the *interface object*. /// Fails on JSAPI failure. -fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject, - constructorNative: NonNullJSNative, - ctorNargs: u32, proto: *mut JSObject, - members: &'static NativeProperties, - name: *const libc::c_char) { +fn create_interface_object(cx: *mut JSContext, global: *mut JSObject, + receiver: *mut JSObject, + constructorNative: NonNullJSNative, + ctorNargs: u32, proto: *mut JSObject, + members: &'static NativeProperties, + name: *const libc::c_char) { unsafe { let fun = JS_NewFunction(cx, Some(constructorNative), ctorNargs, JSFUN_CONSTRUCTOR, global, name); From b336b024f7117908255e1f1d9290638715762d7d Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:54:30 +0100 Subject: [PATCH 07/19] Use snake case for arguments to and locals in create_interface_object. --- components/script/dom/bindings/utils.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index f1e6d42f8d8..69779d5920c 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -217,12 +217,12 @@ pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject, /// Fails on JSAPI failure. fn create_interface_object(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject, - constructorNative: NonNullJSNative, - ctorNargs: u32, proto: *mut JSObject, + constructor_native: NonNullJSNative, + ctor_nargs: u32, proto: *mut JSObject, members: &'static NativeProperties, name: *const libc::c_char) { unsafe { - let fun = JS_NewFunction(cx, Some(constructorNative), ctorNargs, + let fun = JS_NewFunction(cx, Some(constructor_native), ctor_nargs, JSFUN_CONSTRUCTOR, global, name); assert!(!fun.is_null()); @@ -252,10 +252,10 @@ fn create_interface_object(cx: *mut JSContext, global: *mut JSObject, assert!(JS_LinkConstructorAndPrototype(cx, constructor, proto) != 0); } - let mut alreadyDefined = 0; - assert!(JS_AlreadyHasOwnProperty(cx, receiver, name, &mut alreadyDefined) != 0); + let mut already_defined = 0; + assert!(JS_AlreadyHasOwnProperty(cx, receiver, name, &mut already_defined) != 0); - if alreadyDefined == 0 { + if already_defined == 0 { assert!(JS_DefineProperty(cx, receiver, name, ObjectValue(&*constructor), None, None, 0) != 0); From ffaffd9df8a7007f41c20e42ee92b0967456727e Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:57:08 +0100 Subject: [PATCH 08/19] Rename Define{Constants, Methods, Properties} to define_{constants, methods, properties}. --- components/script/dom/bindings/utils.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 69779d5920c..a40faed5228 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -231,20 +231,20 @@ fn create_interface_object(cx: *mut JSContext, global: *mut JSObject, match members.static_methods { Some(static_methods) => { - DefineMethods(cx, constructor, static_methods) + define_methods(cx, constructor, static_methods) }, _ => (), } match members.static_attrs { Some(static_properties) => { - DefineProperties(cx, constructor, static_properties) + define_properties(cx, constructor, static_properties) }, _ => (), } match members.consts { - Some(constants) => DefineConstants(cx, constructor, constants), + Some(constants) => define_constants(cx, constructor, constants), _ => (), } @@ -265,7 +265,8 @@ fn create_interface_object(cx: *mut JSContext, global: *mut JSObject, /// Defines constants on `obj`. /// Fails on JSAPI failure. -fn DefineConstants(cx: *mut JSContext, obj: *mut JSObject, constants: &'static [ConstantSpec]) { +fn define_constants(cx: *mut JSContext, obj: *mut JSObject, + constants: &'static [ConstantSpec]) { for spec in constants.iter() { unsafe { assert!(JS_DefineProperty(cx, obj, spec.name.as_ptr() as *const libc::c_char, @@ -279,7 +280,8 @@ fn DefineConstants(cx: *mut JSContext, obj: *mut JSObject, constants: &'static [ /// Defines methods on `obj`. The last entry of `methods` must contain zeroed /// memory. /// Fails on JSAPI failure. -fn DefineMethods(cx: *mut JSContext, obj: *mut JSObject, methods: &'static [JSFunctionSpec]) { +fn define_methods(cx: *mut JSContext, obj: *mut JSObject, + methods: &'static [JSFunctionSpec]) { unsafe { assert!(JS_DefineFunctions(cx, obj, methods.as_ptr()) != 0); } @@ -288,7 +290,8 @@ fn DefineMethods(cx: *mut JSContext, obj: *mut JSObject, methods: &'static [JSFu /// Defines attributes on `obj`. The last entry of `properties` must contain /// zeroed memory. /// Fails on JSAPI failure. -fn DefineProperties(cx: *mut JSContext, obj: *mut JSObject, properties: &'static [JSPropertySpec]) { +fn define_properties(cx: *mut JSContext, obj: *mut JSObject, + properties: &'static [JSPropertySpec]) { unsafe { assert!(JS_DefineProperties(cx, obj, properties.as_ptr()) != 0); } @@ -305,17 +308,17 @@ fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject, assert!(!ourProto.is_null()); match members.methods { - Some(methods) => DefineMethods(cx, ourProto, methods), + Some(methods) => define_methods(cx, ourProto, methods), _ => (), } match members.attrs { - Some(properties) => DefineProperties(cx, ourProto, properties), + Some(properties) => define_properties(cx, ourProto, properties), _ => (), } match members.consts { - Some(constants) => DefineConstants(cx, ourProto, constants), + Some(constants) => define_constants(cx, ourProto, constants), _ => (), } From 23743e3c203fc2f8a59185f851cdfaf001e89240 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:57:53 +0100 Subject: [PATCH 09/19] Rename CreateInterfacePrototypeObject to create_interface_prototype_object. --- components/script/dom/bindings/utils.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index a40faed5228..df3a10f0159 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -192,8 +192,8 @@ pub fn do_create_interface_objects(cx: *mut JSContext, global: *mut JSObject, dom_class: *const DOMClass, members: &'static NativeProperties) -> *mut JSObject { - let proto = CreateInterfacePrototypeObject(cx, global, proto_proto, - proto_class, members); + let proto = create_interface_prototype_object(cx, global, proto_proto, + proto_class, members); unsafe { JS_SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT, @@ -299,10 +299,11 @@ fn define_properties(cx: *mut JSContext, obj: *mut JSObject, /// Creates the *interface prototype object*. /// Fails on JSAPI failure. -fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject, - parentProto: *mut JSObject, - protoClass: &'static JSClass, - members: &'static NativeProperties) -> *mut JSObject { +fn create_interface_prototype_object(cx: *mut JSContext, global: *mut JSObject, + parentProto: *mut JSObject, + protoClass: &'static JSClass, + members: &'static NativeProperties) + -> *mut JSObject { unsafe { let ourProto = JS_NewObjectWithUniqueType(cx, protoClass, &*parentProto, &*global); assert!(!ourProto.is_null()); From 4d1cbae6110242b0ad6831a8f82f8b6c05d70da3 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:59:02 +0100 Subject: [PATCH 10/19] Use snake case for arguments to and locals in create_interface_prototype_object. --- components/script/dom/bindings/utils.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index df3a10f0159..c79200235ca 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -300,30 +300,31 @@ fn define_properties(cx: *mut JSContext, obj: *mut JSObject, /// Creates the *interface prototype object*. /// Fails on JSAPI failure. fn create_interface_prototype_object(cx: *mut JSContext, global: *mut JSObject, - parentProto: *mut JSObject, - protoClass: &'static JSClass, + parent_proto: *mut JSObject, + proto_class: &'static JSClass, members: &'static NativeProperties) -> *mut JSObject { unsafe { - let ourProto = JS_NewObjectWithUniqueType(cx, protoClass, &*parentProto, &*global); - assert!(!ourProto.is_null()); + let our_proto = JS_NewObjectWithUniqueType(cx, proto_class, + &*parent_proto, &*global); + assert!(!our_proto.is_null()); match members.methods { - Some(methods) => define_methods(cx, ourProto, methods), + Some(methods) => define_methods(cx, our_proto, methods), _ => (), } match members.attrs { - Some(properties) => define_properties(cx, ourProto, properties), + Some(properties) => define_properties(cx, our_proto, properties), _ => (), } match members.consts { - Some(constants) => define_constants(cx, ourProto, constants), + Some(constants) => define_constants(cx, our_proto, constants), _ => (), } - return ourProto; + return our_proto; } } From 04f5dea19f3c493ce8b3df1f5bb77241f3f3d323 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 18:59:48 +0100 Subject: [PATCH 11/19] Rename ThrowingConstructor to throwing_constructor. --- components/script/dom/bindings/codegen/CodegenRust.py | 4 ++-- components/script/dom/bindings/utils.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 082ab972f5b..820dfde8d63 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1991,7 +1991,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): constructHook = CONSTRUCT_HOOK_NAME constructArgs = methodLength(self.descriptor.interface.ctor()) else: - constructHook = "ThrowingConstructor" + constructHook = "throwing_constructor" constructArgs = 0 constructor = 'Some((%s as NonNullJSNative, "%s", %d))' % ( @@ -4558,7 +4558,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::utils::IsPlatformObject', 'dom::bindings::utils::{Reflectable}', 'dom::bindings::utils::{squirrel_away_unique}', - 'dom::bindings::utils::{ThrowingConstructor}', + 'dom::bindings::utils::throwing_constructor', 'dom::bindings::utils::get_dictionary_property', 'dom::bindings::utils::{NativeProperties, NativePropertyHooks}', 'dom::bindings::utils::ConstantVal::{IntVal, UintVal}', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index c79200235ca..afa3cbda6e4 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -330,7 +330,8 @@ fn create_interface_prototype_object(cx: *mut JSContext, global: *mut JSObject, /// A throwing constructor, for those interfaces that have neither /// `NoInterfaceObject` nor `Constructor`. -pub unsafe extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp: *mut JSVal) -> JSBool { +pub unsafe extern fn throwing_constructor(cx: *mut JSContext, _argc: c_uint, + _vp: *mut JSVal) -> JSBool { throw_type_error(cx, "Illegal constructor."); return 0; } From 1af130201092bd77cd4ce37352c0ae6ed5518075 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 19:01:10 +0100 Subject: [PATCH 12/19] Use snake case for the local in initialize_global. --- components/script/dom/bindings/utils.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index afa3cbda6e4..2df02a3ed18 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -339,10 +339,11 @@ pub unsafe extern fn throwing_constructor(cx: *mut JSContext, _argc: c_uint, /// Construct and cache the ProtoOrIfaceArray for the given global. /// Fails if the argument is not a DOM global. pub fn initialize_global(global: *mut JSObject) { - let protoArray = box () ([0 as *mut JSObject; PrototypeList::ID::Count as uint]); + let proto_array = box () + ([0 as *mut JSObject; PrototypeList::ID::Count as uint]); unsafe { assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0); - let box_ = squirrel_away_unique(protoArray); + let box_ = squirrel_away_unique(proto_array); JS_SetReservedSlot(global, DOM_PROTOTYPE_SLOT, PrivateValue(box_ as *const libc::c_void)); From 747b6c4262ad93f1eb521d06693b4ea8878e20ef Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 19:03:36 +0100 Subject: [PATCH 13/19] Rename GetPropertyOnPrototype to get_property_on_prototype. --- components/script/dom/bindings/codegen/CodegenRust.py | 4 ++-- components/script/dom/bindings/utils.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 820dfde8d63..7d71ff51160 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -3908,7 +3908,7 @@ if !expando.is_null() { %s let mut found = false; -if !GetPropertyOnPrototype(cx, proxy, id, &mut found, vp) { +if !get_property_on_prototype(cx, proxy, id, &mut found, vp) { return false; } @@ -4553,7 +4553,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::utils::{DOMClass}', 'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}', 'dom::bindings::utils::{FindEnumStringIndex, GetArrayIndexFromId}', - 'dom::bindings::utils::{GetPropertyOnPrototype, get_proto_or_iface_array}', + 'dom::bindings::utils::{get_property_on_prototype, get_proto_or_iface_array}', 'dom::bindings::utils::HasPropertyOnPrototype', 'dom::bindings::utils::IsPlatformObject', 'dom::bindings::utils::{Reflectable}', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 2df02a3ed18..674c38cbc53 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -410,8 +410,9 @@ impl Reflector { /// set to true and `*vp` to the value, otherwise `*found` is set to false. /// /// Returns false on JSAPI failure. -pub fn GetPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, found: *mut bool, - vp: *mut JSVal) -> bool { +pub fn get_property_on_prototype(cx: *mut JSContext, proxy: *mut JSObject, + id: jsid, found: *mut bool, vp: *mut JSVal) + -> bool { unsafe { //let proto = GetObjectProto(proxy); let proto = JS_GetPrototype(proxy); @@ -553,7 +554,7 @@ pub fn get_dictionary_property(cx: *mut JSContext, pub fn HasPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> bool { // MOZ_ASSERT(js::IsProxy(proxy) && js::GetProxyHandler(proxy) == handler); let mut found = false; - return !GetPropertyOnPrototype(cx, proxy, id, &mut found, ptr::null_mut()) || found; + return !get_property_on_prototype(cx, proxy, id, &mut found, ptr::null_mut()) || found; } /// Returns whether `obj` can be converted to a callback interface per IDL. From ab52927ac5407e3a9057a03e2207c2dfb10ff572 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 19:04:26 +0100 Subject: [PATCH 14/19] Use snake case for the local in get_property_on_prototype. --- components/script/dom/bindings/utils.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 674c38cbc53..37e150b5fc2 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -420,13 +420,13 @@ pub fn get_property_on_prototype(cx: *mut JSContext, proxy: *mut JSObject, *found = false; return true; } - let mut hasProp = 0; - if JS_HasPropertyById(cx, proto, id, &mut hasProp) == 0 { + let mut has_property = 0; + if JS_HasPropertyById(cx, proto, id, &mut has_property) == 0 { return false; } - *found = hasProp != 0; + *found = has_property != 0; let no_output = vp.is_null(); - if hasProp == 0 || no_output { + if has_property == 0 || no_output { return true; } From a0f5250cb8226363c4c1ccb914f15634614f2759 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 19:06:38 +0100 Subject: [PATCH 15/19] Rename GetArrayIndexFromId to get_array_index_from_id. --- .../script/dom/bindings/codegen/CodegenRust.py | 12 ++++++------ components/script/dom/bindings/utils.rs | 2 +- components/script/dom/browsercontext.rs | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 7d71ff51160..38fbd83aaf6 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -3627,7 +3627,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): setOrIndexedGet = "" if indexedGetter or indexedSetter: - setOrIndexedGet += "let index = GetArrayIndexFromId(cx, id);\n" + setOrIndexedGet += "let index = get_array_index_from_id(cx, id);\n" if indexedGetter: readonly = toStringBool(self.descriptor.operations['IndexedSetter'] is None) @@ -3725,7 +3725,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): if indexedSetter: if not (self.descriptor.operations['IndexedCreator'] is indexedSetter): raise TypeError("Can't handle creator that's different from the setter") - set += ("let index = GetArrayIndexFromId(cx, id);\n" + + set += ("let index = get_array_index_from_id(cx, id);\n" + "if index.is_some() {\n" + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + @@ -3735,7 +3735,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): " return true;\n" + "}\n") elif self.descriptor.operations['IndexedGetter']: - set += ("if GetArrayIndexFromId(cx, id).is_some() {\n" + + set += ("if get_array_index_from_id(cx, id).is_some() {\n" + " return false;\n" + " //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" + "}\n") % self.descriptor.name @@ -3800,7 +3800,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): def getBody(self): indexedGetter = self.descriptor.operations['IndexedGetter'] if indexedGetter: - indexed = ("let index = GetArrayIndexFromId(cx, id);\n" + + indexed = ("let index = get_array_index_from_id(cx, id);\n" + "if index.is_some() {\n" + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + @@ -3873,7 +3873,7 @@ if !expando.is_null() { indexedGetter = self.descriptor.operations['IndexedGetter'] if indexedGetter: - getIndexedOrExpando = ("let index = GetArrayIndexFromId(cx, id);\n" + + getIndexedOrExpando = ("let index = get_array_index_from_id(cx, id);\n" + "if index.is_some() {\n" + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + @@ -4552,7 +4552,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::utils::ConstantSpec', 'dom::bindings::utils::{DOMClass}', 'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}', - 'dom::bindings::utils::{FindEnumStringIndex, GetArrayIndexFromId}', + 'dom::bindings::utils::{FindEnumStringIndex, get_array_index_from_id}', 'dom::bindings::utils::{get_property_on_prototype, get_proto_or_iface_array}', 'dom::bindings::utils::HasPropertyOnPrototype', 'dom::bindings::utils::IsPlatformObject', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 37e150b5fc2..3d3de73fa95 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -436,7 +436,7 @@ pub fn get_property_on_prototype(cx: *mut JSContext, proxy: *mut JSObject, /// Get an array index from the given `jsid`. Returns `None` if the given /// `jsid` is not an integer. -pub fn GetArrayIndexFromId(_cx: *mut JSContext, id: jsid) -> Option { +pub fn get_array_index_from_id(_cx: *mut JSContext, id: jsid) -> Option { unsafe { if RUST_JSID_IS_INT(id) != 0 { return Some(RUST_JSID_TO_INT(id) as u32); diff --git a/components/script/dom/browsercontext.rs b/components/script/dom/browsercontext.rs index f3e52d0f46d..3d486a3fe11 100644 --- a/components/script/dom/browsercontext.rs +++ b/components/script/dom/browsercontext.rs @@ -9,7 +9,7 @@ use dom::bindings::js::{OptionalRootable, OptionalRootedRootable, ResultRootable use dom::bindings::js::{OptionalRootedReference, OptionalOptionalRootedRootable}; use dom::bindings::proxyhandler::{get_property_descriptor, fill_property_descriptor}; use dom::bindings::utils::{Reflectable, WindowProxyHandler}; -use dom::bindings::utils::{GetArrayIndexFromId}; +use dom::bindings::utils::get_array_index_from_id; use dom::document::{Document, DocumentHelpers}; use dom::window::Window; use dom::window::WindowHelpers; @@ -100,7 +100,7 @@ impl SessionHistoryEntry { } unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> Option> { - let index = GetArrayIndexFromId(cx, id); + let index = get_array_index_from_id(cx, id); if let Some(index) = index { let target = GetProxyPrivate(proxy).to_object(); let win: Root = unwrap_jsmanaged(target).unwrap().root(); @@ -139,7 +139,7 @@ unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObje unsafe extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, desc: *mut JSPropertyDescriptor) -> bool { - if GetArrayIndexFromId(cx, id).is_some() { + if get_array_index_from_id(cx, id).is_some() { // Spec says to Reject whether this is a supported index or not, // since we have no indexed setter or indexed creator. That means // throwing in strict mode (FIXME: Bug 828137), doing nothing in @@ -182,7 +182,7 @@ unsafe extern fn get(cx: *mut JSContext, proxy: *mut JSObject, receiver: *mut JS } unsafe extern fn set(cx: *mut JSContext, proxy: *mut JSObject, _receiver: *mut JSObject, id: jsid, _strict: bool, vp: *mut JSVal) -> bool { - if GetArrayIndexFromId(cx, id).is_some() { + if get_array_index_from_id(cx, id).is_some() { // Reject (which means throw if and only if strict) the set. // FIXME: Throw return true; From 59909efff120ec422f4d58e73d4bbf685a23182b Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 19:10:51 +0100 Subject: [PATCH 16/19] Rename IsPlatformObject to is_platform_object. --- components/script/dom/bindings/codegen/CodegenRust.py | 8 ++++---- components/script/dom/bindings/utils.rs | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 38fbd83aaf6..cbebec7396a 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -336,7 +336,7 @@ class CGMethodCall(CGThing): # Check for vanilla JS objects # XXXbz Do we need to worry about security wrappers? - pickFirstSignature("%s.is_object() && !IsPlatformObject(%s.to_object())" % + pickFirstSignature("%s.is_object() && !is_platform_object(%s.to_object())" % (distinguishingArg, distinguishingArg), lambda s: (s[1][distinguishingIndex].type.isCallback() or s[1][distinguishingIndex].type.isCallbackInterface() or @@ -719,7 +719,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, handleInvalidEnumValueCode = "return 1;" template = ( - "match FindEnumStringIndex(cx, ${val}, %(values)s) {\n" + "match find_enum_string_index(cx, ${val}, %(values)s) {\n" " Err(_) => { %(exceptionCode)s },\n" " Ok(None) => { %(handleInvalidEnumValueCode)s },\n" " Ok(Some(index)) => {\n" @@ -4552,10 +4552,10 @@ class CGBindingRoot(CGThing): 'dom::bindings::utils::ConstantSpec', 'dom::bindings::utils::{DOMClass}', 'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}', - 'dom::bindings::utils::{FindEnumStringIndex, get_array_index_from_id}', + 'dom::bindings::utils::{find_enum_string_index, get_array_index_from_id}', 'dom::bindings::utils::{get_property_on_prototype, get_proto_or_iface_array}', 'dom::bindings::utils::HasPropertyOnPrototype', - 'dom::bindings::utils::IsPlatformObject', + 'dom::bindings::utils::is_platform_object', 'dom::bindings::utils::{Reflectable}', 'dom::bindings::utils::{squirrel_away_unique}', 'dom::bindings::utils::throwing_constructor', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 3d3de73fa95..934b644befe 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -462,9 +462,10 @@ pub fn get_array_index_from_id(_cx: *mut JSContext, id: jsid) -> Option { /// Find the index of a string given by `v` in `values`. /// Returns `Err(())` on JSAPI failure (there is a pending exception), and /// `Ok(None)` if there was no matching string. -pub fn FindEnumStringIndex(cx: *mut JSContext, - v: JSVal, - values: &[&'static str]) -> Result, ()> { +pub fn find_enum_string_index(cx: *mut JSContext, + v: JSVal, + values: &[&'static str]) + -> Result, ()> { unsafe { let jsstr = JS_ValueToString(cx, v); if jsstr.is_null() { @@ -488,7 +489,7 @@ pub fn FindEnumStringIndex(cx: *mut JSContext, /// Returns wether `obj` is a platform object /// http://heycam.github.io/webidl/#dfn-platform-object -pub fn IsPlatformObject(obj: *mut JSObject) -> bool { +pub fn is_platform_object(obj: *mut JSObject) -> bool { unsafe { // Fast-path the common case let mut clasp = JS_GetClass(obj); From 69c4c8223c90ed6122c0e85e3947841f665ededd Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 19:12:40 +0100 Subject: [PATCH 17/19] Rename HasPropertyOnPrototype to has_property_on_prototype. --- components/script/dom/bindings/codegen/CodegenRust.py | 6 +++--- components/script/dom/bindings/utils.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index cbebec7396a..0f946062900 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -3680,7 +3680,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): # ResolveOwnProperty or EnumerateOwnProperties filter out named # properties that shadow prototype properties. namedGet = ("\n" + - "if !set && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" + + "if !set && RUST_JSID_IS_STRING(id) != 0 && !has_property_on_prototype(cx, proxy, id) {\n" + " let name = jsid_to_str(cx, id);\n" + " let this = UnwrapProxy(proxy);\n" + " let this = JS::from_raw(this);\n" + @@ -3815,7 +3815,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): namedGetter = self.descriptor.operations['NamedGetter'] if namedGetter: - named = ("if RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" + + named = ("if RUST_JSID_IS_STRING(id) != 0 && !has_property_on_prototype(cx, proxy, id) {\n" + " let name = jsid_to_str(cx, id);\n" + " let this = UnwrapProxy(proxy);\n" + " let this = JS::from_raw(this);\n" + @@ -4554,7 +4554,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}', 'dom::bindings::utils::{find_enum_string_index, get_array_index_from_id}', 'dom::bindings::utils::{get_property_on_prototype, get_proto_or_iface_array}', - 'dom::bindings::utils::HasPropertyOnPrototype', + 'dom::bindings::utils::has_property_on_prototype', 'dom::bindings::utils::is_platform_object', 'dom::bindings::utils::{Reflectable}', 'dom::bindings::utils::{squirrel_away_unique}', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 934b644befe..8a3012eae9f 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -552,7 +552,8 @@ pub fn get_dictionary_property(cx: *mut JSContext, } /// Returns whether `proxy` has a property `id` on its prototype. -pub fn HasPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> bool { +pub fn has_property_on_prototype(cx: *mut JSContext, proxy: *mut JSObject, + id: jsid) -> bool { // MOZ_ASSERT(js::IsProxy(proxy) && js::GetProxyHandler(proxy) == handler); let mut found = false; return !get_property_on_prototype(cx, proxy, id, &mut found, ptr::null_mut()) || found; From d0627a2592c0fdddbaa78b45ead0c7842dcc8f2e Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 19:13:56 +0100 Subject: [PATCH 18/19] Remove unused IsConvertibleToCallbackInterface. --- components/script/dom/bindings/utils.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 8a3012eae9f..960926fdd41 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -24,7 +24,7 @@ use js::glue::{IsWrapper, RUST_JSID_IS_INT, RUST_JSID_TO_INT}; use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewFunction}; use js::jsapi::{JS_DefineProperties, JS_ForwardGetPropertyTo}; use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype, JS_GetStringCharsAndLength}; -use js::jsapi::{JS_ObjectIsRegExp, JS_ObjectIsDate, JSHandleObject}; +use js::jsapi::JSHandleObject; use js::jsapi::JS_GetFunctionObject; use js::jsapi::{JS_HasPropertyById, JS_GetPrototype}; use js::jsapi::{JS_GetProperty, JS_HasProperty}; @@ -559,13 +559,6 @@ pub fn has_property_on_prototype(cx: *mut JSContext, proxy: *mut JSObject, return !get_property_on_prototype(cx, proxy, id, &mut found, ptr::null_mut()) || found; } -/// Returns whether `obj` can be converted to a callback interface per IDL. -pub fn IsConvertibleToCallbackInterface(cx: *mut JSContext, obj: *mut JSObject) -> bool { - unsafe { - JS_ObjectIsDate(cx, obj) == 0 && JS_ObjectIsRegExp(cx, obj) == 0 - } -} - /// Create a DOM global object with the given class. pub fn CreateDOMGlobal(cx: *mut JSContext, class: *const JSClass) -> *mut JSObject { unsafe { From d752cdc44f4e0bb924538ee4ae758f71236b4483 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 19:15:04 +0100 Subject: [PATCH 19/19] Rename CreateDOMGlobal to create_dom_global. --- components/script/dom/bindings/codegen/CodegenRust.py | 4 ++-- components/script/dom/bindings/utils.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 0f946062900..b723f16dca0 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1811,7 +1811,7 @@ assert!(!obj.is_null());\ """ % (descriptor.name, parent) else: if descriptor.isGlobal(): - create += "let obj = CreateDOMGlobal(aCx, &Class.base as *const js::Class as *const JSClass);\n" + create += "let obj = create_dom_global(aCx, &Class.base as *const js::Class as *const JSClass);\n" else: create += ("let obj = with_compartment(aCx, proto, || {\n" " JS_NewObject(aCx, &Class.base as *const js::Class as *const JSClass, &*proto, &*%s)\n" @@ -4548,7 +4548,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::js::{JS, JSRef, Root, RootedReference, Temporary}', 'dom::bindings::js::{OptionalRootable, OptionalRootedRootable, ResultRootable}', 'dom::bindings::js::{OptionalRootedReference, OptionalOptionalRootedRootable}', - 'dom::bindings::utils::{CreateDOMGlobal, do_create_interface_objects}', + 'dom::bindings::utils::{create_dom_global, do_create_interface_objects}', 'dom::bindings::utils::ConstantSpec', 'dom::bindings::utils::{DOMClass}', 'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}', diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 960926fdd41..5c68dfce33d 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -560,7 +560,8 @@ pub fn has_property_on_prototype(cx: *mut JSContext, proxy: *mut JSObject, } /// Create a DOM global object with the given class. -pub fn CreateDOMGlobal(cx: *mut JSContext, class: *const JSClass) -> *mut JSObject { +pub fn create_dom_global(cx: *mut JSContext, class: *const JSClass) + -> *mut JSObject { unsafe { let obj = JS_NewGlobalObject(cx, class, ptr::null_mut()); if obj.is_null() {