Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
Implement FromJSValConvertible for HandleValue
Browse files Browse the repository at this point in the history
  • Loading branch information
KiChjang committed Apr 25, 2017
1 parent 7f380ab commit 04e9e3a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/conversions.rs
Expand Up @@ -30,6 +30,7 @@
use core::nonzero::NonZero;
use error::throw_type_error;
use glue::RUST_JS_NumberValue;
use jsapi::AssertSameCompartment;
use jsapi::{ForOfIterator, ForOfIterator_NonIterableBehavior, HandleValue};
use jsapi::{Heap, JS_DefineElement, JS_GetLatin1StringCharsAndLength};
use jsapi::{JS_GetTwoByteStringCharsAndLength, JS_NewArrayObject1};
Expand Down Expand Up @@ -184,6 +185,20 @@ impl ToJSValConvertible for () {
}
}

impl FromJSValConvertible for HandleValue {
type Config = ();
#[inline]
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<HandleValue>, ()> {
if value.is_object() {
AssertSameCompartment(cx, value.to_object());
}
Ok(ConversionResult::Success(value))
}
}

impl FromJSValConvertible for JSVal {
type Config = ();
unsafe fn from_jsval(_cx: *mut JSContext,
Expand Down

0 comments on commit 04e9e3a

Please sign in to comment.