diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index b34c6441b70..28e1b439775 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -102,17 +102,13 @@ class CastableObjectUnwrapper(): """ def __init__(self, descriptor, source, codeOnFailure): self.substitution = { - "type": descriptor.nativeType, - "depth": descriptor.interface.inheritanceDepth(), - "prototype": "PrototypeList::ID::" + descriptor.name, - "protoID": "PrototypeList::ID::" + descriptor.name + " as uint", "source": source, "codeOnFailure": CGIndenter(CGGeneric(codeOnFailure), 4).define(), } def __str__(self): return string.Template( -"""match unwrap_jsmanaged(${source}, ${prototype}, ${depth}) { +"""match unwrap_jsmanaged(${source}) { Ok(val) => val, Err(()) => { ${codeOnFailure} diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 52150b26f9c..ceac869a19e 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -350,9 +350,7 @@ impl FromJSValConvertible<()> for JS { if !value.is_object() { return Err(()); } - unwrap_jsmanaged(value.to_object(), - IDLInterface::get_prototype_id(None::), - IDLInterface::get_prototype_depth(None::)) + unwrap_jsmanaged(value.to_object()) } } diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 4f12d1dbc7d..048a54eee4a 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -123,9 +123,9 @@ pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result { /// Returns Err(()) if `obj` is an opaque security wrapper or if the object is /// not a reflector for a DOM object of the given type (as defined by the /// proto_id and proto_depth). -pub fn unwrap_jsmanaged(mut obj: *mut JSObject, - proto_id: PrototypeList::ID, - proto_depth: uint) -> Result, ()> { +pub fn unwrap_jsmanaged(mut obj: *mut JSObject) -> Result, ()> + where T: Reflectable + IDLInterface +{ unsafe { let dom_class = try!(get_dom_class(obj).or_else(|_| { if IsWrapper(obj) == 1 { @@ -145,6 +145,8 @@ pub fn unwrap_jsmanaged(mut obj: *mut JSObject, } })); + let proto_id = IDLInterface::get_prototype_id(None::); + let proto_depth = IDLInterface::get_prototype_depth(None::); if dom_class.interface_chain[proto_depth] == proto_id { debug!("good prototype"); Ok(JS::from_raw(unwrap(obj))) @@ -648,12 +650,7 @@ pub extern fn outerize_global(_cx: *mut JSContext, obj: JSHandleObject) -> *mut unsafe { debug!("outerizing"); let obj = *obj.unnamed_field1; - let win: Root = - unwrap_jsmanaged(obj, - IDLInterface::get_prototype_id(None::), - IDLInterface::get_prototype_depth(None::)) - .unwrap() - .root(); + let win: Root = unwrap_jsmanaged(obj).unwrap().root(); win.browser_context().as_ref().unwrap().window_proxy() } }