From 1056ea320b4cd808af87c198497d801eea0081ff Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 30 Jan 2015 16:08:19 +0100 Subject: [PATCH 1/5] Use snake case for arguments and locals in CGWrapMethod. --- .../dom/bindings/codegen/CodegenRust.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 257ab3b1675..ff40b936e92 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1795,14 +1795,14 @@ class CGAbstractMethod(CGThing): assert(False) # Override me! def CreateBindingJSObject(descriptor, parent=None): - create = "let mut raw: JS<%s> = JS::from_raw(&*aObject);\n" % descriptor.concreteType + create = "let mut raw: JS<%s> = JS::from_raw(&*object);\n" % descriptor.concreteType if descriptor.proxy: assert not descriptor.isGlobal() create += """ let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as uint]; -let mut private = PrivateValue(squirrel_away_unique(aObject) as *const libc::c_void); -let obj = with_compartment(aCx, proto, || { - NewProxyObject(aCx, handler, +let mut private = PrivateValue(squirrel_away_unique(object) as *const libc::c_void); +let obj = with_compartment(cx, proto, || { + NewProxyObject(cx, handler, &private, proto, %s, ptr::null_mut(), ptr::null_mut()) @@ -1811,16 +1811,16 @@ assert!(!obj.is_null());\ """ % (descriptor.name, parent) else: if descriptor.isGlobal(): - create += "let obj = create_dom_global(aCx, &Class.base as *const js::Class as *const JSClass);\n" + create += "let obj = create_dom_global(cx, &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" + create += ("let obj = with_compartment(cx, proto, || {\n" + " JS_NewObject(cx, &Class.base as *const js::Class as *const JSClass, &*proto, &*%s)\n" "});\n" % parent) create += """\ assert!(!obj.is_null()); JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32, - PrivateValue(squirrel_away_unique(aObject) as *const libc::c_void));""" + PrivateValue(squirrel_away_unique(object) as *const libc::c_void));""" return create class CGWrapMethod(CGAbstractMethod): @@ -1831,22 +1831,22 @@ class CGWrapMethod(CGAbstractMethod): def __init__(self, descriptor): assert not descriptor.interface.isCallback() if not descriptor.isGlobal(): - args = [Argument('*mut JSContext', 'aCx'), Argument('GlobalRef', 'aScope'), - Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)] + args = [Argument('*mut JSContext', 'cx'), Argument('GlobalRef', 'scope'), + Argument("Box<%s>" % descriptor.concreteType, 'object', mutable=True)] else: - args = [Argument('*mut JSContext', 'aCx'), - Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)] + args = [Argument('*mut JSContext', 'cx'), + Argument("Box<%s>" % descriptor.concreteType, 'object', mutable=True)] retval = 'Temporary<%s>' % descriptor.concreteType CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True) def definition_body(self): if not self.descriptor.isGlobal(): return CGGeneric("""\ -let scope = aScope.reflector().get_jsobject(); +let scope = scope.reflector().get_jsobject(); assert!(!scope.is_null()); assert!(((*JS_GetClass(scope)).flags & JSCLASS_IS_GLOBAL) != 0); -let proto = with_compartment(aCx, scope, || GetProtoObject(aCx, scope, scope)); +let proto = with_compartment(cx, scope, || GetProtoObject(cx, scope, scope)); assert!(!proto.is_null()); %s @@ -1857,13 +1857,13 @@ Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor, "scope")) else: return CGGeneric("""\ %s -with_compartment(aCx, obj, || { - let proto = GetProtoObject(aCx, obj, obj); - JS_SetPrototype(aCx, obj, proto); +with_compartment(cx, obj, || { + let proto = GetProtoObject(cx, obj, obj); + JS_SetPrototype(cx, obj, proto); raw.reflector().set_jsobject(obj); - RegisterBindings::Register(aCx, obj); + RegisterBindings::Register(cx, obj); }); Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor)) From 10ce1c8df55b6621a13d3bd4864052a9a6e0b665 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 30 Jan 2015 16:09:43 +0100 Subject: [PATCH 2/5] Use snake case for arguments and locals in CGCreateInterfaceObjectsMethod. --- .../script/dom/bindings/codegen/CodegenRust.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index ff40b936e92..07b45737008 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1962,21 +1962,21 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): """ def __init__(self, descriptor, properties): assert not descriptor.interface.isCallback() - args = [Argument('*mut JSContext', 'aCx'), Argument('*mut JSObject', 'aGlobal'), - Argument('*mut JSObject', 'aReceiver')] + args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'global'), + Argument('*mut JSObject', 'receiver')] CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', '*mut JSObject', args) self.properties = properties def definition_body(self): protoChain = self.descriptor.prototypeChain if len(protoChain) == 1: - getParentProto = "JS_GetObjectPrototype(aCx, aGlobal)" + getParentProto = "JS_GetObjectPrototype(cx, global)" else: parentProtoName = self.descriptor.prototypeChain[-2] - getParentProto = ("%s::GetProtoObject(aCx, aGlobal, aReceiver)" % + getParentProto = ("%s::GetProtoObject(cx, global, receiver)" % toBindingNamespace(parentProtoName)) - getParentProto = ("let parentProto: *mut JSObject = %s;\n" - "assert!(!parentProto.is_null());\n") % getParentProto + getParentProto = ("let parent_proto: *mut JSObject = %s;\n" + "assert!(!parent_proto.is_null());\n") % getParentProto if self.descriptor.concrete: if self.descriptor.proxy: @@ -2001,7 +2001,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): constructor = 'None' call = """\ -return do_create_interface_objects(aCx, aGlobal, aReceiver, parentProto, +return do_create_interface_objects(cx, global, receiver, parent_proto, &PrototypeClass, %s, %s, &sNativeProperties);""" % (constructor, domClass) From f5412355b1c350270552378b19199882c0dd1f68 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 30 Jan 2015 16:10:45 +0100 Subject: [PATCH 3/5] Use snake case for arguments and locals in CGGetPerInterfaceObject. --- .../dom/bindings/codegen/CodegenRust.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 07b45737008..795204466df 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2017,32 +2017,32 @@ class CGGetPerInterfaceObject(CGAbstractMethod): constructor object). """ def __init__(self, descriptor, name, idPrefix="", pub=False): - args = [Argument('*mut JSContext', 'aCx'), Argument('*mut JSObject', 'aGlobal'), - Argument('*mut JSObject', 'aReceiver')] + args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'global'), + Argument('*mut JSObject', 'receiver')] CGAbstractMethod.__init__(self, descriptor, name, '*mut JSObject', args, pub=pub) self.id = idPrefix + "ID::" + self.descriptor.name def definition_body(self): return CGGeneric(""" -/* aGlobal and aReceiver are usually the same, but they can be different +/* global and receiver are usually the same, but they can be different too. For example a sandbox often has an xray wrapper for a window as the - prototype of the sandbox's global. In that case aReceiver is the xray - wrapper and aGlobal is the sandbox's global. + prototype of the sandbox's global. In that case receiver is the xray + wrapper and global is the sandbox's global. */ -assert!(((*JS_GetClass(aGlobal)).flags & JSCLASS_DOM_GLOBAL) != 0); +assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0); /* Check to see whether the interface objects are already installed */ -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); +let proto_or_iface_array = get_proto_or_iface_array(global); +let cached_object: *mut JSObject = *proto_or_iface_array.offset(%s as int); +if cached_object.is_null() { + let tmp: *mut JSObject = CreateInterfaceObjects(cx, global, receiver); assert!(!tmp.is_null()); - *protoOrIfaceArray.offset(%s as int) = tmp; + *proto_or_iface_array.offset(%s as int) = tmp; tmp } else { - cachedObject + cached_object }""" % (self.id, self.id)) class CGGetProtoObjectMethod(CGGetPerInterfaceObject): From 6311ff07ef5a7fbc453e6ce5c1863bf1c75340a9 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sun, 18 Jan 2015 23:57:23 +0100 Subject: [PATCH 4/5] Use snake case in Node. --- components/script/dom/node.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index bd262ae2aaa..7b68f7ba6b8 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1376,7 +1376,7 @@ impl Node { } // Step 7-8. - let referenceChild = match child { + let reference_child = match child { Some(child) if child.clone() == node => node.next_sibling().map(|node| (*node.root()).clone()), _ => child }; @@ -1386,7 +1386,7 @@ impl Node { Node::adopt(node, *document); // Step 10. - Node::insert(node, parent, referenceChild, SuppressObserver::Unsuppressed); + Node::insert(node, parent, reference_child, SuppressObserver::Unsuppressed); // Step 11. return Ok(Temporary::from_rooted(node)) @@ -1467,10 +1467,10 @@ impl Node { } // Step 2. - let removedNodes: Vec> = parent.children().collect(); + let removed_nodes: Vec> = parent.children().collect(); // Step 3. - let addedNodes = match node { + let added_nodes = match node { None => vec!(), Some(node) => match node.type_id() { NodeTypeId::DocumentFragment => node.children().collect(), @@ -1493,11 +1493,11 @@ impl Node { // Step 7. let parent_in_doc = parent.is_in_doc(); - for removedNode in removedNodes.iter() { - removedNode.node_removed(parent_in_doc); + for removed_node in removed_nodes.iter() { + removed_node.node_removed(parent_in_doc); } - for addedNode in addedNodes.iter() { - addedNode.node_inserted(); + for added_node in added_nodes.iter() { + added_node.node_inserted(); } } From a71ccfabef35b0bbfe5a45ecfb24e3c96cc2eee2 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 19 Jan 2015 00:00:30 +0100 Subject: [PATCH 5/5] Use snake case in Worker. --- components/script/dom/worker.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 2f52f0576d1..776ffe5699c 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -57,10 +57,10 @@ impl Worker { } // http://www.whatwg.org/html/#dom-worker - pub fn Constructor(global: GlobalRef, scriptURL: DOMString) -> Fallible> { + pub fn Constructor(global: GlobalRef, script_url: DOMString) -> Fallible> { // Step 2-4. let worker_url = match UrlParser::new().base_url(&global.get_url()) - .parse(scriptURL.as_slice()) { + .parse(script_url.as_slice()) { Ok(url) => url, Err(_) => return Err(Syntax), };