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

Implement FromJSValConvertible for HandleValue #352

Merged
merged 1 commit into from
Apr 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/conversions.rs
Original file line number Diff line number Diff line change
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