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

Remove FromJSValConvertible implementation for HandleValue #388

Merged
merged 3 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "mozjs"
description = "Rust bindings to the Mozilla SpiderMonkey JavaScript engine."
repository = "https://github.com/servo/rust-mozjs"
version = "0.1.9"
version = "0.1.10"
authors = ["The Servo Project Developers"]
build = "build.rs"
license = "MPL-2.0"
Expand Down
33 changes: 19 additions & 14 deletions src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,6 @@ 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 Expand Up @@ -668,3 +654,22 @@ impl ToJSValConvertible for Heap<*mut JSObject> {
maybe_wrap_object_or_null_value(cx, rval);
}
}

// https://heycam.github.io/webidl/#es-object
impl FromJSValConvertible for *mut JSObject {
type Config = ();
#[inline]
unsafe fn from_jsval(cx: *mut JSContext,
value: HandleValue,
_option: ())
-> Result<ConversionResult<*mut JSObject>, ()> {
if !value.is_object() {
throw_type_error(cx, "value is not an object");
return Err(());
}

AssertSameCompartment(cx, value.to_object());

Ok(ConversionResult::Success(value.to_object()))
}
}
2 changes: 1 addition & 1 deletion src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ impl<T: CustomTrace> CustomAutoRooter<T> {
/// The underlying data can be accessed through this guard via its Deref and
/// DerefMut implementations.
/// This structure is created by `root` method on `CustomAutoRooter` or
/// by an appropriate macro (e.g. `rooted_vec!` for `SequenceRooter` alias).
/// by the `auto_root!` macro.
pub struct CustomAutoRooterGuard<'a, T: 'a + CustomTrace> {
rooter: &'a mut CustomAutoRooter<T>
}
Expand Down