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

Commit 2f473fa

Browse files
committed
Implement FromJSValConvertible for *mut JSObject
1 parent 7a85bcd commit 2f473fa

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/conversions.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,3 +654,22 @@ impl ToJSValConvertible for Heap<*mut JSObject> {
654654
maybe_wrap_object_or_null_value(cx, rval);
655655
}
656656
}
657+
658+
// https://heycam.github.io/webidl/#es-object
659+
impl FromJSValConvertible for *mut JSObject {
660+
type Config = ();
661+
#[inline]
662+
unsafe fn from_jsval(cx: *mut JSContext,
663+
value: HandleValue,
664+
_option: ())
665+
-> Result<ConversionResult<*mut JSObject>, ()> {
666+
if !value.is_object() {
667+
throw_type_error(cx, "value is not an object");
668+
return Err(());
669+
}
670+
671+
AssertSameCompartment(cx, value.to_object());
672+
673+
Ok(ConversionResult::Success(value.to_object()))
674+
}
675+
}

src/rust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ impl<T: CustomTrace> CustomAutoRooter<T> {
593593
/// The underlying data can be accessed through this guard via its Deref and
594594
/// DerefMut implementations.
595595
/// This structure is created by `root` method on `CustomAutoRooter` or
596-
/// by an appropriate macro (e.g. `rooted_vec!` for `SequenceRooter` alias).
596+
/// by the `auto_root!` macro.
597597
pub struct CustomAutoRooterGuard<'a, T: 'a + CustomTrace> {
598598
rooter: &'a mut CustomAutoRooter<T>
599599
}

0 commit comments

Comments
 (0)