Return a Temporary from *Binding::Wrap.

Returning a JS<T> is GC-unsafe.

This commit also includes some cleanup around Node and Document reflection.
This commit is contained in:
Ms2ger 2014-07-10 16:40:41 +02:00
parent 360d5d01d8
commit 439bc78cab
5 changed files with 16 additions and 28 deletions

View file

@ -377,9 +377,9 @@ pub trait Reflectable {
pub fn reflect_dom_object<T: Reflectable>
(obj: Box<T>,
window: &JSRef<window::Window>,
wrap_fn: extern "Rust" fn(*mut JSContext, &JSRef<window::Window>, Box<T>) -> JS<T>)
wrap_fn: extern "Rust" fn(*mut JSContext, &JSRef<window::Window>, Box<T>) -> Temporary<T>)
-> Temporary<T> {
Temporary::new(wrap_fn(window.deref().get_cx(), window, obj))
wrap_fn(window.get_cx(), window, obj)
}
#[allow(raw_pointer_deriving)]