aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script/dom/bindings/utils.rs')
-rw-r--r--src/components/script/dom/bindings/utils.rs17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs
index 46b6175fbfe..ec1472bac28 100644
--- a/src/components/script/dom/bindings/utils.rs
+++ b/src/components/script/dom/bindings/utils.rs
@@ -97,12 +97,14 @@ pub unsafe fn get_dom_class(obj: *JSObject) -> Result<DOMClass, ()> {
return Err(());
}
-pub fn unwrap_object<T>(obj: *JSObject, proto_id: PrototypeList::id::ID, proto_depth: uint) -> Result<*mut T, ()> {
+pub fn unwrap_jsmanaged<T: Reflectable>(obj: *JSObject,
+ proto_id: PrototypeList::id::ID,
+ proto_depth: uint) -> Result<JS<T>, ()> {
unsafe {
get_dom_class(obj).and_then(|dom_class| {
if dom_class.interface_chain[proto_depth] == proto_id {
debug!("good prototype");
- Ok(unwrap(obj))
+ Ok(JS::from_raw(unwrap(obj)))
} else {
debug!("bad prototype");
Err(())
@@ -111,17 +113,6 @@ pub fn unwrap_object<T>(obj: *JSObject, proto_id: PrototypeList::id::ID, proto_d
}
}
-pub fn unwrap_jsmanaged<T: Reflectable>(obj: *JSObject,
- proto_id: PrototypeList::id::ID,
- proto_depth: uint) -> Result<JS<T>, ()> {
- let result: Result<*mut T, ()> = unwrap_object(obj, proto_id, proto_depth);
- result.map(|unwrapped| {
- unsafe {
- JS::from_raw(unwrapped)
- }
- })
-}
-
pub unsafe fn squirrel_away_unique<T>(x: ~T) -> *T {
cast::transmute(x)
}