mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Make unwrap and unwrap_object less generic.
This commit is contained in:
parent
a4fc6961a8
commit
6ee2e29e62
2 changed files with 6 additions and 6 deletions
|
@ -81,10 +81,10 @@ pub unsafe fn dom_object_slot(obj: *JSObject) -> u32 {
|
|||
}
|
||||
}
|
||||
|
||||
pub unsafe fn unwrap<T>(obj: *JSObject) -> T {
|
||||
pub unsafe fn unwrap<T>(obj: *JSObject) -> *mut T {
|
||||
let slot = dom_object_slot(obj);
|
||||
let val = JS_GetReservedSlot(obj, slot);
|
||||
cast::transmute(val.to_private())
|
||||
val.to_private() as *mut T
|
||||
}
|
||||
|
||||
pub unsafe fn get_dom_class(obj: *JSObject) -> Result<DOMClass, ()> {
|
||||
|
@ -103,7 +103,7 @@ 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<T, ()> {
|
||||
pub fn unwrap_object<T>(obj: *JSObject, proto_id: PrototypeList::id::ID, proto_depth: uint) -> Result<*mut T, ()> {
|
||||
unsafe {
|
||||
get_dom_class(obj).and_then(|dom_class| {
|
||||
if dom_class.interface_chain[proto_depth] == proto_id {
|
||||
|
@ -637,7 +637,7 @@ pub fn global_object_for_js_object(obj: *JSObject) -> JS<window::Window> {
|
|||
let clasp = JS_GetClass(global);
|
||||
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
|
||||
// FIXME(jdm): Either don't hardcode or sanity assert prototype stuff.
|
||||
match unwrap_object::<*mut window::Window>(global, PrototypeList::id::Window, 1) {
|
||||
match unwrap_object(global, PrototypeList::id::Window, 1) {
|
||||
Ok(win) => JS::from_raw(win),
|
||||
Err(_) => fail!("found DOM global that doesn't unwrap to Window"),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue