From dac0190b6d47fcc58919e13a0b04a72231292538 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 21:07:46 +0100 Subject: [PATCH 1/5] Use snake case for the argument to from_jsval for DOMString. --- components/script/dom/bindings/conversions.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 2258566499e..bf805a35fbf 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -286,8 +286,10 @@ pub fn jsid_to_str(cx: *mut JSContext, id: jsid) -> DOMString { } impl FromJSValConvertible for DOMString { - fn from_jsval(cx: *mut JSContext, value: JSVal, nullBehavior: StringificationBehavior) -> Result { - if nullBehavior == StringificationBehavior::Empty && value.is_null() { + fn from_jsval(cx: *mut JSContext, value: JSVal, + null_behavior: StringificationBehavior) + -> Result { + if null_behavior == StringificationBehavior::Empty && value.is_null() { Ok("".to_owned()) } else { let jsstr = unsafe { JS_ValueToString(cx, value) }; From cfbe4644281b2b2d0fe955a2594badbef2083585 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 21:09:52 +0100 Subject: [PATCH 2/5] Rename GetCallableProperty to get_callable_property. --- components/script/dom/bindings/callback.rs | 3 ++- components/script/dom/bindings/codegen/CodegenRust.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index dd0bf8bf65c..ef3819438cb 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -95,7 +95,8 @@ impl CallbackInterface { /// Returns the property with the given `name`, if it is a callable object, /// or `Err(())` otherwise. If it returns `Err(())`, a JSAPI exception is /// pending. - pub fn GetCallableProperty(&self, cx: *mut JSContext, name: &str) -> Result { + pub fn get_callable_property(&self, cx: *mut JSContext, name: &str) + -> Result { let mut callable = UndefinedValue(); unsafe { let name = CString::from_slice(name.as_bytes()); diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index b723f16dca0..2fbda77ad3d 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5083,7 +5083,7 @@ class CallbackOperationBase(CallbackMethod): "methodName": self.methodName } getCallableFromProp = string.Template( - 'match self.parent.GetCallableProperty(cx, "${methodName}") {\n' + 'match self.parent.get_callable_property(cx, "${methodName}") {\n' ' Err(_) => return Err(FailureUnknown),\n' ' Ok(callable) => callable,\n' '}').substitute(replacements) From bbf13590243866f1ca57a56ebd4be1d9bf04a56f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 21:12:00 +0100 Subject: [PATCH 3/5] Rename WrapCallThisObject to wrap_call_this_object. --- components/script/dom/bindings/callback.rs | 4 ++-- components/script/dom/bindings/codegen/CodegenRust.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index ef3819438cb..7d4cdc56802 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -116,8 +116,8 @@ impl CallbackInterface { } /// Wraps the reflector for `p` into the compartment of `cx`. -pub fn WrapCallThisObject(cx: *mut JSContext, - p: JSRef) -> *mut JSObject { +pub fn wrap_call_this_object(cx: *mut JSContext, + p: JSRef) -> *mut JSObject { let mut obj = p.reflector().get_jsobject(); assert!(!obj.is_null()); diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 2fbda77ad3d..48b147c4ebe 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -4566,7 +4566,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::trace::JSTraceable', 'dom::bindings::callback::{CallbackContainer,CallbackInterface,CallbackFunction}', 'dom::bindings::callback::{CallSetup,ExceptionHandling}', - 'dom::bindings::callback::{WrapCallThisObject}', + 'dom::bindings::callback::wrap_call_this_object', 'dom::bindings::conversions::{FromJSValConvertible, ToJSValConvertible}', 'dom::bindings::conversions::{unwrap, unwrap_jsmanaged}', 'dom::bindings::conversions::DOM_OBJECT_SLOT', @@ -4748,7 +4748,7 @@ class CGCallback(CGClass): bodyWithThis = string.Template( setupCall+ - "let thisObjJS = WrapCallThisObject(s.GetContext(), thisObj);\n" + "let thisObjJS = wrap_call_this_object(s.GetContext(), thisObj);\n" "if thisObjJS.is_null() {\n" " return Err(FailureUnknown);\n" "}\n" From 36ce24454c2f51a6e84630e42141d75b21e259e2 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 21:13:15 +0100 Subject: [PATCH 4/5] Rename GetContext to get_context. --- components/script/dom/bindings/callback.rs | 2 +- components/script/dom/bindings/codegen/CodegenRust.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index 7d4cdc56802..24bdc815509 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -154,7 +154,7 @@ impl CallSetup { } /// Returns the `JSContext` used for the call. - pub fn GetContext(&self) -> *mut JSContext { + pub fn get_context(&self) -> *mut JSContext { self.cx } } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 48b147c4ebe..257ab3b1675 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -4721,8 +4721,8 @@ class CGCallback(CGClass): # Record the names of all the arguments, so we can use them when we call # the private method. argnames = [arg.name for arg in args] - argnamesWithThis = ["s.GetContext()", "thisObjJS"] + argnames - argnamesWithoutThis = ["s.GetContext()", "ptr::null_mut()"] + argnames + argnamesWithThis = ["s.get_context()", "thisObjJS"] + argnames + argnamesWithoutThis = ["s.get_context()", "ptr::null_mut()"] + argnames # Now that we've recorded the argnames for our call to our private # method, insert our optional argument for deciding whether the # CallSetup should re-throw exceptions on aRv. @@ -4742,13 +4742,13 @@ class CGCallback(CGClass): argsWithoutThis.insert(0, Argument(None, "self")) setupCall = ("let s = CallSetup::new(self, aExceptionHandling);\n" - "if s.GetContext().is_null() {\n" + "if s.get_context().is_null() {\n" " return Err(FailureUnknown);\n" "}\n") bodyWithThis = string.Template( setupCall+ - "let thisObjJS = wrap_call_this_object(s.GetContext(), thisObj);\n" + "let thisObjJS = wrap_call_this_object(s.get_context(), thisObj);\n" "if thisObjJS.is_null() {\n" " return Err(FailureUnknown);\n" "}\n" @@ -5000,7 +5000,7 @@ class CallbackMember(CGNativeMember): return "" return ( "CallSetup s(CallbackPreserveColor(), aRv, aExceptionHandling);\n" - "JSContext* cx = s.GetContext();\n" + "JSContext* cx = s.get_context();\n" "if (!cx) {\n" " return Err(FailureUnknown);\n" "}\n") From 311d936169b719730d2ecb0fb98bc6f9cef301f6 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 29 Jan 2015 21:20:03 +0100 Subject: [PATCH 5/5] Require snake case in bindings code. --- components/script/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/script/lib.rs b/components/script/lib.rs index 17a05dac3fb..faa80504a55 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -56,7 +56,7 @@ pub mod dom { /// The code to expose the DOM to JavaScript through IDL bindings. #[allow(unsafe_blocks)] - #[deny(missing_docs)] + #[deny(missing_docs, non_snake_case)] pub mod bindings { pub mod cell; pub mod global; @@ -72,7 +72,7 @@ pub mod dom { pub mod trace; /// Generated JS-Rust bindings. - #[allow(missing_docs)] + #[allow(missing_docs, non_snake_case)] pub mod codegen { #[allow(unrooted_must_root)] pub mod Bindings;