mirror of
https://github.com/servo/servo.git
synced 2025-09-23 05:10:09 +01:00
Replace NonZero<*mut JSObject> with a wrapper to enable local trait impls.
This commit is contained in:
parent
115d859551
commit
e2fafd2dfc
22 changed files with 108 additions and 69 deletions
|
@ -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;
|
||||
|
@ -69,6 +70,15 @@ pub trait IDLInterface {
|
|||
#[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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue