Store rootable dictionary members of dictionaries in RootedTraceableBox.

This commit is contained in:
Josh Matthews 2017-05-26 13:25:05 -04:00
parent da65698c5c
commit b169689f32
4 changed files with 29 additions and 26 deletions

View file

@ -116,19 +116,11 @@ impl <T: DomObject + IDLInterface> FromJSValConvertible for Root<T> {
}
}
impl <T: FromJSValConvertible + JSTraceable> FromJSValConvertible for RootedTraceableBox<T> {
type Config = T::Config;
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
config: Self::Config)
-> Result<ConversionResult<Self>, ()> {
T::from_jsval(cx, value, config).map(|result| {
match result {
ConversionResult::Success(v) => ConversionResult::Success(RootedTraceableBox::new(v)),
ConversionResult::Failure(e) => ConversionResult::Failure(e),
}
})
impl<T: ToJSValConvertible + JSTraceable> ToJSValConvertible for RootedTraceableBox<T> {
#[inline]
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
let value = &**self;
value.to_jsval(cx, rval);
}
}