Port modern callback handling code from Gecko, and copy related WebIDL parser bits too.

This commit is contained in:
Josh Matthews 2014-04-22 17:14:48 -04:00 committed by Ms2ger
parent 04931adf70
commit 003e5bcd46
18 changed files with 442 additions and 223 deletions

View file

@ -328,6 +328,12 @@ impl<'a, T: Reflectable> ToJSValConvertible for JSRef<'a, T> {
}
}
impl<'a, T: Reflectable> ToJSValConvertible for JS<T> {
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
self.reflector().to_jsval(cx)
}
}
impl<T: ToJSValConvertible> ToJSValConvertible for Option<T> {
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
match self {
@ -350,7 +356,11 @@ impl<X: Default, T: FromJSValConvertible<X>> FromJSValConvertible<()> for Option
}
impl ToJSValConvertible for *mut JSObject {
fn to_jsval(&self, _cx: *mut JSContext) -> JSVal {
ObjectOrNullValue(*self)
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
let mut wrapped = ObjectOrNullValue(*self);
unsafe {
assert!(JS_WrapValue(cx, &mut wrapped) != 0);
}
wrapped
}
}