Return a JS<T> from *Binding::Wrap rather than a JSObject.

This lets us avoid the sketchy tricks in JS::new and Window::new, where we
kept an unsafe pointer to the native object across the Wrap call that
consumed the owned pointer.
This commit is contained in:
Ms2ger 2014-03-14 13:06:48 +01:00
parent 71f4fd0478
commit 4ad3b6ccd1
6 changed files with 30 additions and 43 deletions

View file

@ -39,7 +39,7 @@ use servo_util::namespace::{Namespace, Null};
use servo_util::str::DOMString;
use extra::url::{Url, from_str};
use js::jsapi::{JSObject, JSContext};
use js::jsapi::JSContext;
use std::ascii::StrAsciiExt;
use std::hashmap::HashMap;
@ -87,7 +87,7 @@ impl Document {
pub fn reflect_document<D: Reflectable+DocumentBase>
(document: ~D,
window: &JS<Window>,
wrap_fn: extern "Rust" fn(*JSContext, &JS<Window>, ~D) -> *JSObject)
wrap_fn: extern "Rust" fn(*JSContext, &JS<Window>, ~D) -> JS<D>)
-> JS<D> {
assert!(document.reflector().get_jsobject().is_null());
let raw_doc = reflect_dom_object(document, window, wrap_fn);