diff --git a/Cargo.toml b/Cargo.toml index c2c3539d9..7444450eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mozjs" description = "Rust bindings to the Mozilla SpiderMonkey JavaScript engine." repository = "https://github.com/servo/rust-mozjs" -version = "0.5.0" +version = "0.6.0" authors = ["The Servo Project Developers"] build = "build.rs" license = "MPL-2.0" diff --git a/src/conversions.rs b/src/conversions.rs index ec0b01c6a..44e300bb9 100644 --- a/src/conversions.rs +++ b/src/conversions.rs @@ -30,15 +30,16 @@ use error::throw_type_error; use glue::RUST_JS_NumberValue; use jsapi::AssertSameCompartment; -use jsapi::{ForOfIterator, ForOfIterator_NonIterableBehavior, HandleValue}; +use jsapi::{ForOfIterator, ForOfIterator_NonIterableBehavior}; use jsapi::{Heap, JS_DefineElement, JS_GetLatin1StringCharsAndLength}; use jsapi::{JS_GetTwoByteStringCharsAndLength, JS_NewArrayObject1}; use jsapi::{JS_NewUCStringCopyN, JSPROP_ENUMERATE, JS_StringHasLatin1Chars}; -use jsapi::{JSContext, JSObject, JSString, MutableHandleValue, RootedObject}; +use jsapi::{JSContext, JSObject, JSString, RootedObject}; use jsval::{BooleanValue, Int32Value, NullValue, UInt32Value, UndefinedValue}; use jsval::{JSVal, ObjectValue, ObjectOrNullValue, StringValue}; use rust::{ToBoolean, ToInt32, ToInt64, ToNumber, ToUint16, ToUint32, ToUint64}; use rust::{ToString, maybe_wrap_object_or_null_value, maybe_wrap_object_value}; +use rust::{HandleValue, MutableHandleValue}; use rust::maybe_wrap_value; use libc; use num_traits::{Bounded, Zero}; @@ -180,7 +181,7 @@ fn clamp_to(d: f64) -> D // https://heycam.github.io/webidl/#es-void impl ToJSValConvertible for () { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(UndefinedValue()); } } @@ -197,15 +198,15 @@ impl FromJSValConvertible for JSVal { impl ToJSValConvertible for JSVal { #[inline] - unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(*self); maybe_wrap_value(cx, rval); } } -impl ToJSValConvertible for HandleValue { +impl<'a> ToJSValConvertible for HandleValue<'a> { #[inline] - unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(self.get()); maybe_wrap_value(cx, rval); } @@ -213,7 +214,7 @@ impl ToJSValConvertible for HandleValue { impl ToJSValConvertible for Heap { #[inline] - unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(self.get()); maybe_wrap_value(cx, rval); } @@ -238,7 +239,7 @@ unsafe fn convert_int_from_jsval(cx: *mut JSContext, value: HandleValue, // https://heycam.github.io/webidl/#es-boolean impl ToJSValConvertible for bool { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(BooleanValue(*self)); } } @@ -254,7 +255,7 @@ impl FromJSValConvertible for bool { // https://heycam.github.io/webidl/#es-byte impl ToJSValConvertible for i8 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(Int32Value(*self as i32)); } } @@ -273,7 +274,7 @@ impl FromJSValConvertible for i8 { // https://heycam.github.io/webidl/#es-octet impl ToJSValConvertible for u8 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(Int32Value(*self as i32)); } } @@ -292,7 +293,7 @@ impl FromJSValConvertible for u8 { // https://heycam.github.io/webidl/#es-short impl ToJSValConvertible for i16 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(Int32Value(*self as i32)); } } @@ -311,7 +312,7 @@ impl FromJSValConvertible for i16 { // https://heycam.github.io/webidl/#es-unsigned-short impl ToJSValConvertible for u16 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(Int32Value(*self as i32)); } } @@ -330,7 +331,7 @@ impl FromJSValConvertible for u16 { // https://heycam.github.io/webidl/#es-long impl ToJSValConvertible for i32 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(Int32Value(*self)); } } @@ -349,7 +350,7 @@ impl FromJSValConvertible for i32 { // https://heycam.github.io/webidl/#es-unsigned-long impl ToJSValConvertible for u32 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(UInt32Value(*self)); } } @@ -368,7 +369,7 @@ impl FromJSValConvertible for u32 { // https://heycam.github.io/webidl/#es-long-long impl ToJSValConvertible for i64 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(RUST_JS_NumberValue(*self as f64)); } } @@ -387,7 +388,7 @@ impl FromJSValConvertible for i64 { // https://heycam.github.io/webidl/#es-unsigned-long-long impl ToJSValConvertible for u64 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(RUST_JS_NumberValue(*self as f64)); } } @@ -406,7 +407,7 @@ impl FromJSValConvertible for u64 { // https://heycam.github.io/webidl/#es-float impl ToJSValConvertible for f32 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(RUST_JS_NumberValue(*self as f64)); } } @@ -423,7 +424,7 @@ impl FromJSValConvertible for f32 { // https://heycam.github.io/webidl/#es-double impl ToJSValConvertible for f64 { #[inline] - unsafe fn to_jsval(&self, _cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(RUST_JS_NumberValue(*self)); } } @@ -467,7 +468,7 @@ pub unsafe fn jsstr_to_string(cx: *mut JSContext, jsstr: *mut JSString) -> Strin // https://heycam.github.io/webidl/#es-USVString impl ToJSValConvertible for str { #[inline] - unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) { let mut string_utf16: Vec = Vec::with_capacity(self.len()); string_utf16.extend(self.encode_utf16()); let jsstr = JS_NewUCStringCopyN(cx, @@ -503,7 +504,7 @@ impl FromJSValConvertible for String { impl ToJSValConvertible for Option { #[inline] - unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) { match self { &Some(ref value) => value.to_jsval(cx, rval), &None => rval.set(NullValue()), @@ -538,7 +539,7 @@ impl FromJSValConvertible for Option { // https://heycam.github.io/webidl/#es-sequence impl ToJSValConvertible for [T] { #[inline] - unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) { rooted!(in(cx) let js_array = JS_NewArrayObject1(cx, self.len() as libc::size_t)); assert!(!js_array.handle().is_null()); @@ -546,8 +547,8 @@ impl ToJSValConvertible for [T] { for (index, obj) in self.iter().enumerate() { obj.to_jsval(cx, val.handle_mut()); - assert!(JS_DefineElement(cx, js_array.handle(), - index as u32, val.handle(), JSPROP_ENUMERATE, None, None)); + assert!(JS_DefineElement(cx, js_array.handle().into(), + index as u32, val.handle().into(), JSPROP_ENUMERATE, None, None)); } rval.set(ObjectValue(js_array.handle().get())); @@ -604,7 +605,7 @@ impl> FromJSValConvertible for Vec> FromJSValConvertible for Vec> FromJSValConvertible for Vec { #[inline] - unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(ObjectValue(self.as_ptr())); maybe_wrap_object_value(cx, rval); } @@ -656,7 +657,7 @@ impl ToJSValConvertible for ptr::NonNull { // https://heycam.github.io/webidl/#es-object impl ToJSValConvertible for Heap<*mut JSObject> { #[inline] - unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + unsafe fn to_jsval(&self, cx: *mut JSContext, mut rval: MutableHandleValue) { rval.set(ObjectOrNullValue(self.get())); maybe_wrap_object_or_null_value(cx, rval); } diff --git a/src/generate_wrappers.sh b/src/generate_wrappers.sh new file mode 100755 index 000000000..d8a2481ba --- /dev/null +++ b/src/generate_wrappers.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# This is one big heuristic but seems to work well enough +grep_heur() { + grep -v "link_name" "$1" | \ + grep -v '"\]' | \ + grep -F -v '/\*\*' | \ + sed -z 's/,\n */, /g' | \ + sed -z 's/:\n */: /g' | \ + sed -z 's/\n *->/ ->/g' | \ + grep -v '^\}$' | \ + sed 's/^ *pub/pub/' | \ + sed -z 's/\;\n/\n/g' | \ + grep 'pub fn' | \ + grep Handle | \ + grep -v roxyHandler | \ + grep -v 'pub fn Unbox' | # this function seems to be platform specific \ + sed 's/Handle<\*mut JSObject>/HandleObject/g' +} + +grep_heur jsapi_linux_64.rs | sed 's/\(.*\)/wrap!(jsapi: \1);/g' > jsapi_wrappers.in +grep_heur glue.rs | sed 's/\(.*\)/wrap!(glue: \1);/g' > glue_wrappers.in diff --git a/src/glue_wrappers.in b/src/glue_wrappers.in new file mode 100644 index 000000000..9959600f0 --- /dev/null +++ b/src/glue_wrappers.in @@ -0,0 +1,12 @@ +wrap!(glue: pub fn InvokeGetOwnPropertyDescriptor(handler: *const ::libc::c_void, cx: *mut JSContext, proxy: HandleObject, id: HandleId, desc: MutableHandle) -> bool); +wrap!(glue: pub fn InvokeHasOwn(handler: *const ::libc::c_void, cx: *mut JSContext, proxy: HandleObject, id: HandleId, bp: *mut bool) -> bool); +wrap!(glue: pub fn CallJitGetterOp(info: *const JSJitInfo, cx: *mut JSContext, thisObj: HandleObject, specializedThis: *mut ::libc::c_void, argc: u32, vp: *mut Value) -> bool); +wrap!(glue: pub fn CallJitSetterOp(info: *const JSJitInfo, cx: *mut JSContext, thisObj: HandleObject, specializedThis: *mut ::libc::c_void, argc: u32, vp: *mut Value) -> bool); +wrap!(glue: pub fn CallJitMethodOp(info: *const JSJitInfo, cx: *mut JSContext, thisObj: HandleObject, specializedThis: *mut ::libc::c_void, argc: u32, vp: *mut Value) -> bool); +wrap!(glue: pub fn NewProxyObject(aCx: *mut JSContext, aHandler: *const ::libc::c_void, aPriv: HandleValue, proto: *mut JSObject, parent: *mut JSObject, call: *mut JSObject, construct: *mut JSObject) -> *mut JSObject); +wrap!(glue: pub fn WrapperNew(aCx: *mut JSContext, aObj: HandleObject, aHandler: *const ::libc::c_void, aClass: *const JSClass, aSingleton: bool) -> *mut JSObject); +wrap!(glue: pub fn NewWindowProxy(aCx: *mut JSContext, aObj: HandleObject, aHandler: *const ::libc::c_void) -> *mut JSObject); +wrap!(glue: pub fn RUST_JSID_IS_INT(id: HandleId) -> bool); +wrap!(glue: pub fn RUST_JSID_TO_INT(id: HandleId) -> i32); +wrap!(glue: pub fn RUST_JSID_IS_STRING(id: HandleId) -> bool); +wrap!(glue: pub fn RUST_JSID_TO_STRING(id: HandleId) -> *mut JSString); diff --git a/src/jsapi_wrappers.in b/src/jsapi_wrappers.in new file mode 100644 index 000000000..e616817a7 --- /dev/null +++ b/src/jsapi_wrappers.in @@ -0,0 +1,343 @@ +wrap!(jsapi: pub fn IsArray(cx: *mut JSContext, obj: HandleObject, isArray: *mut bool) -> bool); +wrap!(jsapi: pub fn IsArray1(cx: *mut JSContext, obj: HandleObject, answer: *mut IsArrayAnswer) -> bool); +wrap!(jsapi: pub fn JS_ReadStructuredClone(cx: *mut JSContext, data: *mut u64, nbytes: usize, version: u32, vp: MutableHandleValue, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void) -> bool); +wrap!(jsapi: pub fn JS_WriteStructuredClone(cx: *mut JSContext, v: HandleValue, datap: *mut *mut u64, nbytesp: *mut usize, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void, transferable: HandleValue) -> bool); +wrap!(jsapi: pub fn JS_StructuredClone(cx: *mut JSContext, v: HandleValue, vp: MutableHandleValue, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void) -> bool); +wrap!(jsapi: pub fn JS_ReadTypedArray(r: *mut JSStructuredCloneReader, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_WriteString(w: *mut JSStructuredCloneWriter, str: HandleString) -> bool); +wrap!(jsapi: pub fn JS_WriteTypedArray(w: *mut JSStructuredCloneWriter, v: HandleValue) -> bool); +wrap!(jsapi: pub fn JS_ObjectNotWritten(w: *mut JSStructuredCloneWriter, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_ValueToObject(cx: *mut JSContext, v: HandleValue, objp: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_ValueToFunction(cx: *mut JSContext, v: HandleValue) -> *mut JSFunction); +wrap!(jsapi: pub fn JS_ValueToConstructor(cx: *mut JSContext, v: HandleValue) -> *mut JSFunction); +wrap!(jsapi: pub fn JS_ValueToSource(cx: *mut JSContext, v: Handle) -> *mut JSString); +wrap!(jsapi: pub fn JS_TypeOfValue(cx: *mut JSContext, v: Handle) -> JSType); +wrap!(jsapi: pub fn JS_StrictlyEqual(cx: *mut JSContext, v1: Handle, v2: Handle, equal: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_LooselyEqual(cx: *mut JSContext, v1: Handle, v2: Handle, equal: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_SameValue(cx: *mut JSContext, v1: Handle, v2: Handle, same: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_WrapObject(cx: *mut JSContext, objp: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_WrapValue(cx: *mut JSContext, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_TransplantObject(cx: *mut JSContext, origobj: HandleObject, target: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_RefreshCrossCompartmentWrappers(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_InitStandardClasses(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_ResolveStandardClass(cx: *mut JSContext, obj: HandleObject, id: HandleId, resolved: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_EnumerateStandardClasses(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_GetClassObject(cx: *mut JSContext, key: JSProtoKey, objp: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_GetClassPrototype(cx: *mut JSContext, key: JSProtoKey, objp: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn ProtoKeyToId(cx: *mut JSContext, key: JSProtoKey, idp: MutableHandleId)); +wrap!(jsapi: pub fn JS_IdToProtoKey(cx: *mut JSContext, id: HandleId) -> JSProtoKey); +wrap!(jsapi: pub fn JS_GetFunctionPrototype(cx: *mut JSContext, forObj: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_GetObjectPrototype(cx: *mut JSContext, forObj: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_GetArrayPrototype(cx: *mut JSContext, forObj: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_InitReflectParse(cx: *mut JSContext, global: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_DefineProfilingFunctions(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_DefineDebuggerObject(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_ValueToId(cx: *mut JSContext, v: HandleValue, idp: MutableHandleId) -> bool); +wrap!(jsapi: pub fn JS_StringToId(cx: *mut JSContext, s: HandleString, idp: MutableHandleId) -> bool); +wrap!(jsapi: pub fn JS_IdToValue(cx: *mut JSContext, id: jsid, vp: MutableHandle) -> bool); +wrap!(jsapi: pub fn ToPrimitive(cx: *mut JSContext, obj: HandleObject, hint: JSType, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_PropertyStub(cx: *mut JSContext, obj: HandleObject, id: HandleId, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_StrictPropertyStub(cx: *mut JSContext, obj: HandleObject, id: HandleId, vp: MutableHandleValue, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_InitClass(cx: *mut JSContext, obj: HandleObject, parent_proto: HandleObject, clasp: *const JSClass, constructor: JSNative, nargs: ::std::os::raw::c_uint, ps: *const JSPropertySpec, fs: *const JSFunctionSpec, static_ps: *const JSPropertySpec, static_fs: *const JSFunctionSpec) -> *mut JSObject); +wrap!(jsapi: pub fn JS_LinkConstructorAndPrototype(cx: *mut JSContext, ctor: HandleObject, proto: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_InstanceOf(cx: *mut JSContext, obj: HandleObject, clasp: *const JSClass, args: *mut CallArgs) -> bool); +wrap!(jsapi: pub fn JS_HasInstance(cx: *mut JSContext, obj: HandleObject, v: Handle, bp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_GetInstancePrivate(cx: *mut JSContext, obj: HandleObject, clasp: *const JSClass, args: *mut CallArgs) -> *mut ::std::os::raw::c_void); +wrap!(jsapi: pub fn JS_GetConstructor(cx: *mut JSContext, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_FireOnNewGlobalObject(cx: *mut JSContext, global: HandleObject)); +wrap!(jsapi: pub fn JS_NewObjectWithGivenProto(cx: *mut JSContext, clasp: *const JSClass, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_DeepFreezeObject(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_FreezeObject(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn ObjectToCompletePropertyDescriptor(cx: *mut JSContext, obj: HandleObject, descriptor: HandleValue, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn FromPropertyDescriptor(cx: *mut JSContext, desc: Handle, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_GetPrototype(cx: *mut JSContext, obj: HandleObject, result: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_GetPrototypeIfOrdinary(cx: *mut JSContext, obj: HandleObject, isOrdinary: *mut bool, result: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_SetPrototype(cx: *mut JSContext, obj: HandleObject, proto: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_IsExtensible(cx: *mut JSContext, obj: HandleObject, extensible: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_PreventExtensions(cx: *mut JSContext, obj: HandleObject, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_SetImmutablePrototype(cx: *mut JSContext, obj: HandleObject, succeeded: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_GetOwnPropertyDescriptorById(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn JS_GetOwnPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn JS_GetOwnUCPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn JS_GetPropertyDescriptorById(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn JS_GetPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: Handle, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById1(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: Handle) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById2(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleValue, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById3(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleObject, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById4(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleString, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById5(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: i32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById6(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: u32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById7(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: f64, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleValue, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty1(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleObject, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty2(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleString, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty3(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: i32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty4(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: u32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty5(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: f64, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, desc: Handle, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty1(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, desc: Handle) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty2(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: HandleValue, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty3(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: HandleObject, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty4(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: HandleString, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty5(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: i32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty6(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: u32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty7(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: f64, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineElement(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleValue, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineElement1(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleObject, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineElement2(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleString, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineElement3(cx: *mut JSContext, obj: HandleObject, index: u32, value: i32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineElement4(cx: *mut JSContext, obj: HandleObject, index: u32, value: u32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefineElement5(cx: *mut JSContext, obj: HandleObject, index: u32, value: f64, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_HasPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_HasProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_HasUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, vp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_HasElement(cx: *mut JSContext, obj: HandleObject, index: u32, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_HasOwnPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_HasOwnProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_ForwardGetPropertyTo(cx: *mut JSContext, obj: HandleObject, id: HandleId, receiver: HandleValue, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ForwardGetElementTo(cx: *mut JSContext, obj: HandleObject, index: u32, receiver: HandleObject, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_GetPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_GetProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_GetUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_GetElement(cx: *mut JSContext, obj: HandleObject, index: u32, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ForwardSetPropertyTo(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_SetPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue) -> bool); +wrap!(jsapi: pub fn JS_SetProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, v: HandleValue) -> bool); +wrap!(jsapi: pub fn JS_SetUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, v: HandleValue) -> bool); +wrap!(jsapi: pub fn JS_SetElement(cx: *mut JSContext, obj: HandleObject, index: u32, v: HandleValue) -> bool); +wrap!(jsapi: pub fn JS_SetElement1(cx: *mut JSContext, obj: HandleObject, index: u32, v: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_SetElement2(cx: *mut JSContext, obj: HandleObject, index: u32, v: HandleString) -> bool); +wrap!(jsapi: pub fn JS_SetElement3(cx: *mut JSContext, obj: HandleObject, index: u32, v: i32) -> bool); +wrap!(jsapi: pub fn JS_SetElement4(cx: *mut JSContext, obj: HandleObject, index: u32, v: u32) -> bool); +wrap!(jsapi: pub fn JS_SetElement5(cx: *mut JSContext, obj: HandleObject, index: u32, v: f64) -> bool); +wrap!(jsapi: pub fn JS_DeletePropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_DeleteProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_DeleteUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_DeleteElement(cx: *mut JSContext, obj: HandleObject, index: u32, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_DeletePropertyById1(cx: *mut JSContext, obj: HandleObject, id: jsid) -> bool); +wrap!(jsapi: pub fn JS_DeleteProperty1(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char) -> bool); +wrap!(jsapi: pub fn JS_DeleteElement1(cx: *mut JSContext, obj: HandleObject, index: u32) -> bool); +wrap!(jsapi: pub fn JS_CallFunctionValue(cx: *mut JSContext, obj: HandleObject, fval: HandleValue, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_CallFunction(cx: *mut JSContext, obj: HandleObject, fun: HandleFunction, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_CallFunctionName(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Call(cx: *mut JSContext, thisv: HandleValue, fun: HandleValue, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Construct(cx: *mut JSContext, fun: HandleValue, newTarget: HandleObject, args: *const HandleValueArray, objp: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn Construct1(cx: *mut JSContext, fun: HandleValue, args: *const HandleValueArray, objp: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_New(cx: *mut JSContext, ctor: HandleObject, args: *const HandleValueArray) -> *mut JSObject); +wrap!(jsapi: pub fn JS_DefineObject(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, clasp: *const JSClass, attrs: ::std::os::raw::c_uint) -> *mut JSObject); +wrap!(jsapi: pub fn JS_DefineConstDoubles(cx: *mut JSContext, obj: HandleObject, cds: *const JSConstDoubleSpec) -> bool); +wrap!(jsapi: pub fn JS_DefineConstIntegers(cx: *mut JSContext, obj: HandleObject, cis: *const JSConstIntegerSpec) -> bool); +wrap!(jsapi: pub fn JS_DefineProperties(cx: *mut JSContext, obj: HandleObject, ps: *const JSPropertySpec) -> bool); +wrap!(jsapi: pub fn JS_AlreadyHasOwnPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_AlreadyHasOwnProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_AlreadyHasOwnUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_AlreadyHasOwnElement(cx: *mut JSContext, obj: HandleObject, index: u32, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_NewArrayObject(cx: *mut JSContext, contents: *const HandleValueArray) -> *mut JSObject); +wrap!(jsapi: pub fn JS_IsArrayObject(cx: *mut JSContext, value: HandleValue, isArray: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_IsArrayObject1(cx: *mut JSContext, obj: HandleObject, isArray: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_GetArrayLength(cx: *mut JSContext, obj: HandleObject, lengthp: *mut u32) -> bool); +wrap!(jsapi: pub fn JS_SetArrayLength(cx: *mut JSContext, obj: HandleObject, length: u32) -> bool); +wrap!(jsapi: pub fn JS_StealArrayBufferContents(cx: *mut JSContext, obj: HandleObject) -> *mut ::std::os::raw::c_void); +wrap!(jsapi: pub fn GetSelfHostedFunction(cx: *mut JSContext, selfHostedName: *const ::std::os::raw::c_char, id: HandleId, nargs: ::std::os::raw::c_uint) -> *mut JSFunction); +wrap!(jsapi: pub fn NewFunctionFromSpec(cx: *mut JSContext, fs: *const JSFunctionSpec, id: HandleId) -> *mut JSFunction); +wrap!(jsapi: pub fn JS_DefineFunctions(cx: *mut JSContext, obj: HandleObject, fs: *const JSFunctionSpec) -> bool); +wrap!(jsapi: pub fn JS_DefineFunction(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, call: JSNative, nargs: ::std::os::raw::c_uint, attrs: ::std::os::raw::c_uint) -> *mut JSFunction); +wrap!(jsapi: pub fn JS_DefineUCFunction(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, call: JSNative, nargs: ::std::os::raw::c_uint, attrs: ::std::os::raw::c_uint) -> *mut JSFunction); +wrap!(jsapi: pub fn JS_DefineFunctionById(cx: *mut JSContext, obj: HandleObject, id: Handle, call: JSNative, nargs: ::std::os::raw::c_uint, attrs: ::std::os::raw::c_uint) -> *mut JSFunction); +wrap!(jsapi: pub fn CloneFunctionObject(cx: *mut JSContext, funobj: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn CloneFunctionObject1(cx: *mut JSContext, funobj: HandleObject, scopeChain: *mut AutoObjectVector) -> *mut JSObject); +wrap!(jsapi: pub fn JS_BufferIsCompilableUnit(cx: *mut JSContext, obj: HandleObject, utf8: *const ::std::os::raw::c_char, length: usize) -> bool); +wrap!(jsapi: pub fn JS_CompileScript(cx: *mut JSContext, ascii: *const ::std::os::raw::c_char, length: usize, options: *const CompileOptions, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn JS_CompileUCScript(cx: *mut JSContext, chars: *const ::std::os::raw::c_ushort, length: usize, options: *const CompileOptions, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn JS_GetFunctionScript(cx: *mut JSContext, fun: HandleFunction) -> *mut JSScript); +wrap!(jsapi: pub fn Compile(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn Compile1(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn Compile2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const ::std::os::raw::c_ushort, length: usize, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn Compile3(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, file: *mut FILE, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn Compile4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope1(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const ::std::os::raw::c_ushort, length: usize, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope3(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, file: *mut FILE, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileFunction(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, chars: *const ::std::os::raw::c_ushort, length: usize, fun: MutableHandleFunction) -> bool); +wrap!(jsapi: pub fn CompileFunction1(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, srcBuf: *mut SourceBufferHolder, fun: MutableHandleFunction) -> bool); +wrap!(jsapi: pub fn CompileFunction2(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, bytes: *const ::std::os::raw::c_char, length: usize, fun: MutableHandleFunction) -> bool); +wrap!(jsapi: pub fn JS_DecompileScript(cx: *mut JSContext, script: Handle<*mut JSScript>, name: *const ::std::os::raw::c_char, indent: ::std::os::raw::c_uint) -> *mut JSString); +wrap!(jsapi: pub fn JS_DecompileFunction(cx: *mut JSContext, fun: Handle<*mut JSFunction>, indent: ::std::os::raw::c_uint) -> *mut JSString); +wrap!(jsapi: pub fn JS_ExecuteScript(cx: *mut JSContext, script: HandleScript, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ExecuteScript1(cx: *mut JSContext, script: HandleScript) -> bool); +wrap!(jsapi: pub fn JS_ExecuteScript2(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, script: HandleScript, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ExecuteScript3(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, script: HandleScript) -> bool); +wrap!(jsapi: pub fn CloneAndExecuteScript(cx: *mut JSContext, script: Handle<*mut JSScript>) -> bool); +wrap!(jsapi: pub fn Evaluate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate1(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const ::std::os::raw::c_ushort, length: usize, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate3(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, chars: *const ::std::os::raw::c_ushort, length: usize, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate5(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetModuleResolveHook(cx: *mut JSContext, func: HandleFunction)); +wrap!(jsapi: pub fn CompileModule(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, moduleRecord: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn ModuleDeclarationInstantiation(cx: *mut JSContext, moduleRecord: HandleObject) -> bool); +wrap!(jsapi: pub fn ModuleEvaluation(cx: *mut JSContext, moduleRecord: HandleObject) -> bool); +wrap!(jsapi: pub fn GetRequestedModules(cx: *mut JSContext, moduleRecord: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn GetModuleScript(cx: *mut JSContext, moduleRecord: HandleObject) -> *mut JSScript); +wrap!(jsapi: pub fn NewPromiseObject(cx: *mut JSContext, executor: HandleObject, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn IsPromiseObject(obj: HandleObject) -> bool); +wrap!(jsapi: pub fn GetPromiseState(promise: HandleObject) -> PromiseState); +wrap!(jsapi: pub fn GetPromiseID(promise: HandleObject) -> u64); +wrap!(jsapi: pub fn GetPromiseResult(promise: HandleObject) -> Value); +wrap!(jsapi: pub fn GetPromiseAllocationSite(promise: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn GetPromiseResolutionSite(promise: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn CallOriginalPromiseResolve(cx: *mut JSContext, resolutionValue: HandleValue) -> *mut JSObject); +wrap!(jsapi: pub fn CallOriginalPromiseReject(cx: *mut JSContext, rejectionValue: HandleValue) -> *mut JSObject); +wrap!(jsapi: pub fn ResolvePromise(cx: *mut JSContext, promise: HandleObject, resolutionValue: HandleValue) -> bool); +wrap!(jsapi: pub fn RejectPromise(cx: *mut JSContext, promise: HandleObject, rejectionValue: HandleValue) -> bool); +wrap!(jsapi: pub fn CallOriginalPromiseThen(cx: *mut JSContext, promise: HandleObject, onResolve: HandleObject, onReject: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn AddPromiseReactions(cx: *mut JSContext, promise: HandleObject, onResolve: HandleObject, onReject: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_AtomizeAndPinJSString(cx: *mut JSContext, str: HandleString) -> *mut JSString); +wrap!(jsapi: pub fn JS_NewDependentString(cx: *mut JSContext, str: HandleString, start: usize, length: usize) -> *mut JSString); +wrap!(jsapi: pub fn JS_ConcatStrings(cx: *mut JSContext, left: HandleString, right: HandleString) -> *mut JSString); +wrap!(jsapi: pub fn JS_EncodeStringToUTF8(cx: *mut JSContext, str: HandleString) -> *mut ::std::os::raw::c_char); +wrap!(jsapi: pub fn NewAddonId(cx: *mut JSContext, str: HandleString) -> *mut JSAddonId); +wrap!(jsapi: pub fn NewSymbol(cx: *mut JSContext, description: HandleString) -> *mut Symbol); +wrap!(jsapi: pub fn GetSymbolFor(cx: *mut JSContext, key: HandleString) -> *mut Symbol); +wrap!(jsapi: pub fn GetSymbolDescription(symbol: HandleSymbol) -> *mut JSString); +wrap!(jsapi: pub fn GetSymbolCode(symbol: Handle<*mut Symbol>) -> SymbolCode); +wrap!(jsapi: pub fn PropertySpecNameEqualsId(name: *const ::std::os::raw::c_char, id: HandleId) -> bool); +wrap!(jsapi: pub fn JS_Stringify(cx: *mut JSContext, value: MutableHandleValue, replacer: HandleObject, space: HandleValue, callback: JSONWriteCallback, data: *mut ::std::os::raw::c_void) -> bool); +wrap!(jsapi: pub fn ToJSONMaybeSafely(cx: *mut JSContext, input: HandleObject, callback: JSONWriteCallback, data: *mut ::std::os::raw::c_void) -> bool); +wrap!(jsapi: pub fn JS_ParseJSON(cx: *mut JSContext, chars: *const ::std::os::raw::c_ushort, len: u32, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ParseJSON1(cx: *mut JSContext, str: HandleString, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ParseJSONWithReviver(cx: *mut JSContext, chars: *const ::std::os::raw::c_ushort, len: u32, reviver: HandleValue, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ParseJSONWithReviver1(cx: *mut JSContext, str: HandleString, reviver: HandleValue, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn CreateError(cx: *mut JSContext, type_: JSExnType, stack: HandleObject, fileName: HandleString, lineNumber: u32, columnNumber: u32, report: *mut JSErrorReport, message: HandleString, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn GetWeakMapEntry(cx: *mut JSContext, mapObj: HandleObject, key: HandleObject, val: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetWeakMapEntry(cx: *mut JSContext, mapObj: HandleObject, key: HandleObject, val: HandleValue) -> bool); +wrap!(jsapi: pub fn MapSize(cx: *mut JSContext, obj: HandleObject) -> u32); +wrap!(jsapi: pub fn MapGet(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn MapHas(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); +wrap!(jsapi: pub fn MapSet(cx: *mut JSContext, obj: HandleObject, key: HandleValue, val: HandleValue) -> bool); +wrap!(jsapi: pub fn MapDelete(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); +wrap!(jsapi: pub fn MapClear(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn MapKeys(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn MapValues(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn MapEntries(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn MapForEach(cx: *mut JSContext, obj: HandleObject, callbackFn: HandleValue, thisVal: HandleValue) -> bool); +wrap!(jsapi: pub fn SetSize(cx: *mut JSContext, obj: HandleObject) -> u32); +wrap!(jsapi: pub fn SetHas(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); +wrap!(jsapi: pub fn SetDelete(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); +wrap!(jsapi: pub fn SetAdd(cx: *mut JSContext, obj: HandleObject, key: HandleValue) -> bool); +wrap!(jsapi: pub fn SetClear(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn SetKeys(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetValues(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetEntries(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetForEach(cx: *mut JSContext, obj: HandleObject, callbackFn: HandleValue, thisVal: HandleValue) -> bool); +wrap!(jsapi: pub fn JS_ObjectIsDate(cx: *mut JSContext, obj: HandleObject, isDate: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_SetRegExpInput(cx: *mut JSContext, obj: HandleObject, input: HandleString) -> bool); +wrap!(jsapi: pub fn JS_ClearRegExpStatics(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_ExecuteRegExp(cx: *mut JSContext, obj: HandleObject, reobj: HandleObject, chars: *mut ::std::os::raw::c_ushort, length: usize, indexp: *mut usize, test: bool, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ExecuteRegExpNoStatics(cx: *mut JSContext, reobj: HandleObject, chars: *mut ::std::os::raw::c_ushort, length: usize, indexp: *mut usize, test: bool, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ObjectIsRegExp(cx: *mut JSContext, obj: HandleObject, isRegExp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_GetRegExpFlags(cx: *mut JSContext, obj: HandleObject) -> ::std::os::raw::c_uint); +wrap!(jsapi: pub fn JS_GetRegExpSource(cx: *mut JSContext, obj: HandleObject) -> *mut JSString); +wrap!(jsapi: pub fn JS_GetPendingException(cx: *mut JSContext, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_SetPendingException(cx: *mut JSContext, v: HandleValue)); +wrap!(jsapi: pub fn JS_ErrorFromException(cx: *mut JSContext, obj: HandleObject) -> *mut JSErrorReport); +wrap!(jsapi: pub fn ExceptionStackOrNull(obj: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_IndexToId(cx: *mut JSContext, index: u32, arg1: MutableHandleId) -> bool); +wrap!(jsapi: pub fn JS_CharsToId(cx: *mut JSContext, chars: TwoByteChars, arg1: MutableHandleId) -> bool); +wrap!(jsapi: pub fn JS_IsIdentifier(cx: *mut JSContext, str: HandleString, isIdentifier: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_EncodeScript(cx: *mut JSContext, script: HandleScript, lengthp: *mut u32) -> *mut ::std::os::raw::c_void); +wrap!(jsapi: pub fn JS_EncodeInterpretedFunction(cx: *mut JSContext, funobj: HandleObject, lengthp: *mut u32) -> *mut ::std::os::raw::c_void); +wrap!(jsapi: pub fn CaptureCurrentStack(cx: *mut JSContext, stackp: MutableHandleObject, maxFrameCount: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn CopyAsyncStack(cx: *mut JSContext, asyncStack: HandleObject, asyncCause: HandleString, stackp: MutableHandleObject, maxFrameCount: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn GetSavedFrameSource(cx: *mut JSContext, savedFrame: HandleObject, sourcep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameLine(cx: *mut JSContext, savedFrame: HandleObject, linep: *mut u32, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameColumn(cx: *mut JSContext, savedFrame: HandleObject, columnp: *mut u32, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameFunctionDisplayName(cx: *mut JSContext, savedFrame: HandleObject, namep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameAsyncCause(cx: *mut JSContext, savedFrame: HandleObject, asyncCausep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameAsyncParent(cx: *mut JSContext, savedFrame: HandleObject, asyncParentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameParent(cx: *mut JSContext, savedFrame: HandleObject, parentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn BuildStackString(cx: *mut JSContext, stack: HandleObject, stringp: MutableHandleString, indent: usize) -> bool); +wrap!(jsapi: pub fn JS_FindCompilationScope(cx: *mut JSContext, obj: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_SplicePrototype(cx: *mut JSContext, obj: HandleObject, proto: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_NewObjectWithUniqueType(cx: *mut JSContext, clasp: *const JSClass, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewObjectWithoutMetadata(cx: *mut JSContext, clasp: *const JSClass, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_ObjectCountDynamicSlots(obj: HandleObject) -> u32); +wrap!(jsapi: pub fn JS_NondeterministicGetWeakMapKeys(cx: *mut JSContext, obj: HandleObject, ret: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_NondeterministicGetWeakSetKeys(cx: *mut JSContext, obj: HandleObject, ret: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_CloneObject(cx: *mut JSContext, obj: HandleObject, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_InitializePropertiesFromCompatibleNativeObject(cx: *mut JSContext, dst: HandleObject, src: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_BasicObjectToString(cx: *mut JSContext, obj: HandleObject) -> *mut JSString); +wrap!(jsapi: pub fn GetBuiltinClass(cx: *mut JSContext, obj: HandleObject, cls: *mut ESClass) -> bool); +wrap!(jsapi: pub fn ObjectClassName(cx: *mut JSContext, obj: HandleObject) -> *const ::std::os::raw::c_char); +wrap!(jsapi: pub fn ForceLexicalInitialization(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_CopyPropertiesFrom(cx: *mut JSContext, target: HandleObject, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_CopyPropertyFrom(cx: *mut JSContext, id: HandleId, target: HandleObject, obj: HandleObject, copyBehavior: PropertyCopyBehavior) -> bool); +wrap!(jsapi: pub fn JS_WrapPropertyDescriptor(cx: *mut JSContext, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn JS_DefineFunctionsWithHelp(cx: *mut JSContext, obj: HandleObject, fs: *const JSFunctionSpecWithHelp) -> bool); +wrap!(jsapi: pub fn proxy_LookupProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, objp: MutableHandleObject, propp: MutableHandle<*mut Shape>) -> bool); +wrap!(jsapi: pub fn proxy_DefineProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: Handle, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn proxy_HasProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn proxy_GetProperty(cx: *mut JSContext, obj: HandleObject, receiver: HandleValue, id: HandleId, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn proxy_SetProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, bp: HandleValue, receiver: HandleValue, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn proxy_GetOwnPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn proxy_DeleteProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn proxy_Convert(cx: *mut JSContext, proxy: HandleObject, hint: JSType, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn proxy_HasInstance(cx: *mut JSContext, proxy: HandleObject, v: MutableHandleValue, bp: *mut bool) -> bool); +wrap!(jsapi: pub fn proxy_Watch(cx: *mut JSContext, obj: HandleObject, id: HandleId, callable: HandleObject) -> bool); +wrap!(jsapi: pub fn proxy_Unwatch(cx: *mut JSContext, obj: HandleObject, id: HandleId) -> bool); +wrap!(jsapi: pub fn proxy_GetElements(cx: *mut JSContext, proxy: HandleObject, begin: u32, end: u32, adder: *mut ElementAdder) -> bool); +wrap!(jsapi: pub fn proxy_FunToString(cx: *mut JSContext, proxy: HandleObject, indent: ::std::os::raw::c_uint) -> *mut JSString); +wrap!(jsapi: pub fn GetObjectProto(cx: *mut JSContext, obj: HandleObject, proto: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn GetOriginalEval(cx: *mut JSContext, scope: HandleObject, eval: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn GetPropertyKeys(cx: *mut JSContext, obj: HandleObject, flags: ::std::os::raw::c_uint, props: *mut AutoIdVector) -> bool); +wrap!(jsapi: pub fn RegExpToSharedNonInline(cx: *mut JSContext, regexp: HandleObject, shared: *mut RegExpGuard) -> bool); +wrap!(jsapi: pub fn DateIsValid(cx: *mut JSContext, obj: HandleObject, isValid: *mut bool) -> bool); +wrap!(jsapi: pub fn DateGetMsecSinceEpoch(cx: *mut JSContext, obj: HandleObject, msecSinceEpoch: *mut f64) -> bool); +wrap!(jsapi: pub fn JS_NewInt8ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewUint8ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewUint8ClampedArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewInt16ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewUint16ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewInt32ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewUint32ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewFloat32ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewFloat64ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewInt8ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewUint8ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewUint8ClampedArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewInt16ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewUint16ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewInt32ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewUint32ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewFloat32ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewFloat64ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_GetArrayBufferViewBuffer(cx: *mut JSContext, obj: HandleObject, isSharedMemory: *mut bool) -> *mut JSObject); +wrap!(jsapi: pub fn JS_DetachArrayBuffer(cx: *mut JSContext, obj: HandleObject, changeData: DetachDataDisposition) -> bool); +wrap!(jsapi: pub fn JS_NewDataView(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, byteLength: i32) -> *mut JSObject); +wrap!(jsapi: pub fn WatchGuts(cx: *mut JSContext, obj: HandleObject, id: HandleId, callable: HandleObject) -> bool); +wrap!(jsapi: pub fn UnwatchGuts(cx: *mut JSContext, obj: HandleObject, id: HandleId) -> bool); +wrap!(jsapi: pub fn PrepareScriptEnvironmentAndInvoke(cx: *mut JSContext, scope: HandleObject, closure: *mut ScriptEnvironmentPreparer_Closure)); +wrap!(jsapi: pub fn GetElementsWithAdder(cx: *mut JSContext, obj: HandleObject, receiver: HandleObject, begin: u32, end: u32, adder: *mut ElementAdder) -> bool); +wrap!(jsapi: pub fn SetPropertyIgnoringNamedGetter(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, ownDesc: Handle, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn ReportErrorWithId(cx: *mut JSContext, msg: *const ::std::os::raw::c_char, id: HandleId)); +wrap!(jsapi: pub fn ExecuteInGlobalAndReturnScope(cx: *mut JSContext, obj: HandleObject, script: HandleScript, scope: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn GetFirstSubsumedSavedFrame(cx: *mut JSContext, savedFrame: HandleObject, selfHosted: SavedFrameSelfHosted) -> *mut JSObject); +wrap!(jsapi: pub fn ReportIsNotFunction(cx: *mut JSContext, v: HandleValue) -> bool); +wrap!(jsapi: pub fn SetWindowProxy(cx: *mut JSContext, global: HandleObject, windowProxy: HandleObject)); +wrap!(jsapi: pub fn ToBooleanSlow(v: HandleValue) -> bool); +wrap!(jsapi: pub fn ToInt8Slow(cx: *mut JSContext, v: HandleValue, out: *mut i8) -> bool); +wrap!(jsapi: pub fn ToUint8Slow(cx: *mut JSContext, v: HandleValue, out: *mut u8) -> bool); +wrap!(jsapi: pub fn ToInt16Slow(cx: *mut JSContext, v: HandleValue, out: *mut i16) -> bool); +wrap!(jsapi: pub fn ToInt32Slow(cx: *mut JSContext, v: HandleValue, out: *mut i32) -> bool); +wrap!(jsapi: pub fn ToUint32Slow(cx: *mut JSContext, v: HandleValue, out: *mut u32) -> bool); +wrap!(jsapi: pub fn ToUint16Slow(cx: *mut JSContext, v: HandleValue, out: *mut u16) -> bool); +wrap!(jsapi: pub fn ToInt64Slow(cx: *mut JSContext, v: HandleValue, out: *mut i64) -> bool); +wrap!(jsapi: pub fn ToUint64Slow(cx: *mut JSContext, v: HandleValue, out: *mut u64) -> bool); +wrap!(jsapi: pub fn ToStringSlow(cx: *mut JSContext, v: HandleValue) -> *mut JSString); +wrap!(jsapi: pub fn ToObjectSlow(cx: *mut JSContext, v: HandleValue, reportScanStack: bool) -> *mut JSObject); +wrap!(jsapi: pub fn OrdinaryToPrimitive(cx: *mut JSContext, obj: HandleObject, type_: JSType, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn AddSizeOfTab(rt: *mut JSRuntime, obj: HandleObject, mallocSizeOf: MallocSizeOf, opv: *mut ObjectPrivateVisitor, sizes: *mut TabSizes) -> bool); diff --git a/src/rust.rs b/src/rust.rs index 781245a60..7fd70558a 100644 --- a/src/rust.rs +++ b/src/rust.rs @@ -4,7 +4,9 @@ //! Rust wrappers around the raw JS apis + use libc::{size_t, c_uint, c_char}; + use std::char; use std::ffi; use std::ptr; @@ -16,12 +18,15 @@ use std::ops::{Deref, DerefMut}; use std::cell::{Cell, UnsafeCell}; use std::marker::PhantomData; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; + use consts::{JSCLASS_RESERVED_SLOTS_MASK, JSCLASS_GLOBAL_SLOT_COUNT}; use consts::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; + use conversions::jsstr_to_string; + use jsapi; use jsapi::{AutoGCRooter, AutoIdVector, AutoObjectVector, CallArgs, CompartmentOptions, ContextFriendFields}; -use jsapi::{Evaluate2, Handle, HandleBase, HandleObject, HandleValue, HandleValueArray, Heap}; +use jsapi::{Evaluate2, HandleBase, HandleValueArray, Heap}; use jsapi::{HeapObjectPostBarrier, HeapValuePostBarrier, InitSelfHostedCode, IsWindowSlow, JS_BeginRequest}; use jsapi::{JS_DefineFunctions, JS_DefineProperties, JS_DestroyRuntime, JS_EndRequest, JS_ShutDown}; use jsapi::{JS_EnterCompartment, JS_EnumerateStandardClasses, JS_GetContext, JS_GlobalObjectTraceHook}; @@ -31,7 +36,7 @@ use jsapi::{JSClass, JSCLASS_RESERVED_SLOTS_SHIFT, JSClassOps, JSCompartment, JS use jsapi::{JSErrorReport, JSFlatString, JSFunction, JSFunctionSpec, JSGCParamKey}; use jsapi::{JSID_VOID, JSJitGetterCallArgs, JSJitMethodCallArgs, JSJitSetterCallArgs}; use jsapi::{JSNativeWrapper, JSObject, JSPropertySpec, JSRuntime, JSScript}; -use jsapi::{JSString, JSTracer, MutableHandle, MutableHandleBase, MutableHandleValue}; +use jsapi::{JSString, JSTracer, MutableHandleBase}; use jsapi::{NullHandleValue, Object, ObjectGroup,ReadOnlyCompileOptions, Rooted}; use jsapi::{RootedBase, RuntimeOptionsRef, SetWarningReporter, Symbol, ToBooleanSlow}; use jsapi::{ToInt32Slow, ToInt64Slow, ToNumberSlow, ToStringSlow, ToUint16Slow}; @@ -39,14 +44,21 @@ use jsapi::{ToUint32Slow, ToUint64Slow, ToWindowProxyIfWindow, UndefinedHandleVa use jsapi::{Value, jsid, PerThreadDataFriendFields, PerThreadDataFriendFields_RuntimeDummy}; use jsapi::{CaptureCurrentStack, BuildStackString, IsSavedFrame}; use jsapi::{AutoGCRooter_jspubtd_h_unnamed_1 as AutoGCRooterTag, _vftable_CustomAutoRooter as CustomAutoRooterVFTable}; +use jsapi::Handle as RawHandle; +use jsapi::MutableHandle as RawMutableHandle; +use jsapi::HandleValue as RawHandleValue; + use jsapi::PropertyDescriptor; use jsval::{ObjectValue, UndefinedValue}; + use glue::{AppendToAutoObjectVector, CallFunctionTracer, CallIdTracer, CallObjectTracer}; use glue::{CallScriptTracer, CallStringTracer, CallValueTracer, CreateAutoIdVector}; use glue::{CreateAutoObjectVector, CreateCallArgsFromVp, DeleteAutoObjectVector}; use glue::{DestroyAutoIdVector, DeleteCompileOptions, NewCompileOptions, SliceAutoIdVector}; use glue::{CallObjectRootTracer, CallValueRootTracer}; + use panic::maybe_resume_unwind; + use default_heapsize; // From Gecko: @@ -223,7 +235,7 @@ impl Runtime { let options = CompileOptionsWrapper::new(self.cx(), filename_cstr.as_ptr(), line_num); unsafe { - if !Evaluate2(self.cx(), options.ptr, ptr as *const u16, len as size_t, rval) { + if !Evaluate2(self.cx(), options.ptr, ptr as *const u16, len as size_t, rval.into()) { debug!("...err!"); maybe_resume_unwind(); Err(()) @@ -413,10 +425,10 @@ impl<'a, T: 'a + RootKind + GCMethods> RootedGuard<'a, T> { } } - pub fn handle(&self) -> Handle { - unsafe { - Handle::from_marked_location(&self.root.ptr) - } + // REVIEW: is this equivalent to? + // pub fn handle(&self) -> Handle + pub fn handle(&'a self) -> Handle<'a, T> { + Handle::new(&self.root.ptr) } pub fn handle_mut(&mut self) -> MutableHandle { @@ -617,10 +629,9 @@ impl<'a, T: 'a + CustomTrace> CustomAutoRooterGuard<'a, T> { } } - pub fn handle(&self) -> Handle where T: RootKind { - unsafe { - Handle::from_marked_location(&self.rooter.data) - } + // REVIEW: as in line 429 + pub fn handle(&'a self) -> Handle<'a, T> where T: RootKind { + Handle::new(&self.rooter.data) } pub fn handle_mut(&mut self) -> MutableHandle where T: RootKind { @@ -666,22 +677,74 @@ macro_rules! auto_root { } } -impl Handle { +#[derive(Clone, Copy)] +pub struct Handle<'a, T: 'a> { + ptr: &'a T, +} + +#[derive(Copy, Clone)] +pub struct MutableHandle<'a, T: 'a> { + ptr: *mut T, + anchor: PhantomData<&'a mut T>, +} + +pub type MutableHandleValue<'a> = MutableHandle<'a, Value>; +pub type MutableHandleObject<'a> = MutableHandle<'a, *mut JSObject>; + +pub type HandleValue<'a> = Handle<'a, Value>; +pub type HandleObject<'a> = Handle<'a, *mut JSObject>; +pub type HandleId<'a> = Handle<'a, jsid>; + +impl RawHandle { pub fn get(&self) -> T where T: Copy { unsafe { *self.ptr } } - pub unsafe fn from_marked_location(ptr: *const T) -> Handle { - Handle { + pub unsafe fn from_marked_location(ptr: *const T) -> Self { + RawHandle { _base: HandleBase { _phantom0: PhantomData }, ptr: ptr, } } } -impl Deref for Handle { +impl<'a, T> Handle<'a, T> { + pub fn get(&self) -> T + where T: Copy + { + *self.ptr + } + + pub fn new(ptr: &'a T) -> Self { + Handle { ptr: ptr } + } + + pub unsafe fn from_marked_location(ptr: *const T) -> Self { + Handle::new(&*ptr) + } + + pub unsafe fn from_raw(handle: RawHandle) -> Self { + Handle::from_marked_location(handle.ptr) + } +} + +impl<'a, T> From> for RawHandle { + fn from(handle: Handle<'a, T>) -> Self { + unsafe { RawHandle::from_marked_location(handle.ptr) } + } +} + +impl<'a, T> Deref for Handle<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + self.ptr + } +} + +impl Deref for RawHandle { type Target = T; fn deref<'a>(&'a self) -> &'a T { @@ -689,17 +752,17 @@ impl Deref for Handle { } } -impl MutableHandle { - pub unsafe fn from_marked_location(ptr: *mut T) -> MutableHandle { - MutableHandle { +impl RawMutableHandle { + pub unsafe fn from_marked_location(ptr: *mut T) -> Self { + Self { _base: MutableHandleBase { _phantom0: PhantomData }, ptr: ptr, } } - pub fn handle(&self) -> Handle { + pub fn handle(&self) -> RawHandle { unsafe { - Handle::from_marked_location(self.ptr as *const _) + RawHandle::from_marked_location(self.ptr as *const T) } } @@ -716,7 +779,43 @@ impl MutableHandle { } } -impl Deref for MutableHandle { +impl<'a, T> MutableHandle<'a, T> { + pub unsafe fn from_marked_location(ptr: *mut T) -> Self { + MutableHandle::new(&mut *ptr) + } + + pub unsafe fn from_raw(handle: RawMutableHandle) -> Self { + MutableHandle::from_marked_location(handle.ptr) + } + + pub fn handle(&self) -> Handle { + unsafe { Handle::new(&*self.ptr) } + } + + pub fn new(ptr: &'a mut T) -> Self { + Self { ptr: ptr, anchor: PhantomData } + } + + pub fn get(&self) -> T + where T: Copy + { + unsafe { *self.ptr } + } + + pub fn set(&mut self, v: T) + where T: Copy + { + unsafe { *self.ptr = v } + } + + fn raw(&mut self) -> RawMutableHandle { + unsafe { + RawMutableHandle::from_marked_location(self.ptr) + } + } +} + +impl Deref for RawMutableHandle { type Target = T; fn deref<'a>(&'a self) -> &'a T { @@ -724,26 +823,56 @@ impl Deref for MutableHandle { } } -impl DerefMut for MutableHandle { +impl DerefMut for RawMutableHandle { fn deref_mut<'a>(&'a mut self) -> &'a mut T { unsafe { &mut *self.ptr } } } -impl HandleValue { - pub fn null() -> HandleValue { +impl<'a, T> Deref for MutableHandle<'a, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*self.ptr } + } +} + +impl<'a, T> DerefMut for MutableHandle<'a, T> { + fn deref_mut(&mut self) -> &mut T { + unsafe { &mut *self.ptr } + } +} + +impl<'a, T> From> for RawMutableHandle { + fn from(handle: MutableHandle<'a, T>) -> Self { + unsafe { RawMutableHandle::from_marked_location(handle.ptr) } + } +} + +impl RawHandleValue { + pub fn null() -> &'static Self { unsafe { - NullHandleValue + &NullHandleValue } } - pub fn undefined() -> HandleValue { + pub fn undefined() -> &'static Self { unsafe { - UndefinedHandleValue + &UndefinedHandleValue } } } +impl HandleValue<'static> { + pub fn null() -> Self { + Self::new(RawHandleValue::null()) + } + + pub fn undefined() -> Self { + Self::new(RawHandleValue::undefined()) + } +} + impl HandleValueArray { pub fn new() -> HandleValueArray { HandleValueArray { @@ -762,8 +891,8 @@ impl HandleValueArray { const ConstNullValue: *mut JSObject = 0 as *mut JSObject; -impl HandleObject { - pub fn null() -> HandleObject { +impl<'a> HandleObject<'a> { + pub fn null() -> Self { unsafe { HandleObject::from_marked_location(&ConstNullValue) } @@ -869,6 +998,11 @@ impl Heap { self.ptr.get() } + pub fn handle_mut(&self) -> MutableHandle { + unsafe { + MutableHandle::from_marked_location(self.ptr.get()) + } + } /// Retrieves a Handle to the underlying value. /// /// # Safety @@ -943,9 +1077,11 @@ impl JSJitMethodCallArgs { pub fn get(&self, i: u32) -> HandleValue { unsafe { if i < self._base.argc_ { - HandleValue::from_marked_location(self._base.argv_.offset(i as isize)) + HandleValue::from_marked_location( + self._base.argv_.offset(i as isize) + ) } else { - UndefinedHandleValue + HandleValue::from_raw(UndefinedHandleValue) } } } @@ -1004,7 +1140,7 @@ impl CallArgs { if i < self._base.argc_ { HandleValue::from_marked_location(self._base.argv_.offset(i as isize)) } else { - UndefinedHandleValue + HandleValue::from_raw(UndefinedHandleValue) } } } @@ -1047,7 +1183,9 @@ impl CallArgs { impl JSJitGetterCallArgs { #[inline] pub fn rval(&self) -> MutableHandleValue { - self._base + unsafe { + MutableHandleValue::from_raw(self._base) + } } } @@ -1055,7 +1193,9 @@ impl JSJitSetterCallArgs { #[inline] pub fn get(&self, i: u32) -> HandleValue { assert!(i == 0); - self._base.handle() + unsafe { + HandleValue::from_raw(self._base.handle()) + } } } @@ -1134,7 +1274,7 @@ pub unsafe fn ToBoolean(v: HandleValue) -> bool { return true; } - ToBooleanSlow(v) + ToBooleanSlow(v.into()) } #[inline] @@ -1156,7 +1296,7 @@ pub unsafe fn ToNumber(cx: *mut JSContext, v: HandleValue) -> Result { unsafe fn convert_from_int32( cx: *mut JSContext, v: HandleValue, - conv_fn: unsafe extern "C" fn(*mut JSContext, HandleValue, *mut T) -> bool) + conv_fn: unsafe extern "C" fn(*mut JSContext, RawHandleValue, *mut T) -> bool) -> Result { let val = *v.ptr; @@ -1168,7 +1308,7 @@ unsafe fn convert_from_int32( } let mut out = Default::default(); - if conv_fn(cx, v, &mut out) { + if conv_fn(cx, v.into(), &mut out) { Ok(out) } else { Err(()) @@ -1207,7 +1347,7 @@ pub unsafe fn ToString(cx: *mut JSContext, v: HandleValue) -> *mut JSString { return val.to_string(); } - ToStringSlow(cx, v) + ToStringSlow(cx, v.into()) } pub unsafe extern fn report_warning(_cx: *mut JSContext, _: *const c_char, report: *mut JSErrorReport) { @@ -1303,7 +1443,7 @@ pub unsafe fn define_methods(cx: *mut JSContext, obj: HandleObject, } }); - JS_DefineFunctions(cx, obj, methods.as_ptr()).to_result() + JS_DefineFunctions(cx, obj.into(), methods.as_ptr()).to_result() } /// Defines attributes on `obj`. The last entry of `properties` must contain @@ -1333,7 +1473,7 @@ pub unsafe fn define_properties(cx: *mut JSContext, obj: HandleObject, } }); - JS_DefineProperties(cx, obj, properties.as_ptr()).to_result() + JS_DefineProperties(cx, obj.into(), properties.as_ptr()).to_result() } static SIMPLE_GLOBAL_CLASS_OPS: JSClassOps = JSClassOps { @@ -1398,7 +1538,7 @@ pub unsafe fn is_window(obj: *mut JSObject) -> bool { } #[inline] -pub unsafe fn try_to_outerize(rval: MutableHandleValue) { +pub unsafe fn try_to_outerize(mut rval: MutableHandleValue) { let obj = rval.to_object(); if is_window(obj) { let obj = ToWindowProxyIfWindow(obj); @@ -1412,7 +1552,7 @@ pub unsafe fn maybe_wrap_object_value(cx: *mut JSContext, rval: MutableHandleVal assert!(rval.is_object()); let obj = rval.to_object(); if get_object_compartment(obj) != get_context_compartment(cx) { - assert!(JS_WrapValue(cx, rval)); + assert!(JS_WrapValue(cx, rval.into())); } else if is_dom_object(obj) { try_to_outerize(rval); } @@ -1431,7 +1571,7 @@ pub unsafe fn maybe_wrap_object_or_null_value( #[inline] pub unsafe fn maybe_wrap_value(cx: *mut JSContext, rval: MutableHandleValue) { if rval.is_string() { - assert!(JS_WrapValue(cx, rval)); + assert!(JS_WrapValue(cx, rval.into())); } else if rval.is_object() { maybe_wrap_object_value(cx, rval); } @@ -1474,9 +1614,7 @@ impl<'a> CapturedJSStack<'a> { pub unsafe fn new(cx: *mut JSContext, mut guard: RootedGuard<'a, *mut JSObject>, max_frame_count: Option) -> Option { - let obj_handle = guard.handle_mut(); - - if !CaptureCurrentStack(cx, obj_handle, max_frame_count.unwrap_or(0)) { + if !CaptureCurrentStack(cx, guard.handle_mut().raw(), max_frame_count.unwrap_or(0)) { None } else { @@ -1491,13 +1629,13 @@ impl<'a> CapturedJSStack<'a> { unsafe { let stack_handle = self.stack.handle(); rooted!(in(self.cx) let mut js_string = ptr::null_mut::()); - let string_handle = js_string.handle_mut(); + let mut string_handle = js_string.handle_mut(); if !IsSavedFrame(stack_handle.get()) { return None; } - if !BuildStackString(self.cx, stack_handle, string_handle, indent.unwrap_or(0)) { + if !BuildStackString(self.cx, stack_handle.into(), string_handle.raw(), indent.unwrap_or(0)) { return None; } @@ -1518,6 +1656,113 @@ macro_rules! capture_stack { } } +macro_rules! wrap { + // The invocation of @inner has the following form: + // @inner (input args) <> (accumulator) <> unparsed tokens + // when `unparsed tokens == \eps`, accumulator contains the final result + + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: Handle<$gentype:ty>, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: MutableHandle<$gentype:ty>, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: Handle, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: HandleValue, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: HandleObject, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: HandleId, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: MutableHandle, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: MutableHandleObject, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: MutableHandleValue, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); + }; + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: $type:ty, $($rest:tt)*) => { + wrap!(@inner $saved <> ($($acc,)* $arg,) <> $($rest)*); + }; + (@inner ($module:tt: $func_name:ident ($($args:tt)*) -> $outtype:ty) <> ($($argexprs:expr,)*) <> ) => { + #[inline] + pub unsafe fn $func_name($($args)*) -> $outtype { + $module::$func_name($($argexprs),*) + } + }; + ($module:tt: pub fn $func_name:ident($($args:tt)*) -> $outtype:ty) => { + wrap!(@inner ($module: $func_name ($($args)*) -> $outtype) <> () <> $($args)* ,); + }; + ($module:tt: pub fn $func_name:ident($($args:tt)*)) => { + wrap!($module: pub fn $func_name($($args)*) -> ()); + } +} + +/** Wrappers for JSAPI methods that accept lifetimed Handle and MutableHandle arguments. + * + * The wrapped methods are identical except that they accept Handle and MutableHandle arguments + * that include lifetimes instead. + * */ +pub mod wrappers { + use jsapi; + use glue; + use jsapi::{IsArrayAnswer, PropertyDescriptor, ElementAdder, DetachDataDisposition}; + use jsapi::{JSStructuredCloneCallbacks, JSStructuredCloneReader, JSStructuredCloneWriter}; + use jsapi::{JSNative, JSObject, JSContext, JSFunction, JSRuntime, JSString}; + use jsapi::{JSType}; + use jsapi::{HandleString, HandleScript}; + use jsapi::{SavedFrameResult, SavedFrameSelfHosted}; + use jsapi::{MallocSizeOf, ObjectPrivateVisitor, ObjectOpResult, TabSizes}; + use jsapi::AutoIdVector; + use jsapi::AutoObjectVector; + use jsapi::CallArgs; + use jsapi::CompileOptions; + use jsapi::ESClass; + use jsapi::HandleFunction; + use jsapi::HandleSymbol; + use jsapi::HandleValueArray; + use jsapi::JSAddonId; + use jsapi::JSClass; + use jsapi::JSConstDoubleSpec; + use jsapi::JSConstIntegerSpec; + use jsapi::JSErrorReport; + use jsapi::JSExnType; + use jsapi::JSFunctionSpec; + use jsapi::JSFunctionSpecWithHelp; + use jsapi::jsid; + use jsapi::JSONWriteCallback; + use jsapi::JSPropertySpec; + use jsapi::JSProtoKey; + use jsapi::JSScript; + use jsapi::MutableHandleFunction; + use jsapi::MutableHandleId; + use jsapi::MutableHandleScript; + use jsapi::MutableHandleString; + use jsapi::PromiseState; + use jsapi::PropertyCopyBehavior; + use jsapi::ReadOnlyCompileOptions; + use jsapi::RegExpGuard; + use jsapi::ScriptEnvironmentPreparer_Closure; + use jsapi::Shape; + use jsapi::SourceBufferHolder; + use jsapi::Symbol; + use jsapi::SymbolCode; + use jsapi::TwoByteChars; + use jsapi::Value; + use jsapi::JSJitInfo; + use libc::FILE; + use super::{Handle, HandleId, HandleObject, HandleValue}; + use super::{MutableHandle, MutableHandleObject, MutableHandleValue}; + include!("jsapi_wrappers.in"); + include!("glue_wrappers.in"); +} impl Default for PropertyDescriptor { fn default() -> PropertyDescriptor { diff --git a/src/typedarray.rs b/src/typedarray.rs index b9d7e9530..cac0bca88 100644 --- a/src/typedarray.rs +++ b/src/typedarray.rs @@ -20,7 +20,6 @@ use glue::GetUint8ArrayLengthAndData; use glue::GetUint8ClampedArrayLengthAndData; use jsapi::GetArrayBufferLengthAndData; use jsapi::GetArrayBufferViewLengthAndData; -use jsapi::HandleValue; use jsapi::Heap; use jsapi::JSContext; use jsapi::JSObject; @@ -46,8 +45,6 @@ use jsapi::JS_NewUint16Array; use jsapi::JS_NewUint32Array; use jsapi::JS_NewUint8Array; use jsapi::JS_NewUint8ClampedArray; -use jsapi::MutableHandleObject; -use jsapi::MutableHandleValue; use jsapi::Type; use jsapi::UnwrapArrayBuffer; use jsapi::UnwrapArrayBufferView; @@ -60,6 +57,7 @@ use jsapi::UnwrapUint16Array; use jsapi::UnwrapUint32Array; use jsapi::UnwrapUint8Array; use jsapi::UnwrapUint8ClampedArray; +use rust::{HandleValue, MutableHandleObject, MutableHandleValue}; use rust::CustomTrace; use std::ptr; @@ -210,7 +208,7 @@ impl TypedA /// be copied into the newly-allocated buffer. Returns the new JS reflector. pub unsafe fn create(cx: *mut JSContext, with: CreateWith, - result: MutableHandleObject) + mut result: MutableHandleObject) -> Result<(), ()> { let length = match with { CreateWith::Length(len) => len, diff --git a/tests/callback.rs b/tests/callback.rs index 84dcd66e2..be22b95c2 100644 --- a/tests/callback.rs +++ b/tests/callback.rs @@ -35,7 +35,7 @@ fn callback() { rooted!(in(context) let global_root = global); let global = global_root.handle(); let _ac = JSAutoCompartment::new(context, global.get()); - let function = JS_DefineFunction(context, global, b"puts\0".as_ptr() as *const libc::c_char, + let function = JS_DefineFunction(context, global.into(), b"puts\0".as_ptr() as *const libc::c_char, Some(puts), 1, 0); assert!(!function.is_null()); let javascript = "puts('Test Iñtërnâtiônàlizætiøn ┬─┬ノ( º _ ºノ) ');"; @@ -55,7 +55,7 @@ unsafe extern "C" fn puts(context: *mut JSContext, argc: u32, vp: *mut Value) -> let arg = args.get(0); let js = mozjs::rust::ToString(context, arg); rooted!(in(context) let message_root = js); - let message = JS_EncodeStringToUTF8(context, message_root.handle()); + let message = JS_EncodeStringToUTF8(context, message_root.handle().into()); let message = CStr::from_ptr(message); println!("{}", str::from_utf8(message.to_bytes()).unwrap()); diff --git a/tests/capture_stack.rs b/tests/capture_stack.rs index 68b00ec57..b2a9c57a2 100644 --- a/tests/capture_stack.rs +++ b/tests/capture_stack.rs @@ -31,7 +31,7 @@ fn capture_stack() { rooted!(in(context) let global_root = global); let global = global_root.handle(); let _ac = JSAutoCompartment::new(context, global.get()); - let function = JS_DefineFunction(context, global, b"print_stack\0".as_ptr() as *const libc::c_char, + let function = JS_DefineFunction(context, global.into(), b"print_stack\0".as_ptr() as *const libc::c_char, Some(print_stack), 0, 0); assert!(!function.is_null()); let javascript = " diff --git a/tests/enumerate.rs b/tests/enumerate.rs index 3e30554e9..be795e124 100644 --- a/tests/enumerate.rs +++ b/tests/enumerate.rs @@ -38,13 +38,13 @@ fn enumerate() { rooted!(in(cx) let object = rval.to_object()); let ids = IdVector::new(cx); - assert!(GetPropertyKeys(cx, object.handle(), JSITER_OWNONLY, ids.get())); + assert!(GetPropertyKeys(cx, object.handle().into(), JSITER_OWNONLY, ids.get())); assert_eq!(ids.len(), 1); rooted!(in(cx) let id = ids[0]); - assert!(RUST_JSID_IS_STRING(id.handle())); - rooted!(in(cx) let id = RUST_JSID_TO_STRING(id.handle())); + assert!(RUST_JSID_IS_STRING(id.handle().into())); + rooted!(in(cx) let id = RUST_JSID_TO_STRING(id.handle().into())); let mut matches = false; assert!(JS_StringEqualsAscii(cx, diff --git a/tests/panic.rs b/tests/panic.rs index e5fa89906..c25653e82 100644 --- a/tests/panic.rs +++ b/tests/panic.rs @@ -31,7 +31,7 @@ fn panic() { rooted!(in(context) let global_root = global); let global = global_root.handle(); let _ac = JSAutoCompartment::new(context, global.get()); - let function = JS_DefineFunction(context, global, + let function = JS_DefineFunction(context, global.into(), b"test\0".as_ptr() as *const _, Some(test), 0, 0); assert!(!function.is_null()); diff --git a/tests/rooting.rs b/tests/rooting.rs index ab0d2211e..e6370e85e 100644 --- a/tests/rooting.rs +++ b/tests/rooting.rs @@ -42,10 +42,10 @@ fn rooting() { h_option, &c_option)); let _ac = JSAutoCompartment::new(cx, global.get()); - rooted!(in(cx) let prototype_proto = JS_GetObjectPrototype(cx, global.handle())); + rooted!(in(cx) let prototype_proto = JS_GetObjectPrototype(cx, global.handle().into())); rooted!(in(cx) let proto = JS_NewObjectWithUniqueType(cx, &CLASS as *const _, - prototype_proto.handle())); + prototype_proto.handle().into())); define_methods(cx, proto.handle(), METHODS).unwrap(); } } diff --git a/tests/vec_conversion.rs b/tests/vec_conversion.rs index d5987a104..6947b318e 100644 --- a/tests/vec_conversion.rs +++ b/tests/vec_conversion.rs @@ -34,7 +34,7 @@ fn vec_conversion() { let global = global_root.handle(); let _ac = JSAutoCompartment::new(cx, global.get()); - assert!(JS_InitStandardClasses(cx, global)); + assert!(JS_InitStandardClasses(cx, global.into())); rooted!(in(cx) let mut rval = UndefinedValue());