mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Remove unwrap_object.
There is no good reason to have both unwrap_object and unwrap_jsmanaged. Removing unwrap_object simplifies the codegen and makes further simplifications easier.
This commit is contained in:
parent
7149a25e91
commit
f77b775e62
2 changed files with 11 additions and 21 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue