Skip to content

Commit

Permalink
auto merge of #4773 : Ms2ger/servo/snake-bindings, r=jdm
Browse files Browse the repository at this point in the history
  • Loading branch information
bors-servo committed Jan 30, 2015
2 parents 7359f99 + 311d936 commit 648b499
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
9 changes: 5 additions & 4 deletions components/script/dom/bindings/callback.rs
Expand Up @@ -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<JSVal, ()> {
pub fn get_callable_property(&self, cx: *mut JSContext, name: &str)
-> Result<JSVal, ()> {
let mut callable = UndefinedValue();
unsafe {
let name = CString::from_slice(name.as_bytes());
Expand All @@ -115,8 +116,8 @@ impl CallbackInterface {
}

/// Wraps the reflector for `p` into the compartment of `cx`.
pub fn WrapCallThisObject<T: Reflectable>(cx: *mut JSContext,
p: JSRef<T>) -> *mut JSObject {
pub fn wrap_call_this_object<T: Reflectable>(cx: *mut JSContext,
p: JSRef<T>) -> *mut JSObject {
let mut obj = p.reflector().get_jsobject();
assert!(!obj.is_null());

Expand Down Expand Up @@ -153,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
}
}
Expand Down
14 changes: 7 additions & 7 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -4566,7 +4566,7 @@ def __init__(self, config, prefix, webIDLFile):
'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',
Expand Down Expand Up @@ -4721,8 +4721,8 @@ def getMethodImpls(self, method):
# 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.
Expand All @@ -4742,13 +4742,13 @@ def getMethodImpls(self, method):
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 = WrapCallThisObject(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"
Expand Down Expand Up @@ -5000,7 +5000,7 @@ def getCallSetup(self):
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")
Expand Down Expand Up @@ -5083,7 +5083,7 @@ def getCallableDecl(self):
"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)
Expand Down
6 changes: 4 additions & 2 deletions components/script/dom/bindings/conversions.rs
Expand Up @@ -286,8 +286,10 @@ pub fn jsid_to_str(cx: *mut JSContext, id: jsid) -> DOMString {
}

impl FromJSValConvertible<StringificationBehavior> for DOMString {
fn from_jsval(cx: *mut JSContext, value: JSVal, nullBehavior: StringificationBehavior) -> Result<DOMString, ()> {
if nullBehavior == StringificationBehavior::Empty && value.is_null() {
fn from_jsval(cx: *mut JSContext, value: JSVal,
null_behavior: StringificationBehavior)
-> Result<DOMString, ()> {
if null_behavior == StringificationBehavior::Empty && value.is_null() {
Ok("".to_owned())
} else {
let jsstr = unsafe { JS_ValueToString(cx, value) };
Expand Down
4 changes: 2 additions & 2 deletions components/script/lib.rs
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 648b499

Please sign in to comment.