diff --git a/Makefile.in b/Makefile.in index df1f09aa6..86e14aae4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -5,11 +5,17 @@ RUSTC ?= rustc AR ?= ar RUSTFLAGS ?= EXT_DEPS ?= -CFLAGS += -fPIC + RUSTDOC ?= rustdoc RUSTDOC_FLAGS ?= RUSTDOC_TARGET ?= doc +CFLAGS += -fPIC -std=c++11 + +ifdef CFG_ENABLE_DEBUG_MOZJS +CFLAGS += -g -O0 -DDEBUG -D_DEBUG +endif + ifeq ($(shell $(CXX) -v 2>&1 | grep -c 'clang version\|Apple.*clang'),1) CFLAGS += -Wno-c++0x-extensions -Wno-return-type-c-linkage -Wno-invalid-offsetof endif diff --git a/makefile.cargo b/makefile.cargo index ed3d569f0..059e8f619 100644 --- a/makefile.cargo +++ b/makefile.cargo @@ -10,7 +10,7 @@ AR ?= ar endif -CFLAGS += -fPIC +CFLAGS += -std=c++11 -fPIC -g -O0 -DDEBUG -D_DEBUG ifeq ($(shell $(CXX) -v 2>&1 | grep -c 'clang version\|Apple.*clang'),1) CFLAGS += -Wno-c++0x-extensions -Wno-return-type-c-linkage -Wno-invalid-offsetof diff --git a/src/glue.rs b/src/glue.rs index 8decabc1d..6feb518ab 100644 --- a/src/glue.rs +++ b/src/glue.rs @@ -2,45 +2,55 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* automatically generated by rust-bindgen */ - -use libc; -use jsapi::*; -use jsfriendapi::JSJitInfo; +#![allow(ctypes)] + +use jsapi::{JSContext, JSPropertyDescriptor, jschar, JSRuntime}; +use jsapi::{JSTracer, JSFunction, JSNative, JSErrorFormatString, JSFreeOp}; +use jsapi::{JSClass, JSString, JSObject, jsid, JSVersion, JSTraceOp}; +use jsapi::{Enum_OnNewGlobalHookOption, JSPrincipals, Enum_JSType, Struct_JSFreeOp}; +use jsapi::{JSStrictPropertyOp, JSPropertyOp}; +use jsapi::{Handle, MutableHandle}; +use jsapi::{JSHandleObject, JSHandleId, JSMutableHandleValue}; +use jsapi::{JSMutableHandleObject, JSHandleValue}; + +use jsfriendapi::{JSJitInfo, DOMProxyShadowsCheck}; use jsval::JSVal; +use libc; +use libc::c_void; pub static JS_STRUCTURED_CLONE_VERSION: u32 = 1; +pub type JSBool = libc::c_int; + pub struct ProxyTraps { - pub getPropertyDescriptor: Option bool>, - pub getOwnPropertyDescriptor: Option bool>, - pub defineProperty: Option bool>, + pub preventExtensions: Option bool>, + pub getPropertyDescriptor: Option, u32) -> bool>, + pub getOwnPropertyDescriptor: Option, u32) -> bool>, + pub defineProperty: Option) -> bool>, pub getOwnPropertyNames: *const u8, //XXX need a representation for AutoIdVector& - pub delete_: Option bool>, + pub delete_: Option bool>, pub enumerate: *const u8, //XXX need a representation for AutoIdVector& - pub has: Option bool>, - pub hasOwn: Option bool>, - pub get: Option bool>, - pub set: Option bool>, + pub has: Option bool>, + pub hasOwn: Option bool>, + pub get: Option bool>, + pub set: Option bool>, pub keys: *const u8, //XXX need a representation for AutoIdVector& - pub iterate: Option bool>, + pub iterate: Option bool>, - pub call: Option bool>, - pub construct: Option bool>, + pub isExtensible: Option bool>, + pub call: Option bool>, + pub construct: Option bool>, pub nativeCall: *const u8, //XXX need a representation for IsAcceptableThis, NativeImpl, and CallArgs - pub hasInstance: Option bool>, - pub typeOf: Option uint>, //XXX JSType enum - pub objectClassIs: Option bool>, //XXX ESClassValue enum - pub obj_toString: Option *mut JSString>, - pub fun_toString: Option *mut JSString>, + pub hasInstance: Option bool>, + pub objectClassIs: Option bool>, //XXX ESClassValue enum + pub className: Option *const libc::c_char>, + pub fun_toString: Option *mut JSString>, //regexp_toShared: *u8, - pub defaultValue: Option bool>, //XXX JSType enum - pub iteratorNext: Option bool>, + pub defaultValue: Option bool>, pub finalize: Option, - pub getElementIfPresent: Option bool>, - pub getPrototypeOf: Option bool>, - pub trace: Option, + pub getPrototypeOf: Option bool>, + pub trace: Option } #[link(name = "jsglue")] @@ -56,38 +66,40 @@ extern { } extern { -//#[rust_stack] pub fn RUST_JS_NumberValue(d: f64) -> JSVal; -//#[rust_stack] -pub fn CallJitPropertyOp(info: *const JSJitInfo, cx: *mut JSContext, thisObj: *mut JSObject, specializedThis: *mut libc::c_void, vp: *mut JSVal) -> JSBool; +pub fn CallJitSetterOp(info: *const JSJitInfo, cx: *mut JSContext, thisObj: JSHandleObject, specializedThis: *const libc::c_void, vp: *mut JSVal) -> bool; + +pub fn CallJitGetterOp(info: *const JSJitInfo, cx: *mut JSContext, thisObj: JSHandleObject, specializedThis: *const libc::c_void, vp: *mut JSVal) -> bool; -//#[rust_stack] -pub fn CallJitMethodOp(info: *const JSJitInfo, cx: *mut JSContext, thisObj: *mut JSObject, specializedThis: *mut libc::c_void, argc: libc::c_uint, vp: *mut JSVal) -> JSBool; +pub fn CallJitMethodOp(info: *const JSJitInfo, cx: *mut JSContext, thisObj: JSHandleObject, specializedThis: *const libc::c_void, argc: libc::c_uint, vp: *mut JSVal) -> bool; -//#[rust_stack] pub fn RUST_FUNCTION_VALUE_TO_JITINFO(v: JSVal) -> *const JSJitInfo; -pub fn SetFunctionNativeReserved(fun: *mut JSObject, which: libc::size_t, val: *mut JSVal); -pub fn GetFunctionNativeReserved(fun: *mut JSObject, which: libc::size_t) -> *mut JSVal; +pub fn SetFunctionNativeReserved(fun: *mut JSObject, which: libc::size_t, val: *const JSVal); +pub fn GetFunctionNativeReserved(fun: *mut JSObject, which: libc::size_t) -> *const JSVal; pub fn CreateProxyHandler(traps: *const ProxyTraps, extra: *const libc::c_void) -> *const libc::c_void; pub fn CreateWrapperProxyHandler(traps: *const ProxyTraps) -> *const libc::c_void; -pub fn NewProxyObject(cx: *mut JSContext, handler: *const libc::c_void, priv_: *const JSVal, - proto: *mut JSObject, parent: *mut JSObject, call: *mut JSObject, - construct: *mut JSObject) -> *mut JSObject; -pub fn WrapperNew(cx: *mut JSContext, parent: *mut JSObject, handler: *const libc::c_void) -> *mut JSObject; +pub fn NewProxyObject(cx: *mut JSContext, handler: *const libc::c_void, clasp: */*const*/mut super::Class, + priv_: JSHandleValue, proto: *mut JSObject, parent: *mut JSObject) -> *mut JSObject; +pub fn WrapperNew(cx: *mut JSContext, obj: JSHandleObject, parent: JSHandleObject, + handler: *const libc::c_void, clasp: */*const*/mut super::Class, singleton: bool) -> *mut JSObject; pub fn GetProxyExtra(obj: *mut JSObject, slot: libc::c_uint) -> JSVal; pub fn GetProxyPrivate(obj: *mut JSObject) -> JSVal; pub fn SetProxyExtra(obj: *mut JSObject, slot: libc::c_uint, val: JSVal); -pub fn GetObjectProto(obj: *mut JSObject) -> *mut JSObject; +pub fn SetDOMProxyInformation(domProxyHandlerFamily: *const libc::c_void, + domProxyExpandoSlot: u32, + domProxyShadowsCheck: DOMProxyShadowsCheck); + +pub fn GetObjectProto(cx: *mut JSContext, obj: JSHandleObject, proto: JSMutableHandleObject) -> bool; pub fn GetObjectParent(obj: *mut JSObject) -> *mut JSObject; -pub fn RUST_JSID_IS_INT(id: jsid) -> JSBool; +pub fn RUST_JSID_IS_INT(id: jsid) -> bool; pub fn RUST_JSID_TO_INT(id: jsid) -> libc::c_int; -pub fn RUST_JSID_IS_STRING(id: jsid) -> JSBool; +pub fn RUST_JSID_IS_STRING(id: jsid) -> bool; pub fn RUST_JSID_TO_STRING(id: jsid) -> *mut JSString; pub fn RUST_SET_JITINFO(func: *mut JSFunction, info: *const JSJitInfo); @@ -97,17 +109,108 @@ pub fn RUST_INTERNED_STRING_TO_JSID(cx: *mut JSContext, str: *mut JSString) -> j pub fn DefineFunctionWithReserved(cx: *mut JSContext, obj: *mut JSObject, name: *const libc::c_char, call: JSNative, nargs: libc::c_uint, attrs: libc::c_uint) -> *mut JSObject; -pub fn GetObjectJSClass(obj: *mut JSObject) -> *mut JSClass; +pub fn GetObjectJSClass(obj: *mut JSObject) -> *const JSClass; pub fn RUST_js_GetErrorMessage(userRef: *mut libc::c_void, locale: *const libc::c_char, errorNumber: libc::c_uint) -> *const JSErrorFormatString; -pub fn js_IsObjectProxyClass(obj: *mut JSObject) -> bool; -pub fn js_IsFunctionProxyClass(obj: *mut JSObject) -> bool; +pub fn GetProxyHandlerFamily() -> *const libc::c_void; pub fn IsProxyHandlerFamily(obj: *mut JSObject) -> bool; pub fn GetProxyHandlerExtra(obj: *mut JSObject) -> *const libc::c_void; pub fn GetProxyHandler(obj: *mut JSObject) -> *mut libc::c_void; -pub fn InvokeGetOwnPropertyDescriptor(handler: *mut libc::c_void, cx: *mut JSContext, proxy: *mut JSObject, id: jsid, set: bool, desc: *mut JSPropertyDescriptor) -> bool; +pub fn InvokeGetOwnPropertyDescriptor(handler: *mut libc::c_void, cx: *mut JSContext, proxy: JSHandleObject, id: JSHandleId, desc: MutableHandle, flags: libc::c_uint) -> bool; +pub fn InvokeHasOwn(handler: *mut libc::c_void, cx: *mut JSContext, proxy: JSHandleObject, id: JSHandleId, hasOwn: *mut bool) -> bool; pub fn GetGlobalForObjectCrossCompartment(obj: *mut JSObject) -> *mut JSObject; pub fn ReportError(cx: *mut JSContext, error: *const libc::c_char); pub fn IsWrapper(obj: *mut JSObject) -> JSBool; -pub fn UnwrapObject(obj: *mut JSObject, stopAtOuter: JSBool, flags: *mut libc::c_uint) -> *mut JSObject; +pub fn UnwrapObject(obj: *mut JSObject, stopAtOuter: bool) -> *mut JSObject; + +pub fn ContextOptions_SetVarObjFix(cx: *mut JSContext, enable: bool); +pub fn CompartmentOptions_SetVersion(cx: *mut JSContext, version: JSVersion); +pub fn CompartmentOptions_SetTraceGlobal(cx: *mut JSContext, op: JSTraceOp); + +pub fn ToBoolean(v: JSHandleValue) -> bool; +pub fn ToString(cx: *mut JSContext, v: JSHandleValue) -> *mut JSString; +pub fn ToNumber(cx: *mut JSContext, v: JSHandleValue, out: *mut f64) -> bool; +pub fn ToUint16(cx: *mut JSContext, v: JSHandleValue, out: *mut u16) -> bool; +pub fn ToInt32(cx: *mut JSContext, v: JSHandleValue, out: *mut i32) -> bool; +pub fn ToUint32(cx: *mut JSContext, v: JSHandleValue, out: *mut u32) -> bool; +pub fn ToInt64(cx: *mut JSContext, v: JSHandleValue, out: *mut i64) -> bool; +pub fn ToUint64(cx: *mut JSContext, v: JSHandleValue, out: *mut u64) -> bool; + +//XXX Heap pub fn AddObjectRoot(cx: *mut JSContext, obj: *mut *mut JSObject) -> bool; +//XXX Heap pub fn RemoveObjectRoot(cx: *mut JSContext, obj: *mut *mut libc::c_void); + +pub fn NewGlobalObject(cx: *mut JSContext, clasp: *const JSClass, + principals: *mut JSPrincipals, + hookOption: Enum_OnNewGlobalHookOption) -> *mut JSObject; + +pub fn CallFunctionValue(cx: *mut JSContext, obj: JSHandleObject, fval: JSHandleValue, + argc: libc::size_t, argv: *const JSVal, rval: JSMutableHandleValue) -> bool; +pub fn CompileUCFunction(cx: *mut JSContext, obj: JSHandleObject, + name: *const libc::c_schar, nargs: libc::c_uint, + argnames: *const *const libc::c_schar, chars: *const jschar, + length: libc::size_t, url: *const libc::c_schar, + lineno: libc::c_uint) -> *mut c_void; +pub fn CompileEventHandler(cx: *mut JSContext, name: *const libc::c_char, + nargs: libc::c_uint, argnames: *const *const libc::c_char, + chars: *const u16, length: libc::size_t, + url: *const libc::c_char, lineNo: libc::c_uint) -> *mut JSObject; + +pub fn proxy_LookupGeneric(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + objp: JSMutableHandleObject, propp: MutableHandle<*mut c_void>) -> bool; +pub fn proxy_LookupProperty(cx: *mut JSContext, obj: JSHandleObject, name: Handle<*mut c_void>, + objp: JSMutableHandleObject, propp: MutableHandle<*mut c_void>) -> bool; +pub fn proxy_LookupElement(cx: *mut JSContext, obj: JSHandleObject, index: u32, + objp: JSMutableHandleObject, propp: MutableHandle<*mut c_void>) -> bool; +pub fn proxy_DefineGeneric(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + value: JSHandleValue, getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: libc::c_uint) -> bool; +pub fn proxy_DefineProperty(cx: *mut JSContext, obj: JSHandleObject, name: Handle<*mut c_void>, + value: JSHandleValue, getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: libc::c_uint) -> bool; +pub fn proxy_DefineElement(cx: *mut JSContext, obj: JSHandleObject, index: u32, + value: JSHandleValue, getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: libc::c_uint) -> bool; +pub fn proxy_GetGeneric(cx: *mut JSContext, obj: JSHandleObject, receiver: JSHandleObject, + id: JSHandleId, vp: JSMutableHandleValue) -> bool; +pub fn proxy_GetProperty(cx: *mut JSContext, obj: JSHandleObject, receiver: JSHandleObject, + name: Handle<*mut c_void>, vp: JSMutableHandleValue) -> bool; +pub fn proxy_GetElement(cx: *mut JSContext, obj: JSHandleObject, receiver: JSHandleObject, + index: u32, vp: JSMutableHandleValue) -> bool; +pub fn proxy_SetGeneric(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + bp: JSMutableHandleValue, strict: bool) -> bool; +pub fn proxy_SetProperty(cx: *mut JSContext, obj: JSHandleObject, name: Handle<*mut c_void>, + bp: JSMutableHandleValue, strict: bool) -> bool; +pub fn proxy_SetElement(cx: *mut JSContext, obj: JSHandleObject, index: u32, + vp: JSMutableHandleValue, strict: bool) -> bool; +pub fn proxy_GetGenericAttributes(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + attrsp: *mut libc::c_uint) -> bool; +pub fn proxy_SetGenericAttributes(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + attrsp: *mut libc::c_uint) -> bool; +pub fn proxy_DeleteProperty(cx: *mut JSContext, obj: JSHandleObject, name: Handle<*mut c_void>, + succeeded: *mut bool) -> bool; +pub fn proxy_DeleteElement(cx: *mut JSContext, obj: JSHandleObject, index: u32, + succeeded: *mut bool) -> bool; +pub fn proxy_Trace(cx: *mut JSTracer, obj: *mut JSObject); +pub fn proxy_WeakmapKeyDelegate(obj: *mut JSObject) -> *mut JSObject; +pub fn proxy_Convert(cx: *mut JSContext, obj: JSHandleObject, hint: Enum_JSType, + vp: JSMutableHandleValue) -> bool; +pub fn proxy_Finalize(fop: *mut Struct_JSFreeOp, obj: *mut JSObject); +pub fn proxy_HasInstance(cx: *mut JSContext, proxy: JSHandleObject, v: JSMutableHandleValue, + bp: *mut bool) -> bool; +pub fn proxy_Call(cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal) -> bool; +pub fn proxy_Construct(cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal) -> bool; +pub fn proxy_innerObject(cx: *mut JSContext, obj: JSHandleObject) -> *mut JSObject; +pub fn proxy_Watch(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + callable: JSHandleObject) -> bool; +pub fn proxy_Unwatch(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId) -> bool; +pub fn proxy_Slice(cx: *mut JSContext, obj: JSHandleObject, begin: u32, end: u32, + result: JSHandleObject) -> bool; + +pub fn objectNeedsPostBarrier(obj: *mut JSObject) -> bool; +pub fn objectPostBarrier(obj: *mut *mut JSObject); +pub fn objectRelocate(obj: *mut *mut JSObject); +pub fn objectIsPoisoned(obj: *mut JSObject) -> bool; + +pub fn getPersistentRootedObjectList(rt: *mut JSRuntime) -> *mut libc::c_void; +pub fn insertObjectLinkedListElement(list: *mut libc::c_void, elem: *mut libc::c_void); } diff --git a/src/jsapi.rs b/src/jsapi.rs index a2c27b55a..2b5daeebb 100644 --- a/src/jsapi.rs +++ b/src/jsapi.rs @@ -1,182 +1,401 @@ -/* automatically generated by rust-bindgen */ - -use libc::*; -use jsfriendapi::JSJitInfo; -use jsval::JSVal; - -pub enum JSString {} -pub enum JSFlatString {} -pub enum JSObject {} -pub enum JSScript {} -pub enum JSFunction {} -pub enum JSContext {} -pub enum JSRuntime {} -pub enum JSIdArray {} -pub enum JSExceptionState {} -pub enum JSStructuredCloneReader {} -pub enum JSStructuredCloneWriter {} -pub enum JSCompartment {} -pub enum JSCrossCompartmentCall {} -pub type JSBool = c_int; -pub type jschar = uint16_t; -pub type jsid = ptrdiff_t; -pub type JSCallOnceType = JSBool; -pub type JSInitCallback = *mut u8; +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ -pub type JSProtoKey = c_uint; -pub static JSProto_LIMIT: JSProtoKey = 41; +#![allow(non_uppercase_statics, non_camel_case_types, ctypes)] -#[repr(u32)] -pub enum JSVersion { - JSVERSION_DEFAULT = 0, - JSVERSION_LATEST = 185 -} - -#[repr(u32)] -pub enum JSIterateOp { - JSENUMERATE_INIT = 0, - JSENUMERATE_INIT_ALL = 1, - JSENUMERATE_NEXT = 2, - JSENUMERATE_DESTROY = 3, -} - -#[repr(u32)] -pub enum JSType { - JSTYPE_VOID, /* undefined */ - JSTYPE_OBJECT, /* object */ - JSTYPE_FUNCTION, /* function */ - JSTYPE_STRING, /* string */ - JSTYPE_NUMBER, /* number */ - JSTYPE_BOOLEAN, /* boolean */ - JSTYPE_NULL, /* null */ - JSTYPE_XML, /* xml object */ - JSTYPE_LIMIT -} - -#[repr(u32)] -pub enum JSAccessMode { - JSACC_PROTO = 0, - JSACC_WATCH = 3, - JSACC_READ = 4, - JSACC_WRITE = 8, - JSACC_LIMIT -} +use jsfriendapi::JSJitInfo; -#[repr(u32)] -pub enum JSGCTraceKind { - JSTRACE_OBJECT = 0, - JSTRACE_STRING = 1, - JSTRACE_SCRIPT = 2, -} +use jsval::JSVal; +//more custom additions at bottom -pub static JS_DEFAULT_ZEAL_FREQ: u32 = 100; +/* automatically generated by rust-bindgen */ -pub type moz_static_assert6 = [c_int, ..1u]; -pub struct JSHandleObject { - pub unnamed_field1: *mut *mut JSObject, -} -pub struct JSHandleValue { - pub unnamed_field1: JSVal, +use libc::*; +pub type Struct_JSContext = JSContext; +pub type jschar = u16; //jdm c_void->u16 +pub type MozMallocSizeOf = + ::std::option::Option size_t>; +pub type Enum_JSVersion = c_int; +pub static JSVERSION_ECMA_3: c_int = 148; +pub static JSVERSION_1_6: c_int = 160; +pub static JSVERSION_1_7: c_int = 170; +pub static JSVERSION_1_8: c_int = 180; +pub static JSVERSION_ECMA_5: c_int = 185; +pub static JSVERSION_DEFAULT: c_int = 0; +pub static JSVERSION_UNKNOWN: c_int = -1; +pub static JSVERSION_LATEST: c_int = 185; +pub type Enum_JSType = c_uint; +pub static JSTYPE_VOID: c_uint = 0; +pub static JSTYPE_OBJECT: c_uint = 1; +pub static JSTYPE_FUNCTION: c_uint = 2; +pub static JSTYPE_STRING: c_uint = 3; +pub static JSTYPE_NUMBER: c_uint = 4; +pub static JSTYPE_BOOLEAN: c_uint = 5; +pub static JSTYPE_NULL: c_uint = 6; +pub static JSTYPE_LIMIT: c_uint = 7; +pub type Enum_JSProtoKey = c_uint; +pub static JSProto_Null: c_uint = 0; +pub static JSProto_Object: c_uint = 1; +pub static JSProto_Function: c_uint = 2; +pub static JSProto_Array: c_uint = 3; +pub static JSProto_Boolean: c_uint = 4; +pub static JSProto_JSON: c_uint = 5; +pub static JSProto_Date: c_uint = 6; +pub static JSProto_Math: c_uint = 7; +pub static JSProto_Number: c_uint = 8; +pub static JSProto_String: c_uint = 9; +pub static JSProto_RegExp: c_uint = 10; +pub static JSProto_Error: c_uint = 11; +pub static JSProto_InternalError: c_uint = 12; +pub static JSProto_EvalError: c_uint = 13; +pub static JSProto_RangeError: c_uint = 14; +pub static JSProto_ReferenceError: c_uint = 15; +pub static JSProto_SyntaxError: c_uint = 16; +pub static JSProto_TypeError: c_uint = 17; +pub static JSProto_URIError: c_uint = 18; +pub static JSProto_Iterator: c_uint = 19; +pub static JSProto_StopIteration: c_uint = 20; +pub static JSProto_ArrayBuffer: c_uint = 21; +pub static JSProto_Int8Array: c_uint = 22; +pub static JSProto_Uint8Array: c_uint = 23; +pub static JSProto_Int16Array: c_uint = 24; +pub static JSProto_Uint16Array: c_uint = 25; +pub static JSProto_Int32Array: c_uint = 26; +pub static JSProto_Uint32Array: c_uint = 27; +pub static JSProto_Float32Array: c_uint = 28; +pub static JSProto_Float64Array: c_uint = 29; +pub static JSProto_Uint8ClampedArray: c_uint = 30; +pub static JSProto_Proxy: c_uint = 31; +pub static JSProto_WeakMap: c_uint = 32; +pub static JSProto_Map: c_uint = 33; +pub static JSProto_Set: c_uint = 34; +pub static JSProto_DataView: c_uint = 35; +pub static JSProto_SharedArrayBuffer: c_uint = 36; +pub static JSProto_Intl: c_uint = 37; +pub static JSProto_TypedObject: c_uint = 38; +pub static JSProto_GeneratorFunction: c_uint = 39; +pub static JSProto_SIMD: c_uint = 40; +pub static JSProto_LIMIT: c_uint = 41; +pub type Enum_JSIterateOp = c_uint; +pub static JSENUMERATE_INIT: c_uint = 0; +pub static JSENUMERATE_INIT_ALL: c_uint = 1; +pub static JSENUMERATE_NEXT: c_uint = 2; +pub static JSENUMERATE_DESTROY: c_uint = 3; +pub type Enum_JSGCTraceKind = c_uint; +pub static JSTRACE_OBJECT: c_uint = 0; +pub static JSTRACE_STRING: c_uint = 1; +pub static JSTRACE_SCRIPT: c_uint = 2; +pub static JSTRACE_LAZY_SCRIPT: c_uint = 3; +pub static JSTRACE_JITCODE: c_uint = 4; +pub static JSTRACE_SHAPE: c_uint = 5; +pub static JSTRACE_BASE_SHAPE: c_uint = 6; +pub static JSTRACE_TYPE_OBJECT: c_uint = 7; +pub static JSTRACE_LAST: c_uint = 7; +pub type Struct_JSCompartment = c_void; +pub type Struct_JSCrossCompartmentCall = c_void; +pub type Struct_JSExceptionState = c_void; +pub type Struct_JSIdArray = c_void; +pub type Struct_JSObjectMap = c_void; +pub type Struct_JSPropertyName = c_void; +pub type Struct_JSRuntime = JSRuntime; +pub type Struct_JSStructuredCloneCallbacks = c_void; +pub type Struct_JSStructuredCloneReader = c_void; +pub type Struct_JSStructuredCloneWriter = c_void; +pub type Struct_PRCallOnceType = c_void; +pub type JSCallOnceType = Struct_PRCallOnceType; +pub type JSInitCallback = ::std::option::Option bool>; +pub type JSTraceDataOp = + ::std::option::Option; //jdm void->jstracer +pub type Enum_JSValueType = c_uchar; +pub static JSVAL_TYPE_DOUBLE: c_uchar = 0; +pub static JSVAL_TYPE_INT32: c_uchar = 1; +pub static JSVAL_TYPE_UNDEFINED: c_uchar = 2; +pub static JSVAL_TYPE_BOOLEAN: c_uchar = 3; +pub static JSVAL_TYPE_MAGIC: c_uchar = 4; +pub static JSVAL_TYPE_STRING: c_uchar = 5; +pub static JSVAL_TYPE_NULL: c_uchar = 6; +pub static JSVAL_TYPE_OBJECT: c_uchar = 7; +pub static JSVAL_TYPE_UNKNOWN: c_uchar = 32; +pub static JSVAL_TYPE_MISSING: c_uchar = 33; +pub type Enum_JSValueTag = c_uint; +pub static JSVAL_TAG_MAX_DOUBLE: c_uint = 131056; +pub static JSVAL_TAG_INT32: c_uint = 131057; +pub static JSVAL_TAG_UNDEFINED: c_uint = 131058; +pub static JSVAL_TAG_STRING: c_uint = 131061; +pub static JSVAL_TAG_BOOLEAN: c_uint = 131059; +pub static JSVAL_TAG_MAGIC: c_uint = 131060; +pub static JSVAL_TAG_NULL: c_uint = 131062; +pub static JSVAL_TAG_OBJECT: c_uint = 131063; +pub type Enum_JSValueShiftedTag = c_ulong; +pub static JSVAL_SHIFTED_TAG_MAX_DOUBLE: c_ulong = -2251795518717953; +pub static JSVAL_SHIFTED_TAG_INT32: c_ulong = -2111062325329920; +pub static JSVAL_SHIFTED_TAG_UNDEFINED: c_ulong = -1970324836974592; +pub static JSVAL_SHIFTED_TAG_STRING: c_ulong = -1548112371908608; +pub static JSVAL_SHIFTED_TAG_BOOLEAN: c_ulong = -1829587348619264; +pub static JSVAL_SHIFTED_TAG_MAGIC: c_ulong = -1688849860263936; +pub static JSVAL_SHIFTED_TAG_NULL: c_ulong = -1407374883553280; +pub static JSVAL_SHIFTED_TAG_OBJECT: c_ulong = -1266637395197952; +pub type Enum_JSWhyMagic = c_uint; +pub static JS_ELEMENTS_HOLE: c_uint = 0; +pub static JS_NATIVE_ENUMERATE: c_uint = 1; +pub static JS_NO_ITER_VALUE: c_uint = 2; +pub static JS_GENERATOR_CLOSING: c_uint = 3; +pub static JS_NO_CONSTANT: c_uint = 4; +pub static JS_THIS_POISON: c_uint = 5; +pub static JS_ARG_POISON: c_uint = 6; +pub static JS_SERIALIZE_NO_NODE: c_uint = 7; +pub static JS_LAZY_ARGUMENTS: c_uint = 8; +pub static JS_OPTIMIZED_ARGUMENTS: c_uint = 9; +pub static JS_IS_CONSTRUCTING: c_uint = 10; +pub static JS_OVERWRITTEN_CALLEE: c_uint = 11; +pub static JS_BLOCK_NEEDS_CLONE: c_uint = 12; +pub static JS_HASH_KEY_EMPTY: c_uint = 13; +pub static JS_ION_ERROR: c_uint = 14; +pub static JS_ION_BAILOUT: c_uint = 15; +pub static JS_OPTIMIZED_OUT: c_uint = 16; +pub static JS_GENERIC_MAGIC: c_uint = 17; +pub type JSWhyMagic = Enum_JSWhyMagic; +/*pub struct Union_jsval_layout { //jdm moved to jsval.rs + pub data: [u64, ..1u], } -pub struct JSHandleString { - pub unnamed_field1: *mut *mut JSString, +impl Union_jsval_layout { + pub fn asBits(&mut self) -> *mut uint64_t { + unsafe { ::std::mem::transmute(self) } + } + pub fn debugView(&mut self) -> *mut Struct_Unnamed1 { + unsafe { ::std::mem::transmute(self) } + } + pub fn s(&mut self) -> *mut Struct_Unnamed2 { + unsafe { ::std::mem::transmute(self) } + } + pub fn asDouble(&mut self) -> *mut c_double { + unsafe { ::std::mem::transmute(self) } + } + pub fn asPtr(&mut self) -> *mut *mut c_void { + unsafe { ::std::mem::transmute(self) } + } + pub fn asWord(&mut self) -> *mut size_t { + unsafe { ::std::mem::transmute(self) } + } + pub fn asUIntPtr(&mut self) -> *mut uintptr_t { + unsafe { ::std::mem::transmute(self) } + } +}*/ +//pub struct Struct_Unnamed1 { +// payload47: uint64_t, +// tag: Enum_JSValueTag, +//} +pub struct Struct_Unnamed2 { + pub payload: Union_Unnamed3, } -pub struct JSMutableHandleObject { - pub unnamed_field1: *mut *mut JSObject, +pub struct Union_Unnamed3 { + pub data: [u32, ..1u], } -pub struct JSHandleId { - pub unnamed_field1: *mut jsid, +impl Union_Unnamed3 { + pub fn i32(&mut self) -> *mut int32_t { + unsafe { ::std::mem::transmute(self) } + } + pub fn u32(&mut self) -> *mut uint32_t { + unsafe { ::std::mem::transmute(self) } + } + pub fn why(&mut self) -> *mut JSWhyMagic { + unsafe { ::std::mem::transmute(self) } + } } -pub struct JSMutableHandleValue { - pub unnamed_field1: *mut JSVal, +//pub type jsval_layout = Union_jsval_layout; +//pub type jsval = c_void; //jdm +pub type JSNative = + ::std::option::Option bool>; //jdm c_void->jsval +pub type JSParallelNative = + ::std::option::Option bool>; +pub type JSThreadSafeNative = + ::std::option::Option bool>; +#[repr(C)] +pub struct Struct_jsid { + asBits: size_t, } -pub type JSRawObject = *mut JSObject; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSPropertyOp = - Option JSBool>; + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSStrictPropertyOp = - Option JSBool>; + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +pub type JSDeletePropertyOp = + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSNewEnumerateOp = - Option JSBool>; + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSEnumerateOp = - Option JSBool>; + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSResolveOp = - Option JSBool>; + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSNewResolveOp = - Option JSBool>; + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSConvertOp = - Option JSBool>; -pub type JSTypeOfOp = - Option JSType>; -pub struct JSFreeOp { - pub runtime: *mut JSRuntime, -} + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSFinalizeOp = - Option; -pub struct JSStringFinalizer { - pub finalize: Option, + ::std::option::Option; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSStringFinalizer { + finalize: ::std::option::Option, } -pub type JSCheckAccessOp = - Option JSBool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSHasInstanceOp = - Option JSBool>; + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSTraceOp = - Option; + ::std::option::Option; //jdm c_void->... +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +pub type JSObjectOp = + ::std::option::Option *mut JSObject>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +pub type JSIteratorOp = + ::std::option::Option *mut JSObject>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +pub type JSWeakmapKeyDelegateOp = + ::std::option::Option *mut JSObject>; //jdm +unsafe +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +pub type JSClassInternal = ::std::option::Option; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSClass { + pub name: *const c_schar, + pub flags: uint32_t, + pub addProperty: JSPropertyOp, + pub delProperty: JSDeletePropertyOp, + pub getProperty: JSPropertyOp, + pub setProperty: JSStrictPropertyOp, + pub enumerate: JSEnumerateOp, + pub resolve: JSResolveOp, + pub convert: JSConvertOp, + pub finalize: JSFinalizeOp, + pub call: JSNative, + pub hasInstance: JSHasInstanceOp, + pub construct: JSNative, + pub trace: JSTraceOp, + pub reserved: [*mut c_void, ..31u], +} +//pub struct Struct_JSPrincipals { +// refcount: c_void, +//} +pub enum Struct_JSPrincipals {} +pub type JSSubsumesOp = + ::std::option::Option bool>; +pub type JSCSPEvalChecker = + ::std::option::Option bool>; +#[repr(C)] +pub struct Struct_JSSecurityCallbacks { + contentSecurityPolicyAllows: JSCSPEvalChecker, + subsumes: JSSubsumesOp, +} +pub type JSDestroyPrincipalsOp = + ::std::option::Option; +pub type JSTraceCallback = + ::std::option::Option; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSTraceNamePrinter = - Option; -pub type JSEqualityOp = - Option JSBool>; -pub type JSNative = - Option JSBool>; + ::std::option::Option; +pub type Enum_WeakMapTraceKind = c_uint; +pub static DoNotTraceWeakMaps: c_uint = 0; +pub static TraceWeakMapValues: c_uint = 1; +pub static TraceWeakMapKeysValues: c_uint = 2; +//pub struct Struct_JSFreeOp { +// runtime_: *mut Struct_JSRuntime, +//} +pub enum Struct_JSFreeOp {} pub type Enum_JSContextOp = c_uint; pub static JSCONTEXT_NEW: c_uint = 0; pub static JSCONTEXT_DESTROY: c_uint = 1; pub type JSContextOp = Enum_JSContextOp; pub type JSContextCallback = - Option JSBool>; + ::std::option::Option bool>; pub type Enum_JSGCStatus = c_uint; pub static JSGC_BEGIN: c_uint = 0; pub static JSGC_END: c_uint = 1; pub type JSGCStatus = Enum_JSGCStatus; pub type JSGCCallback = - Option; + ::std::option::Option; pub type Enum_JSFinalizeStatus = c_uint; -pub static JSFINALIZE_START: c_uint = 0; -pub static JSFINALIZE_END: c_uint = 1; +pub static JSFINALIZE_GROUP_START: c_uint = 0; +pub static JSFINALIZE_GROUP_END: c_uint = 1; +pub static JSFINALIZE_COLLECTION_END: c_uint = 2; pub type JSFinalizeStatus = Enum_JSFinalizeStatus; pub type JSFinalizeCallback = - Option; -pub type JSTraceDataOp = - Option; -pub type JSOperationCallback = - Option JSBool>; + ::std::option::Option; +pub type JSInterruptCallback = + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSErrorReporter = - Option; + ::std::option::Option; pub type Enum_JSExnType = c_int; pub static JSEXN_NONE: c_int = -1; pub static JSEXN_ERR: c_int = 0; @@ -189,91 +408,89 @@ pub static JSEXN_TYPEERR: c_int = 6; pub static JSEXN_URIERR: c_int = 7; pub static JSEXN_LIMIT: c_int = 8; pub type JSExnType = Enum_JSExnType; -pub struct JSErrorFormatString { - pub format: *const c_char, +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSErrorFormatString { + pub format: *const c_schar, pub argCount: uint16_t, pub exnType: int16_t, } + +pub type JSErrorFormatString = Struct_JSErrorFormatString; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSErrorCallback = - Option *const JSErrorFormatString>; + ::std::option::Option *const JSErrorFormatString>; pub type JSLocaleToUpperCase = - Option JSBool>; + ::std::option::Option bool>; pub type JSLocaleToLowerCase = - Option JSBool>; + ::std::option::Option bool>; pub type JSLocaleCompare = - Option JSBool>; + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSLocaleToUnicode = - Option JSBool>; -pub type JSDestroyPrincipalsOp = - Option; -pub type JSSubsumePrincipalsOp = - Option JSBool>; -pub type JSObjectPrincipalsFinder = - Option *mut JSPrincipals>; -pub type JSCSPEvalChecker = - Option JSBool>; + ::std::option::Option bool>; pub type JSWrapObjectCallback = - Option *mut JSObject>; + ::std::option::Option *mut c_void>; pub type JSPreWrapCallback = - Option *mut JSObject>; -pub type JSSameCompartmentWrapObjectCallback = - Option *mut JSObject>; + ::std::option::Option *mut c_void>; +#[repr(C)] +pub struct Struct_JSWrapObjectCallbacks { + pub wrap: JSWrapObjectCallback, + pub preWrap: JSPreWrapCallback, +} + pub type JSDestroyCompartmentCallback = - Option; + ::std::option::Option; +pub type JSZoneCallback = + ::std::option::Option; pub type JSCompartmentNameCallback = - Option; -pub type ReadStructuredCloneOp = - Option *mut JSObject>; -pub type WriteStructuredCloneOp = - Option JSBool>; -pub type StructuredCloneErrorOp = - Option; + ::std::option::Option; +pub type Enum_JSUseHelperThreads = c_uint; +pub static JS_NO_HELPER_THREADS: c_uint = 0; +pub static JS_USE_HELPER_THREADS: c_uint = 1; +pub type JSUseHelperThreads = Enum_JSUseHelperThreads; +pub type JS_ICUAllocFn = + ::std::option::Option *mut c_void>; +pub type JS_ICUReallocFn = + ::std::option::Option *mut c_void>; +pub type JS_ICUFreeFn = + ::std::option::Option; pub type JSIterateCompartmentCallback = - Option; + ::std::option::Option; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSEnumerateDiagnosticMemoryCallback = - Option JSBool>; -pub type Enum_JSGCRootType = c_uint; -pub static JS_GC_ROOT_VALUE_PTR: c_uint = 0; -pub static JS_GC_ROOT_GCTHING_PTR: c_uint = 1; -pub type JSGCRootType = Enum_JSGCRootType; -pub type JSGCRootMapFun = - Option c_int>; -pub type JSTraceCallback = - Option; -pub struct JSTracer { - pub runtime: *mut JSRuntime, - pub callback: JSTraceCallback, - pub debugPrinter: JSTraceNamePrinter, - pub debugPrintArg: *const c_void, - pub debugPrintIndex: size_t, - pub eagerlyTraceWeakMaps: JSBool, - pub realLocation: *mut c_void, -} + ::std::option::Option bool>; pub type Enum_JSGCParamKey = c_uint; pub static JSGC_MAX_BYTES: c_uint = 0; pub static JSGC_MAX_MALLOC_BYTES: c_uint = 1; @@ -293,106 +510,114 @@ pub static JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN: c_uint = 15; pub static JSGC_LOW_FREQUENCY_HEAP_GROWTH: c_uint = 16; pub static JSGC_DYNAMIC_HEAP_GROWTH: c_uint = 17; pub static JSGC_DYNAMIC_MARK_SLICE: c_uint = 18; -pub static JSGC_ANALYSIS_PURGE_TRIGGER: c_uint = 19; +pub static JSGC_ALLOCATION_THRESHOLD: c_uint = 19; +pub static JSGC_DECOMMIT_THRESHOLD: c_uint = 20; pub type JSGCParamKey = Enum_JSGCParamKey; -pub type Enum_JSGCMode = c_uint; -pub static JSGC_MODE_GLOBAL: c_uint = 0; -pub static JSGC_MODE_COMPARTMENT: c_uint = 1; -pub static JSGC_MODE_INCREMENTAL: c_uint = 2; -pub type JSGCMode = Enum_JSGCMode; -pub type JSClassInternal = Option; -pub struct JSClass { - pub name: *const c_char, - pub flags: uint32_t, - pub addProperty: JSPropertyOp, - pub delProperty: JSPropertyOp, - pub getProperty: JSPropertyOp, - pub setProperty: JSStrictPropertyOp, - pub enumerate: JSEnumerateOp, - pub resolve: JSResolveOp, - pub convert: JSConvertOp, - pub finalize: JSFinalizeOp, - pub checkAccess: JSCheckAccessOp, - pub call: JSNative, - pub hasInstance: JSHasInstanceOp, - pub construct: JSNative, - pub trace: JSTraceOp, - pub reserved: [*mut c_void, ..40u], -} -pub struct JSConstDoubleSpec { - pub dval: c_double, - pub name: *const c_char, - pub flags: uint8_t, - pub spare: [uint8_t, ..3u], +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSConstDoubleSpec { + dval: c_double, + name: *const c_schar, + flags: uint8_t, + spare: [uint8_t, ..3u], } -pub struct JSStrictPropertyOpWrapper { - pub op: JSNative, - pub info: *const JSJitInfo, +//pub type Struct_JSJitInfo = c_void; //jdm property defn in jsfriendapi.h +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSStrictPropertyOpWrapper { + pub op: JSStrictPropertyOp, + pub info: *const Struct_JSJitInfo, } -pub struct JSPropertyOpWrapper { - pub op: JSNative, - pub info: *const JSJitInfo, +pub type JSStrictPropertyOpWrapper = Struct_JSStrictPropertyOpWrapper; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSPropertyOpWrapper { + pub op: JSPropertyOp, + pub info: *const Struct_JSJitInfo, } -pub struct JSNativeWrapper { +pub type JSPropertyOpWrapper = Struct_JSPropertyOpWrapper; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSNativeWrapper { pub op: JSNative, - pub info: *const JSJitInfo, + pub info: *const Struct_JSJitInfo, } -pub struct JSPropertySpec { - pub name: *const c_char, - pub tinyid: int8_t, +pub type JSNativeWrapper = Struct_JSNativeWrapper; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSPropertySpec { + pub name: *const c_schar, pub flags: uint8_t, - pub getter: JSPropertyOpWrapper, - pub setter: JSStrictPropertyOpWrapper, + pub getter: JSNativeWrapper, //jdm in practice this is always a native, not a property op + pub setter: JSNativeWrapper, //jdm in practice this is always a native, not a strict property op } -pub struct JSFunctionSpec { - pub name: *const c_char, +//pub struct Struct_SelfHostedWrapper { +// unused: *mut c_void, +// funname: *const c_schar, +//} +//pub struct Union_Unnamed4 { +// data: [u64, ..2u], +//} +//impl Union_Unnamed4 { +// pub fn propertyOp(&mut self) -> *mut JSPropertyOpWrapper { +// unsafe { ::std::cast::transmute(self) } +// } +// pub fn selfHosted(&mut self) -> *mut Struct_SelfHostedWrapper { +// unsafe { ::std::cast::transmute(self) } +// } +//} +//pub struct Union_Unnamed5 { +// data: [u64, ..2u], +//} +//impl Union_Unnamed5 { +// pub fn propertyOp(&mut self) -> *mut JSStrictPropertyOpWrapper { +// unsafe { ::std::cast::transmute(self) } +// } +// pub fn selfHosted(&mut self) -> *mut Struct_SelfHostedWrapper { +// unsafe { ::std::cast::transmute(self) } +// } +//} +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSFunctionSpec { + pub name: *const c_schar, pub call: JSNativeWrapper, pub nargs: uint16_t, pub flags: uint16_t, - pub selfHostedName: *const c_char, + pub selfHostedName: *const c_schar, } -pub struct JSPropertyDescriptor { +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSPropertyDescriptor { pub obj: *mut JSObject, pub attrs: c_uint, - pub shortid: c_uint, pub getter: JSPropertyOp, pub setter: JSStrictPropertyOp, - pub value: JSVal, -} -pub struct JSPrincipals { - pub refcount: c_int, -} -pub struct JSSecurityCallbacks { - pub checkObjectAccess: JSCheckAccessOp, - pub subsumePrincipals: JSSubsumePrincipalsOp, - pub findObjectPrincipals: JSObjectPrincipalsFinder, - pub contentSecurityPolicyAllows: JSCSPEvalChecker, + pub value: jsval, //jdm c_void->JSVal } -pub type Enum_JSExecPart = c_uint; -pub static JSEXEC_PROLOG: c_uint = 0; -pub static JSEXEC_MAIN: c_uint = 1; -pub type JSExecPart = Enum_JSExecPart; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 pub type JSONWriteCallback = - Option JSBool>; -pub struct JSStructuredCloneCallbacks { - pub read: ReadStructuredCloneOp, - pub write: WriteStructuredCloneOp, - pub reportError: StructuredCloneErrorOp, + ::std::option::Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSLocaleCallbacks { + localeToUpperCase: JSLocaleToUpperCase, + localeToLowerCase: JSLocaleToLowerCase, + localeCompare: JSLocaleCompare, + localeToUnicode: JSLocaleToUnicode, + localeGetErrorMessage: JSErrorCallback, } -pub struct JSLocaleCallbacks { - pub localeToUpperCase: JSLocaleToUpperCase, - pub localeToLowerCase: JSLocaleToLowerCase, - pub localeCompare: JSLocaleCompare, - pub localeToUnicode: JSLocaleToUnicode, - pub localeGetErrorMessage: JSErrorCallback, -} -pub struct JSErrorReport { - pub filename: *const c_char, - pub originPrincipals: *mut JSPrincipals, + +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct Struct_JSErrorReport { + pub filename: *const c_schar, + pub originPrincipals: *mut Struct_JSPrincipals, pub lineno: c_uint, - pub linebuf: *const c_char, - pub tokenptr: *const c_char, + pub linebuf: *const c_schar, + pub tokenptr: *const c_schar, pub uclinebuf: *const jschar, pub uctokenptr: *const jschar, pub flags: c_uint, @@ -409,852 +634,911 @@ pub static JSREPORT_EXCEPTION: c_uint = 0x2; pub static JSREPORT_STRICT: c_uint = 0x4; pub static JSREPORT_STRICT_MODE_ERROR: c_uint = 0x8; -extern "C" { -pub fn JS_CreateHandleObject(cx: *mut JSContext, obj: *mut JSObject, phandle: *mut JSHandleObject) -> JSBool; - -pub fn JS_DestroyHandleObject(cx: *mut JSContext, handle: JSHandleObject); - -pub fn JS_CreateMutableHandleObject(cx: *mut JSContext, obj: *mut JSObject, phandle: *mut JSMutableHandleObject) -> JSBool; - -pub fn JS_DestroyMutableHandleObject(cx: *mut JSContext, handle: JSMutableHandleObject); - -pub fn JS_CreateHandleId(cx: *mut JSContext, id: jsid, phandle: *mut JSHandleId) -> JSBool; - -pub fn JS_DestroyHandleId(cx: *mut JSContext, handle: JSHandleId); - -pub fn JS_StringHasBeenInterned(cx: *mut JSContext, str: *mut JSString) -> JSBool; - -pub fn INTERNED_STRING_TO_JSID(cx: *mut JSContext, str: *mut JSString) -> jsid; - -pub fn JS_CallOnce(_once: *mut JSCallOnceType, func: JSInitCallback) -> JSBool; - -pub fn JS_Now() -> int64_t; - -pub fn JS_GetNaNValue(cx: *mut JSContext) -> JSVal; - -pub fn JS_GetNegativeInfinityValue(cx: *mut JSContext) -> JSVal; - -pub fn JS_GetPositiveInfinityValue(cx: *mut JSContext) -> JSVal; - -pub fn JS_GetEmptyStringValue(cx: *mut JSContext) -> JSVal; - -pub fn JS_GetEmptyString(rt: *mut JSRuntime) -> *mut JSString; - -pub fn JS_ConvertArguments(cx: *mut JSContext, argc: c_uint, argv: *mut JSVal, format: *const c_char, ...) -> JSBool; - -pub fn JS_ConvertValue(cx: *mut JSContext, v: JSVal, _type: JSType, vp: *mut JSVal) -> JSBool; - -pub fn JS_ValueToObject(cx: *mut JSContext, v: JSVal, objp: *mut *mut JSObject) -> JSBool; - -pub fn JS_ValueToFunction(cx: *mut JSContext, v: JSVal) -> *mut JSFunction; - -pub fn JS_ValueToConstructor(cx: *mut JSContext, v: JSVal) -> *mut JSFunction; - -pub fn JS_ValueToString(cx: *mut JSContext, v: JSVal) -> *mut JSString; - -pub fn JS_ValueToSource(cx: *mut JSContext, v: JSVal) -> *mut JSString; - -pub fn JS_ValueToNumber(cx: *mut JSContext, v: JSVal, dp: *mut c_double) -> JSBool; - -pub fn JS_DoubleIsInt32(d: c_double, ip: *mut int32_t) -> JSBool; - -pub fn JS_DoubleToInt32(d: c_double) -> int32_t; - -pub fn JS_DoubleToUint32(d: c_double) -> uint32_t; - -pub fn JS_ValueToECMAInt32(cx: *mut JSContext, v: JSVal, ip: *mut int32_t) -> JSBool; - -pub fn JS_ValueToInt64(cx: *mut JSContext, v: JSVal, ip: *mut int64_t) -> JSBool; - -pub fn JS_ValueToUint64(cx: *mut JSContext, v: JSVal, ip: *mut uint64_t) -> JSBool; - -pub fn JS_ValueToECMAUint32(cx: *mut JSContext, v: JSVal, ip: *mut uint32_t) -> JSBool; - -pub fn JS_ValueToInt32(cx: *mut JSContext, v: JSVal, ip: *mut int32_t) -> JSBool; - -pub fn JS_ValueToUint16(cx: *mut JSContext, v: JSVal, ip: *mut uint16_t) -> JSBool; - -pub fn JS_ValueToBoolean(cx: *mut JSContext, v: JSVal, bp: *mut JSBool) -> JSBool; - -pub fn JS_TypeOfValue(cx: *mut JSContext, v: JSVal) -> JSType; - -pub fn JS_GetTypeName(cx: *mut JSContext, _type: JSType) -> *const c_char; - -pub fn JS_StrictlyEqual(cx: *mut JSContext, v1: JSVal, v2: JSVal, equal: *mut JSBool) -> JSBool; - -pub fn JS_LooselyEqual(cx: *mut JSContext, v1: JSVal, v2: JSVal, equal: *mut JSBool) -> JSBool; - -pub fn JS_SameValue(cx: *mut JSContext, v1: JSVal, v2: JSVal, same: *mut JSBool) -> JSBool; - -pub fn JS_IsBuiltinEvalFunction(fun: *mut JSFunction) -> JSBool; - -pub fn JS_IsBuiltinFunctionConstructor(fun: *mut JSFunction) -> JSBool; - -pub fn JS_Init(maxbytes: uint32_t) -> *mut JSRuntime; - -pub fn JS_Finish(rt: *mut JSRuntime); - -pub fn JS_ShutDown(); - -pub fn JS_GetRuntimePrivate(rt: *mut JSRuntime) -> *mut c_void; - -pub fn JS_GetRuntime(cx: *mut JSContext) -> *mut JSRuntime; - -pub fn JS_SetRuntimePrivate(rt: *mut JSRuntime, data: *mut c_void); - -pub fn JS_BeginRequest(cx: *mut JSContext); - -pub fn JS_EndRequest(cx: *mut JSContext); - -pub fn JS_YieldRequest(cx: *mut JSContext); - -pub fn JS_SuspendRequest(cx: *mut JSContext) -> c_uint; - -pub fn JS_ResumeRequest(cx: *mut JSContext, saveDepth: c_uint); - -pub fn JS_IsInRequest(rt: *mut JSRuntime) -> JSBool; - -pub fn JS_IsInSuspendedRequest(rt: *mut JSRuntime) -> JSBool; - -pub fn JS_SetContextCallback(rt: *mut JSRuntime, cxCallback: JSContextCallback) -> JSContextCallback; - -pub fn JS_NewContext(rt: *mut JSRuntime, stackChunkSize: size_t) -> *mut JSContext; - -pub fn JS_DestroyContext(cx: *mut JSContext); - -pub fn JS_DestroyContextNoGC(cx: *mut JSContext); - -pub fn JS_GetContextPrivate(cx: *mut JSContext) -> *mut c_void; - -pub fn JS_SetContextPrivate(cx: *mut JSContext, data: *mut c_void); - -pub fn JS_GetSecondContextPrivate(cx: *mut JSContext) -> *mut c_void; - -pub fn JS_SetSecondContextPrivate(cx: *mut JSContext, data: *mut c_void); - -pub fn JS_ContextIterator(rt: *mut JSRuntime, iterp: *mut *mut JSContext) -> *mut JSContext; - -pub fn JS_GetVersion(cx: *mut JSContext) -> JSVersion; - -pub fn JS_SetVersion(cx: *mut JSContext, version: JSVersion) -> JSVersion; - -pub fn JS_VersionToString(version: JSVersion) -> *const c_char; - -pub fn JS_StringToVersion(string: *const c_char) -> JSVersion; - -pub fn JS_GetOptions(cx: *mut JSContext) -> uint32_t; - -pub fn JS_SetOptions(cx: *mut JSContext, options: uint32_t) -> uint32_t; - -pub fn JS_ToggleOptions(cx: *mut JSContext, options: uint32_t) -> uint32_t; - -pub fn JS_SetJitHardening(rt: *mut JSRuntime, enabled: JSBool); - -pub fn JS_GetImplementationVersion() -> *const c_char; - -pub fn JS_SetDestroyCompartmentCallback(rt: *mut JSRuntime, callback: JSDestroyCompartmentCallback); - -pub fn JS_SetCompartmentNameCallback(rt: *mut JSRuntime, callback: JSCompartmentNameCallback); - -pub fn JS_SetWrapObjectCallbacks(rt: *mut JSRuntime, callback: JSWrapObjectCallback, sccallback: JSSameCompartmentWrapObjectCallback, precallback: JSPreWrapCallback) -> JSWrapObjectCallback; - -pub fn JS_EnterCrossCompartmentCall(cx: *mut JSContext, target: JSRawObject) -> *mut JSCrossCompartmentCall; - -pub fn JS_LeaveCrossCompartmentCall(call: *mut JSCrossCompartmentCall); - -pub fn JS_SetCompartmentPrivate(compartment: *mut JSCompartment, data: *mut c_void); - -pub fn JS_GetCompartmentPrivate(compartment: *mut JSCompartment) -> *mut c_void; - -pub fn JS_WrapObject(cx: *mut JSContext, objp: *mut *mut JSObject) -> JSBool; - -pub fn JS_WrapValue(cx: *mut JSContext, vp: *mut JSVal) -> JSBool; - -pub fn JS_TransplantObject(cx: *mut JSContext, origobj: *mut JSObject, target: *mut JSObject) -> *mut JSObject; - -pub fn js_TransplantObjectWithWrapper(cx: *mut JSContext, origobj: *mut JSObject, origwrapper: *mut JSObject, targetobj: *mut JSObject, targetwrapper: *mut JSObject) -> *mut JSObject; - -pub fn JS_RefreshCrossCompartmentWrappers(cx: *mut JSContext, ob: *mut JSObject) -> JSBool; - -pub fn JS_IterateCompartments(rt: *mut JSRuntime, data: *mut c_void, compartmentCallback: JSIterateCompartmentCallback); - -pub fn JS_GetGlobalObject(cx: *mut JSContext) -> *mut JSObject; - -pub fn JS_SetGlobalObject(cx: *mut JSContext, obj: JSRawObject); - -pub fn JS_InitStandardClasses(cx: *mut JSContext, obj: *mut JSObject) -> JSBool; - -pub fn JS_ResolveStandardClass(cx: *mut JSContext, obj: *mut JSObject, id: jsid, resolved: *mut JSBool) -> JSBool; - -pub fn JS_EnumerateStandardClasses(cx: *mut JSContext, obj: *mut JSObject) -> JSBool; - -pub fn JS_EnumerateResolvedStandardClasses(cx: *mut JSContext, obj: *mut JSObject, ida: *mut JSIdArray) -> *mut JSIdArray; - -pub fn JS_GetClassObject(cx: *mut JSContext, obj: JSRawObject, key: JSProtoKey, objp: *mut *mut JSObject) -> JSBool; - -pub fn JS_GetClassPrototype(cx: *mut JSContext, key: JSProtoKey, objp: *mut *mut JSObject) -> JSBool; - -pub fn JS_IdentifyClassPrototype(cx: *mut JSContext, obj: *mut JSObject) -> JSProtoKey; - -pub fn JS_GetFunctionPrototype(cx: *mut JSContext, forObj: JSRawObject) -> *mut JSObject; - -pub fn JS_GetObjectPrototype(cx: *mut JSContext, forObj: JSRawObject) -> *mut JSObject; - -pub fn JS_GetGlobalForObject(cx: *mut JSContext, obj: JSRawObject) -> *mut JSObject; - -pub fn JS_GetGlobalForCompartmentOrNull(cx: *mut JSContext, c: *mut JSCompartment) -> *mut JSObject; - -pub fn JS_GetGlobalForScopeChain(cx: *mut JSContext) -> *mut JSObject; - -pub fn JS_GetScriptedGlobal(cx: *mut JSContext) -> *mut JSObject; - -pub fn JS_InitReflect(cx: *mut JSContext, global: *mut JSObject) -> *mut JSObject; - -pub fn JS_EnumerateDiagnosticMemoryRegions(callback: JSEnumerateDiagnosticMemoryCallback); - -pub fn JS_ComputeThis(cx: *mut JSContext, vp: *mut JSVal) -> JSVal; - -pub fn JS_MallocInCompartment(comp: *mut JSCompartment, nbytes: size_t); - -pub fn JS_FreeInCompartment(comp: *mut JSCompartment, nbytes: size_t); - -pub fn JS_malloc(cx: *mut JSContext, nbytes: size_t) -> *mut c_void; - -pub fn JS_realloc(cx: *mut JSContext, p: *mut c_void, nbytes: size_t) -> *mut c_void; - -pub fn JS_free(cx: *mut JSContext, p: *mut c_void); - -pub fn JS_freeop(fop: *mut JSFreeOp, p: *mut c_void); - -pub fn JS_GetDefaultFreeOp(rt: *mut JSRuntime) -> *mut JSFreeOp; - -pub fn JS_updateMallocCounter(cx: *mut JSContext, nbytes: size_t); - -pub fn JS_strdup(cx: *mut JSContext, s: *const c_char) -> *mut c_char; - -pub fn JS_AddValueRoot(cx: *mut JSContext, vp: *mut JSVal) -> JSBool; - -pub fn JS_AddStringRoot(cx: *mut JSContext, rp: *mut *mut JSString) -> JSBool; - -pub fn JS_AddObjectRoot(cx: *mut JSContext, rp: *mut *mut JSObject) -> JSBool; - -pub fn JS_AddGCThingRoot(cx: *mut JSContext, rp: *mut *mut c_void) -> JSBool; - -pub fn JS_AddNamedValueRoot(cx: *mut JSContext, vp: *mut JSVal, name: *const c_char) -> JSBool; - -pub fn JS_AddNamedStringRoot(cx: *mut JSContext, rp: *mut *mut JSString, name: *const c_char) -> JSBool; - -pub fn JS_AddNamedObjectRoot(cx: *mut JSContext, rp: *mut *mut JSObject, name: *const c_char) -> JSBool; - -pub fn JS_AddNamedScriptRoot(cx: *mut JSContext, rp: *mut *mut JSScript, name: *const c_char) -> JSBool; - -pub fn JS_AddNamedGCThingRoot(cx: *mut JSContext, rp: *mut *mut c_void, name: *const c_char) -> JSBool; - -pub fn JS_RemoveValueRoot(cx: *mut JSContext, vp: *mut JSVal); - -pub fn JS_RemoveStringRoot(cx: *mut JSContext, rp: *mut *mut JSString); - -pub fn JS_RemoveObjectRoot(cx: *mut JSContext, rp: *mut *mut JSObject); - -pub fn JS_RemoveScriptRoot(cx: *mut JSContext, rp: *mut *mut JSScript); - -pub fn JS_RemoveGCThingRoot(cx: *mut JSContext, rp: *mut *mut c_void); - -pub fn JS_RemoveValueRootRT(rt: *mut JSRuntime, vp: *mut JSVal); - -pub fn JS_RemoveStringRootRT(rt: *mut JSRuntime, rp: *mut *mut JSString); - -pub fn JS_RemoveObjectRootRT(rt: *mut JSRuntime, rp: *mut *mut JSObject); - -pub fn js_AddRootRT(rt: *mut JSRuntime, vp: *mut JSVal, name: *const c_char) -> JSBool; - -pub fn js_AddGCThingRootRT(rt: *mut JSRuntime, rp: *mut *mut c_void, name: *const c_char) -> JSBool; - -pub fn js_RemoveRoot(rt: *mut JSRuntime, rp: *mut c_void); - -pub fn JS_AnchorPtr(p: *mut c_void); - -pub fn JS_MapGCRoots(rt: *mut JSRuntime, map: JSGCRootMapFun, data: *mut c_void) -> uint32_t; - -pub fn JS_LockGCThing(cx: *mut JSContext, thing: *mut c_void) -> JSBool; - -pub fn JS_LockGCThingRT(rt: *mut JSRuntime, thing: *mut c_void) -> JSBool; - -pub fn JS_UnlockGCThing(cx: *mut JSContext, thing: *mut c_void) -> JSBool; - -pub fn JS_UnlockGCThingRT(rt: *mut JSRuntime, thing: *mut c_void) -> JSBool; - -pub fn JS_SetExtraGCRootsTracer(rt: *mut JSRuntime, traceOp: JSTraceDataOp, data: *mut c_void); - -pub fn JS_CallTracer(trc: *mut JSTracer, thing: *mut c_void, kind: JSGCTraceKind); - -pub fn JS_TracerInit(trc: *mut JSTracer, rt: *mut JSRuntime, callback: JSTraceCallback); - -pub fn JS_TraceChildren(trc: *mut JSTracer, thing: *mut c_void, kind: JSGCTraceKind); - -pub fn JS_TraceRuntime(trc: *mut JSTracer); - -pub fn JS_GetTraceThingInfo(buf: *mut c_char, bufsize: size_t, trc: *mut JSTracer, thing: *mut c_void, kind: JSGCTraceKind, includeDetails: JSBool); - -pub fn JS_GetTraceEdgeName(trc: *mut JSTracer, buffer: *mut c_char, bufferSize: c_int) -> *const c_char; - -pub fn JS_GC(rt: *mut JSRuntime); - -pub fn JS_MaybeGC(cx: *mut JSContext); - -pub fn JS_SetGCZeal(cx: *mut JSContext, zeal: uint8_t, frequency: uint32_t); - -pub fn JS_InhibitGC(cx: *mut JSContext); - -pub fn JS_AllowGC(cx: *mut JSContext); - -pub fn JS_SetGCCallback(rt: *mut JSRuntime, cb: JSGCCallback); - -pub fn JS_SetFinalizeCallback(rt: *mut JSRuntime, cb: JSFinalizeCallback); - -pub fn JS_IsGCMarkingTracer(trc: *mut JSTracer) -> JSBool; - -pub fn JS_IsAboutToBeFinalized(thing: *mut c_void) -> JSBool; - -pub fn JS_SetGCParameter(rt: *mut JSRuntime, key: JSGCParamKey, value: uint32_t); - -pub fn JS_GetGCParameter(rt: *mut JSRuntime, key: JSGCParamKey) -> uint32_t; - -pub fn JS_SetGCParameterForThread(cx: *mut JSContext, key: JSGCParamKey, value: uint32_t); - -pub fn JS_GetGCParameterForThread(cx: *mut JSContext, key: JSGCParamKey) -> uint32_t; - -pub fn JS_NewExternalString(cx: *mut JSContext, chars: *const jschar, length: size_t, fin: *const JSStringFinalizer) -> *mut JSString; - -pub fn JS_IsExternalString(str: *mut JSString) -> JSBool; - -pub fn JS_GetExternalStringFinalizer(str: *mut JSString) -> *const JSStringFinalizer; - -pub fn JS_SetNativeStackQuota(cx: *mut JSRuntime, stackSize: size_t); - -pub fn JS_IdArrayLength(cx: *mut JSContext, ida: *mut JSIdArray) -> c_int; - -pub fn JS_IdArrayGet(cx: *mut JSContext, ida: *mut JSIdArray, index: c_int) -> jsid; - -pub fn JS_DestroyIdArray(cx: *mut JSContext, ida: *mut JSIdArray); - -pub fn JS_ValueToId(cx: *mut JSContext, v: JSVal, idp: *mut jsid) -> JSBool; - -pub fn JS_IdToValue(cx: *mut JSContext, id: jsid, vp: *mut JSVal) -> JSBool; - -pub fn JS_DefaultValue(cx: *mut JSContext, obj: *mut JSObject, hint: JSType, vp: *mut JSVal) -> JSBool; - -pub fn JS_PropertyStub(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, vp: JSMutableHandleValue) -> JSBool; - -pub fn JS_StrictPropertyStub(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, strict: JSBool, vp: JSMutableHandleValue) -> JSBool; - -pub fn JS_EnumerateStub(cx: *mut JSContext, obj: JSHandleObject) -> JSBool; - -pub fn JS_ResolveStub(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId) -> JSBool; - -pub fn JS_ConvertStub(cx: *mut JSContext, obj: JSHandleObject, _type: JSType, vp: JSMutableHandleValue) -> JSBool; - -pub fn JS_InitClass(cx: *mut JSContext, obj: *mut JSObject, parent_proto: *mut JSObject, clasp: *mut JSClass, constructor: JSNative, nargs: c_uint, ps: *mut JSPropertySpec, fs: *mut JSFunctionSpec, static_ps: *mut JSPropertySpec, static_fs: *mut JSFunctionSpec) -> *mut JSObject; - -pub fn JS_LinkConstructorAndPrototype(cx: *mut JSContext, ctor: *mut JSObject, proto: *mut JSObject) -> JSBool; - -pub fn JS_GetClass(obj: JSRawObject) -> *mut JSClass; - -pub fn JS_InstanceOf(cx: *mut JSContext, obj: *mut JSObject, clasp: *mut JSClass, argv: *mut JSVal) -> JSBool; -pub fn JS_HasInstance(cx: *mut JSContext, obj: *mut JSObject, v: JSVal, bp: *mut JSBool) -> JSBool; - -pub fn JS_GetPrivate(obj: JSRawObject) -> *mut c_void; - -pub fn JS_SetPrivate(obj: JSRawObject, data: *mut c_void); - -pub fn JS_GetInstancePrivate(cx: *mut JSContext, obj: *mut JSObject, clasp: *mut JSClass, argv: *mut JSVal) -> *mut c_void; - -pub fn JS_GetPrototype(obj: JSRawObject) -> *mut JSObject; - -pub fn JS_SetPrototype(cx: *mut JSContext, obj: *mut JSObject, proto: *mut JSObject) -> JSBool; - -pub fn JS_GetParent(obj: JSRawObject) -> *mut JSObject; - -pub fn JS_SetParent(cx: *mut JSContext, obj: *mut JSObject, parent: *mut JSObject) -> JSBool; - -pub fn JS_GetConstructor(cx: *mut JSContext, proto: *mut JSObject) -> *mut JSObject; - -pub fn JS_GetObjectId(cx: *mut JSContext, obj: JSRawObject, idp: *mut jsid) -> JSBool; - -pub fn JS_NewGlobalObject(cx: *mut JSContext, clasp: *const JSClass, principals: *mut JSPrincipals) -> *mut JSObject; - -pub fn JS_NewObject(cx: *mut JSContext, clasp: *const JSClass, proto: *const JSObject, parent: *const JSObject) -> *mut JSObject; - -pub fn JS_IsExtensible(obj: JSRawObject) -> JSBool; - -pub fn JS_IsNative(obj: JSRawObject) -> JSBool; - -pub fn JS_GetObjectRuntime(obj: JSRawObject) -> *mut JSRuntime; - -pub fn JS_NewObjectWithGivenProto(cx: *mut JSContext, clasp: *mut JSClass, proto: *mut JSObject, parent: *mut JSObject) -> *mut JSObject; - -pub fn JS_DeepFreezeObject(cx: *mut JSContext, obj: *mut JSObject) -> JSBool; - -pub fn JS_FreezeObject(cx: *mut JSContext, obj: *mut JSObject) -> JSBool; - -pub fn JS_New(cx: *mut JSContext, ctor: *mut JSObject, argc: c_uint, argv: *mut JSVal) -> *mut JSObject; - -pub fn JS_DefineObject(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, clasp: *mut JSClass, proto: *mut JSObject, attrs: c_uint) -> *mut JSObject; - -pub fn JS_DefineConstDoubles(cx: *mut JSContext, obj: *mut JSObject, cds: *mut JSConstDoubleSpec) -> JSBool; - -pub fn JS_DefineProperties(cx: *mut JSContext, obj: *mut JSObject, ps: *const JSPropertySpec) -> JSBool; - -pub fn JS_DefineProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_DefinePropertyById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_DefineOwnProperty(cx: *mut JSContext, obj: *mut JSObject, id: jsid, descriptor: JSVal, bp: *mut JSBool) -> JSBool; - -pub fn JS_GetPropertyAttributes(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, attrsp: *mut c_uint, foundp: *mut JSBool) -> JSBool; - -pub fn JS_GetPropertyAttrsGetterAndSetter(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, attrsp: *mut c_uint, foundp: *mut JSBool, getterp: *mut JSPropertyOp, setterp: *mut JSStrictPropertyOp) -> JSBool; - -pub fn JS_GetPropertyAttrsGetterAndSetterById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, attrsp: *mut c_uint, foundp: *mut JSBool, getterp: *mut JSPropertyOp, setterp: *mut JSStrictPropertyOp) -> JSBool; - -pub fn JS_SetPropertyAttributes(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, attrs: c_uint, foundp: *mut JSBool) -> JSBool; - -pub fn JS_DefinePropertyWithTinyId(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, tinyid: int8_t, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_AlreadyHasOwnProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, foundp: *mut JSBool) -> JSBool; - -pub fn JS_AlreadyHasOwnPropertyById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, foundp: *mut JSBool) -> JSBool; - -pub fn JS_HasProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, foundp: *mut JSBool) -> JSBool; - -pub fn JS_HasPropertyById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, foundp: *mut JSBool) -> JSBool; - -pub fn JS_LookupProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, vp: *mut JSVal) -> JSBool; - -pub fn JS_LookupPropertyById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, vp: *mut JSVal) -> JSBool; - -pub fn JS_LookupPropertyWithFlags(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, flags: c_uint, vp: *mut JSVal) -> JSBool; - -pub fn JS_LookupPropertyWithFlagsById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, flags: c_uint, objp: *mut *mut JSObject, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetPropertyDescriptorById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, flags: c_uint, desc: *mut JSPropertyDescriptor) -> JSBool; - -pub fn JS_GetOwnPropertyDescriptor(cx: *mut JSContext, obj: *mut JSObject, id: jsid, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetPropertyDefault(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, def: JSVal, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetPropertyById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetPropertyByIdDefault(cx: *mut JSContext, obj: *mut JSObject, id: jsid, def: JSVal, vp: *mut JSVal) -> JSBool; - -pub fn JS_ForwardGetPropertyTo(cx: *mut JSContext, obj: *mut JSObject, id: jsid, onBehalfOf: *mut JSObject, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetMethodById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, objp: *mut *mut JSObject, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetMethod(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, objp: *mut *mut JSObject, vp: *mut JSVal) -> JSBool; - -pub fn JS_SetProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, vp: *mut JSVal) -> JSBool; - -pub fn JS_SetPropertyById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, vp: *mut JSVal) -> JSBool; - -pub fn JS_DeleteProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char) -> JSBool; - -pub fn JS_DeleteProperty2(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, rval: *mut JSVal) -> JSBool; - -pub fn JS_DeletePropertyById(cx: *mut JSContext, obj: *mut JSObject, id: jsid) -> JSBool; - -pub fn JS_DeletePropertyById2(cx: *mut JSContext, obj: *mut JSObject, id: jsid, rval: *mut JSVal) -> JSBool; - -pub fn JS_DefineUCProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_GetUCPropertyAttributes(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, attrsp: *mut c_uint, foundp: *mut JSBool) -> JSBool; - -pub fn JS_GetUCPropertyAttrsGetterAndSetter(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, attrsp: *mut c_uint, foundp: *mut JSBool, getterp: *mut JSPropertyOp, setterp: *mut JSStrictPropertyOp) -> JSBool; - -pub fn JS_SetUCPropertyAttributes(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, attrs: c_uint, foundp: *mut JSBool) -> JSBool; - -pub fn JS_DefineUCPropertyWithTinyId(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, tinyid: int8_t, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_AlreadyHasOwnUCProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, foundp: *mut JSBool) -> JSBool; - -pub fn JS_HasUCProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, vp: *mut JSBool) -> JSBool; - -pub fn JS_LookupUCProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetUCProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, vp: *mut JSVal) -> JSBool; - -pub fn JS_SetUCProperty(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, vp: *mut JSVal) -> JSBool; - -pub fn JS_DeleteUCProperty2(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, rval: *mut JSVal) -> JSBool; - -pub fn JS_NewArrayObject(cx: *mut JSContext, length: c_int, vector: *mut JSVal) -> *mut JSObject; - -pub fn JS_IsArrayObject(cx: *mut JSContext, obj: *mut JSObject) -> JSBool; - -pub fn JS_GetArrayLength(cx: *mut JSContext, obj: *mut JSObject, lengthp: *mut uint32_t) -> JSBool; - -pub fn JS_SetArrayLength(cx: *mut JSContext, obj: *mut JSObject, length: uint32_t) -> JSBool; - -pub fn JS_DefineElement(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_AlreadyHasOwnElement(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, foundp: *mut JSBool) -> JSBool; - -pub fn JS_HasElement(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, foundp: *mut JSBool) -> JSBool; - -pub fn JS_LookupElement(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetElement(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, vp: *mut JSVal) -> JSBool; - -pub fn JS_ForwardGetElementTo(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, onBehalfOf: *mut JSObject, vp: *mut JSVal) -> JSBool; - -pub fn JS_GetElementIfPresent(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, onBehalfOf: *mut JSObject, vp: *mut JSVal, present: *mut JSBool) -> JSBool; - -pub fn JS_SetElement(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, vp: *mut JSVal) -> JSBool; - -pub fn JS_DeleteElement(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t) -> JSBool; - -pub fn JS_DeleteElement2(cx: *mut JSContext, obj: *mut JSObject, index: uint32_t, rval: *mut JSVal) -> JSBool; - -pub fn JS_ClearScope(cx: *mut JSContext, obj: *mut JSObject); - -pub fn JS_Enumerate(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSIdArray; - -pub fn JS_NewPropertyIterator(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject; - -pub fn JS_NextProperty(cx: *mut JSContext, iterobj: *mut JSObject, idp: *mut jsid) -> JSBool; - -pub fn JS_ArrayIterator(cx: *mut JSContext, argc: c_uint, vp: *mut JSVal) -> JSBool; - -pub fn JS_CheckAccess(cx: *mut JSContext, obj: *mut JSObject, id: jsid, mode: JSAccessMode, vp: *mut JSVal, attrsp: *mut c_uint) -> JSBool; - -pub fn JS_GetReservedSlot(obj: JSRawObject, index: uint32_t) -> JSVal; - -pub fn JS_SetReservedSlot(obj: JSRawObject, index: uint32_t, v: JSVal); - -pub fn JS_HoldPrincipals(principals: *mut JSPrincipals); - -pub fn JS_DropPrincipals(rt: *mut JSRuntime, principals: *mut JSPrincipals); - -pub fn JS_SetSecurityCallbacks(rt: *mut JSRuntime, callbacks: *const JSSecurityCallbacks); - -pub fn JS_GetSecurityCallbacks(rt: *mut JSRuntime) -> *const JSSecurityCallbacks; - -pub fn JS_SetTrustedPrincipals(rt: *mut JSRuntime, prin: *mut JSPrincipals); - -pub fn JS_InitDestroyPrincipalsCallback(rt: *mut JSRuntime, destroyPrincipals: JSDestroyPrincipalsOp); - -pub fn JS_NewFunction(cx: *mut JSContext, call: JSNative, nargs: c_uint, flags: c_uint, parent: *mut JSObject, name: *const c_char) -> *mut JSFunction; - -pub fn JS_NewFunctionById(cx: *mut JSContext, call: JSNative, nargs: c_uint, flags: c_uint, parent: *mut JSObject, id: jsid) -> *mut JSFunction; - -pub fn JS_GetFunctionObject(fun: *mut JSFunction) -> *mut JSObject; - -pub fn JS_GetFunctionId(fun: *mut JSFunction) -> *mut JSString; - -pub fn JS_GetFunctionDisplayId(fun: *mut JSFunction) -> *mut JSString; - -pub fn JS_GetFunctionFlags(fun: *mut JSFunction) -> c_uint; - -pub fn JS_GetFunctionArity(fun: *mut JSFunction) -> uint16_t; - -pub fn JS_ObjectIsFunction(cx: *mut JSContext, obj: JSRawObject) -> JSBool; - -pub fn JS_ObjectIsCallable(cx: *mut JSContext, obj: JSRawObject) -> JSBool; - -pub fn JS_IsNativeFunction(funobj: JSRawObject, call: JSNative) -> JSBool; - -pub fn JS_BindCallable(cx: *mut JSContext, callable: *mut JSObject, newThis: JSRawObject) -> *mut JSObject; - -pub fn JS_DefineFunctions(cx: *mut JSContext, obj: *mut JSObject, fs: *const JSFunctionSpec) -> JSBool; - -pub fn JS_DefineFunction(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, call: JSNative, nargs: c_uint, attrs: c_uint) -> *mut JSFunction; - -pub fn JS_DefineUCFunction(cx: *mut JSContext, obj: *mut JSObject, name: *const jschar, namelen: size_t, call: JSNative, nargs: c_uint, attrs: c_uint) -> *mut JSFunction; - -pub fn JS_DefineFunctionById(cx: *mut JSContext, obj: *mut JSObject, id: jsid, call: JSNative, nargs: c_uint, attrs: c_uint) -> *mut JSFunction; - -pub fn JS_CloneFunctionObject(cx: *mut JSContext, funobj: *mut JSObject, parent: JSRawObject) -> *mut JSObject; - -pub fn JS_BufferIsCompilableUnit(cx: *mut JSContext, bytes_are_utf8: JSBool, obj: *mut JSObject, bytes: *const c_char, length: size_t) -> JSBool; - -pub fn JS_CompileScript(cx: *mut JSContext, obj: *mut JSObject, bytes: *const c_char, length: size_t, filename: *const c_char, lineno: c_uint) -> *mut JSScript; - -pub fn JS_CompileScriptForPrincipals(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, bytes: *const c_char, length: size_t, filename: *const c_char, lineno: c_uint) -> *mut JSScript; - -pub fn JS_CompileScriptForPrincipalsVersion(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, bytes: *const c_char, length: size_t, filename: *const c_char, lineno: c_uint, version: JSVersion) -> *mut JSScript; - -pub fn JS_CompileUCScript(cx: *mut JSContext, obj: *mut JSObject, chars: *const jschar, length: size_t, filename: *const c_char, lineno: c_uint) -> *mut JSScript; - -pub fn JS_CompileUCScriptForPrincipals(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, chars: *const jschar, length: size_t, filename: *const c_char, lineno: c_uint) -> *mut JSScript; - -pub fn JS_CompileUCScriptForPrincipalsVersion(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, chars: *const jschar, length: size_t, filename: *const c_char, lineno: c_uint, version: JSVersion) -> *mut JSScript; - -pub fn JS_CompileUCScriptForPrincipalsVersionOrigin(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, originPrincipals: *mut JSPrincipals, chars: *const jschar, length: size_t, filename: *const c_char, lineno: c_uint, version: JSVersion) -> *mut JSScript; - -pub fn JS_CompileUTF8File(cx: *mut JSContext, obj: *mut JSObject, filename: *const c_char) -> *mut JSScript; - -pub fn JS_CompileUTF8FileHandle(cx: *mut JSContext, obj: *mut JSObject, filename: *const c_char, fh: *mut FILE) -> *mut JSScript; - -pub fn JS_CompileUTF8FileHandleForPrincipals(cx: *mut JSContext, obj: *mut JSObject, filename: *const c_char, fh: *mut FILE, principals: *mut JSPrincipals) -> *mut JSScript; - -pub fn JS_CompileUTF8FileHandleForPrincipalsVersion(cx: *mut JSContext, obj: *mut JSObject, filename: *const c_char, fh: *mut FILE, principals: *mut JSPrincipals, version: JSVersion) -> *mut JSScript; - -pub fn JS_GetGlobalFromScript(script: *mut JSScript) -> *mut JSObject; - -pub fn JS_CompileFunction(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, nargs: c_uint, argnames: *mut *const c_char, bytes: *const c_char, length: size_t, filename: *const c_char, lineno: c_uint) -> *mut JSFunction; - -pub fn JS_CompileFunctionForPrincipals(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, name: *const c_char, nargs: c_uint, argnames: *mut *const c_char, bytes: *const c_char, length: size_t, filename: *const c_char, lineno: c_uint) -> *mut JSFunction; - -pub fn JS_CompileUCFunction(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, nargs: c_uint, argnames: *mut *const c_char, chars: *const jschar, length: size_t, filename: *const c_char, lineno: c_uint) -> *mut JSFunction; - -pub fn JS_CompileUCFunctionForPrincipals(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, name: *const c_char, nargs: c_uint, argnames: *mut *const c_char, chars: *const jschar, length: size_t, filename: *const c_char, lineno: c_uint) -> *mut JSFunction; - -pub fn JS_CompileUCFunctionForPrincipalsVersion(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, name: *const c_char, nargs: c_uint, argnames: *mut *const c_char, chars: *const jschar, length: size_t, filename: *const c_char, lineno: c_uint, version: JSVersion) -> *mut JSFunction; - -pub fn JS_DecompileScript(cx: *mut JSContext, script: *mut JSScript, name: *const c_char, indent: c_uint) -> *mut JSString; - -pub fn JS_DecompileFunction(cx: *mut JSContext, fun: *mut JSFunction, indent: c_uint) -> *mut JSString; - -pub fn JS_DecompileFunctionBody(cx: *mut JSContext, fun: *mut JSFunction, indent: c_uint) -> *mut JSString; - -pub fn JS_ExecuteScript(cx: *mut JSContext, obj: *mut JSObject, script: *mut JSScript, rval: *mut JSVal) -> JSBool; - -pub fn JS_ExecuteScriptVersion(cx: *mut JSContext, obj: *mut JSObject, script: *mut JSScript, rval: *mut JSVal, version: JSVersion) -> JSBool; - -pub fn JS_EvaluateScript(cx: *mut JSContext, obj: *mut JSObject, bytes: *const c_char, length: c_uint, filename: *const c_char, lineno: c_uint, rval: *mut JSVal) -> JSBool; - -pub fn JS_EvaluateScriptForPrincipals(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, bytes: *const c_char, length: c_uint, filename: *const c_char, lineno: c_uint, rval: *mut JSVal) -> JSBool; - -pub fn JS_EvaluateScriptForPrincipalsVersion(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, bytes: *const c_char, length: c_uint, filename: *const c_char, lineno: c_uint, rval: *mut JSVal, version: JSVersion) -> JSBool; - -pub fn JS_EvaluateUCScript(cx: *mut JSContext, obj: *mut JSObject, chars: *const jschar, length: c_uint, filename: *const c_char, lineno: c_uint, rval: *mut JSVal) -> JSBool; - -pub fn JS_EvaluateUCScriptForPrincipals(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, chars: *const jschar, length: c_uint, filename: *const c_char, lineno: c_uint, rval: *mut JSVal) -> JSBool; - -pub fn JS_EvaluateUCScriptForPrincipalsVersion(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, chars: *const jschar, length: c_uint, filename: *const c_char, lineno: c_uint, rval: *mut JSVal, version: JSVersion) -> JSBool; - -pub fn JS_EvaluateUCScriptForPrincipalsVersionOrigin(cx: *mut JSContext, obj: *mut JSObject, principals: *mut JSPrincipals, originPrincipals: *mut JSPrincipals, chars: *const jschar, length: c_uint, filename: *const c_char, lineno: c_uint, rval: *mut JSVal, version: JSVersion) -> JSBool; - -pub fn JS_CallFunction(cx: *mut JSContext, obj: *mut JSObject, fun: *mut JSFunction, argc: c_uint, argv: *mut JSVal, rval: *mut JSVal) -> JSBool; - -pub fn JS_CallFunctionName(cx: *mut JSContext, obj: *mut JSObject, name: *const c_char, argc: c_uint, argv: *mut JSVal, rval: *mut JSVal) -> JSBool; - -pub fn JS_CallFunctionValue(cx: *mut JSContext, obj: *mut JSObject, fval: JSVal, argc: c_uint, argv: *mut JSVal, rval: *mut JSVal) -> JSBool; - -pub fn JS_SetOperationCallback(cx: *mut JSContext, callback: JSOperationCallback) -> JSOperationCallback; - -pub fn JS_GetOperationCallback(cx: *mut JSContext) -> JSOperationCallback; - -pub fn JS_TriggerOperationCallback(rt: *mut JSRuntime); - -pub fn JS_IsRunning(cx: *mut JSContext) -> JSBool; - -pub fn JS_SaveFrameChain(cx: *mut JSContext) -> JSBool; - -pub fn JS_RestoreFrameChain(cx: *mut JSContext); - -pub fn JS_NewStringCopyN(cx: *mut JSContext, s: *const c_char, n: size_t) -> *mut JSString; - -pub fn JS_NewStringCopyZ(cx: *mut JSContext, s: *const c_char) -> *mut JSString; - -pub fn JS_InternJSString(cx: *mut JSContext, str: *mut JSString) -> *mut JSString; - -pub fn JS_InternStringN(cx: *mut JSContext, s: *const c_char, length: size_t) -> *mut JSString; - -pub fn JS_InternString(cx: *mut JSContext, s: *const c_char) -> *mut JSString; - -pub fn JS_NewUCString(cx: *mut JSContext, chars: *mut jschar, length: size_t) -> *mut JSString; - -pub fn JS_NewUCStringCopyN(cx: *mut JSContext, s: *const jschar, n: size_t) -> *mut JSString; - -pub fn JS_NewUCStringCopyZ(cx: *mut JSContext, s: *const jschar) -> *mut JSString; - -pub fn JS_InternUCStringN(cx: *mut JSContext, s: *const jschar, length: size_t) -> *mut JSString; - -pub fn JS_InternUCString(cx: *mut JSContext, s: *const jschar) -> *mut JSString; - -pub fn JS_CompareStrings(cx: *mut JSContext, str1: *mut JSString, str2: *mut JSString, result: *mut int32_t) -> JSBool; - -pub fn JS_StringEqualsAscii(cx: *mut JSContext, str: *mut JSString, asciiBytes: *const c_char, _match: *mut JSBool) -> JSBool; - -pub fn JS_PutEscapedString(cx: *mut JSContext, buffer: *mut c_char, size: size_t, str: *mut JSString, quote: c_char) -> size_t; - -pub fn JS_FileEscapedString(fp: *mut FILE, str: *mut JSString, quote: c_char) -> JSBool; - -pub fn JS_GetStringLength(str: *mut JSString) -> size_t; - -pub fn JS_GetStringCharsAndLength(cx: *mut JSContext, str: *mut JSString, length: *mut size_t) -> *const jschar; - -pub fn JS_GetInternedStringChars(str: *mut JSString) -> *const jschar; - -pub fn JS_GetInternedStringCharsAndLength(str: *mut JSString, length: *mut size_t) -> *const jschar; - -pub fn JS_GetStringCharsZ(cx: *mut JSContext, str: *mut JSString) -> *const jschar; - -pub fn JS_GetStringCharsZAndLength(cx: *mut JSContext, str: *mut JSString, length: *mut size_t) -> *const jschar; - -pub fn JS_FlattenString(cx: *mut JSContext, str: *mut JSString) -> *mut JSFlatString; - -pub fn JS_GetFlatStringChars(str: *mut JSFlatString) -> *const jschar; - -pub fn JS_FlatStringEqualsAscii(str: *mut JSFlatString, asciiBytes: *const c_char) -> JSBool; - -pub fn JS_PutEscapedFlatString(buffer: *mut c_char, size: size_t, str: *mut JSFlatString, quote: c_char) -> size_t; - -pub fn JS_NewGrowableString(cx: *mut JSContext, chars: *mut jschar, length: size_t) -> *mut JSString; - -pub fn JS_NewDependentString(cx: *mut JSContext, str: *mut JSString, start: size_t, length: size_t) -> *mut JSString; - -pub fn JS_ConcatStrings(cx: *mut JSContext, left: *mut JSString, right: *mut JSString) -> *mut JSString; - -pub fn JS_UndependString(cx: *mut JSContext, str: *mut JSString) -> *const jschar; - -pub fn JS_MakeStringImmutable(cx: *mut JSContext, str: *mut JSString) -> JSBool; - -pub fn JS_CStringsAreUTF8() -> JSBool; - -pub fn JS_SetCStringsAreUTF8(); - -pub fn JS_EncodeCharacters(cx: *mut JSContext, src: *const jschar, srclen: size_t, dst: *mut c_char, dstlenp: *mut size_t) -> JSBool; - -pub fn JS_DecodeBytes(cx: *mut JSContext, src: *const c_char, srclen: size_t, dst: *mut jschar, dstlenp: *mut size_t) -> JSBool; - -pub fn JS_DecodeUTF8(cx: *mut JSContext, src: *const c_char, srclen: size_t, dst: *mut jschar, dstlenp: *mut size_t) -> JSBool; - -pub fn JS_EncodeString(cx: *mut JSContext, str: *mut JSString) -> *mut c_char; - -pub fn JS_GetStringEncodingLength(cx: *mut JSContext, str: *mut JSString) -> size_t; - -pub fn JS_EncodeStringToBuffer(str: *mut JSString, buffer: *mut c_char, length: size_t) -> size_t; - -pub fn JS_Stringify(cx: *mut JSContext, vp: *mut JSVal, replacer: *mut JSObject, space: JSVal, callback: JSONWriteCallback, data: *mut c_void) -> JSBool; - -pub fn JS_ParseJSON(cx: *mut JSContext, chars: *const jschar, len: uint32_t, vp: *mut JSVal) -> JSBool; - -pub fn JS_ParseJSONWithReviver(cx: *mut JSContext, chars: *const jschar, len: uint32_t, reviver: JSVal, vp: *mut JSVal) -> JSBool; - -pub fn JS_ReadStructuredClone(cx: *mut JSContext, data: *const uint64_t, nbytes: size_t, version: uint32_t, vp: *mut JSVal, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut c_void) -> JSBool; - -pub fn JS_WriteStructuredClone(cx: *mut JSContext, v: JSVal, datap: *mut *mut uint64_t, nbytesp: *mut size_t, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut c_void) -> JSBool; - -pub fn JS_StructuredClone(cx: *mut JSContext, v: JSVal, vp: *mut JSVal, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut c_void) -> JSBool; - -pub fn JS_SetStructuredCloneCallbacks(rt: *mut JSRuntime, callbacks: *const JSStructuredCloneCallbacks); - -pub fn JS_ReadUint32Pair(r: *mut JSStructuredCloneReader, p1: *mut uint32_t, p2: *mut uint32_t) -> JSBool; - -pub fn JS_ReadBytes(r: *mut JSStructuredCloneReader, p: *mut c_void, len: size_t) -> JSBool; - -pub fn JS_ReadTypedArray(r: *mut JSStructuredCloneReader, vp: *mut JSVal) -> JSBool; - -pub fn JS_WriteUint32Pair(w: *mut JSStructuredCloneWriter, tag: uint32_t, data: uint32_t) -> JSBool; - -pub fn JS_WriteBytes(w: *mut JSStructuredCloneWriter, p: *const c_void, len: size_t) -> JSBool; - -pub fn JS_WriteTypedArray(w: *mut JSStructuredCloneWriter, v: JSVal) -> JSBool; - -pub fn JS_SetLocaleCallbacks(cx: *mut JSContext, callbacks: *mut JSLocaleCallbacks); - -pub fn JS_GetLocaleCallbacks(cx: *mut JSContext) -> *mut JSLocaleCallbacks; - -pub fn JS_ReportError(cx: *mut JSContext, format: *const c_char, ...); - -pub fn JS_ReportErrorNumber(cx: *mut JSContext, errorCallback: JSErrorCallback, userRef: *mut c_void, errorNumber: c_uint, ...); - -pub fn JS_ReportErrorNumberUC(cx: *mut JSContext, errorCallback: JSErrorCallback, userRef: *mut c_void, errorNumber: c_uint, ...); - -pub fn JS_ReportWarning(cx: *mut JSContext, format: *const c_char, ...) -> JSBool; - -pub fn JS_ReportErrorFlagsAndNumber(cx: *mut JSContext, flags: c_uint, errorCallback: JSErrorCallback, userRef: *mut c_void, errorNumber: c_uint, ...) -> JSBool; - -pub fn JS_ReportErrorFlagsAndNumberUC(cx: *mut JSContext, flags: c_uint, errorCallback: JSErrorCallback, userRef: *mut c_void, errorNumber: c_uint, ...) -> JSBool; - -pub fn JS_ReportOutOfMemory(cx: *mut JSContext); - -pub fn JS_ReportAllocationOverflow(cx: *mut JSContext); - -pub fn JS_GetErrorReporter(cx: *mut JSContext) -> JSErrorReporter; - -pub fn JS_SetErrorReporter(cx: *mut JSContext, er: JSErrorReporter) -> JSErrorReporter; - -pub fn JS_NewDateObject(cx: *mut JSContext, year: c_int, mon: c_int, mday: c_int, hour: c_int, min: c_int, sec: c_int) -> *mut JSObject; - -pub fn JS_NewDateObjectMsec(cx: *mut JSContext, msec: c_double) -> *mut JSObject; - -pub fn JS_ObjectIsDate(cx: *mut JSContext, obj: JSRawObject) -> JSBool; - -pub fn JS_ClearDateCaches(cx: *mut JSContext); - -pub fn JS_NewRegExpObject(cx: *mut JSContext, obj: *mut JSObject, bytes: *mut c_char, length: size_t, flags: c_uint) -> *mut JSObject; - -pub fn JS_NewUCRegExpObject(cx: *mut JSContext, obj: *mut JSObject, chars: *mut jschar, length: size_t, flags: c_uint) -> *mut JSObject; - -pub fn JS_SetRegExpInput(cx: *mut JSContext, obj: *mut JSObject, input: *mut JSString, multiline: JSBool); - -pub fn JS_ClearRegExpStatics(cx: *mut JSContext, obj: *mut JSObject); - -pub fn JS_ExecuteRegExp(cx: *mut JSContext, obj: *mut JSObject, reobj: *mut JSObject, chars: *mut jschar, length: size_t, indexp: *mut size_t, test: JSBool, rval: *mut JSVal) -> JSBool; - -pub fn JS_NewRegExpObjectNoStatics(cx: *mut JSContext, bytes: *mut c_char, length: size_t, flags: c_uint) -> *mut JSObject; - -pub fn JS_NewUCRegExpObjectNoStatics(cx: *mut JSContext, chars: *mut jschar, length: size_t, flags: c_uint) -> *mut JSObject; - -pub fn JS_ExecuteRegExpNoStatics(cx: *mut JSContext, reobj: *mut JSObject, chars: *mut jschar, length: size_t, indexp: *mut size_t, test: JSBool, rval: *mut JSVal) -> JSBool; - -pub fn JS_ObjectIsRegExp(cx: *mut JSContext, obj: *mut JSObject) -> JSBool; - -pub fn JS_GetRegExpFlags(cx: *mut JSContext, obj: *mut JSObject) -> c_uint; - -pub fn JS_GetRegExpSource(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSString; - -pub fn JS_IsExceptionPending(cx: *mut JSContext) -> JSBool; - -pub fn JS_GetPendingException(cx: *mut JSContext, vp: *mut JSVal) -> JSBool; - -pub fn JS_SetPendingException(cx: *mut JSContext, v: JSVal); - -pub fn JS_ClearPendingException(cx: *mut JSContext); - -pub fn JS_ReportPendingException(cx: *mut JSContext) -> JSBool; - -pub fn JS_SaveExceptionState(cx: *mut JSContext) -> *mut JSExceptionState; - -pub fn JS_RestoreExceptionState(cx: *mut JSContext, state: *mut JSExceptionState); - -pub fn JS_DropExceptionState(cx: *mut JSContext, state: *mut JSExceptionState); - -pub fn JS_ErrorFromException(cx: *mut JSContext, v: JSVal) -> *mut JSErrorReport; - -pub fn JS_ThrowReportedError(cx: *mut JSContext, message: *const c_char, reportp: *mut JSErrorReport) -> JSBool; - -pub fn JS_ThrowStopIteration(cx: *mut JSContext) -> JSBool; - -pub fn JS_GetCurrentThread() -> intptr_t; - -pub fn JS_AbortIfWrongThread(rt: *mut JSRuntime); - -pub fn JS_ClearRuntimeThread(rt: *mut JSRuntime); - -pub fn JS_SetRuntimeThread(rt: *mut JSRuntime); - -pub fn JS_SetNativeStackBounds(rt: *mut JSRuntime, minValue: uintptr_t, maxValue: uintptr_t); - -pub fn JS_NewObjectForConstructor(cx: *mut JSContext, clasp: *mut JSClass, vp: *const JSVal) -> *mut JSObject; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +pub type Enum_JSJitCompilerOption = c_uint; +pub static JSJITCOMPILER_BASELINE_USECOUNT_TRIGGER: c_uint = 0; +pub static JSJITCOMPILER_ION_USECOUNT_TRIGGER: c_uint = 1; +pub static JSJITCOMPILER_ION_ENABLE: c_uint = 2; +pub static JSJITCOMPILER_BASELINE_ENABLE: c_uint = 3; +pub static JSJITCOMPILER_PARALLEL_COMPILATION_ENABLE: c_uint = 4; +pub static JSJITCOMPILER_NOT_AN_OPTION: c_uint = 5; +pub type JSJitCompilerOption = Enum_JSJitCompilerOption; +extern "C" { + pub static JSVAL_NULL: jsval; + pub static JSVAL_ZERO: jsval; + pub static JSVAL_ONE: jsval; + pub static JSVAL_FALSE: jsval; + pub static JSVAL_TRUE: jsval; + pub static JSVAL_VOID: jsval; + pub static JSID_VOID: Struct_jsid; + pub static JSID_EMPTY: Struct_jsid; + pub static JSID_VOIDHANDLE: HandleId<'static>; + pub static JSID_EMPTYHANDLE: HandleId<'static>; + pub fn JS_Assert(s: *const c_schar, file: *const c_schar, ln: c_int); + pub fn JS_Abort(); + pub fn js_FinishGC(rt: *mut Struct_JSRuntime); + pub fn JS_ComputeThis(cx: *mut Struct_JSContext, vp: *mut jsval) -> jsval; //jdm c_void->jsval + pub fn JS_THIS(cx: *mut Struct_JSContext, vp: *mut c_void); + pub fn JS_HoldPrincipals(principals: *mut Struct_JSPrincipals); + pub fn JS_DropPrincipals(rt: *mut Struct_JSRuntime, + principals: *mut Struct_JSPrincipals); + pub fn JS_SetSecurityCallbacks(rt: *mut Struct_JSRuntime, + callbacks: *const Struct_JSSecurityCallbacks); + pub fn JS_GetSecurityCallbacks(rt: *mut Struct_JSRuntime) -> + *const Struct_JSSecurityCallbacks; + pub fn JS_SetTrustedPrincipals(rt: *mut Struct_JSRuntime, + prin: *const Struct_JSPrincipals); + pub fn JS_InitDestroyPrincipalsCallback(rt: *mut Struct_JSRuntime, + destroyPrincipals: + JSDestroyPrincipalsOp); + pub fn JS_CallValueTracer(trc: *mut JSTracer, valuep: *mut jsval, //jdm c_void->JSTracer, c_void->JSVal + name: *const c_schar); + pub fn JS_CallIdTracer(trc: *mut c_void, idp: *mut Struct_jsid, + name: *const c_schar); + pub fn JS_CallObjectTracer(trc: *mut JSTracer, objp: *mut *mut JSObject, //jdm c_void->JSTracer, c_void->JSObject + name: *const c_schar); + pub fn JS_CallStringTracer(trc: *mut c_void, strp: *mut *mut c_void, + name: *const c_schar); + pub fn JS_CallScriptTracer(trc: *mut c_void, scriptp: *mut *mut c_void, + name: *const c_schar); + pub fn JS_CallHeapValueTracer(trc: *mut c_void, valuep: *mut c_void, + name: *const c_schar); + pub fn JS_CallHeapIdTracer(trc: *mut c_void, idp: *mut c_void, + name: *const c_schar); + pub fn JS_CallHeapObjectTracer(trc: *mut c_void, objp: *mut c_void, + name: *const c_schar); + pub fn JS_CallHeapStringTracer(trc: *mut c_void, strp: *mut c_void, + name: *const c_schar); + pub fn JS_CallHeapScriptTracer(trc: *mut c_void, scriptp: *mut c_void, + name: *const c_schar); + pub fn JS_CallHeapFunctionTracer(trc: *mut c_void, funp: *mut c_void, + name: *const c_schar); + pub fn JS_CallTenuredObjectTracer(trc: *mut c_void, objp: *mut c_void, + name: *const c_schar); + pub fn JS_TraceChildren(trc: *mut c_void, thing: *mut c_void, + kind: Enum_JSGCTraceKind); + pub fn JS_TraceRuntime(trc: *mut c_void); + pub fn JS_GetTraceThingInfo(buf: *mut c_schar, bufsize: size_t, + trc: *mut c_void, thing: *mut c_void, + kind: Enum_JSGCTraceKind, + includeDetails: bool); + pub fn JS_StringHasBeenInterned(cx: *mut Struct_JSContext, + str: *mut c_void) -> bool; + pub fn INTERNED_STRING_TO_JSID(cx: *mut Struct_JSContext, + str: *mut c_void) -> Struct_jsid; + pub fn JS_CallOnce(_once: *mut JSCallOnceType, func: JSInitCallback) -> + bool; + pub fn JS_Now() -> int64_t; + pub fn JS_GetNaNValue(cx: *mut Struct_JSContext) -> jsval; + pub fn JS_GetNegativeInfinityValue(cx: *mut Struct_JSContext) -> jsval; + pub fn JS_GetPositiveInfinityValue(cx: *mut Struct_JSContext) -> jsval; + pub fn JS_GetEmptyStringValue(cx: *mut Struct_JSContext) -> jsval; + pub fn JS_GetEmptyString(rt: *mut Struct_JSRuntime) -> *mut c_void; + pub fn JS_ConvertArguments(cx: *mut Struct_JSContext, args: c_void, + format: *const c_schar, ...) -> bool; + pub fn JS_ConvertArgumentsVA(cx: *mut Struct_JSContext, args: c_void, + format: *const c_schar, ap: va_list) -> bool; + pub fn JS_ConvertValue(cx: *mut Struct_JSContext, v: HandleValue, + _type: Enum_JSType, vp: MutableHandleValue) -> + bool; + pub fn JS_ValueToObject(cx: *mut Struct_JSContext, v: HandleValue, + objp: MutableHandleObject) -> bool; + pub fn JS_ValueToFunction(cx: *mut Struct_JSContext, v: HandleValue) -> + *mut c_void; + pub fn JS_ValueToConstructor(cx: *mut Struct_JSContext, v: HandleValue) -> + *mut c_void; + pub fn JS_ValueToSource(cx: *mut Struct_JSContext, v: HandleValue) -> //jdm c_void->HandleValue + *mut c_void; + pub fn JS_DoubleIsInt32(d: c_double, ip: *mut int32_t) -> bool; + pub fn JS_DoubleToInt32(d: c_double) -> int32_t; + pub fn JS_DoubleToUint32(d: c_double) -> uint32_t; + pub fn JS_TypeOfValue(cx: *mut Struct_JSContext, v: c_void) -> + Enum_JSType; + pub fn JS_GetTypeName(cx: *mut Struct_JSContext, _type: Enum_JSType) -> + *const c_schar; + pub fn JS_StrictlyEqual(cx: *mut Struct_JSContext, v1: jsval, v2: jsval, + equal: *mut bool) -> bool; + pub fn JS_LooselyEqual(cx: *mut Struct_JSContext, v1: c_void, v2: c_void, + equal: *mut bool) -> bool; + pub fn JS_SameValue(cx: *mut Struct_JSContext, v1: jsval, v2: jsval, + same: *mut bool) -> bool; + pub fn JS_IsBuiltinEvalFunction(fun: *mut c_void) -> bool; + pub fn JS_IsBuiltinFunctionConstructor(fun: *mut c_void) -> bool; + pub fn JS_Init() -> bool; + pub fn JS_ShutDown(); + pub fn JS_NewRuntime(maxbytes: uint32_t, + useHelperThreads: JSUseHelperThreads, + parentRuntime: *mut Struct_JSRuntime) -> + *mut Struct_JSRuntime; + pub fn JS_DestroyRuntime(rt: *mut Struct_JSRuntime); + pub fn JS_SetICUMemoryFunctions(allocFn: JS_ICUAllocFn, + reallocFn: JS_ICUReallocFn, + freeFn: JS_ICUFreeFn) -> bool; + pub fn JS_GetRuntimePrivate(rt: *mut Struct_JSRuntime) -> *mut c_void; + pub fn JS_GetRuntime(cx: *mut Struct_JSContext) -> *mut Struct_JSRuntime; + pub fn JS_GetParentRuntime(cx: *mut Struct_JSContext) -> + *mut Struct_JSRuntime; + pub fn JS_SetRuntimePrivate(rt: *mut Struct_JSRuntime, data: *mut c_void); + pub fn JS_BeginRequest(cx: *mut Struct_JSContext); + pub fn JS_EndRequest(cx: *mut Struct_JSContext); + pub fn JS_IsInRequest(rt: *mut Struct_JSRuntime) -> bool; + pub fn JS_SetContextCallback(rt: *mut Struct_JSRuntime, + cxCallback: JSContextCallback, + data: *mut c_void); + pub fn JS_NewContext(rt: *mut Struct_JSRuntime, stackChunkSize: size_t) -> + *mut Struct_JSContext; + pub fn JS_DestroyContext(cx: *mut Struct_JSContext); + pub fn JS_DestroyContextNoGC(cx: *mut Struct_JSContext); + pub fn JS_GetContextPrivate(cx: *mut Struct_JSContext) -> *mut c_void; + pub fn JS_SetContextPrivate(cx: *mut Struct_JSContext, data: *mut c_void); + pub fn JS_GetSecondContextPrivate(cx: *mut Struct_JSContext) -> + *mut c_void; + pub fn JS_SetSecondContextPrivate(cx: *mut Struct_JSContext, + data: *mut c_void); + pub fn JS_ContextIterator(rt: *mut Struct_JSRuntime, + iterp: *mut *mut Struct_JSContext) -> + *mut Struct_JSContext; + pub fn JS_GetVersion(cx: *mut Struct_JSContext) -> Enum_JSVersion; + pub fn JS_SetVersionForCompartment(compartment: *mut Struct_JSCompartment, + version: Enum_JSVersion); + pub fn JS_VersionToString(version: Enum_JSVersion) -> *const c_schar; + pub fn JS_StringToVersion(string: *const c_schar) -> Enum_JSVersion; + pub fn JS_GetImplementationVersion() -> *const c_schar; + pub fn JS_SetDestroyCompartmentCallback(rt: *mut Struct_JSRuntime, + callback: + JSDestroyCompartmentCallback); + pub fn JS_SetDestroyZoneCallback(rt: *mut Struct_JSRuntime, + callback: JSZoneCallback); + pub fn JS_SetSweepZoneCallback(rt: *mut Struct_JSRuntime, + callback: JSZoneCallback); + pub fn JS_SetCompartmentNameCallback(rt: *mut Struct_JSRuntime, + callback: JSCompartmentNameCallback); + pub fn JS_SetWrapObjectCallbacks(rt: *mut Struct_JSRuntime, + callbacks: + *const Struct_JSWrapObjectCallbacks); + pub fn JS_SetCompartmentPrivate(compartment: *mut Struct_JSCompartment, + data: *mut c_void); + pub fn JS_GetCompartmentPrivate(compartment: *mut Struct_JSCompartment) -> + *mut c_void; + pub fn JS_SetZoneUserData(zone: *mut Struct_Zone, data: *mut c_void); + pub fn JS_GetZoneUserData(zone: *mut Struct_Zone) -> *mut c_void; + pub fn JS_WrapObject(cx: *mut Struct_JSContext, objp: MutableHandleObject) + -> bool; + pub fn JS_WrapValue(cx: *mut Struct_JSContext, vp: MutableHandleValue) -> + bool; + pub fn JS_WrapId(cx: *mut Struct_JSContext, idp: MutableHandleId) -> + bool; + pub fn JS_TransplantObject(cx: *mut Struct_JSContext, + origobj: HandleObject, target: HandleObject) -> + *mut c_void; + pub fn JS_RefreshCrossCompartmentWrappers(cx: *mut Struct_JSContext, + obj: c_void) -> bool; + pub fn JS_EnterCompartment(cx: *mut Struct_JSContext, target: *mut JSObject) //jdm c_void->JSObject + -> *mut Struct_JSCompartment; + pub fn JS_LeaveCompartment(cx: *mut Struct_JSContext, + oldCompartment: *mut Struct_JSCompartment); + pub fn JS_IterateCompartments(rt: *mut Struct_JSRuntime, + data: *mut c_void, + compartmentCallback: + JSIterateCompartmentCallback); + pub fn JS_InitStandardClasses(cx: *mut Struct_JSContext, obj: JSHandleObject) -> //jdm c_void->JSHandleObject + bool; + pub fn JS_ResolveStandardClass(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + resolved: *mut bool) -> bool; + pub fn JS_EnumerateStandardClasses(cx: *mut Struct_JSContext, + obj: HandleObject) -> bool; + pub fn JS_GetClassObject(cx: *mut Struct_JSContext, key: Enum_JSProtoKey, + objp: c_void) -> bool; + pub fn JS_GetClassPrototype(cx: *mut Struct_JSContext, + key: Enum_JSProtoKey, objp: c_void) -> bool; + pub fn JS_IdToProtoKey(cx: *mut Struct_JSContext, id: HandleId) -> + Enum_JSProtoKey; + pub fn JS_GetFunctionPrototype(cx: *mut Struct_JSContext, + forObj: HandleObject) -> *mut c_void; + pub fn JS_GetObjectPrototype(cx: *mut Struct_JSContext, + forObj: HandleObject) -> *mut JSObject; //jdm c_void->JSObject + pub fn JS_GetArrayPrototype(cx: *mut Struct_JSContext, + forObj: HandleObject) -> *mut c_void; + pub fn JS_GetGlobalForObject(cx: *mut Struct_JSContext, obj: *mut c_void) + -> *mut c_void; + pub fn JS_IsGlobalObject(obj: *mut c_void) -> bool; + pub fn JS_GetGlobalForCompartmentOrNull(cx: *mut Struct_JSContext, + c: *mut Struct_JSCompartment) -> + *mut c_void; + pub fn JS_InitReflect(cx: *mut Struct_JSContext, global: HandleObject) -> + *mut c_void; + pub fn JS_EnumerateDiagnosticMemoryRegions(callback: + JSEnumerateDiagnosticMemoryCallback); + pub fn JS_malloc(cx: *mut Struct_JSContext, nbytes: size_t) -> + *mut c_void; + pub fn JS_realloc(cx: *mut Struct_JSContext, p: *mut c_void, + nbytes: size_t) -> *mut c_void; + pub fn JS_free(cx: *mut Struct_JSContext, p: *mut c_void); + pub fn JS_freeop(fop: *mut Struct_JSFreeOp, p: *mut c_void); + pub fn JS_GetDefaultFreeOp(rt: *mut Struct_JSRuntime) -> + *mut Struct_JSFreeOp; + pub fn JS_updateMallocCounter(cx: *mut Struct_JSContext, nbytes: size_t); + pub fn JS_strdup(rt: *mut Struct_JSRuntime, s: *const c_schar) -> *mut c_schar; + pub fn JS_AddExtraGCRootsTracer(rt: *mut Struct_JSRuntime, + traceOp: JSTraceDataOp, data: *mut c_void) + -> bool; + pub fn JS_RemoveExtraGCRootsTracer(rt: *mut Struct_JSRuntime, + traceOp: JSTraceDataOp, + data: *mut c_void); + pub fn JS_GC(rt: *mut Struct_JSRuntime); + pub fn JS_MaybeGC(cx: *mut Struct_JSContext); + pub fn JS_SetGCCallback(rt: *mut Struct_JSRuntime, cb: JSGCCallback, + data: *mut c_void); + pub fn JS_SetFinalizeCallback(rt: *mut Struct_JSRuntime, + cb: JSFinalizeCallback); + pub fn JS_IsGCMarkingTracer(trc: *mut c_void) -> bool; + pub fn JS_IsAboutToBeFinalized(objp: *mut c_void) -> bool; + pub fn JS_IsAboutToBeFinalizedUnbarriered(objp: *mut *mut c_void) -> + bool; + pub fn JS_SetGCParameter(rt: *mut Struct_JSRuntime, key: JSGCParamKey, + value: uint32_t); + pub fn JS_GetGCParameter(rt: *mut Struct_JSRuntime, key: JSGCParamKey) -> + uint32_t; + pub fn JS_SetGCParameterForThread(cx: *mut Struct_JSContext, + key: JSGCParamKey, value: uint32_t); + pub fn JS_GetGCParameterForThread(cx: *mut Struct_JSContext, + key: JSGCParamKey) -> uint32_t; + pub fn JS_SetGCParametersBasedOnAvailableMemory(rt: *mut Struct_JSRuntime, + availMem: uint32_t); + pub fn JS_NewExternalString(cx: *mut Struct_JSContext, chars: *const jschar, + length: size_t, + fin: *const Struct_JSStringFinalizer) -> + *mut c_void; + pub fn JS_IsExternalString(str: *mut c_void) -> bool; + pub fn JS_GetExternalStringFinalizer(str: *mut c_void) -> + *const Struct_JSStringFinalizer; + pub fn JS_SetNativeStackQuota(cx: *mut Struct_JSRuntime, + systemCodeStackSize: size_t, + trustedScriptStackSize: size_t, + untrustedScriptStackSize: size_t); + pub fn JS_IdArrayLength(cx: *mut Struct_JSContext, + ida: *mut Struct_JSIdArray) -> c_int; + pub fn JS_IdArrayGet(cx: *mut Struct_JSContext, + ida: *mut Struct_JSIdArray, index: c_int) -> + Struct_jsid; + pub fn JS_DestroyIdArray(cx: *mut Struct_JSContext, + ida: *mut Struct_JSIdArray); + pub fn JS_ValueToId(cx: *mut Struct_JSContext, v: HandleValue, + idp: MutableHandleId) -> bool; + pub fn JS_StringToId(cx: *mut Struct_JSContext, s: HandleString, + idp: MutableHandleId) -> bool; + pub fn JS_IdToValue(cx: *mut Struct_JSContext, id: Struct_jsid, + vp: c_void) -> bool; + pub fn JS_DefaultValue(cx: *mut Struct_JSContext, obj: c_void, + hint: Enum_JSType, vp: c_void) -> bool; + pub fn JS_PropertyStub(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, vp: MutableHandleValue) -> bool; + pub fn JS_StrictPropertyStub(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, strict: bool, + vp: MutableHandleValue) -> bool; + pub fn JS_DeletePropertyStub(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, succeeded: *mut bool) -> + bool; + pub fn JS_EnumerateStub(cx: *mut Struct_JSContext, obj: HandleObject) -> + bool; + pub fn JS_ResolveStub(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId) -> bool; + pub fn JS_ConvertStub(cx: *mut Struct_JSContext, obj: HandleObject, + _type: Enum_JSType, vp: MutableHandleValue) -> + bool; + pub fn JS_InitClass(cx: *mut Struct_JSContext, obj: HandleObject, + parent_proto: HandleObject, clasp: *const Struct_JSClass, + constructor: JSNative, nargs: c_uint, + ps: *const Struct_JSPropertySpec, + fs: *const Struct_JSFunctionSpec, + static_ps: *const Struct_JSPropertySpec, + static_fs: *const Struct_JSFunctionSpec) -> *mut c_void; + pub fn JS_LinkConstructorAndPrototype(cx: *mut Struct_JSContext, + ctor: JSHandleObject, proto: JSHandleObject) -> //jdm c_void->JSHandleObject + bool; + pub fn JS_GetClass(obj: *mut JSObject) -> *const Struct_JSClass; //jdm c_void->JSObject + pub fn JS_InstanceOf(cx: *mut Struct_JSContext, obj: c_void, + clasp: *const Struct_JSClass, args: *mut c_void) -> bool; + pub fn JS_HasInstance(cx: *mut Struct_JSContext, obj: c_void, v: c_void, + bp: *mut bool) -> bool; + pub fn JS_GetPrivate(obj: *mut c_void) -> *mut c_void; + pub fn JS_SetPrivate(obj: *mut c_void, data: *mut c_void); + pub fn JS_GetInstancePrivate(cx: *mut Struct_JSContext, obj: c_void, + clasp: *const Struct_JSClass, args: *mut c_void) -> + *mut c_void; + pub fn JS_GetPrototype(cx: *mut Struct_JSContext, obj: HandleObject, + protop: MutableHandleObject) -> bool; + pub fn JS_SetPrototype(cx: *mut Struct_JSContext, obj: HandleObject, + proto: HandleObject) -> bool; + pub fn JS_GetParent(obj: *mut c_void) -> *mut c_void; + pub fn JS_SetParent(cx: *mut Struct_JSContext, obj: HandleObject, + parent: HandleObject) -> bool; + pub fn JS_GetConstructor(cx: *mut Struct_JSContext, proto: c_void) -> + *mut c_void; + pub fn JS_NewGlobalObject(cx: *mut Struct_JSContext, + clasp: *const Struct_JSClass, + principals: *mut Struct_JSPrincipals, + hookOption: Enum_OnNewGlobalHookOption, + options: c_void) -> *mut c_void; + pub fn JS_GlobalObjectTraceHook(trc: *mut JSTracer, global: *mut JSObject); //jdm c_void->JSTracer, c_void->JSObject + pub fn JS_FireOnNewGlobalObject(cx: *mut Struct_JSContext, + global: HandleObject); + pub fn JS_NewObject(cx: *mut Struct_JSContext, clasp: *const Struct_JSClass, + proto: HandleObject, parent: HandleObject) -> *mut JSObject; //jdm c_void->HandleObject, c_void->JSObject + pub fn JS_IsExtensible(cx: *mut Struct_JSContext, obj: HandleObject, + extensible: *mut bool) -> bool; + pub fn JS_IsNative(obj: *mut c_void) -> bool; + pub fn JS_GetObjectRuntime(obj: *mut c_void) -> *mut Struct_JSRuntime; + pub fn JS_NewObjectWithGivenProto(cx: *mut Struct_JSContext, + clasp: *const Struct_JSClass, proto: HandleObject, //jdm c_void->HandleObject + parent: HandleObject) -> *mut JSObject; //jdm c_void->HandleObject,c_void->JSObject + pub fn JS_DeepFreezeObject(cx: *mut Struct_JSContext, obj: c_void) -> + bool; + pub fn JS_FreezeObject(cx: *mut Struct_JSContext, obj: c_void) -> bool; + pub fn JS_PreventExtensions(cx: *mut Struct_JSContext, obj: HandleObject) + -> bool; + pub fn JS_New(cx: *mut Struct_JSContext, ctor: HandleObject, args: c_void) + -> *mut c_void; + pub fn JS_DefineObject(cx: *mut Struct_JSContext, obj: *mut c_void, + name: *const c_schar, clasp: *const Struct_JSClass, + proto: *mut c_void, attrs: c_uint) -> *mut c_void; + pub fn JS_DefineConstDoubles(cx: *mut Struct_JSContext, obj: HandleObject, + cds: *const Struct_JSConstDoubleSpec) -> bool; + pub fn JS_DefineProperties(cx: *mut Struct_JSContext, obj: HandleObject, + ps: *const Struct_JSPropertySpec) -> bool; + pub fn JS_DefineProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, value: HandleValue, + attrs: c_uint, getter: JSPropertyOp, + setter: JSStrictPropertyOp) -> bool; + pub fn JS_DefinePropertyById(cx: *mut Struct_JSContext, obj: *mut JSObject, //jdm c_void->JSObject + id: Struct_jsid, value: jsval, + getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: c_uint) -> + bool; + pub fn JS_DefineOwnProperty(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, descriptor: HandleValue, + bp: *mut bool) -> bool; + pub fn JS_AlreadyHasOwnProperty(cx: *mut Struct_JSContext, + obj: HandleObject, name: *const c_schar, + foundp: *mut bool) -> bool; + pub fn JS_AlreadyHasOwnPropertyById(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + foundp: *mut bool) -> bool; + pub fn JS_HasProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, foundp: *mut bool) -> bool; + pub fn JS_HasPropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, foundp: *mut bool) -> bool; + pub fn JS_LookupProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, vp: MutableHandleValue) -> bool; + pub fn JS_LookupPropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, vp: MutableHandleValue) -> + bool; + pub fn JS_LookupPropertyWithFlags(cx: *mut Struct_JSContext, + obj: HandleObject, name: *const c_schar, + flags: c_uint, vp: MutableHandleValue) + -> bool; + pub fn JS_LookupPropertyWithFlagsById(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + flags: c_uint, + objp: MutableHandleObject, + vp: MutableHandleValue) -> bool; + pub fn JS_GetOwnPropertyDescriptorById(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + flags: c_uint, desc: c_void) -> + bool; + pub fn JS_GetOwnPropertyDescriptor(cx: *mut Struct_JSContext, + obj: HandleObject, name: *const c_schar, + flags: c_uint, desc: c_void) -> bool; + pub fn JS_GetPropertyDescriptorById(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + flags: c_uint, desc: MutableHandle) -> bool; //jdm c_void->JSMutableHandle + pub fn JS_GetPropertyDescriptor(cx: *mut Struct_JSContext, + obj: HandleObject, name: *const c_schar, + flags: c_uint, desc: c_void) -> bool; + pub fn JS_GetProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, vp: MutableHandleValue) -> bool; + pub fn JS_GetPropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, vp: MutableHandleValue) -> bool; + pub fn JS_ForwardGetPropertyTo(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + onBehalfOf: HandleObject, + vp: MutableHandleValue) -> bool; + pub fn JS_SetProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, v: HandleValue) -> bool; + pub fn JS_SetPropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, v: HandleValue) -> bool; + pub fn JS_DeleteProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar) -> bool; + pub fn JS_DeleteProperty2(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, succeeded: *mut bool) -> bool; + pub fn JS_DeletePropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: Struct_jsid) -> bool; + pub fn JS_DeletePropertyById2(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + succeeded: *mut bool) -> bool; + pub fn JS_DefineUCProperty(cx: *mut Struct_JSContext, obj: *mut c_void, + name: *const jschar, namelen: size_t, value: jsval, + getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: c_uint) -> + bool; + pub fn JS_AlreadyHasOwnUCProperty(cx: *mut Struct_JSContext, + obj: HandleObject, name: *const jschar, + namelen: size_t, foundp: *mut bool) -> + bool; + pub fn JS_HasUCProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const jschar, namelen: size_t, vp: *mut bool) -> + bool; + pub fn JS_LookupUCProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const jschar, namelen: size_t, + vp: MutableHandleValue) -> bool; + pub fn JS_GetUCProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const jschar, namelen: size_t, + vp: MutableHandleValue) -> bool; + pub fn JS_SetUCProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const jschar, namelen: size_t, v: HandleValue) -> + bool; + pub fn JS_DeleteUCProperty2(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const jschar, namelen: size_t, + succeeded: *mut bool) -> bool; + pub fn JS_NewArrayObject(cx: *mut Struct_JSContext, length: size_t) -> + *mut c_void; + pub fn JS_IsArrayObject(cx: *mut Struct_JSContext, obj: HandleObject) -> + bool; + pub fn JS_GetArrayLength(cx: *mut Struct_JSContext, obj: c_void, + lengthp: *mut uint32_t) -> bool; + pub fn JS_SetArrayLength(cx: *mut Struct_JSContext, obj: c_void, + length: uint32_t) -> bool; + pub fn JS_DefineElement(cx: *mut Struct_JSContext, obj: *mut c_void, + index: uint32_t, value: jsval, + getter: JSPropertyOp, setter: JSStrictPropertyOp, + attrs: c_uint) -> bool; + pub fn JS_AlreadyHasOwnElement(cx: *mut Struct_JSContext, + obj: HandleObject, index: uint32_t, + foundp: *mut bool) -> bool; + pub fn JS_HasElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, foundp: *mut bool) -> bool; + pub fn JS_LookupElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, vp: MutableHandleValue) -> bool; + pub fn JS_GetElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, vp: MutableHandleValue) -> bool; + pub fn JS_ForwardGetElementTo(cx: *mut Struct_JSContext, + obj: HandleObject, index: uint32_t, + onBehalfOf: HandleObject, + vp: MutableHandleValue) -> bool; + pub fn JS_SetElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, v: HandleObject) -> bool; + pub fn JS_DeleteElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t) -> bool; + pub fn JS_DeleteElement2(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, succeeded: *mut bool) -> bool; + pub fn JS_ClearNonGlobalObject(cx: *mut Struct_JSContext, + obj: HandleObject); + pub fn JS_SetAllNonReservedSlotsToUndefined(cx: *mut Struct_JSContext, + objArg: *mut c_void); + pub fn JS_NewArrayBufferWithContents(cx: *mut Struct_JSContext, + nbytes: size_t, + contents: *mut c_void) -> + *mut c_void; + pub fn JS_StealArrayBufferContents(cx: *mut Struct_JSContext, + obj: HandleObject) -> *mut c_void; + pub fn JS_AllocateArrayBufferContents(maybecx: *mut Struct_JSContext, + nbytes: uint32_t) -> *mut c_void; + pub fn JS_ReallocateArrayBufferContents(cx: *mut Struct_JSContext, + nbytes: uint32_t, + oldContents: *mut c_void, + oldNbytes: uint32_t) -> + *mut c_void; + pub fn JS_NewMappedArrayBufferWithContents(cx: *mut Struct_JSContext, + nbytes: size_t, + contents: *mut c_void) -> + *mut c_void; + pub fn JS_CreateMappedArrayBufferContents(fd: c_int, offset: size_t, + length: size_t) -> *mut c_void; + pub fn JS_ReleaseMappedArrayBufferContents(contents: *mut c_void, + length: size_t); + pub fn JS_Enumerate(cx: *mut Struct_JSContext, obj: HandleObject) -> + *mut Struct_JSIdArray; + pub fn JS_NewPropertyIterator(cx: *mut Struct_JSContext, obj: c_void) -> + *mut c_void; + pub fn JS_NextProperty(cx: *mut Struct_JSContext, iterobj: c_void, + idp: *mut Struct_jsid) -> bool; + pub fn JS_GetReservedSlot(obj: *mut JSObject, index: uint32_t) -> jsval; + pub fn JS_SetReservedSlot(obj: *mut JSObject, index: uint32_t, v: jsval); + pub fn JS_NewFunction(cx: *mut Struct_JSContext, call: JSNative, + nargs: c_uint, flags: c_uint, parent: JSHandleObject, //jdm c_void->JSHandleObject + name: *const c_schar) -> *mut JSFunction; //jdm c_void->JSFunction + pub fn JS_NewFunctionById(cx: *mut Struct_JSContext, call: JSNative, + nargs: c_uint, flags: c_uint, parent: c_void, + id: c_void) -> *mut c_void; + pub fn JS_GetFunctionObject(fun: *mut JSFunction) -> *mut JSObject; //jdm c_void->JSFunction,c_void->JSObject + pub fn JS_GetFunctionId(fun: *mut c_void) -> *mut c_void; + pub fn JS_GetFunctionDisplayId(fun: *mut c_void) -> *mut c_void; + pub fn JS_GetFunctionArity(fun: *mut c_void) -> uint16_t; + pub fn JS_ObjectIsFunction(cx: *mut Struct_JSContext, obj: *mut c_void) -> + bool; + pub fn JS_ObjectIsCallable(cx: *mut Struct_JSContext, obj: *mut JSObject) -> //jdm c_void->JSObject + bool; + pub fn JS_IsNativeFunction(funobj: *mut c_void, call: JSNative) -> bool; + pub fn JS_IsConstructor(fun: *mut c_void) -> bool; + pub fn JS_BindCallable(cx: *mut Struct_JSContext, callable: c_void, + newThis: c_void) -> *mut c_void; + pub fn JS_DefineFunctions(cx: *mut Struct_JSContext, obj: JSHandleObject, //jdm c_void->JSHandleObject + fs: *const Struct_JSFunctionSpec) -> bool; + pub fn JS_DefineFunction(cx: *mut Struct_JSContext, obj: c_void, + name: *const c_schar, call: JSNative, nargs: c_uint, + attrs: c_uint) -> *mut c_void; + pub fn JS_DefineUCFunction(cx: *mut Struct_JSContext, obj: c_void, + name: *const jschar, namelen: size_t, call: JSNative, + nargs: c_uint, attrs: c_uint) -> *mut c_void; + pub fn JS_DefineFunctionById(cx: *mut Struct_JSContext, obj: c_void, + id: c_void, call: JSNative, nargs: c_uint, + attrs: c_uint) -> *mut c_void; + pub fn JS_CloneFunctionObject(cx: *mut Struct_JSContext, funobj: JSHandleObject, + parent: JSHandleObject) -> *mut JSObject; //jdm +handles, c_void->JSObject + pub fn JS_BufferIsCompilableUnit(cx: *mut Struct_JSContext, obj: c_void, + utf8: *const c_schar, length: size_t) -> bool; + pub fn JS_CompileScript(cx: *mut Struct_JSContext, obj: HandleObject, + ascii: *const c_schar, length: size_t, options: c_void) + -> *mut c_void; + pub fn JS_CompileUCScript(cx: *mut Struct_JSContext, obj: HandleObject, + chars: *const jschar, length: size_t, options: c_void) + -> *mut c_void; + pub fn JS_GetGlobalFromScript(script: *mut c_void) -> *mut c_void; + pub fn JS_CompileFunction(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, nargs: c_uint, + argnames: *const *const c_schar, bytes: *const c_schar, + length: size_t, options: c_void) -> *mut c_void; + pub fn JS_CompileUCFunction(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, nargs: c_uint, + argnames: *const *const c_schar, chars: *const jschar, + length: size_t, options: c_void) -> + *mut c_void; + pub fn JS_DecompileScript(cx: *mut Struct_JSContext, script: c_void, + name: *const c_schar, indent: c_uint) -> *mut c_void; + pub fn JS_DecompileFunction(cx: *mut Struct_JSContext, fun: c_void, + indent: c_uint) -> *mut c_void; + pub fn JS_DecompileFunctionBody(cx: *mut Struct_JSContext, fun: c_void, + indent: c_uint) -> *mut c_void; + pub fn JS_ExecuteScript(cx: *mut Struct_JSContext, obj: HandleObject, + script: HandleScript, rval: MutableHandleValue) -> + bool; + pub fn JS_ExecuteScriptVersion(cx: *mut Struct_JSContext, + obj: HandleObject, script: HandleScript, + rval: MutableHandleValue, + version: Enum_JSVersion) -> bool; + pub fn JS_EvaluateScript(cx: *mut Struct_JSContext, obj: HandleObject, + bytes: *const c_schar, length: c_uint, + filename: *const c_schar, lineno: c_uint, + rval: MutableHandleValue) -> bool; + pub fn JS_EvaluateUCScript(cx: *mut Struct_JSContext, obj: HandleObject, //jdm c_void->HandleObject + chars: *const jschar, length: c_uint, + filename: *const c_schar, lineno: c_uint, + rval: JSMutableHandleValue) -> bool; //jdm c_void->JSMutableHandleValue + pub fn JS_CallFunction(cx: *mut Struct_JSContext, obj: HandleObject, + fun: HandleFunction, args: c_void, + rval: MutableHandleValue) -> bool; + pub fn JS_CallFunctionName(cx: *mut Struct_JSContext, obj: HandleObject, + name: *const c_schar, args: c_void, + rval: MutableHandleValue) -> bool; + pub fn JS_CallFunctionValue(cx: *mut Struct_JSContext, obj: HandleObject, + fval: HandleValue, args: c_void, + rval: MutableHandleValue) -> bool; + pub fn JS_SetInterruptCallback(rt: *mut Struct_JSRuntime, + callback: JSInterruptCallback) -> + JSInterruptCallback; + pub fn JS_GetInterruptCallback(rt: *mut Struct_JSRuntime) -> + JSInterruptCallback; + pub fn JS_RequestInterruptCallback(rt: *mut Struct_JSRuntime); + pub fn JS_IsRunning(cx: *mut Struct_JSContext) -> bool; + pub fn JS_SaveFrameChain(cx: *mut Struct_JSContext) -> bool; + pub fn JS_RestoreFrameChain(cx: *mut Struct_JSContext); + pub fn JS_NewStringCopyN(cx: *mut Struct_JSContext, s: *const c_schar, + n: size_t) -> *mut JSString; //jdm c_void->JSString + pub fn JS_NewStringCopyZ(cx: *mut Struct_JSContext, s: *const c_schar) -> + *mut c_void; + pub fn JS_InternJSString(cx: *mut Struct_JSContext, str: HandleString) -> + *mut c_void; + pub fn JS_InternStringN(cx: *mut Struct_JSContext, s: *const c_schar, + length: size_t) -> *mut c_void; + pub fn JS_InternString(cx: *mut Struct_JSContext, s: *const c_schar) -> + *mut c_void; + pub fn JS_NewUCString(cx: *mut Struct_JSContext, chars: *mut jschar, + length: size_t) -> *mut JSString; //jdm c_void->JSString + pub fn JS_NewUCStringCopyN(cx: *mut Struct_JSContext, s: *const jschar, + n: size_t) -> *mut JSString; //jdm -> c_void->JSString + pub fn JS_NewUCStringCopyZ(cx: *mut Struct_JSContext, s: *const jschar) -> + *mut c_void; + pub fn JS_InternUCStringN(cx: *mut Struct_JSContext, s: *const jschar, + length: size_t) -> *mut c_void; + pub fn JS_InternUCString(cx: *mut Struct_JSContext, s: *const jschar) -> + *mut c_void; + pub fn JS_CompareStrings(cx: *mut Struct_JSContext, str1: *mut c_void, + str2: *mut c_void, result: *mut int32_t) -> + bool; + pub fn JS_StringEqualsAscii(cx: *mut Struct_JSContext, str: *mut c_void, + asciiBytes: *const c_schar, _match: *mut bool) -> + bool; + pub fn JS_PutEscapedString(cx: *mut Struct_JSContext, + buffer: *mut c_schar, size: size_t, + str: *mut c_void, quote: c_schar) -> size_t; + pub fn JS_FileEscapedString(fp: *mut FILE, str: *mut c_void, + quote: c_schar) -> bool; + pub fn JS_GetStringLength(str: *mut c_void) -> size_t; + pub fn JS_GetStringCharsAndLength(cx: *mut Struct_JSContext, + str: *mut JSString, length: *mut size_t) //jdm c_void->JSString + -> *const jschar; + pub fn JS_GetInternedStringChars(str: *mut c_void) -> *const jschar; + pub fn JS_GetInternedStringCharsAndLength(str: *mut c_void, + length: *mut size_t) -> *const jschar; + pub fn JS_GetStringCharsZ(cx: *mut Struct_JSContext, str: *mut c_void) -> + *const jschar; + pub fn JS_GetStringCharsZAndLength(cx: *mut Struct_JSContext, + str: *mut c_void, length: *mut size_t) + -> *const jschar; + pub fn JS_FlattenString(cx: *mut Struct_JSContext, str: *mut c_void) -> + *mut c_void; + pub fn JS_GetFlatStringChars(str: *mut c_void) -> *const jschar; + pub fn JS_FlatStringEqualsAscii(str: *mut c_void, asciiBytes: *const c_schar) -> + bool; + pub fn JS_PutEscapedFlatString(buffer: *mut c_schar, size: size_t, + str: *mut c_void, quote: c_schar) -> + size_t; + pub fn JS_NewDependentString(cx: *mut Struct_JSContext, str: HandleString, + start: size_t, length: size_t) -> + *mut c_void; + pub fn JS_ConcatStrings(cx: *mut Struct_JSContext, left: HandleString, + right: HandleString) -> *mut c_void; + pub fn JS_DecodeBytes(cx: *mut Struct_JSContext, src: *const c_schar, + srclen: size_t, dst: *mut jschar, + dstlenp: *mut size_t) -> bool; + pub fn JS_EncodeString(cx: *mut Struct_JSContext, str: *mut c_void) -> + *mut c_schar; + pub fn JS_EncodeStringToUTF8(cx: *mut Struct_JSContext, str: HandleString) + -> *mut c_schar; + pub fn JS_GetStringEncodingLength(cx: *mut Struct_JSContext, + str: *mut c_void) -> size_t; + pub fn JS_EncodeStringToBuffer(cx: *mut Struct_JSContext, + str: *mut c_void, buffer: *mut c_schar, + length: size_t) -> size_t; + pub fn JS_Stringify(cx: *mut Struct_JSContext, value: MutableHandleValue, + replacer: HandleObject, space: HandleValue, + callback: JSONWriteCallback, data: *mut c_void) -> + bool; + pub fn JS_ParseJSON(cx: *mut Struct_JSContext, chars: *const jschar, + len: uint32_t, vp: MutableHandleValue) -> bool; + pub fn JS_ParseJSONWithReviver(cx: *mut Struct_JSContext, chars: *const jschar, + len: uint32_t, reviver: HandleValue, + vp: MutableHandleValue) -> bool; + pub fn JS_SetDefaultLocale(rt: *mut Struct_JSRuntime, locale: *const c_schar) -> + bool; + pub fn JS_ResetDefaultLocale(rt: *mut Struct_JSRuntime); + pub fn JS_SetLocaleCallbacks(rt: *mut Struct_JSRuntime, + callbacks: *mut Struct_JSLocaleCallbacks); + pub fn JS_GetLocaleCallbacks(rt: *mut Struct_JSRuntime) -> + *mut Struct_JSLocaleCallbacks; + pub fn JS_ReportError(cx: *mut Struct_JSContext, format: *const c_schar, ...); + pub fn JS_ReportErrorNumber(cx: *mut Struct_JSContext, + errorCallback: JSErrorCallback, + userRef: *mut c_void, + errorNumber: c_uint, ...); + pub fn JS_ReportErrorNumberVA(cx: *mut Struct_JSContext, + errorCallback: JSErrorCallback, + userRef: *mut c_void, errorNumber: c_uint, + ap: va_list); + pub fn JS_ReportErrorNumberUC(cx: *mut Struct_JSContext, + errorCallback: JSErrorCallback, + userRef: *mut c_void, + errorNumber: c_uint, ...); + pub fn JS_ReportErrorNumberUCArray(cx: *mut Struct_JSContext, + errorCallback: JSErrorCallback, + userRef: *mut c_void, + errorNumber: c_uint, + args: *mut *const jschar); + pub fn JS_ReportWarning(cx: *mut Struct_JSContext, format: *const c_schar, ...) + -> bool; + pub fn JS_ReportErrorFlagsAndNumber(cx: *mut Struct_JSContext, + flags: c_uint, + errorCallback: JSErrorCallback, + userRef: *mut c_void, + errorNumber: c_uint, ...) -> bool; + pub fn JS_ReportErrorFlagsAndNumberUC(cx: *mut Struct_JSContext, + flags: c_uint, + errorCallback: JSErrorCallback, + userRef: *mut c_void, + errorNumber: c_uint, ...) -> bool; + pub fn JS_ReportOutOfMemory(cx: *mut Struct_JSContext); + pub fn JS_ReportAllocationOverflow(cx: *mut Struct_JSContext); + pub fn JS_GetErrorReporter(cx: *mut Struct_JSContext) -> JSErrorReporter; + pub fn JS_SetErrorReporter(cx: *mut Struct_JSContext, er: JSErrorReporter) + -> JSErrorReporter; + pub fn JS_NewDateObject(cx: *mut Struct_JSContext, year: c_int, + mon: c_int, mday: c_int, hour: c_int, min: c_int, + sec: c_int) -> *mut c_void; + pub fn JS_NewDateObjectMsec(cx: *mut Struct_JSContext, msec: c_double) -> + *mut c_void; + pub fn JS_ObjectIsDate(cx: *mut Struct_JSContext, obj: HandleObject) -> + bool; + pub fn JS_ClearDateCaches(cx: *mut Struct_JSContext); + pub fn JS_NewRegExpObject(cx: *mut Struct_JSContext, obj: HandleObject, + bytes: *mut c_schar, length: size_t, + flags: c_uint) -> *mut c_void; + pub fn JS_NewUCRegExpObject(cx: *mut Struct_JSContext, obj: HandleObject, + chars: *mut jschar, length: size_t, + flags: c_uint) -> *mut c_void; + pub fn JS_SetRegExpInput(cx: *mut Struct_JSContext, obj: HandleObject, + input: HandleString, multiline: bool); + pub fn JS_ClearRegExpStatics(cx: *mut Struct_JSContext, + obj: HandleObject); + pub fn JS_ExecuteRegExp(cx: *mut Struct_JSContext, obj: HandleObject, + reobj: HandleObject, chars: *mut jschar, + length: size_t, indexp: *mut size_t, test: bool, + rval: MutableHandleValue) -> bool; + pub fn JS_NewRegExpObjectNoStatics(cx: *mut Struct_JSContext, + bytes: *mut c_schar, length: size_t, + flags: c_uint) -> *mut c_void; + pub fn JS_NewUCRegExpObjectNoStatics(cx: *mut Struct_JSContext, + chars: *mut jschar, length: size_t, + flags: c_uint) -> *mut c_void; + pub fn JS_ExecuteRegExpNoStatics(cx: *mut Struct_JSContext, + reobj: HandleObject, chars: *mut jschar, + length: size_t, indexp: *mut size_t, + test: bool, rval: MutableHandleValue) -> + bool; + pub fn JS_ObjectIsRegExp(cx: *mut Struct_JSContext, obj: HandleObject) -> + bool; + pub fn JS_GetRegExpFlags(cx: *mut Struct_JSContext, obj: HandleObject) -> + c_uint; + pub fn JS_GetRegExpSource(cx: *mut Struct_JSContext, obj: HandleObject) -> + *mut c_void; + pub fn JS_IsExceptionPending(cx: *mut Struct_JSContext) -> bool; + pub fn JS_GetPendingException(cx: *mut Struct_JSContext, + vp: MutableHandleValue) -> bool; + pub fn JS_SetPendingException(cx: *mut Struct_JSContext, v: HandleValue); + pub fn JS_ClearPendingException(cx: *mut Struct_JSContext); + pub fn JS_ReportPendingException(cx: *mut Struct_JSContext) -> bool; + pub fn JS_SaveExceptionState(cx: *mut Struct_JSContext) -> + *mut Struct_JSExceptionState; + pub fn JS_RestoreExceptionState(cx: *mut Struct_JSContext, + state: *mut Struct_JSExceptionState); + pub fn JS_DropExceptionState(cx: *mut Struct_JSContext, + state: *mut Struct_JSExceptionState); + pub fn JS_ErrorFromException(cx: *mut Struct_JSContext, obj: HandleObject) + -> *mut Struct_JSErrorReport; + pub fn JS_ThrowStopIteration(cx: *mut Struct_JSContext) -> bool; + pub fn JS_IsStopIteration(v: jsval) -> bool; + pub fn JS_GetCurrentThread() -> intptr_t; + pub fn JS_AbortIfWrongThread(rt: *mut Struct_JSRuntime); + pub fn JS_SetNativeStackBounds(rt: *mut Struct_JSRuntime, + minValue: uintptr_t, maxValue: uintptr_t); + pub fn JS_NewObjectForConstructor(cx: *mut Struct_JSContext, + clasp: *const Struct_JSClass, args: c_void) -> + *mut c_void; + pub fn JS_SetGCZeal(cx: *mut Struct_JSContext, zeal: uint8_t, + frequency: uint32_t); + pub fn JS_ScheduleGC(cx: *mut Struct_JSContext, count: uint32_t); + pub fn JS_SetParallelParsingEnabled(rt: *mut Struct_JSRuntime, + enabled: bool); + pub fn JS_SetParallelIonCompilationEnabled(rt: *mut Struct_JSRuntime, + enabled: bool); + pub fn JS_SetGlobalJitCompilerOption(rt: *mut Struct_JSRuntime, + opt: JSJitCompilerOption, + value: uint32_t); + pub fn JS_GetGlobalJitCompilerOption(rt: *mut Struct_JSRuntime, + opt: JSJitCompilerOption) -> bool; + pub fn JS_IndexToId(cx: *mut Struct_JSContext, index: uint32_t, + arg1: MutableHandleId) -> bool; + pub fn JS_CharsToId(cx: *mut Struct_JSContext, chars: c_void, + arg1: MutableHandleId) -> bool; + pub fn JS_IsIdentifier(cx: *mut Struct_JSContext, str: HandleString, + isIdentifier: *mut bool) -> bool; + pub fn JS_EncodeScript(cx: *mut Struct_JSContext, script: HandleScript, + lengthp: *mut uint32_t) -> *mut c_void; + pub fn JS_EncodeInterpretedFunction(cx: *mut Struct_JSContext, + funobj: HandleObject, + lengthp: *mut uint32_t) -> + *mut c_void; + pub fn JS_DecodeScript(cx: *mut Struct_JSContext, data: *const c_void, + length: uint32_t, + originPrincipals: *mut Struct_JSPrincipals) -> + *mut c_void; + pub fn JS_DecodeInterpretedFunction(cx: *mut Struct_JSContext, + data: *const c_void, length: uint32_t, + originPrincipals: + *mut Struct_JSPrincipals) -> + *mut c_void; +} -pub fn JS_IndexToId(cx: *mut JSContext, index: uint32_t, id: *mut jsid) -> JSBool; +/* end automatically generated code */ -pub fn JS_IsIdentifier(cx: *mut JSContext, str: *mut JSString, isIdentifier: *mut JSBool) -> JSBool; +#[repr(C)] +pub struct MutableHandle<'a, T: 'a> { + pub unnamed_field1: &'a mut T, +} -pub fn JS_DescribeScriptedCaller(cx: *mut JSContext, script: *mut *mut JSScript, lineno: *mut c_uint) -> JSBool; +#[repr(C)] +pub struct Handle<'a, T: 'a> { + pub unnamed_field1: &'a T, +} -pub fn JS_EncodeScript(cx: *mut JSContext, script: *mut JSScript, lengthp: *mut uint32_t) -> *mut c_void; +pub type HandleFunction<'a> = Handle<'a, *mut JSFunction>; +pub type HandleId<'a> = Handle<'a, jsid>; +pub type HandleObject<'a> = Handle<'a, *mut JSObject>; +pub type HandleScript<'a> = Handle<'a, *mut JSScript>; +pub type HandleString<'a> = Handle<'a, *mut JSString>; +pub type HandleValue<'a> = Handle<'a, JSVal>; +pub type MutableHandleId<'a> = MutableHandle<'a, jsid>; +pub type MutableHandleObject<'a> = MutableHandle<'a, *mut JSObject>; +pub type MutableHandleValue<'a> = MutableHandle<'a, JSVal>; +pub type JSHandleFunction<'a> = Handle<'a, *mut JSFunction>; +pub type JSHandleId<'a> = Handle<'a, jsid>; +pub type JSHandleObject<'a> = Handle<'a, *mut JSObject>; +pub type JSHandleScript<'a> = Handle<'a, *mut JSScript>; +pub type JSHandleString<'a> = Handle<'a, *mut JSString>; +pub type JSHandleValue<'a> = Handle<'a, JSVal>; +pub type JSMutableHandleId<'a> = MutableHandle<'a, jsid>; +pub type JSMutableHandleObject<'a> = MutableHandle<'a, *mut JSObject>; +pub type JSMutableHandleValue<'a> = MutableHandle<'a, JSVal>; + +#[repr(C)] +pub struct JSTracer(c_void); +#[repr(C)] +pub struct JSRuntime; +#[repr(C)] +pub struct JSContext; +#[repr(C)] +pub struct JSObject; +//pub type jsid = ptrdiff_t; +pub type jsid = Struct_jsid; +pub type JSFunctionSpec = Struct_JSFunctionSpec; +pub type JSPropertyDescriptor = Struct_JSPropertyDescriptor; +pub enum JSFunction {} +pub type JSFreeOp = Struct_JSFreeOp; +pub enum JSString {} +pub type JSErrorReport = Struct_JSErrorReport; +pub type JSClass = Struct_JSClass; +pub type JSPropertySpec = Struct_JSPropertySpec; +pub type Struct_ForkJoinContext= c_void; +pub type Struct_ThreadSafeContext= c_void; +pub type Struct_Zone= c_void; +pub type va_list= c_void; +pub type Enum_OnNewGlobalHookOption = uint; +pub type JSVersion = Enum_JSVersion; +pub type JSScript= c_void; +pub type jsval = JSVal; +pub type JSPrincipals = Struct_JSPrincipals; +pub type Struct_JSJitInfo = JSJitInfo; +pub type JSGCTraceKind = Enum_JSGCTraceKind; + +impl<'a, T> Deref for Handle<'a, T> { + fn deref<'b>(&'b self) -> &'b T { + &*self.unnamed_field1 + } +} -pub fn JS_EncodeInterpretedFunction(cx: *mut JSContext, funobj: JSRawObject, lengthp: *mut uint32_t) -> *mut c_void; +impl<'a, T> MutableHandle<'a, T> { + pub fn immut<'b>(&'b self) -> Handle<'b, T> { + Handle { + unnamed_field1: &*self.unnamed_field1 + } + } + + pub fn clone<'b>(&'b mut self) -> MutableHandle<'b, T> { + MutableHandle { + unnamed_field1: &mut *self.unnamed_field1 + } + } +} -pub fn JS_DecodeScript(cx: *mut JSContext, data: *const c_void, length: uint32_t, principals: *mut JSPrincipals, originPrincipals: *mut JSPrincipals) -> *mut JSScript; +impl<'a, T> Deref for MutableHandle<'a, T> { + fn deref<'b>(&'b self) -> &'b T { + &*self.unnamed_field1 + } +} -pub fn JS_DecodeInterpretedFunction(cx: *mut JSContext, data: *const c_void, length: uint32_t, principals: *mut JSPrincipals, originPrincipals: *mut JSPrincipals) -> *mut JSObject; +impl<'a, T> DerefMut for MutableHandle<'a, T> { + fn deref_mut<'b>(&'b mut self) -> &'b mut T { + &mut *self.unnamed_field1 + } } diff --git a/src/jsfriendapi.rs b/src/jsfriendapi.rs index fb6778b94..8b1df7792 100644 --- a/src/jsfriendapi.rs +++ b/src/jsfriendapi.rs @@ -2,34 +2,80 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -use jsapi::{JSContext, JSObject, JSPropertyDescriptor, JSBool}; +#![allow(ctypes)] + +use jsapi::{JSContext, JSObject, JSPropertyDescriptor, JSMutableHandleValue, JSHandleValue}; +use jsapi::{JSRuntime, Struct_JSStructuredCloneCallbacks, JSHandleObject, JSHandleId}; +use glue::JSBool; +use libc; pub type JSJitPropertyOp = *const u8; +pub enum OpType { + Getter = 0, + Setter = 1, + Method = 2, +} + +#[repr(C)] pub struct JSJitInfo { pub op: JSJitPropertyOp, - pub protoID: u32, - pub depth: u32, - pub isInfallible: bool, - pub isConstant: bool + pub protoID: u16, + pub depth: u16, + pub type_and_aliasSet: u8, + pub returnType: u8, + pub infallible_and_isMovable_and_isInSlot_and_isTypedMethod_and_slotIndex: u16, } extern { + pub fn PR_GetCurrentThread() -> *const libc::c_void; +} + +extern "C" { pub fn JS_ObjectToOuterObject(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject; pub fn JS_WrapPropertyDescriptor(cx: *mut JSContext, desc: *mut JSPropertyDescriptor) -> JSBool; +pub fn JS_ReadStructuredClone(cx: *mut JSContext, data: *const u64, nbytes: libc::size_t, + version: u32, vp: JSMutableHandleValue, + optionalCallbacks: *const Struct_JSStructuredCloneCallbacks, + closure: *mut libc::c_void) -> bool; +pub fn JS_WriteStructuredClone(cx: *mut JSContext, v: JSHandleValue, datap: *mut *mut u64, + nbytesp: *mut libc::size_t, + optionalCallbacks: *const Struct_JSStructuredCloneCallbacks, + closure: *mut libc::c_void, + transferable: JSHandleValue) -> bool; +pub fn SetDOMCallbacks(rt: *mut JSRuntime, callbacks: *const DOMCallbacks); } //pub type JSJitInfo = JSJitInfo_struct; pub mod bindgen { - use jsapi::{JSContext, JSObject, JSClass, JSRuntime}; + use jsapi::{JSContext, JSObject, JSClass, JSRuntime, JSHandleObject, Handle}; use libc::uintptr_t; - extern { + extern "C" { pub fn JS_NewObjectWithUniqueType(cx: *mut JSContext, clasp: *const JSClass, - proto: *const JSObject, parent: *const JSObject) -> *mut JSObject; + proto: JSHandleObject, parent: Handle<*mut JSObject>) -> *mut JSObject; pub fn JS_GetAddressableObject(rt: *mut JSRuntime, candidateObj: uintptr_t) -> *mut JSObject; } } + +pub type DOMInstanceClassMatchesProto = Option bool>; +#[repr(C)] +pub struct DOMCallbacks { + pub instanceClassMatchesProto: DOMInstanceClassMatchesProto, +} + +pub enum DOMProxyShadowsResult { + ShadowCheckFailed = 0, + Shadows = 1, + DoesntShadow = 2, + DoesntShadowUnique = 3, +} + +pub type DOMProxyShadowsCheck = Option DOMProxyShadowsResult>; diff --git a/src/jsglue.cpp b/src/jsglue.cpp index 0d8ce5773..3823268ab 100644 --- a/src/jsglue.cpp +++ b/src/jsglue.cpp @@ -2,102 +2,106 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -//XXXjdm whyyyyyyyyyyy -#define UINT32_MAX ((uint32_t)-1) - +#define __STDC_LIMIT_MACROS +#include #include "jsapi.h" #include "jsfriendapi.h" #include "jsproxy.h" -#include "jsclass.h" #include "jswrapper.h" +#include "mozilla/LinkedList.h" +#include "js/TypeDecls.h" #include "assert.h" struct ProxyTraps { - bool (*getPropertyDescriptor)(JSContext *cx, JSObject *proxy, jsid id, - bool set, JSPropertyDescriptor *desc); - bool (*getOwnPropertyDescriptor)(JSContext *cx, JSObject *proxy, - jsid id, bool set, - JSPropertyDescriptor *desc); - bool (*defineProperty)(JSContext *cx, JSObject *proxy, jsid id, - JSPropertyDescriptor *desc); - bool (*getOwnPropertyNames)(JSContext *cx, JSObject *proxy, + bool (*preventExtensions)(JSContext *cx, JS::HandleObject proxy); + bool (*getPropertyDescriptor)(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, + JS::MutableHandle desc, + unsigned flags); + bool (*getOwnPropertyDescriptor)(JSContext *cx, JS::HandleObject proxy, + JS::HandleId id, + JS::MutableHandle desc, + unsigned flags); + bool (*defineProperty)(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, + JS::MutableHandle desc); + bool (*getOwnPropertyNames)(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props); - bool (*delete_)(JSContext *cx, JSObject *proxy, jsid id, bool *bp); - bool (*enumerate)(JSContext *cx, JSObject *proxy, - JS::AutoIdVector &props); - - bool (*has)(JSContext *cx, JSObject *proxy, jsid id, bool *bp); - bool (*hasOwn)(JSContext *cx, JSObject *proxy, jsid id, bool *bp); - bool (*get)(JSContext *cx, JSObject *proxy, JSObject *receiver, - jsid id, JS::Value *vp); - bool (*set)(JSContext *cx, JSObject *proxy, JSObject *receiver, - jsid id, bool strict, JS::Value *vp); - bool (*keys)(JSContext *cx, JSObject *proxy, JS::AutoIdVector &props); - bool (*iterate)(JSContext *cx, JSObject *proxy, unsigned flags, - JS::Value *vp); - - bool (*call)(JSContext *cx, JSObject *proxy, unsigned argc, JS::Value *vp); - bool (*construct)(JSContext *cx, JSObject *proxy, unsigned argc, JS::Value *argv, JS::Value *rval); + bool (*delete_)(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp); + bool (*enumerate)(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props); + + bool (*has)(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp); + bool (*hasOwn)(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp); + bool (*get)(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver, + JS::HandleId id, JS::MutableHandleValue vp); + bool (*set)(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver, + JS::HandleId id, bool strict, JS::MutableHandleValue vp); + bool (*keys)(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props); + bool (*iterate)(JSContext *cx, JS::HandleObject proxy, unsigned flags, + JS::MutableHandleValue vp); + + bool (*isExtensible)(JSContext *cx, JS::HandleObject proxy, bool *extensible); + bool (*call)(JSContext *cx, JS::HandleObject proxy, unsigned argc, JS::MutableHandleValue vp); + bool (*construct)(JSContext *cx, JS::HandleObject proxy, unsigned argc, JS::MutableHandleValue argv, JS::MutableHandleValue rval); bool (*nativeCall)(JSContext *cx, JS::IsAcceptableThis test, JS::NativeImpl impl, JS::CallArgs args); - bool (*hasInstance)(JSContext *cx, JSObject *proxy, const JS::Value *vp, bool *bp); - JSType (*typeOf)(JSContext *cx, JSObject *proxy); - bool (*objectClassIs)(JSObject *obj, js::ESClassValue classValue, JSContext *cx); - JSString *(*obj_toString)(JSContext *cx, JSObject *proxy); - JSString *(*fun_toString)(JSContext *cx, JSObject *proxy, unsigned indent); - //bool (*regexp_toShared)(JSContext *cx, JSObject *proxy, RegExpGuard *g); - bool (*defaultValue)(JSContext *cx, JSObject *obj, JSType hint, JS::Value *vp); - bool (*iteratorNext)(JSContext *cx, JSObject *proxy, JS::Value *vp); - void (*finalize)(JSFreeOp *fop, JSObject *proxy); - bool (*getElementIfPresent)(JSContext *cx, JSObject *obj, JSObject *receiver, - uint32_t index, JS::Value *vp, bool *present); - bool (*getPrototypeOf)(JSContext *cx, JSObject *proxy, JSObject **proto); - void (*trace)(JSTracer *trc, JSObject *proxy); + bool (*hasInstance)(JSContext *cx, JS::HandleObject proxy, const JS::MutableHandleValue vp, bool *bp); + bool (*objectClassIs)(JS::HandleObject obj, js::ESClassValue classValue, JSContext *cx); + const char *(*className)(JSContext *cx, JS::HandleObject proxy); + JSString *(*fun_toString)(JSContext *cx, JS::HandleObject proxy, unsigned indent); + //bool (*regexp_toShared)(JSContext *cx, JS::HandleObject proxy, RegExpGuard *g); + bool (*defaultValue)(JSContext *cx, JS::HandleObject obj, JSType hint, JS::MutableHandleValue vp); + void (*finalize)(JSFreeOp *fop, JSObject* proxy); + bool (*getPrototypeOf)(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleObject proto); + void (*trace)(JSTracer *trc, JS::HandleObject proxy); }; -int HandlerFamily = js::JSSLOT_PROXY_EXTRA + 0 /*JSPROXYSLOT_EXPANDO*/; +int HandlerFamily = 0 /*JSPROXYSLOT_EXPANDO*/; #define DEFER_TO_TRAP_OR_BASE_CLASS(_base) \ /* ES5 Harmony derived proxy traps. */ \ - virtual bool has(JSContext* cx, JSObject* proxy, jsid id, bool* bp) \ + virtual bool has(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, \ + bool* bp) \ { \ return mTraps.has \ ? mTraps.has(cx, proxy, id, bp) \ : _base::has(cx, proxy, id, bp); \ } \ \ - virtual bool hasOwn(JSContext* cx, JSObject* proxy, jsid id, bool* bp) \ + virtual bool hasOwn(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, \ + bool* bp) \ { \ return mTraps.hasOwn \ ? mTraps.hasOwn(cx, proxy, id, bp) \ : _base::hasOwn(cx, proxy, id, bp); \ } \ \ - virtual bool get(JSContext* cx, JSObject* proxy, JSObject* receiver, \ - jsid id, JS::Value* vp) \ + virtual bool get(JSContext *cx, JS::HandleObject proxy, \ + JS::HandleObject receiver, JS::HandleId id, \ + JS::MutableHandleValue vp) \ { \ return mTraps.get \ ? mTraps.get(cx, proxy, receiver, id, vp) \ : _base::get(cx, proxy, receiver, id, vp); \ } \ \ - virtual bool set(JSContext* cx, JSObject* proxy, JSObject* receiver, \ - jsid id, bool strict, JS::Value* vp) \ + virtual bool set(JSContext *cx, JS::HandleObject proxy, \ + JS::HandleObject receiver, JS::HandleId id, bool strict, \ + JS::MutableHandleValue vp) \ { \ return mTraps.set \ ? mTraps.set(cx, proxy, receiver, id, strict, vp) \ : _base::set(cx, proxy, receiver, id, strict, vp); \ } \ \ - virtual bool keys(JSContext* cx, JSObject* proxy, JS::AutoIdVector& props) \ + virtual bool keys(JSContext *cx, JS::HandleObject proxy, \ + JS::AutoIdVector &props) \ { \ return mTraps.keys \ ? mTraps.keys(cx, proxy, props) \ : _base::keys(cx, proxy, props); \ } \ \ - virtual bool iterate(JSContext* cx, JSObject* proxy, unsigned flags, \ - JS::Value* vp) \ + virtual bool iterate(JSContext *cx, JS::HandleObject proxy, unsigned flags, \ + JS::MutableHandleValue vp) \ { \ return mTraps.iterate \ ? mTraps.iterate(cx, proxy, flags, vp) \ @@ -105,23 +109,23 @@ int HandlerFamily = js::JSSLOT_PROXY_EXTRA + 0 /*JSPROXYSLOT_EXPANDO*/; } \ \ /* Spidermonkey extensions. */ \ - virtual bool call(JSContext* cx, JSObject* proxy, unsigned argc, \ - JS::Value* vp) \ + virtual bool call(JSContext *cx, JS::HandleObject proxy, \ + const JS::CallArgs &args) \ { \ return mTraps.call \ - ? mTraps.call(cx, proxy, argc, vp) \ - : _base::call(cx, proxy, argc, vp); \ + ? mTraps.call(cx, proxy, args.length(), args[0]) \ + : _base::call(cx, proxy, args); \ } \ \ - virtual bool construct(JSContext* cx, JSObject* proxy, unsigned argc, \ - JS::Value* argv, JS::Value* rval) \ + virtual bool construct(JSContext *cx, JS::HandleObject proxy, \ + const JS::CallArgs &args) \ { \ return mTraps.construct \ - ? mTraps.construct(cx, proxy, argc, argv, rval) \ - : _base::construct(cx, proxy, argc, argv, rval); \ + ? mTraps.construct(cx, proxy, args.length(), args[0], args.rval()) \ + : _base::construct(cx, proxy, args); \ } \ \ - virtual bool nativeCall(JSContext* cx, JS::IsAcceptableThis test, \ + virtual bool nativeCall(JSContext *cx, JS::IsAcceptableThis test, \ JS::NativeImpl impl, JS::CallArgs args) \ { \ return mTraps.nativeCall \ @@ -129,37 +133,30 @@ int HandlerFamily = js::JSSLOT_PROXY_EXTRA + 0 /*JSPROXYSLOT_EXPANDO*/; : _base::nativeCall(cx, test, impl, args); \ } \ \ - virtual bool hasInstance(JSContext* cx, JSObject* proxy, \ - const JS::Value* vp, bool* bp) \ + virtual bool hasInstance(JSContext *cx, JS::HandleObject proxy, \ + JS::MutableHandleValue v, bool *bp) \ { \ return mTraps.hasInstance \ - ? mTraps.hasInstance(cx, proxy, vp, bp) \ - : _base::hasInstance(cx, proxy, vp, bp); \ - } \ - \ - virtual JSType typeOf(JSContext* cx, JSObject* proxy) \ - { \ - return mTraps.typeOf \ - ? mTraps.typeOf(cx, proxy) \ - : _base::typeOf(cx, proxy); \ + ? mTraps.hasInstance(cx, proxy, v, bp) \ + : _base::hasInstance(cx, proxy, v, bp); \ } \ \ - virtual bool objectClassIs(JSObject* obj, js::ESClassValue classValue, \ - JSContext* cx) \ + virtual bool objectClassIs(JS::HandleObject obj, \ + js::ESClassValue classValue, JSContext *cx) \ { \ return mTraps.objectClassIs \ ? mTraps.objectClassIs(obj, classValue, cx) \ : _base::objectClassIs(obj, classValue, cx); \ } \ \ - virtual JSString* obj_toString(JSContext* cx, JSObject* proxy) \ + virtual const char *className(JSContext *cx, JS::HandleObject proxy) \ { \ - return mTraps.obj_toString \ - ? mTraps.obj_toString(cx, proxy) \ - : _base::obj_toString(cx, proxy); \ + return mTraps.className \ + ? mTraps.className(cx, proxy) \ + : _base::className(cx, proxy); \ } \ \ - virtual JSString* fun_toString(JSContext* cx, JSObject* proxy, \ + virtual JSString *fun_toString(JSContext *cx, JS::HandleObject proxy, \ unsigned indent) \ { \ return mTraps.fun_toString \ @@ -167,114 +164,113 @@ int HandlerFamily = js::JSSLOT_PROXY_EXTRA + 0 /*JSPROXYSLOT_EXPANDO*/; : _base::fun_toString(cx, proxy, indent); \ } \ \ - virtual bool defaultValue(JSContext* cx, JSObject* obj, JSType hint, \ - JS::Value* vp) \ + virtual bool defaultValue(JSContext *cx, JS::HandleObject obj, JSType hint, \ + JS::MutableHandleValue vp) \ { \ return mTraps.defaultValue \ ? mTraps.defaultValue(cx, obj, hint, vp) \ : _base::defaultValue(cx, obj, hint, vp); \ } \ \ - virtual bool iteratorNext(JSContext* cx, JSObject* proxy, JS::Value* vp) \ - { \ - return mTraps.iteratorNext \ - ? mTraps.iteratorNext(cx, proxy, vp) \ - : _base::iteratorNext(cx, proxy, vp); \ - } \ - \ - virtual void finalize(JSFreeOp* fop, JSObject* proxy) \ - { \ - return mTraps.finalize \ - ? mTraps.finalize(fop, proxy) \ - : _base::finalize(fop, proxy); \ - } \ - \ - virtual bool getElementIfPresent(JSContext* cx, JSObject* obj, \ - JSObject* receiver, uint32_t index, \ - JS::Value* vp, bool* present) \ + virtual void finalize(JSFreeOp *fop, JSObject *proxy) \ { \ - return mTraps.getElementIfPresent \ - ? mTraps.getElementIfPresent(cx, obj, receiver, index, vp, \ - present) \ - : _base::getElementIfPresent(cx, obj, receiver, index, vp, \ - present); \ + if (mTraps.finalize) { \ + mTraps.finalize(fop, proxy); \ + } else { \ + _base::finalize(fop, proxy); \ + } \ } \ \ - virtual bool getPrototypeOf(JSContext* cx, JSObject* proxy, \ - JSObject** proto) \ + virtual bool getPrototypeOf(JSContext *cx, JS::HandleObject proxy, \ + JS::MutableHandleObject proto) \ { \ return mTraps.getPrototypeOf \ ? mTraps.getPrototypeOf(cx, proxy, proto) \ : _base::getPrototypeOf(cx, proxy, proto); \ } \ \ - virtual void trace(JSTracer* trc, JSObject* proxy) \ + virtual void trace(JSTracer *trc, JS::HandleObject proxy) \ { \ return mTraps.trace \ ? mTraps.trace(trc, proxy) \ : _base::trace(trc, proxy); \ } -class WrapperProxyHandler : public js::DirectWrapper +class WrapperProxyHandler : public js::DirectProxyHandler { ProxyTraps mTraps; public: WrapperProxyHandler(const ProxyTraps& aTraps) - : js::DirectWrapper(0), mTraps(aTraps) {} + : js::DirectProxyHandler(&js::sWrapperFamily), mTraps(aTraps) {} virtual bool isOuterWindow() { return true; } - virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, - bool set, JSPropertyDescriptor *desc) + virtual bool preventExtensions(JSContext *cx, JS::HandleObject proxy) + { + return mTraps.preventExtensions ? + mTraps.preventExtensions(cx, proxy) : + DirectProxyHandler::preventExtensions(cx, proxy); + } + + virtual bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, + JS::MutableHandle desc, unsigned flags) { return mTraps.getPropertyDescriptor ? - mTraps.getPropertyDescriptor(cx, proxy, id, set, desc) : - DirectWrapper::getPropertyDescriptor(cx, proxy, id, set, desc); + mTraps.getPropertyDescriptor(cx, proxy, id, desc, flags) : + DirectProxyHandler::getPropertyDescriptor(cx, proxy, id, desc, flags); } - virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, - jsid id, bool set, - JSPropertyDescriptor *desc) + virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, + JS::HandleId id, JS::MutableHandle desc, + unsigned flags) { return mTraps.getOwnPropertyDescriptor ? - mTraps.getOwnPropertyDescriptor(cx, proxy, id, set, desc) : - DirectWrapper::getOwnPropertyDescriptor(cx, proxy, id, set, desc); + mTraps.getOwnPropertyDescriptor(cx, proxy, id, desc, flags) : + DirectProxyHandler::getOwnPropertyDescriptor(cx, proxy, id, desc, flags); } - virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, - JSPropertyDescriptor *desc) + virtual bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, + JS::MutableHandle desc) { return mTraps.defineProperty ? mTraps.defineProperty(cx, proxy, id, desc) : - DirectWrapper::defineProperty(cx, proxy, id, desc); + DirectProxyHandler::defineProperty(cx, proxy, id, desc); } - virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, + virtual bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props) { return mTraps.getOwnPropertyNames ? mTraps.getOwnPropertyNames(cx, proxy, props) : - DirectWrapper::getOwnPropertyNames(cx, proxy, props); + DirectProxyHandler::getOwnPropertyNames(cx, proxy, props); } - virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) + virtual bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, + bool *bp) { return mTraps.delete_ ? mTraps.delete_(cx, proxy, id, bp) : - DirectWrapper::delete_(cx, proxy, id, bp); + DirectProxyHandler::delete_(cx, proxy, id, bp); } - virtual bool enumerate(JSContext *cx, JSObject *proxy, + virtual bool enumerate(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props) { return mTraps.enumerate ? mTraps.enumerate(cx, proxy, props) : - DirectWrapper::enumerate(cx, proxy, props); + DirectProxyHandler::enumerate(cx, proxy, props); + } + + virtual bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible) + { + return mTraps.isExtensible + ? mTraps.isExtensible(cx, proxy, extensible) + : DirectProxyHandler::isExtensible(cx, proxy, extensible); } - DEFER_TO_TRAP_OR_BASE_CLASS(DirectWrapper) + DEFER_TO_TRAP_OR_BASE_CLASS(DirectProxyHandler) }; class ForwardingProxyHandler : public js::BaseProxyHandler @@ -289,42 +285,54 @@ class ForwardingProxyHandler : public js::BaseProxyHandler return mExtra; } - virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, - bool set, JSPropertyDescriptor *desc) + virtual bool preventExtensions(JSContext *cx, JS::HandleObject proxy) { - return mTraps.getPropertyDescriptor(cx, proxy, id, set, desc); + return mTraps.preventExtensions(cx, proxy); } - virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, - jsid id, bool set, - JSPropertyDescriptor *desc) + virtual bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, + JS::MutableHandle desc, + unsigned flags) { - return mTraps.getOwnPropertyDescriptor(cx, proxy, id, set, desc); + return mTraps.getPropertyDescriptor(cx, proxy, id, desc, flags); } - virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, - JSPropertyDescriptor *desc) + virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, + JS::HandleId id, + JS::MutableHandle desc, + unsigned flags) + { + return mTraps.getOwnPropertyDescriptor(cx, proxy, id, desc, flags); + } + + virtual bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, + JS::MutableHandle desc) { return mTraps.defineProperty(cx, proxy, id, desc); } - virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, + virtual bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props) { return mTraps.getOwnPropertyNames(cx, proxy, props); } - virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) + virtual bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp) { return mTraps.delete_(cx, proxy, id, bp); } - virtual bool enumerate(JSContext *cx, JSObject *proxy, + virtual bool enumerate(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props) { return mTraps.enumerate(cx, proxy, props); } + virtual bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible) + { + return mTraps.isExtensible(cx, proxy, extensible); + } + DEFER_TO_TRAP_OR_BASE_CLASS(BaseProxyHandler) }; @@ -333,13 +341,22 @@ extern "C" { bool InvokeGetOwnPropertyDescriptor( void* handler, - JSContext *cx, JSObject *proxy, - jsid id, bool set, - JSPropertyDescriptor *desc) + JSContext *cx, JS::HandleObject proxy, + JS::HandleId id, JS::MutableHandle desc, + unsigned flags) { - return static_cast(handler)->getOwnPropertyDescriptor(cx, proxy, - id, set, - desc); + return static_cast(handler)->getOwnPropertyDescriptor(cx, proxy, + id, desc, + flags); +} + +bool +InvokeHasOwn( + void* handler, + JSContext *cx, JS::HandleObject proxy, + JS::HandleId id, bool* hasOwn) +{ + return static_cast(handler)->hasOwn(cx, proxy, id, hasOwn); } jsval @@ -354,26 +371,47 @@ RUST_FUNCTION_VALUE_TO_JITINFO(jsval v) return FUNCTION_VALUE_TO_JITINFO(v); } -JSBool -CallJitPropertyOp(const JSJitInfo *info, JSContext* cx, JSObject* thisObj, void *specializedThis, jsval *vp) +// Rust code doesn't understand the various JSJit*CallArgs classes, so we have to hack +// around SpiderMonkey's desire to pass them around in place of the raw values and pointers. +typedef bool +(* ServoJSJitGetterOp)(JSContext *cx, JS::HandleObject thisObj, + void *specializedThis, jsval* vp); +typedef bool +(* ServoJSJitSetterOp)(JSContext *cx, JS::HandleObject thisObj, + void *specializedThis, jsval* argv); +typedef bool +(* ServoJSJitMethodOp)(JSContext *cx, JS::HandleObject thisObj, + void *specializedThis, unsigned argc, jsval* vp); + +bool +CallJitGetterOp(const JSJitInfo* info, JSContext* cx, + JS::Handle thisObj, void* specializedThis, + JS::Value* vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(0, vp); + return ((ServoJSJitGetterOp)info->getter)(cx, thisObj, specializedThis, args.base()); +} + +bool +CallJitSetterOp(const JSJitInfo* info, JSContext* cx, + JS::Handle thisObj, void* specializedThis, + JS::Value* vp) { - struct { - JSObject** obj; - } tmp = { &thisObj }; - return ((JSJitPropertyOp)info->op)(cx, *reinterpret_cast(&tmp), specializedThis, vp); + JS::CallArgs args = JS::CallArgsFromVp(1, vp); + return ((ServoJSJitSetterOp)info->setter)(cx, thisObj, specializedThis, args.base()); } -JSBool -CallJitMethodOp(JSJitInfo *info, JSContext* cx, JSObject* thisObj, void *specializedThis, uint32_t argc, jsval *vp) +bool +CallJitMethodOp(const JSJitInfo* info, JSContext* cx, + JS::Handle thisObj, void* specializedThis, + uint32_t argc, JS::Value* vp) { - struct { - JSObject** obj; - } tmp = { &thisObj }; - return ((JSJitMethodOp)info->op)(cx, *reinterpret_cast(&tmp), specializedThis, argc, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + return ((ServoJSJitMethodOp)info->method)(cx, thisObj, specializedThis, args.length(), args.base()); } void -SetFunctionNativeReserved(JSObject* fun, size_t which, js::Value* val) +SetFunctionNativeReserved(JSObject* fun, size_t which, const JS::Value* val) { js::SetFunctionNativeReserved(fun, which, *val); } @@ -397,19 +435,28 @@ CreateWrapperProxyHandler(const ProxyTraps* aTraps) } JSObject* -NewProxyObject(JSContext* aCx, void* aHandler, const js::Value* aPriv, - JSObject* proto, JSObject* parent, JSObject* call, - JSObject* construct) +NewProxyObject(JSContext* aCx, const void* aHandler, /*const*/ js::Class* clasp, + JS::Handle priv, JSObject* proto, JSObject* parent) { - const js::Value &priv = aPriv ? *aPriv : JS::NullValue(); - return js::NewProxyObject(aCx, (js::BaseProxyHandler*)aHandler, priv, proto, - parent, call, construct); + auto handler = static_cast(aHandler); + auto mutable_handler = const_cast(handler); + clasp->trace = js::proxy_Trace; + js::ProxyOptions options; + options.setClass(clasp); + return js::NewProxyObject(aCx, mutable_handler, priv, proto, parent, options); } JSObject* -WrapperNew(JSContext* aCx, JSObject* aParent, void* aHandler) +WrapperNew(JSContext* aCx, JS::HandleObject aObj, JS::HandleObject aParent, void* aHandler, js::Class* clasp, bool singleton) { - return js::Wrapper::New(aCx, aParent, js::GetObjectProto(aParent), aParent, (js::Wrapper*)aHandler); + clasp->trace = js::proxy_Trace; + js::WrapperOptions options(aCx); + JS::RootedObject proto(aCx); + assert(js::GetObjectProto(aCx, aParent, &proto)); + options.setProto(proto.get()); + options.setClass(clasp); + options.setSingleton(singleton); + return js::Wrapper::New(aCx, aObj, aParent, (js::Wrapper*)aHandler, &options); } jsval @@ -430,10 +477,18 @@ SetProxyExtra(JSObject* obj, uint32_t slot, jsval val) return js::SetProxyExtra(obj, slot, val); } -JSObject* -GetObjectProto(JSObject* obj) +void +SetDOMProxyInformation(const void *domProxyHandlerFamily, uint32_t domProxyExpandoSlot, + js::DOMProxyShadowsCheck domProxyShadowsCheck) +{ + return js::SetDOMProxyInformation(domProxyHandlerFamily, domProxyExpandoSlot, + domProxyShadowsCheck); +} + +bool +GetObjectProto(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject proto) { - return js::GetObjectProto(obj); + return js::GetObjectProto(cx, obj, proto); } JSObject* @@ -442,7 +497,7 @@ GetObjectParent(JSObject* obj) return js::GetObjectParent(obj); } -JSBool +bool RUST_JSID_IS_INT(jsid id) { return JSID_IS_INT(id); @@ -454,7 +509,7 @@ RUST_JSID_TO_INT(jsid id) return JSID_TO_INT(id); } -JSBool +bool RUST_JSID_IS_STRING(jsid id) { return JSID_IS_STRING(id); @@ -483,7 +538,7 @@ DefineFunctionWithReserved(JSContext* cx, JSObject* obj, const char* name, JSNat return js::DefineFunctionWithReserved(cx, obj, name, call, nargs, attrs); } -JSClass* +const JSClass* GetObjectJSClass(JSObject* obj) { return js::GetObjectJSClass(obj); @@ -495,16 +550,10 @@ RUST_js_GetErrorMessage(void* userRef, const char* locale, uint32_t errorNumber) return js_GetErrorMessage(userRef, locale, errorNumber); } -JSBool -js_IsObjectProxyClass(JSObject* obj) -{ - return js::IsObjectProxyClass(js::GetObjectClass(obj)); -} - -JSBool -js_IsFunctionProxyClass(JSObject* obj) +void* +GetProxyHandlerFamily() { - return js::IsFunctionProxyClass(js::GetObjectClass(obj)); + return &HandlerFamily; } bool @@ -546,16 +595,356 @@ ReportError(JSContext* aCx, const char* aError) JS_ReportError(aCx, aError); } -JSBool +bool IsWrapper(JSObject* obj) { return js::IsWrapper(obj); } JSObject* -UnwrapObject(JSObject* obj, JSBool stopAtOuter, unsigned* flags) +UnwrapObject(JSObject* obj, bool stopAtOuter) +{ + return js::CheckedUnwrap(obj, stopAtOuter); +} + +void +ContextOptions_SetVarObjFix(JSContext* cx, bool enable) +{ + JS::ContextOptionsRef(cx).setVarObjFix(true); +} + +void +CompartmentOptions_SetTraceGlobal(JSContext* cx, JSTraceOp op) +{ + JS::CompartmentOptionsRef(cx).setTrace(op); +} + +void +CompartmentOptions_SetVersion(JSContext* cx, JSVersion version) +{ + JS::CompartmentOptionsRef(cx).setVersion(version); +} + +bool +ToBoolean(JS::HandleValue v) +{ + return JS::ToBoolean(v); +} + +JSString* +ToString(JSContext* cx, JS::HandleValue v) +{ + return JS::ToString(cx, v); +} + +bool +ToNumber(JSContext* cx, JS::HandleValue v, double* out) +{ + return JS::ToNumber(cx, v, out); +} + +bool +ToUint16(JSContext* cx, JS::HandleValue v, uint16_t* out) +{ + return JS::ToUint16(cx, v, out); +} + +bool +ToInt32(JSContext* cx, JS::HandleValue v, int32_t* out) +{ + return JS::ToInt32(cx, v, out); +} + +bool +ToUint32(JSContext* cx, JS::HandleValue v, uint32_t* out) +{ + return JS::ToUint32(cx, v, out); +} + +bool +ToInt64(JSContext* cx, JS::HandleValue v, int64_t* out) +{ + return JS::ToInt64(cx, v, out); +} + +bool +ToUint64(JSContext* cx, JS::HandleValue v, uint64_t* out) +{ + return JS::ToUint64(cx, v, out); +} + +bool +AddObjectRoot(JSContext* cx, JSObject** obj) +{ + //return JS::AddObjectRoot(cx, reinterpret_cast*>(obj)); + return true; +} + +void +RemoveObjectRoot(JSContext* cx, JSObject** obj) +{ + //JS::RemoveObjectRoot(cx, reinterpret_cast*>(obj)); +} + +JSObject* +NewGlobalObject(JSContext* cx, const JSClass *clasp, JSPrincipals* principals, + JS::OnNewGlobalHookOption hookOption) +{ + return JS_NewGlobalObject(cx, clasp, principals, hookOption); +} + +bool +CallFunctionValue(JSContext* cx, JS::HandleObject obj, JS::HandleValue fval, + size_t argc, JS::Value* argv, JS::MutableHandleValue rval) +{ + return JS_CallFunctionValue(cx, obj, fval, + JS::HandleValueArray::fromMarkedLocation(argc, argv), rval); +} + +JSFunction* +CompileUCFunction(JSContext *cx, JS::HandleObject obj, const char *name, + unsigned nargs, const char *const *argnames, + const jschar *chars, size_t length, const char *url, unsigned lineno) +{ + JS::CompileOptions opts(cx); + opts.setFileAndLine(url, lineno); + return JS_CompileUCFunction(cx, obj, name, nargs, argnames, chars, length, opts); +} + +JSObject* +CompileEventHandler(JSContext* cx, const char* name, + unsigned nargs, const char* const* argnames, + const jschar* chars, size_t length, + const char* url, unsigned lineNo) +{ + JS::CompileOptions options(cx); + options.setIntroductionType("eventHandler") + .setFileAndLine(url, lineNo) + .setVersion(JSVERSION_DEFAULT) + .setDefineOnScope(false); + + JSFunction* function = JS::CompileFunction(cx, JS::NullPtr(), options, name, + nargs, argnames, chars, length); + return JS_GetFunctionObject(function); +} + +bool +proxy_LookupGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleObject objp, + JS::MutableHandle propp) +{ + return js::proxy_LookupGeneric(cx, obj, id, objp, propp); +} + +bool +proxy_LookupProperty(JSContext *cx, JS::HandleObject obj, JS::Handle name, + JS::MutableHandleObject objp, JS::MutableHandle propp) +{ + return js::proxy_LookupProperty(cx, obj, name, objp, propp); +} + +bool +proxy_LookupElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::MutableHandleObject objp, + JS::MutableHandle propp) +{ + return js::proxy_LookupElement(cx, obj, index, objp, propp); +} + +bool +proxy_DefineGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue value, + JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs) +{ + return js::proxy_DefineGeneric(cx, obj, id, value, getter, setter, attrs); +} + +bool +proxy_DefineProperty(JSContext *cx, JS::HandleObject obj, JS::Handle name, + JS::HandleValue value, JSPropertyOp getter, JSStrictPropertyOp setter, + unsigned attrs) +{ + return js::proxy_DefineProperty(cx, obj, name, value, getter, setter, attrs); +} + +bool +proxy_DefineElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::HandleValue value, + JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs) +{ + return js::proxy_DefineElement(cx, obj, index, value, getter, setter, attrs); +} + +bool +proxy_GetGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, JS::HandleId id, + JS::MutableHandleValue vp) +{ + return js::proxy_GetGeneric(cx, obj, receiver, id, vp); +} + +bool +proxy_GetProperty(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, + JS::Handle name, JS::MutableHandleValue vp) +{ + return js::proxy_GetProperty(cx, obj, receiver, name, vp); +} + +bool +proxy_GetElement(JSContext *cx, JS::HandleObject obj, JS::HandleObject receiver, uint32_t index, + JS::MutableHandleValue vp) +{ + return js::proxy_GetElement(cx, obj, receiver, index, vp); +} + +bool +proxy_SetGeneric(JSContext *cx, JS::HandleObject obj, JS::HandleId id, + JS::MutableHandleValue bp, bool strict) +{ + return js::proxy_SetGeneric(cx, obj, id, bp, strict); +} + +bool +proxy_SetProperty(JSContext *cx, JS::HandleObject obj, JS::Handle name, + JS::MutableHandleValue bp, bool strict) +{ + return js::proxy_SetProperty(cx, obj, name, bp, strict); +} + +bool +proxy_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::MutableHandleValue vp, + bool strict) +{ + return js::proxy_SetElement(cx, obj, index, vp, strict); +} + +bool +proxy_GetGenericAttributes(JSContext *cx, JS::HandleObject obj, JS::HandleId id, unsigned *attrsp) +{ + return js::proxy_GetGenericAttributes(cx, obj, id, attrsp); +} + +bool +proxy_SetGenericAttributes(JSContext *cx, JS::HandleObject obj, JS::HandleId id, unsigned *attrsp) +{ + return js::proxy_SetGenericAttributes(cx, obj, id, attrsp); +} + +bool +proxy_DeleteProperty(JSContext *cx, JS::HandleObject obj, JS::Handle name, + bool *succeeded) +{ + return js::proxy_DeleteProperty(cx, obj, name, succeeded); +} + +bool +proxy_DeleteElement(JSContext *cx, JS::HandleObject obj, uint32_t index, bool *succeeded) +{ + return js::proxy_DeleteElement(cx, obj, index, succeeded); +} + +void +proxy_Trace(JSTracer *trc, JSObject *obj) +{ + return js::proxy_Trace(trc, obj); +} + +JSObject* +proxy_WeakmapKeyDelegate(JSObject *obj) +{ + return js::proxy_WeakmapKeyDelegate(obj); +} + +bool +proxy_Convert(JSContext *cx, JS::HandleObject proxy, JSType hint, JS::MutableHandleValue vp) +{ + return js::proxy_Convert(cx, proxy, hint, vp); +} + +void +proxy_Finalize(js::FreeOp *fop, JSObject *obj) +{ + return js::proxy_Finalize(fop, obj); +} + +bool +proxy_HasInstance(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleValue v, bool *bp) +{ + return js::proxy_HasInstance(cx, proxy, v, bp); +} + +bool +proxy_Call(JSContext *cx, unsigned argc, JS::Value *vp) +{ + return js::proxy_Call(cx, argc, vp); +} + +bool +proxy_Construct(JSContext *cx, unsigned argc, JS::Value *vp) +{ + return js::proxy_Construct(cx, argc, vp); +} + +JSObject* +proxy_innerObject(JSContext *cx, JS::HandleObject obj) +{ + return js::proxy_innerObject(cx, obj); +} + +bool +proxy_Watch(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable) +{ + return js::proxy_Watch(cx, obj, id, callable); +} + +bool +proxy_Unwatch(JSContext *cx, JS::HandleObject obj, JS::HandleId id) +{ + return js::proxy_Unwatch(cx, obj, id); +} + +bool +proxy_Slice(JSContext *cx, JS::HandleObject proxy, uint32_t begin, uint32_t end, + JS::HandleObject result) +{ + return js::proxy_Slice(cx, proxy, begin, end, result); +} + +int +objectNeedsPostBarrier(JSObject* obj) +{ + return js::GCMethods::needsPostBarrier(obj); +} + +void +objectPostBarrier(JSObject** obj) +{ +#ifdef JSGC_GENERATIONAL + return js::GCMethods::postBarrier(obj); +#endif +} + +void +objectRelocate(JSObject** obj) +{ +#ifdef JSGC_GENERATIONAL + return js::GCMethods::postBarrier(obj); +#endif +} + +bool +objectIsPoisoned(JSObject* obj) +{ + return js::GCMethods::poisoned(obj); +} + +mozilla::LinkedList* +getPersistentRootedObjectList(JSRuntime* rt) +{ + JS::shadow::Runtime *srt = JS::shadow::Runtime::asShadowRuntime(rt); + return &srt->getPersistentRootedList(); +} + +void +insertObjectLinkedListElement(mozilla::LinkedList* list, + JS::PersistentRootedObject* elem) { - return js::UnwrapObject(obj, stopAtOuter, flags); + list->insertBack(elem); } } // extern "C" diff --git a/src/jsval.rs b/src/jsval.rs index 4ffc469c1..cf7680d03 100644 --- a/src/jsval.rs +++ b/src/jsval.rs @@ -4,14 +4,14 @@ use jsapi::{JSObject, JSString, JSGCTraceKind, JSTRACE_OBJECT, JSTRACE_STRING}; -use libc::c_void; use std::mem; +use libc::c_void; #[cfg(target_word_size = "64")] static JSVAL_TAG_SHIFT: uint = 47u; #[repr(u8)] -enum ValueType { +pub enum ValueType { JSVAL_TYPE_DOUBLE = 0x00, JSVAL_TYPE_INT32 = 0x01, JSVAL_TYPE_UNDEFINED = 0x02, @@ -75,11 +75,10 @@ enum ValueShiftedTag { #[cfg(target_word_size = "64")] static JSVAL_PAYLOAD_MASK: u64 = 0x00007FFFFFFFFFFF; -// JSVal was originally type of u64. -// now this become {u64} because of the union abi issue on ARM arch. See #398. #[deriving(PartialEq,Clone)] +#[repr(C)] pub struct JSVal { - pub v: u64 + v: u64 } #[cfg(target_word_size = "64")] @@ -379,6 +378,5 @@ impl JSVal { } else { JSTRACE_STRING } - } } diff --git a/src/lib.rs b/src/lib.rs index 66ae05275..f9fa3d48b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ #![feature(globs, link_args, managed_boxes, phase, unsafe_destructor)] -#![allow(non_uppercase_statics, non_camel_case_types, non_snake_case_functions)] +#![allow(non_uppercase_statics, non_camel_case_types, non_snake_case)] extern crate green; extern crate libc; @@ -17,17 +17,18 @@ extern crate log; extern crate rustuv; extern crate serialize; -use libc::c_uint; +use libc::{c_uint, c_void}; use libc::types::common::c99::uint32_t; -use jsapi::{JSBool, JSContext, JSPropertyOp, JSStrictPropertyOp, JSEnumerateOp, - JSObject, jsid, JSResolveOp, JSConvertOp, JSFinalizeOp, JSTraceOp, - JSProto_LIMIT, JSHandleObject, JSCheckAccessOp, JSNative, JSHasInstanceOp}; -use jsapi::JS_ComputeThis; +use jsapi::{JSContext, JSPropertyOp, JSStrictPropertyOp, JSEnumerateOp, Enum_JSProtoKey, + JSObject, JSResolveOp, JSConvertOp, JSFinalizeOp, JSTraceOp, JSProto_LIMIT, + JSHandleObject, JSNative, JSHasInstanceOp, JSFunctionSpec, JSDeletePropertyOp}; +use jsapi::{JSWeakmapKeyDelegateOp, JSHandleId, JSMutableHandleObject, JSHandleValue}; +use jsapi::{JS_ComputeThis, JSMutableHandleValue, JSRuntime}; +use jsapi::{MutableHandle, Handle}; use jsval::JSVal; // These are just macros in jsapi.h pub use jsapi::JS_Init as JS_NewRuntime; -pub use jsapi::JS_Finish as JS_DestroyRuntime; /* FIXME: Not sure where JS_Lock is pub use jsapi::bindgen::JS_Lock as JS_LockRuntime; @@ -40,7 +41,6 @@ pub mod jsapi; pub mod linkhack; pub mod rust; pub mod glue; -pub mod trace; pub mod jsval; pub mod jsfriendapi; @@ -53,7 +53,6 @@ pub static JSOPTION_TYPE_INFERENCE: uint32_t = (1u32 << 18) as u32; pub static default_heapsize: u32 = 32_u32 * 1024_u32 * 1024_u32; pub static default_stacksize: uint = 8192u; -pub static ERR: JSBool = 0_i32; pub static JSID_TYPE_STRING: i64 = 0; pub static JSID_TYPE_INT: i64 = 1; @@ -62,9 +61,9 @@ pub static JSID_TYPE_OBJECT: i64 = 4; pub static JSID_TYPE_DEFAULT_XML_NAMESPACE: i64 = 6; pub static JSID_TYPE_MASK: i64 = 7; -pub static JSID_VOID: jsid = JSID_TYPE_VOID as jsid; +//pub static JSID_VOID: jsid = JSID_TYPE_VOID as jsid; -pub static JSFUN_CONSTRUCTOR: u32 = 0x200; /* native that can be called as a ctor */ +pub static JSFUN_CONSTRUCTOR: u32 = 0x400; /* native that can be called as a ctor */ pub static JSPROP_ENUMERATE: c_uint = 0x01; pub static JSPROP_READONLY: c_uint = 0x02; @@ -74,25 +73,37 @@ pub static JSPROP_SETTER: c_uint = 0x20; pub static JSPROP_SHARED: c_uint = 0x40; pub static JSPROP_NATIVE_ACCESSORS: c_uint = 0x08; -pub static JSCLASS_RESERVED_SLOTS_SHIFT: c_uint = 8; -pub static JSCLASS_RESERVED_SLOTS_WIDTH: c_uint = 8; -pub static JSCLASS_RESERVED_SLOTS_MASK: c_uint = ((1u << JSCLASS_RESERVED_SLOTS_WIDTH as uint) - 1) as c_uint; +pub static NON_NATIVE: c_uint = 1<<(JSCLASS_HIGH_FLAGS_SHIFT+2); +pub static JSCLASS_IS_PROXY: c_uint = 1<<(JSCLASS_HIGH_FLAGS_SHIFT+4); +pub static PROXY_MINIMUM_SLOTS: c_uint = 4; -pub static JSCLASS_HIGH_FLAGS_SHIFT: c_uint = +pub static JSCLASS_IMPLEMENTS_BARRIERS: c_uint = 1 << 5; + +pub static JSCLASS_RESERVED_SLOTS_SHIFT: uint = 8; +pub static JSCLASS_RESERVED_SLOTS_WIDTH: uint = 8; +pub static JSCLASS_RESERVED_SLOTS_MASK: uint = ((1 << JSCLASS_RESERVED_SLOTS_WIDTH) - 1); + +pub static JSCLASS_HIGH_FLAGS_SHIFT: uint = JSCLASS_RESERVED_SLOTS_SHIFT + JSCLASS_RESERVED_SLOTS_WIDTH; -pub static JSCLASS_IS_GLOBAL: c_uint = (1<<((JSCLASS_HIGH_FLAGS_SHIFT as uint)+1)); +pub static JSCLASS_IS_GLOBAL: c_uint = 1<<(JSCLASS_HIGH_FLAGS_SHIFT+1); -pub static JSCLASS_GLOBAL_SLOT_COUNT: c_uint = JSProto_LIMIT * 3 + 24; +pub static JSCLASS_GLOBAL_SLOT_COUNT: c_uint = 3 + JSProto_LIMIT * 3 + 31; pub static JSCLASS_IS_DOMJSCLASS: u32 = 1 << 4; pub static JSCLASS_USERBIT1: u32 = 1 << 7; -pub static JSSLOT_PROXY_PRIVATE: u32 = 1; +pub static JSSLOT_PROXY_PRIVATE: u32 = /*1*/0; //XXXjdm wrong fo sho + +pub static PROXY_PRIVATE_SLOT: u32 = 0; +pub static PROXY_HANDLER_SLOT: u32 = 1; +pub static PROXY_EXTRA_SLOT: u32 = 2; pub static JSRESOLVE_QUALIFIED: u32 = 0x01; pub static JSRESOLVE_ASSIGNING: u32 = 0x02; pub static JSRESOLVE_DETECTING: u32 = 0x04; +pub static JS_DEFAULT_ZEAL_FREQ: u32 = 100; + pub enum JSGCTraceKind { JSTRACE_OBJECT, JSTRACE_STRING, @@ -100,7 +111,7 @@ pub enum JSGCTraceKind { } pub fn JSCLASS_HAS_RESERVED_SLOTS(n: c_uint) -> c_uint { - (n & JSCLASS_RESERVED_SLOTS_MASK) << (JSCLASS_RESERVED_SLOTS_SHIFT as uint) + (n & (JSCLASS_RESERVED_SLOTS_MASK as c_uint)) << JSCLASS_RESERVED_SLOTS_SHIFT } #[inline(always)] @@ -139,70 +150,145 @@ fn start(argc: int, argv: *const *const u8) -> int { green::start(argc, argv, rustuv::event_loop, __test::main) } -pub type JSObjectOp = extern "C" fn(*mut JSContext, JSHandleObject) -> *mut JSObject; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +pub type JSObjectOp = Option *mut JSObject>; +pub type ClassObjectCreationOp = Option *mut JSObject>; +pub type FinishClassInitOp = Option bool>; +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] pub struct Class { pub name: *const libc::c_char, pub flags: uint32_t, + + /* Mandatory function pointer members. */ pub addProperty: JSPropertyOp, - pub delProperty: JSPropertyOp, + pub delProperty: JSDeletePropertyOp, pub getProperty: JSPropertyOp, pub setProperty: JSStrictPropertyOp, pub enumerate: JSEnumerateOp, pub resolve: JSResolveOp, pub convert: JSConvertOp, + + /* Optional members (may be null). */ pub finalize: JSFinalizeOp, - pub checkAccess: JSCheckAccessOp, pub call: JSNative, pub hasInstance: JSHasInstanceOp, pub construct: JSNative, pub trace: JSTraceOp, + pub spec: ClassSpec, pub ext: ClassExtension, pub ops: ObjectOps, } +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] +pub struct ClassSpec { + pub createConstructor: ClassObjectCreationOp, + pub createPrototype: ClassObjectCreationOp, + pub constructorFunctions: *const JSFunctionSpec, + pub prototypeFunctions: *const JSFunctionSpec, + pub finishInit: FinishClassInitOp, +} + +// Up-to-date mozjs 075904f5f7ee1176f28630d1dff47820020e5928 +#[repr(C)] pub struct ClassExtension { - pub equality: *const u8, - pub outerObject: Option, - pub innerObject: Option, + pub outerObject: JSObjectOp, + pub innerObject: JSObjectOp, pub iteratorObject: *const u8, - pub unused: *const u8, - pub isWrappedNative: *const u8, + pub isWrappedNative: bool, + pub weakmapKeyDelegateOp: JSWeakmapKeyDelegateOp, } +pub type LookupGenericOp = Option) -> bool>; +pub type LookupPropOp = Option, + JSMutableHandleObject, MutableHandle<*mut c_void>) -> bool>; +pub type LookupElementOp = Option) -> bool>; +pub type DefineGenericOp = Option bool>; +pub type DefinePropOp = Option, + JSHandleValue, JSPropertyOp, JSStrictPropertyOp, + c_uint) -> bool>; +pub type DefineElementOp = Option bool>; +pub type GenericIdOp = Option bool>; +pub type PropertyIdOp = Option, JSMutableHandleValue) -> bool>; +pub type ElementIdOp = Option bool>; +pub type StrictGenericIdOp = Option bool>; +pub type StrictPropertyIdOp = Option, JSMutableHandleValue, + bool) -> bool>; +pub type StrictElementIdOp = Option bool>; +pub type GenericAttributesOp = Option bool>; +pub type PropertyAttributesOp = Option, *mut uint) -> bool>; +pub type DeletePropertyOp = Option, *mut bool) -> bool>; +pub type DeleteElementOp = Option bool>; +pub type WatchOp = Option bool>; +pub type UnwatchOp = Option bool>; +pub type SliceOp = Option bool>; + +#[repr(C)] pub struct ObjectOps { - pub lookupGeneric: *const u8, - pub lookupProperty: *const u8, - pub lookupElement: *const u8, - pub lookupSpecial: *const u8, - pub defineGeneric: *const u8, - pub defineProperty: *const u8, - pub defineElement: *const u8, - pub defineSpecial: *const u8, - pub getGeneric: *const u8, - pub getProperty: *const u8, - pub getElement: *const u8, - pub getElementIfPresent: *const u8, - pub getSpecial: *const u8, - pub setGeneric: *const u8, - pub setProperty: *const u8, - pub setElement: *const u8, - pub setSpecial: *const u8, - pub getGenericAttributes: *const u8, - pub getPropertyAttributes: *const u8, - pub getElementAttributes: *const u8, - pub getSpecialAttributes: *const u8, - pub setGenericAttributes: *const u8, - pub setPropertyAttributes: *const u8, - pub setElementAttributes: *const u8, - pub setSpecialAttributes: *const u8, - pub deleteProperty: *const u8, - pub deleteElement: *const u8, - pub deleteSpecial: *const u8, + pub lookupGeneric: LookupGenericOp, + pub lookupProperty: LookupPropOp, + pub lookupElement: LookupElementOp, + pub defineGeneric: DefineGenericOp, + pub defineProperty: DefinePropOp, + pub defineElement: DefineElementOp, + pub getGeneric: GenericIdOp, + pub getProperty: PropertyIdOp, + pub getElement: ElementIdOp, + pub setGeneric: StrictGenericIdOp, + pub setProperty: StrictPropertyIdOp, + pub setElement: StrictElementIdOp, + pub getGenericAttributes: GenericAttributesOp, + pub setGenericAttributes: GenericAttributesOp, + pub deleteProperty: DeletePropertyOp, + pub deleteElement: DeleteElementOp, + pub watch: WatchOp, + pub unwatch: UnwatchOp, + pub slice: SliceOp, pub enumerate: *const u8, - pub typeOf: *const u8, - pub thisObject: Option, - pub clear: *const u8, + pub thisObject: JSObjectOp, +} + +pub enum ThingRootKind { + THING_ROOT_OBJECT, + THING_ROOT_SHAPE, + THING_ROOT_BASE_SHAPE, + THING_ROOT_TYPE_OBJECT, + THING_ROOT_STRING, + THING_ROOT_JIT_CODE, + THING_ROOT_SCRIPT, + THING_ROOT_LAZY_SCRIPT, + THING_ROOT_ID, + THING_ROOT_VALUE, + THING_ROOT_TYPE, + THING_ROOT_BINDINGS, + THING_ROOT_PROPERTY_DESCRIPTOR, + THING_ROOT_CUSTOM, + THING_ROOT_LIMIT, //14 +} + +#[repr(C)] +pub struct ContextFriendFields { + pub runtime_: *mut JSRuntime, + pub compartment_: *mut libc::c_void, + pub zone_: *mut libc::c_void, + pub thingGCRooters: [*const *const libc::c_void, ..14], //THING_ROOT_LIMIT + pub autoGCRooters: *mut libc::c_void, } diff --git a/src/linkhack.rs b/src/linkhack.rs index 4e74e7d87..cc1cce7f0 100644 --- a/src/linkhack.rs +++ b/src/linkhack.rs @@ -6,6 +6,7 @@ #[cfg(target_os = "linux")] #[link(name = "pthread")] +#[link(name = "jsglue")] #[link(name = "js_static", kind = "static")] #[link(name = "stdc++")] #[link(name = "z")] diff --git a/src/rust.rs b/src/rust.rs index 556a8d853..1b7ae0222 100644 --- a/src/rust.rs +++ b/src/rust.rs @@ -4,22 +4,29 @@ //! Rust wrappers around the raw JS apis +use libc; use libc::types::os::arch::c95::{size_t, c_uint}; use libc::uintptr_t; use libc::c_char; use std::cmp; +use std::ptr; use std::rc; use std::rt::Runtime; use std::string; -use jsapi::*; +use jsapi::{JSContext, JSRuntime, JSGCStatus, JS_NewRuntime, JSObject}; +use jsapi::{JS_SetNativeStackBounds, JS_SetGCCallback, JS_DestroyContext}; +use jsapi::{JS_EnterCompartment, JS_LeaveCompartment}; +use jsapi::{JS_SetErrorReporter, JS_NO_HELPER_THREADS}; +use jsapi::{JS_EvaluateUCScript, JS_BeginRequest, JS_EndRequest}; +use jsapi::{JS_NewContext, JSErrorReport, JSJITCOMPILER_ION_ENABLE}; +use jsapi::{Handle, MutableHandle, JS_DestroyRuntime}; +use jsapi::{JS_SetGlobalJitCompilerOption, JSJITCOMPILER_BASELINE_ENABLE}; +use jsapi::{JSJITCOMPILER_PARALLEL_COMPILATION_ENABLE}; use jsval::{JSVal, NullValue}; +//use glue::{CompartmentOptions_SetVersion}; +use glue::{/*CompartmentOptions_SetTraceGlobal,*/ ContextOptions_SetVarObjFix}; use default_stacksize; use default_heapsize; -use JSOPTION_VAROBJFIX; -use JSOPTION_METHODJIT; -use JSOPTION_TYPE_INFERENCE; -use ERR; -use green::task::GreenTask; // ___________________________________________________________________________ // friendly Rustic API to runtimes @@ -33,7 +40,7 @@ pub struct rt_rsrc { impl Drop for rt_rsrc { fn drop(&mut self) { unsafe { - JS_Finish(self.ptr); + JS_DestroyRuntime(self.ptr); } } } @@ -57,23 +64,35 @@ impl RtUtils for rc::Rc { } } -unsafe extern fn gc_callback(rt: *mut JSRuntime, _status: JSGCStatus) { +unsafe extern fn gc_callback(rt: *mut JSRuntime, _status: JSGCStatus, _data: *mut libc::c_void) { use std::rt::local::Local; use std::rt::task::Task; + let mut task = Local::borrow(None::); + let (start, end) = task.stack_bounds(); + JS_SetNativeStackBounds(rt, cmp::min(start, end) as uintptr_t, cmp::max(start, end) as uintptr_t); +} + +extern { + fn pthread_setspecific(key: i32, arg: *const libc::c_void) -> i32; + fn GetThreadKey() -> *const i32; +} + +pub fn init_thread() { + use std::rt::local::Local; + use std::rt::task::Task; + let task = Local::borrow(None::); unsafe { - let mut task = Local::borrow(None::); - let green_task: Box = task.maybe_take_runtime().unwrap(); - let (start, end) = green_task.stack_bounds(); - JS_SetNativeStackBounds(rt, cmp::min(start, end) as uintptr_t, - cmp::max(start, end) as uintptr_t); - task.put_runtime(green_task); + pthread_setspecific(*GetThreadKey(), &task.heap as *const _ as *const _); } -} + } pub fn rt() -> rt { unsafe { - let runtime = JS_Init(default_heapsize); - JS_SetGCCallback(runtime, Some(gc_callback)); + let runtime = JS_NewRuntime(default_heapsize, JS_NO_HELPER_THREADS, ptr::null_mut()); + JS_SetGCCallback(runtime, Some(gc_callback), ptr::null_mut()); + JS_SetGlobalJitCompilerOption(runtime, JSJITCOMPILER_ION_ENABLE, 1); + JS_SetGlobalJitCompilerOption(runtime, JSJITCOMPILER_BASELINE_ENABLE, 1); + JS_SetGlobalJitCompilerOption(runtime, JSJITCOMPILER_PARALLEL_COMPILATION_ENABLE, 0); return new_runtime(runtime); } } @@ -104,20 +123,9 @@ pub fn new_context(ptr: *mut JSContext, rt: rt) -> rc::Rc { impl Cx { pub fn set_default_options_and_version(&self) { - self.set_options(JSOPTION_VAROBJFIX | JSOPTION_METHODJIT | - JSOPTION_TYPE_INFERENCE); - self.set_version(JSVERSION_LATEST); - } - - pub fn set_options(&self, v: c_uint) { - unsafe { - JS_SetOptions(self.ptr, v); - } - } - - pub fn set_version(&self, v: JSVersion) { unsafe { - JS_SetVersion(self.ptr, v); + ContextOptions_SetVarObjFix(self.ptr, true); + //CompartmentOptions_SetVersion(self.ptr, JSVERSION_LATEST); } } @@ -147,10 +155,16 @@ impl Cx { (script_utf16.as_ptr(), script_utf16.len() as c_uint) }; assert!(ptr.is_not_null()); + let globhandle = Handle { + unnamed_field1: &glob, + }; + let rvalhandle = MutableHandle { + unnamed_field1: &mut rval, + }; unsafe { - if ERR == JS_EvaluateUCScript(self.ptr, glob, ptr, len, - filename_cstr.as_ptr(), line_num as c_uint, - &mut rval) { + if !JS_EvaluateUCScript(self.ptr, globhandle, ptr, len, + filename_cstr.as_ptr(), + line_num as c_uint, rvalhandle) { debug!("...err!"); Err(()) } else { @@ -173,13 +187,60 @@ pub unsafe extern fn reportError(_cx: *mut JSContext, msg: *const c_char, report pub fn with_compartment(cx: *mut JSContext, object: *mut JSObject, cb: || -> R) -> R { unsafe { - let call = JS_EnterCrossCompartmentCall(cx, object); + let _ar = JSAutoRequest::new(cx); + let old_compartment = JS_EnterCompartment(cx, object); let result = cb(); - JS_LeaveCrossCompartmentCall(call); + JS_LeaveCompartment(cx, old_compartment); result } } +pub struct JSAutoCompartment { + cx: *mut JSContext, + old: *mut libc::c_void, +} + +impl JSAutoCompartment { + pub fn new(cx: *mut JSContext, object: *mut JSObject) -> JSAutoCompartment { + let old_compartment = unsafe { JS_EnterCompartment(cx, object) }; + JSAutoCompartment { + cx: cx, + old: old_compartment, + } + } +} + +impl Drop for JSAutoCompartment { + fn drop(&mut self) { + unsafe { + JS_LeaveCompartment(self.cx, self.old); + } + } +} + +pub struct JSAutoRequest { + cx: *mut JSContext, +} + +impl JSAutoRequest { + pub fn new(cx: *mut JSContext) -> JSAutoRequest { + unsafe { + JS_BeginRequest(cx); + } + JSAutoRequest { + cx: cx, + } + } +} + +impl Drop for JSAutoRequest { + fn drop(&mut self) { + unsafe { + JS_EndRequest(self.cx); + } + } +} + #[cfg(test)] pub mod test { use super::rt; diff --git a/src/trace.rs b/src/trace.rs deleted file mode 100644 index 254e26f93..000000000 --- a/src/trace.rs +++ /dev/null @@ -1,81 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use jsapi::JSTracer; - -use serialize::Encoder; - -impl Encoder<()> for JSTracer { - fn emit_nil(&mut self) -> Result<(), ()> { Ok(()) } - fn emit_uint(&mut self, _v: uint) -> Result<(), ()> { Ok(()) } - fn emit_u64(&mut self, _v: u64) -> Result<(), ()> { Ok(()) } - fn emit_u32(&mut self, __v: u32) -> Result<(), ()> { Ok(()) } - fn emit_u16(&mut self, _v: u16) -> Result<(), ()> { Ok(()) } - fn emit_u8(&mut self, _v: u8) -> Result<(), ()> { Ok(()) } - fn emit_int(&mut self, _v: int) -> Result<(), ()> { Ok(()) } - fn emit_i64(&mut self, _v: i64) -> Result<(), ()> { Ok(()) } - fn emit_i32(&mut self, _v: i32) -> Result<(), ()> { Ok(()) } - fn emit_i16(&mut self, _v: i16) -> Result<(), ()> { Ok(()) } - fn emit_i8(&mut self, _v: i8) -> Result<(), ()> { Ok(()) } - fn emit_bool(&mut self, _v: bool) -> Result<(), ()> { Ok(()) } - fn emit_f64(&mut self, _v: f64) -> Result<(), ()> { Ok(()) } - fn emit_f32(&mut self, _v: f32) -> Result<(), ()> { Ok(()) } - fn emit_char(&mut self, _v: char) -> Result<(), ()> { Ok(()) } - fn emit_str(&mut self, _v: &str) -> Result<(), ()> { Ok(()) } - fn emit_enum(&mut self, _name: &str, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_enum_variant(&mut self, _v_name: &str, _v_id: uint, _len: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_enum_variant_arg(&mut self, _a_idx: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_enum_struct_variant(&mut self, _v_name: &str, _v_id: uint, _len: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_enum_struct_variant_field(&mut self, _f_name: &str, _f_idx: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_struct(&mut self, _name: &str, _len: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_struct_field(&mut self, _f_name: &str, _f_idx: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_tuple(&mut self, _len: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_tuple_arg(&mut self, _idx: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_tuple_struct(&mut self, _name: &str, _len: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_tuple_struct_arg(&mut self, _f_idx: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_option(&mut self, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_option_none(&mut self) -> Result<(), ()> { Ok(()) } - fn emit_option_some(&mut self, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_seq(&mut self, _len: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_seq_elt(&mut self, _idx: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_map(&mut self, _len: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_map_elt_key(&mut self, _idx: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } - fn emit_map_elt_val(&mut self, _idx: uint, f: |&mut JSTracer| -> Result<(), ()>) -> Result<(), ()> { - f(self) - } -}