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

Commit d829b21

Browse files
author
bors-servo
authored
Auto merge of #388 - Xanewok:remove-handle-conv, r=jdm
Remove FromJSValConvertible implementation for HandleValue Needed for servo/servo#19644. Removes FromJSValConvertible implementations for `HandleValue`, so `Vec<HandleValue>` conversion is impossible. Also adds the implementation for `*mut JSObject` so the `sequence<object>` -> `CustomAutoRooterGuard<Vec<*mut JSObject>>` conversion works. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-mozjs/388) <!-- Reviewable:end -->
2 parents 31c80d1 + 81e042f commit d829b21

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs"
33
description = "Rust bindings to the Mozilla SpiderMonkey JavaScript engine."
44
repository = "https://github.com/servo/rust-mozjs"
5-
version = "0.1.9"
5+
version = "0.1.10"
66
authors = ["The Servo Project Developers"]
77
build = "build.rs"
88
license = "MPL-2.0"

src/conversions.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,6 @@ impl ToJSValConvertible for () {
185185
}
186186
}
187187

188-
impl FromJSValConvertible for HandleValue {
189-
type Config = ();
190-
#[inline]
191-
unsafe fn from_jsval(cx: *mut JSContext,
192-
value: HandleValue,
193-
_option: ())
194-
-> Result<ConversionResult<HandleValue>, ()> {
195-
if value.is_object() {
196-
AssertSameCompartment(cx, value.to_object());
197-
}
198-
Ok(ConversionResult::Success(value))
199-
}
200-
}
201-
202188
impl FromJSValConvertible for JSVal {
203189
type Config = ();
204190
unsafe fn from_jsval(_cx: *mut JSContext,
@@ -668,3 +654,22 @@ impl ToJSValConvertible for Heap<*mut JSObject> {
668654
maybe_wrap_object_or_null_value(cx, rval);
669655
}
670656
}
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)