diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-10-16 17:07:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-16 17:07:50 -0500 |
commit | e8a6f2862c2a6084e4f4e64ab466c89ae83cff59 (patch) | |
tree | 645db1e37eceef034743c28f9af1544a3fff6d8d /components/script/dom/bindings/conversions.rs | |
parent | 3209d22968046b5c3d29a37b79a655497db2050a (diff) | |
parent | 49e4540ece8641afcb6534a9c3b74e88895f5447 (diff) | |
download | servo-e8a6f2862c2a6084e4f4e64ab466c89ae83cff59.tar.gz servo-e8a6f2862c2a6084e4f4e64ab466c89ae83cff59.zip |
Auto merge of #18875 - servo:stable-js, r=nox,jdm
Remove the need for rust-mozjs to use unstable Rust features
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18875)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/conversions.rs')
-rw-r--r-- | components/script/dom/bindings/conversions.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 075f681308e..e27813d20f9 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -34,6 +34,7 @@ use dom::bindings::error::{Error, Fallible}; use dom::bindings::inheritance::Castable; +use dom::bindings::nonnull::NonNullJSObjectPtr; use dom::bindings::num::Finite; use dom::bindings::reflector::{DomObject, Reflector}; use dom::bindings::root::DomRoot; @@ -53,7 +54,7 @@ use js::jsapi::{JS_GetLatin1StringCharsAndLength, JS_GetProperty, JS_GetReserved use js::jsapi::{JS_GetTwoByteStringCharsAndLength, JS_IsArrayObject, JS_IsExceptionPending}; use js::jsapi::{JS_NewStringCopyN, JS_StringHasLatin1Chars, MutableHandleValue}; use js::jsval::{ObjectValue, StringValue, UndefinedValue}; -use js::rust::{ToString, get_object_class, is_dom_class, is_dom_object, maybe_wrap_value}; +use js::rust::{ToString, get_object_class, is_dom_class, is_dom_object, maybe_wrap_value, maybe_wrap_object_value}; use libc; use num_traits::Float; use servo_config::opts; @@ -66,9 +67,19 @@ pub trait IDLInterface { } /// A trait to mark an IDL interface as deriving from another one. -#[rustc_on_unimplemented = "The IDL interface `{Self}` is not derived from `{T}`."] +#[cfg_attr(feature = "unstable", + rustc_on_unimplemented = "The IDL interface `{Self}` is not derived from `{T}`.")] pub trait DerivedFrom<T: Castable>: Castable {} +// https://heycam.github.io/webidl/#es-object +impl ToJSValConvertible for NonNullJSObjectPtr { + #[inline] + unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + rval.set(ObjectValue(self.get())); + maybe_wrap_object_value(cx, rval); + } +} + impl<T: Float + ToJSValConvertible> ToJSValConvertible for Finite<T> { #[inline] unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { |