From 24e1a1864b7e6199f02830743d358bf0cc79ab94 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sun, 11 Dec 2016 22:16:56 -0800 Subject: [PATCH] Implement FromJSValConvertible for *mut JSObject --- src/conversions.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/conversions.rs b/src/conversions.rs index a6065b055..2866570e3 100644 --- a/src/conversions.rs +++ b/src/conversions.rs @@ -622,6 +622,18 @@ impl ToJSValConvertible for *mut JSObject { } } +// https://heycam.github.io/webidl/#es-object +impl FromJSValConvertible for *mut JSObject { + type Config = (); + #[inline] + unsafe fn from_jsval(_cx: *mut JSContext, + val: HandleValue, + _option: ()) + -> Result, ()> { + Ok(ConversionResult::Success(val.to_object_or_null())) + } +} + // https://heycam.github.io/webidl/#es-object impl ToJSValConvertible for NonZero<*mut JSObject> { #[inline] @@ -630,3 +642,15 @@ impl ToJSValConvertible for NonZero<*mut JSObject> { maybe_wrap_object_value(cx, rval); } } + +// https://heycam.github.io/webidl/#es-object +impl FromJSValConvertible for NonZero<*mut JSObject> { + type Config = (); + #[inline] + unsafe fn from_jsval(_cx: *mut JSContext, + val: HandleValue, + _option: ()) + -> Result>, ()> { + Ok(ConversionResult::Success(NonZero::new(val.to_object()))) + } +}