mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Use the conversion traits from js.
This commit is contained in:
parent
acb24e80b8
commit
6d2ae85c1f
15 changed files with 285 additions and 647 deletions
|
@ -48,6 +48,19 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, annotatable:
|
|||
impl_item.map(|it| push(Annotatable::Item(it)))
|
||||
}
|
||||
};
|
||||
|
||||
let impl_item = quote_item!(cx,
|
||||
impl ::js::conversions::ToJSValConvertible for $struct_name {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn to_jsval(&self,
|
||||
cx: *mut ::js::jsapi::JSContext,
|
||||
rval: ::js::jsapi::MutableHandleValue) {
|
||||
let object = ::dom::bindings::reflector::Reflectable::reflector(self).get_jsobject();
|
||||
object.to_jsval(cx, rval)
|
||||
}
|
||||
}
|
||||
);
|
||||
impl_item.map(|it| push(Annotatable::Item(it)));
|
||||
} else {
|
||||
cx.span_err(span, "#[dom_struct] seems to have been applied to a non-struct");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue