diff --git a/Makefile.in b/Makefile.in index 2f7112820..21db9d0f7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,7 +4,7 @@ CXX ?= g++ RUSTC ?= rustc AR ?= ar RUSTFLAGS ?= -CFLAGS += -fPIC +CFLAGS += -fPIC -std=c++11 -g -O0 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/glue.rs b/glue.rs index 3203d3a97..60361c85a 100644 --- a/glue.rs +++ b/glue.rs @@ -4,43 +4,55 @@ /* automatically generated by rust-bindgen */ -use libc; -use jsapi::*; +use jsapi::{JSContext, JSHandleObject, JSHandleId, JSPropertyDescriptor, JSMutableHandleValue}; +use jsapi::{JSTracer, JSFunction, JSNative, JSErrorFormatString, JSFreeOp, JSMutableHandleObject}; +use jsapi::{JSClass, JSString, JSObject, jsid, JSVersion, JSHandleValue, JSTraceOp}; +use jsapi::{Enum_OnNewGlobalHookOption, JSPrincipals, Enum_JSType, Struct_JSFreeOp}; +use jsapi::{JSStrictPropertyOp, JSPropertyOp}; use jsfriendapi::JSJitInfo; use jsval::JSVal; +use libc; +use libc::c_void; -type c_bool = libc::c_int; +pub type c_bool = libc::c_int; +pub type JSBool = c_bool; + +pub struct JSMutableHandle { + pub unnamed_field1: *mut T, +} + +pub struct JSHandle { + pub unnamed_field1: *T, +} pub struct ProxyTraps { - pub getPropertyDescriptor: Option c_bool>, - pub getOwnPropertyDescriptor: Option JSBool>, - pub defineProperty: Option JSBool>, + pub preventExtensions: Option c_bool>, + pub getPropertyDescriptor: Option, u32) -> c_bool>, + pub getOwnPropertyDescriptor: Option, u32) -> c_bool>, + pub defineProperty: Option) -> c_bool>, pub getOwnPropertyNames: *u8, //XXX need a representation for AutoIdVector& - pub delete_: Option JSBool>, + pub delete_: Option JSBool>, pub enumerate: *u8, //XXX need a representation for AutoIdVector& - pub has: Option JSBool>, - pub hasOwn: Option JSBool>, - pub get: Option JSBool>, - pub set: Option JSBool>, + pub has: Option JSBool>, + pub hasOwn: Option c_bool>, + pub get: Option c_bool>, + pub set: Option JSBool>, pub keys: *u8, //XXX need a representation for AutoIdVector& - pub iterate: Option JSBool>, + pub iterate: Option JSBool>, - pub call: Option JSBool>, - pub construct: Option JSBool>, + pub isExtensible: Option c_bool>, + pub call: Option JSBool>, + pub construct: Option JSBool>, pub nativeCall: *u8, //XXX need a representation for IsAcceptableThis, NativeImpl, and CallArgs - pub hasInstance: Option JSBool>, - pub typeOf: Option uint>, //XXX JSType enum - pub objectClassIs: Option JSBool>, //XXX ESClassValue enum - pub obj_toString: Option *JSString>, - pub fun_toString: Option *JSString>, + pub hasInstance: Option JSBool>, + pub objectClassIs: Option JSBool>, //XXX ESClassValue enum + pub fun_toString: Option *JSString>, //regexp_toShared: *u8, - pub defaultValue: Option JSBool>, //XXX JSType enum - pub iteratorNext: Option JSBool>, - pub finalize: Option, - pub getElementIfPresent: Option JSBool>, - pub getPrototypeOf: Option JSBool>, - pub trace: Option, + pub defaultValue: Option JSBool>, //XXX JSType enum + pub finalize: Option, + pub getPrototypeOf: Option c_bool>, + pub trace: Option } #[link(name = "jsglue")] @@ -57,54 +69,130 @@ extern { pub fn RUST_JS_NumberValue(d: f64) -> JSVal; //#[rust_stack] -pub fn CallJitPropertyOp(info: *JSJitInfo, cx: *JSContext, thisObj: *JSObject, specializedThis: *libc::c_void, vp: *JSVal) -> JSBool; +pub fn CallJitSetterOp(info: *JSJitInfo, cx: *mut JSContext, thisObj: JSHandleObject, specializedThis: *libc::c_void, argc: libc::c_uint, vp: *mut JSVal) -> c_bool; + +pub fn CallJitGetterOp(info: *JSJitInfo, cx: *mut JSContext, thisObj: JSHandleObject, specializedThis: *libc::c_void, argc: libc::c_uint, vp: *mut JSVal) -> c_bool; //#[rust_stack] -pub fn CallJitMethodOp(info: *JSJitInfo, cx: *JSContext, thisObj: *JSObject, specializedThis: *libc::c_void, argc: libc::c_uint, vp: *JSVal) -> JSBool; +pub fn CallJitMethodOp(info: *JSJitInfo, cx: *mut JSContext, thisObj: JSHandleObject, specializedThis: *libc::c_void, argc: libc::c_uint, vp: *mut JSVal) -> c_bool; //#[rust_stack] pub fn RUST_FUNCTION_VALUE_TO_JITINFO(v: JSVal) -> *JSJitInfo; -pub fn SetFunctionNativeReserved(fun: *JSObject, which: libc::size_t, val: *JSVal); -pub fn GetFunctionNativeReserved(fun: *JSObject, which: libc::size_t) -> *JSVal; +pub fn SetFunctionNativeReserved(fun: *mut JSObject, which: libc::size_t, val: *JSVal); +pub fn GetFunctionNativeReserved(fun: *mut JSObject, which: libc::size_t) -> *JSVal; pub fn CreateProxyHandler(traps: *ProxyTraps, extra: *libc::c_void) -> *libc::c_void; pub fn CreateWrapperProxyHandler(traps: *ProxyTraps) -> *libc::c_void; -pub fn NewProxyObject(cx: *JSContext, handler: *libc::c_void, priv_: *JSVal, - proto: *JSObject, parent: *JSObject, call: *JSObject, - construct: *JSObject) -> *JSObject; -pub fn WrapperNew(cx: *JSContext, parent: *JSObject, handler: *libc::c_void) -> *JSObject; +pub fn NewProxyObject(cx: *mut JSContext, handler: *libc::c_void, clasp: *super::Class, + priv_: JSHandleValue, proto: *mut JSObject, parent: *mut JSObject) -> *mut JSObject; +pub fn WrapperNew(cx: *mut JSContext, obj: JSHandleObject, parent: JSHandleObject, + handler: *libc::c_void, clasp: *super::Class, singleton: bool) -> *mut JSObject; -pub fn GetProxyExtra(obj: *JSObject, slot: libc::c_uint) -> JSVal; -pub fn GetProxyPrivate(obj: *JSObject) -> JSVal; -pub fn SetProxyExtra(obj: *JSObject, slot: libc::c_uint, val: JSVal); +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: *JSObject) -> *JSObject; -pub fn GetObjectParent(obj: *JSObject) -> *JSObject; +pub fn GetObjectProto(cx: *mut JSContext, obj: JSHandleObject, proto: JSMutableHandleObject) -> c_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) -> c_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_TO_STRING(id: jsid) -> *JSString; +pub fn RUST_JSID_IS_STRING(id: jsid) -> c_bool; +pub fn RUST_JSID_TO_STRING(id: jsid) -> *mut JSString; -pub fn RUST_SET_JITINFO(func: *JSFunction, info: *JSJitInfo); +pub fn RUST_SET_JITINFO(func: *mut JSFunction, info: *mut JSJitInfo); -pub fn RUST_INTERNED_STRING_TO_JSID(cx: *JSContext, str: *JSString) -> jsid; +pub fn RUST_INTERNED_STRING_TO_JSID(cx: *mut JSContext, str: *mut JSString) -> jsid; -pub fn DefineFunctionWithReserved(cx: *JSContext, obj: *JSObject, +pub fn DefineFunctionWithReserved(cx: *mut JSContext, obj: *mut JSObject, name: *libc::c_char, call: JSNative, nargs: libc::c_uint, - attrs: libc::c_uint) -> *JSObject; -pub fn GetObjectJSClass(obj: *JSObject) -> *JSClass; + attrs: libc::c_uint) -> *mut JSObject; +pub fn GetObjectJSClass(obj: *mut JSObject) -> *mut JSClass; pub fn RUST_js_GetErrorMessage(userRef: *libc::c_void, locale: *libc::c_char, - errorNumber: libc::c_uint) -> *JSErrorFormatString; -pub fn js_IsObjectProxyClass(obj: *JSObject) -> bool; -pub fn js_IsFunctionProxyClass(obj: *JSObject) -> bool; -pub fn IsProxyHandlerFamily(obj: *JSObject) -> bool; -pub fn GetProxyHandlerExtra(obj: *JSObject) -> *libc::c_void; -pub fn GetProxyHandler(obj: *JSObject) -> *libc::c_void; -pub fn InvokeGetOwnPropertyDescriptor(handler: *libc::c_void, cx: *JSContext, proxy: *JSObject, id: jsid, set: JSBool, desc: *mut JSPropertyDescriptor) -> JSBool; -pub fn GetGlobalForObjectCrossCompartment(obj: *JSObject) -> *JSObject; -pub fn ReportError(cx: *JSContext, error: *libc::c_char); -pub fn IsWrapper(obj: *JSObject) -> JSBool; -pub fn UnwrapObject(obj: *JSObject, stopAtOuter: JSBool, flags: *libc::c_uint) -> *JSObject; + errorNumber: libc::c_uint) -> *mut JSErrorFormatString; +pub fn js_IsObjectProxyClass(obj: *mut JSObject) -> bool; +pub fn js_IsFunctionProxyClass(obj: *mut JSObject) -> bool; +pub fn IsProxyHandlerFamily(obj: *mut JSObject) -> bool; +pub fn GetProxyHandlerExtra(obj: *mut JSObject) -> *libc::c_void; +pub fn GetProxyHandler(obj: *mut JSObject) -> *libc::c_void; +pub fn InvokeGetOwnPropertyDescriptor(handler: *libc::c_void, cx: *mut JSContext, proxy: JSHandleObject, id: JSHandleId, desc: JSMutableHandle, flags: u32) -> c_bool; +pub fn GetGlobalForObjectCrossCompartment(obj: *mut JSObject) -> *mut JSObject; +pub fn ReportError(cx: *mut JSContext, error: *libc::c_char); +pub fn IsWrapper(obj: *mut JSObject) -> JSBool; +pub fn UnwrapObject(obj: *mut JSObject, stopAtOuter: JSBool) -> *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; + +pub fn AddObjectRoot(cx: *mut JSContext, obj: *mut *mut JSObject) -> bool; +pub fn RemoveObjectRoot(cx: *mut JSContext, obj: *mut *mut libc::c_void); + +pub fn NewGlobalObject(cx: *mut JSContext, clasp: *JSClass, + principals: *mut JSPrincipals, + hookOption: Enum_OnNewGlobalHookOption) -> *mut JSObject; + +pub fn CallFunctionValue(cx: *mut JSContext, obj: JSHandleObject, fval: JSHandleValue, + argc: libc::size_t, argv: *JSVal, rval: JSMutableHandleValue) -> bool; + +pub fn proxy_LookupGeneric(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + objp: JSMutableHandleObject, propp: JSMutableHandle<*mut c_void>) -> bool; +pub fn proxy_LookupProperty(cx: *mut JSContext, obj: JSHandleObject, name: JSHandle<*mut c_void>, + objp: JSMutableHandleObject, propp: JSMutableHandle<*mut c_void>) -> bool; +pub fn proxy_LookupElement(cx: *mut JSContext, obj: JSHandleObject, index: u32, + objp: JSMutableHandleObject, propp: JSMutableHandle<*mut c_void>) -> bool; +pub fn proxy_DefineGeneric(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + value: JSHandleValue, getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: uint) -> bool; +pub fn proxy_DefineProperty(cx: *mut JSContext, obj: JSHandleObject, name: JSHandle<*mut c_void>, + value: JSHandleValue, getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: uint) -> bool; +pub fn proxy_DefineElement(cx: *mut JSContext, obj: JSHandleObject, index: u32, + value: JSHandleValue, getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: 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: JSHandle<*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: JSHandle<*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 uint) -> bool; +pub fn proxy_SetGenericAttributes(cx: *mut JSContext, obj: JSHandleObject, id: JSHandleId, + attrsp: *mut uint) -> bool; +pub fn proxy_DeleteProperty(cx: *mut JSContext, obj: JSHandleObject, name: JSHandle<*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) -> c_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 c_bool) -> c_bool; +pub fn proxy_Call(cx: *mut JSContext, argc: uint, vp: *mut JSVal) -> bool; +pub fn proxy_Construct(cx: *mut JSContext, argc: 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; } diff --git a/js.rc b/js.rc index c8e81cbfc..73125592b 100644 --- a/js.rc +++ b/js.rc @@ -19,17 +19,18 @@ extern crate log; extern crate rustuv; extern crate serialize; -use libc::c_uint; +use libc::{c_int, 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}; use jsval::JSVal; +use glue::{JSMutableHandle, JSHandle}; // These are just macros in jsapi.h pub use JS_NewRuntime = jsapi::JS_Init; -pub use JS_DestroyRuntime = jsapi::JS_Finish; /* FIXME: Not sure where JS_Lock is pub use JS_LockRuntime = jsapi::bindgen::JS_Lock; @@ -55,7 +56,7 @@ pub static JSOPTION_TYPE_INFERENCE: uint32_t = (1 << 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 ERR: c_int = 0; pub static JSID_TYPE_STRING: i64 = 0; pub static JSID_TYPE_INT: i64 = 1; @@ -64,9 +65,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; @@ -76,6 +77,12 @@ pub static JSPROP_SETTER: c_uint = 0x20; pub static JSPROP_SHARED: c_uint = 0x40; pub static JSPROP_NATIVE_ACCESSORS: c_uint = 0x08; +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_IMPLEMENTS_BARRIERS: c_uint = 1 << 5; + 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 = ((1 << JSCLASS_RESERVED_SLOTS_WIDTH) - 1); @@ -84,17 +91,19 @@ pub static JSCLASS_HIGH_FLAGS_SHIFT: c_uint = JSCLASS_RESERVED_SLOTS_SHIFT + JSCLASS_RESERVED_SLOTS_WIDTH; 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 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, @@ -106,20 +115,19 @@ pub fn JSCLASS_HAS_RESERVED_SLOTS(n: c_uint) -> c_uint { } #[inline(always)] -pub unsafe fn JS_ARGV(_cx: *JSContext, vp: *JSVal) -> *JSVal { +pub unsafe fn JS_ARGV(_cx: *mut JSContext, vp: *mut JSVal) -> *mut JSVal { vp.offset(2) } -pub unsafe fn JS_SET_RVAL(_cx: *JSContext, vp: *JSVal, v: JSVal) { - let vp = vp as *mut JSVal; +pub unsafe fn JS_SET_RVAL(_cx: *mut JSContext, vp: *mut JSVal, v: JSVal) { *vp = v; } #[inline(alwyas)] -pub unsafe fn JS_THIS_OBJECT(cx: *JSContext, vp: *mut JSVal) -> *JSObject { +pub unsafe fn JS_THIS_OBJECT(cx: *mut JSContext, vp: *mut JSVal) -> *mut JSObject { let r = if (*(vp.offset(1))).is_primitive() { - JS_ComputeThis(cx, &*vp) + JS_ComputeThis(cx, &mut *vp) } else { *(vp.offset(1)) }; @@ -127,7 +135,7 @@ pub unsafe fn JS_THIS_OBJECT(cx: *JSContext, vp: *mut JSVal) -> *JSObject { } #[inline(always)] -pub unsafe fn JS_CALLEE(_cx: *JSContext, vp: *JSVal) -> JSVal { +pub unsafe fn JS_CALLEE(_cx: *mut JSContext, vp: *mut JSVal) -> JSVal { *vp } @@ -142,70 +150,106 @@ fn start(argc: int, argv: **u8) -> int { green::start(argc, argv, rustuv::event_loop, __test::main) } -pub type JSObjectOp = extern "C" fn(*JSContext, JSHandleObject) -> *JSObject; +pub type JSObjectOp = Option *mut JSObject>; +pub type ClassCreationOp = Option; +pub type FinishClassInitOp = Option; pub struct Class { pub name: *libc::c_char, pub flags: uint32_t, - pub addProperty: Option, - pub delProperty: Option, - pub getProperty: Option, - pub setProperty: Option, - pub enumerate: Option, - pub resolve: Option, - pub convert: Option, - pub finalize: Option, - pub checkAccess: Option, - pub call: Option, - pub hasInstance: Option, - pub construct: Option, - pub trace: Option, - + 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 spec: ClassSpec, pub ext: ClassExtension, pub ops: ObjectOps, } +pub struct ClassSpec { + pub createConstructor: ClassCreationOp, + pub createPrototype: ClassCreationOp, + pub constructorFunctions: *JSFunctionSpec, + pub prototypeFunctions: *JSFunctionSpec, + pub finishInit: FinishClassInitOp, +} + pub struct ClassExtension { - pub equality: *u8, - pub outerObject: Option, - pub innerObject: Option, + pub outerObject: JSObjectOp, + pub innerObject: JSObjectOp, pub iteratorObject: *u8, - pub unused: *u8, - pub isWrappedNative: *u8, + pub isWrappedNative: libc::c_uint, + pub weakmapKeyDelegateOp: JSWeakmapKeyDelegateOp, } +pub type LookupGenericOp = Option) -> bool>; +pub type LookupPropOp = Option, + JSMutableHandleObject, JSMutableHandle<*mut c_void>) -> bool>; +pub type LookupElementOp = Option) -> bool>; +pub type DefineGenericOp = Option bool>; +pub type DefinePropOp = Option, + JSHandleValue, JSPropertyOp, JSStrictPropertyOp, + 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>; + pub struct ObjectOps { - pub lookupGeneric: *u8, - pub lookupProperty: *u8, - pub lookupElement: *u8, - pub lookupSpecial: *u8, - pub defineGeneric: *u8, - pub defineProperty: *u8, - pub defineElement: *u8, - pub defineSpecial: *u8, - pub getGeneric: *u8, - pub getProperty: *u8, - pub getElement: *u8, - pub getElementIfPresent: *u8, - pub getSpecial: *u8, - pub setGeneric: *u8, - pub setProperty: *u8, - pub setElement: *u8, - pub setSpecial: *u8, - pub getGenericAttributes: *u8, - pub getPropertyAttributes: *u8, - pub getElementAttributes: *u8, - pub getSpecialAttributes: *u8, - pub setGenericAttributes: *u8, - pub setPropertyAttributes: *u8, - pub setElementAttributes: *u8, - pub setSpecialAttributes: *u8, - pub deleteProperty: *u8, - pub deleteElement: *u8, - pub deleteSpecial: *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: *u8, - pub typeOf: *u8, - pub thisObject: Option, - pub clear: *u8, + pub thisObject: JSObjectOp, } diff --git a/jsapi.rs b/jsapi.rs index 0a858a06c..55ace2903 100644 --- a/jsapi.rs +++ b/jsapi.rs @@ -2,1496 +2,1460 @@ * 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 */ - #![allow(non_uppercase_statics, non_camel_case_types)] -use libc::*; use jsfriendapi::JSJitInfo; -use jsval::JSVal; - -pub type moz_static_assert0 = c_int; - -pub type moz_static_assert1 = c_int; - -pub type moz_static_assert2 = c_int; - -pub type moz_static_assert3 = c_int; - -pub type moz_static_assert4 = c_int; - -pub type union_MozDoublePun = c_void /* FIXME: union type */; - -pub type JSBool = c_int; - -pub type jsid = ptrdiff_t; - -pub type jschar = uint16_t; - -pub type enum_JSVersion = c_int; -pub static JSVERSION_1_0: i32 = 100_i32; -pub static JSVERSION_1_1: i32 = 110_i32; -pub static JSVERSION_1_2: i32 = 120_i32; -pub static JSVERSION_1_3: i32 = 130_i32; -pub static JSVERSION_1_4: i32 = 140_i32; -pub static JSVERSION_ECMA_3: i32 = 148_i32; -pub static JSVERSION_1_5: i32 = 150_i32; -pub static JSVERSION_1_6: i32 = 160_i32; -pub static JSVERSION_1_7: i32 = 170_i32; -pub static JSVERSION_1_8: i32 = 180_i32; -pub static JSVERSION_ECMA_5: i32 = 185_i32; -pub static JSVERSION_DEFAULT: i32 = 0_i32; -pub static JSVERSION_UNKNOWN: i32 = -1_i32; -pub static JSVERSION_LATEST: i32 = 185_i32; - -pub type JSVersion = enum_JSVersion; - -pub type enum_JSType = c_uint; -pub static JSTYPE_VOID: u32 = 0_u32; -pub static JSTYPE_OBJECT: u32 = 1_u32; -pub static JSTYPE_FUNCTION: u32 = 2_u32; -pub static JSTYPE_STRING: u32 = 3_u32; -pub static JSTYPE_NUMBER: u32 = 4_u32; -pub static JSTYPE_BOOLEAN: u32 = 5_u32; -pub static JSTYPE_NULL: u32 = 6_u32; -pub static JSTYPE_XML: u32 = 7_u32; -pub static JSTYPE_LIMIT: u32 = 8_u32; - -pub type JSType = enum_JSType; - -pub type enum_JSProtoKey = c_uint; -pub static JSProto_Null: u32 = 0_u32; -pub static JSProto_Object: u32 = 1_u32; -pub static JSProto_Function: u32 = 2_u32; -pub static JSProto_Array: u32 = 3_u32; -pub static JSProto_Boolean: u32 = 4_u32; -pub static JSProto_JSON: u32 = 5_u32; -pub static JSProto_Date: u32 = 6_u32; -pub static JSProto_Math: u32 = 7_u32; -pub static JSProto_Number: u32 = 8_u32; -pub static JSProto_String: u32 = 9_u32; -pub static JSProto_RegExp: u32 = 10_u32; -pub static JSProto_XML: u32 = 11_u32; -pub static JSProto_Namespace: u32 = 12_u32; -pub static JSProto_QName: u32 = 13_u32; -pub static JSProto_Error: u32 = 14_u32; -pub static JSProto_InternalError: u32 = 15_u32; -pub static JSProto_EvalError: u32 = 16_u32; -pub static JSProto_RangeError: u32 = 17_u32; -pub static JSProto_ReferenceError: u32 = 18_u32; -pub static JSProto_SyntaxError: u32 = 19_u32; -pub static JSProto_TypeError: u32 = 20_u32; -pub static JSProto_URIError: u32 = 21_u32; -pub static JSProto_Iterator: u32 = 22_u32; -pub static JSProto_StopIteration: u32 = 23_u32; -pub static JSProto_ArrayBuffer: u32 = 24_u32; -pub static JSProto_Int8Array: u32 = 25_u32; -pub static JSProto_Uint8Array: u32 = 26_u32; -pub static JSProto_Int16Array: u32 = 27_u32; -pub static JSProto_Uint16Array: u32 = 28_u32; -pub static JSProto_Int32Array: u32 = 29_u32; -pub static JSProto_Uint32Array: u32 = 30_u32; -pub static JSProto_Float32Array: u32 = 31_u32; -pub static JSProto_Float64Array: u32 = 32_u32; -pub static JSProto_Uint8ClampedArray: u32 = 33_u32; -pub static JSProto_Proxy: u32 = 34_u32; -pub static JSProto_AnyName: u32 = 35_u32; -pub static JSProto_WeakMap: u32 = 36_u32; -pub static JSProto_Map: u32 = 37_u32; -pub static JSProto_Set: u32 = 38_u32; -pub static JSProto_DataView: u32 = 39_u32; -pub static JSProto_ParallelArray: u32 = 40_u32; -pub static JSProto_LIMIT: u32 = 41_u32; - -pub type JSProtoKey = enum_JSProtoKey; - -pub type enum_JSAccessMode = c_uint; -pub static JSACC_PROTO: u32 = 0_u32; -pub static JSACC_WATCH: u32 = 3_u32; -pub static JSACC_READ: u32 = 4_u32; -pub static JSACC_WRITE: u32 = 8_u32; -pub static JSACC_LIMIT: u32 = 9_u32; - -pub type JSAccessMode = enum_JSAccessMode; - -pub type enum_JSIterateOp = c_uint; -pub static JSENUMERATE_INIT: u32 = 0_u32; -pub static JSENUMERATE_INIT_ALL: u32 = 1_u32; -pub static JSENUMERATE_NEXT: u32 = 2_u32; -pub static JSENUMERATE_DESTROY: u32 = 3_u32; - -pub type JSIterateOp = enum_JSIterateOp; - - -pub type JSGCTraceKind = c_uint; -pub static JSTRACE_OBJECT: u32 = 0_u32; -pub static JSTRACE_STRING: u32 = 1_u32; -pub static JSTRACE_SCRIPT: u32 = 2_u32; -pub static JSTRACE_XML: u32 = 3_u32; -pub static JSTRACE_SHAPE: u32 = 4_u32; -pub static JSTRACE_BASE_SHAPE: u32 = 5_u32; -pub static JSTRACE_TYPE_OBJECT: u32 = 6_u32; -pub static JSTRACE_LAST: u32 = 6_u32; - -pub type struct_JSCompartment = c_void; - -pub type JSCompartment = struct_JSCompartment; - -pub type JSConstDoubleSpec = struct_JSConstDoubleSpec; - -pub type struct_JSContext = c_void; - -pub type JSContext = struct_JSContext; - -pub type struct_JSCrossCompartmentCall = c_void; - -pub type JSCrossCompartmentCall = struct_JSCrossCompartmentCall; - -pub type JSErrorReport = struct_JSErrorReport; - -pub type struct_JSExceptionState = c_void; - -pub type JSExceptionState = struct_JSExceptionState; - -pub type struct_JSFunction = c_void; - -pub type JSFunction = struct_JSFunction; - -pub type struct_JSIdArray = c_void; - -pub type JSIdArray = struct_JSIdArray; - -pub type JSLocaleCallbacks = struct_JSLocaleCallbacks; - -pub type struct_JSObject = c_void; - -pub type JSObject = struct_JSObject; - -pub type struct_JSObjectMap = c_void; - -pub type JSObjectMap = struct_JSObjectMap; - -pub type JSPrincipals = struct_JSPrincipals; - -pub type JSPropertyDescriptor = struct_JSPropertyDescriptor; - -pub type struct_JSPropertyName = c_void; - -pub type JSPropertyName = struct_JSPropertyName; - -pub type struct_JSRuntime = c_void; - -pub type JSRuntime = struct_JSRuntime; - -pub type JSSecurityCallbacks = struct_JSSecurityCallbacks; - -pub type struct_JSStackFrame = c_void; - -pub type JSStackFrame = struct_JSStackFrame; - -pub type struct_JSScript = c_void; - -pub type JSScript = struct_JSScript; - -pub type JSStructuredCloneCallbacks = struct_JSStructuredCloneCallbacks; - -pub type struct_JSStructuredCloneReader = c_void; - -pub type JSStructuredCloneReader = struct_JSStructuredCloneReader; - -pub type struct_JSStructuredCloneWriter = c_void; - -pub type JSStructuredCloneWriter = struct_JSStructuredCloneWriter; - -pub type JSTracer = struct_JSTracer; - -pub type struct_JSFlatString = c_void; - -pub type JSFlatString = struct_JSFlatString; - -pub type struct_JSString = c_void; +use jsval::Union_jsval_layout; +use glue::JSMutableHandle; +//more custom additions at bottom -pub type JSString = struct_JSString; - -pub type JSCallOnceType = JSBool; - -pub type JSInitCallback = *u8; - -pub type JSMallocSizeOfFun = *u8; - -pub type jsbitmap = size_t; - -pub type JSValueType = uint8_t; - -pub type JSValueTag = uint32_t; - -pub type JSValueShiftedTag = uint64_t; - -pub type enum_JSWhyMagic = c_uint; -pub static JS_ARRAY_HOLE: u32 = 0_u32; -pub static JS_NATIVE_ENUMERATE: u32 = 1_u32; -pub static JS_NO_ITER_VALUE: u32 = 2_u32; -pub static JS_GENERATOR_CLOSING: u32 = 3_u32; -pub static JS_NO_CONSTANT: u32 = 4_u32; -pub static JS_THIS_POISON: u32 = 5_u32; -pub static JS_ARG_POISON: u32 = 6_u32; -pub static JS_SERIALIZE_NO_NODE: u32 = 7_u32; -pub static JS_LAZY_ARGUMENTS: u32 = 8_u32; -pub static JS_OPTIMIZED_ARGUMENTS: u32 = 9_u32; -pub static JS_IS_CONSTRUCTING: u32 = 10_u32; -pub static JS_OVERWRITTEN_CALLEE: u32 = 11_u32; -pub static JS_FORWARD_TO_CALL_OBJECT: u32 = 12_u32; -pub static JS_BLOCK_NEEDS_CLONE: u32 = 13_u32; -pub static JS_HASH_KEY_EMPTY: u32 = 14_u32; -pub static JS_GENERIC_MAGIC: u32 = 15_u32; - -pub type JSWhyMagic = enum_JSWhyMagic; - -pub type union_jsval_layout = c_void /* FIXME: union type */; - -pub type jsval_layout = union_jsval_layout; - -pub type moz_static_assert5 = c_int; - -pub type moz_static_assert6 = c_int; +/* automatically generated by rust-bindgen */ -pub struct JSHandleObject { - pub unnamed: **JSObject, +use libc::*; +pub type Struct_JSContext = c_void; +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 = c_void; +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 c_int>; +pub type JSTraceDataOp = + ::std::option::Option; +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 JSHandleValue { - pub unnamed: JSVal, +impl Union_jsval_layout { + pub fn asBits(&mut self) -> *mut uint64_t { + unsafe { ::std::cast::transmute(self) } + } + pub fn debugView(&mut self) -> *mut Struct_Unnamed1 { + unsafe { ::std::cast::transmute(self) } + } + pub fn s(&mut self) -> *mut Struct_Unnamed2 { + unsafe { ::std::cast::transmute(self) } + } + pub fn asDouble(&mut self) -> *mut c_double { + unsafe { ::std::cast::transmute(self) } + } + pub fn asPtr(&mut self) -> *mut *mut c_void { + unsafe { ::std::cast::transmute(self) } + } + pub fn asWord(&mut self) -> *mut size_t { + unsafe { ::std::cast::transmute(self) } + } + pub fn asUIntPtr(&mut self) -> *mut uintptr_t { + unsafe { ::std::cast::transmute(self) } + } +}*/ +pub struct Struct_Unnamed1 { + payload47: uint64_t, + tag: Enum_JSValueTag, } - -pub struct JSHandleString { - pub unnamed: **JSString, +pub struct Struct_Unnamed2 { + pub payload: Union_Unnamed3, } - -pub struct JSMutableHandleObject { - pub unnamed: **JSObject, +pub struct Union_Unnamed3 { + pub data: [u32, ..1u], } - -pub struct JSHandleId { - pub unnamed: *jsid, +impl Union_Unnamed3 { + pub fn i32(&mut self) -> *mut int32_t { + unsafe { ::std::cast::transmute(self) } + } + pub fn u32(&mut self) -> *mut uint32_t { + unsafe { ::std::cast::transmute(self) } + } + pub fn why(&mut self) -> *mut JSWhyMagic { + unsafe { ::std::cast::transmute(self) } + } } - -pub struct JSMutableHandleValue { - pub unnamed: *JSVal, +pub type jsval_layout = Union_jsval_layout; +//pub type jsval = c_void; //jdm +pub type JSNative = + ::std::option::Option c_int>; //jdm c_void->jsval +pub type JSParallelNative = + ::std::option::Option c_int>; +pub type JSThreadSafeNative = + ::std::option::Option c_int>; +pub struct Struct_jsid { + asBits: size_t, } - -pub type JSRawObject = *JSObject; - -pub type JSPropertyOp = extern "C" unsafe fn(*JSContext, JSHandleObject, JSHandleId, JSMutableHandleValue) -> JSBool; - -pub type JSStrictPropertyOp = extern "C" unsafe fn(*JSContext, JSHandleObject, JSHandleId, JSBool, JSMutableHandleValue) -> JSBool; - -pub type JSNewEnumerateOp = *u8; - -pub type JSEnumerateOp = extern "C" unsafe fn(*JSContext, JSHandleObject) -> JSBool; - -pub type JSResolveOp = extern "C" unsafe fn(*JSContext, JSHandleObject, JSHandleId) -> JSBool; - -pub type JSNewResolveOp = *u8; - -pub type JSConvertOp = extern "C" unsafe fn(*JSContext, JSHandleObject, JSType, JSMutableHandleValue) -> JSBool; - -pub type JSTypeOfOp = *u8; - -pub type JSFreeOp = struct_JSFreeOp; - -pub struct struct_JSFreeOp { - pub runtime: *JSRuntime, +pub type JSPropertyOp = + ::std::option::Option c_int>; +pub type JSStrictPropertyOp = + ::std::option::Option c_int>; +pub type JSDeletePropertyOp = + ::std::option::Option c_int>; +pub type JSNewEnumerateOp = + ::std::option::Option c_int>; +pub type JSEnumerateOp = + ::std::option::Option c_int>; +pub type JSResolveOp = + ::std::option::Option c_int>; +pub type JSNewResolveOp = + ::std::option::Option c_int>; +pub type JSConvertOp = + ::std::option::Option c_int>; +pub type JSFinalizeOp = + ::std::option::Option; +pub struct Struct_JSStringFinalizer { + finalize: ::std::option::Option, } - -pub type JSFinalizeOp = extern "C" fn(*JSFreeOp, *JSObject); - -pub type JSStringFinalizer = struct_JSStringFinalizer; - -pub struct struct_JSStringFinalizer { - pub finalize: *u8, +pub type JSHasInstanceOp = + ::std::option::Option c_int>; +pub type JSTraceOp = + ::std::option::Option; //jdm c_void->... +pub type JSObjectOp = + ::std::option::Option *mut c_void>; +pub type JSIteratorOp = + ::std::option::Option *mut c_void>; +pub type JSWeakmapKeyDelegateOp = + ::std::option::Option *mut c_void>; //jdm +unsafe +pub type JSClassInternal = ::std::option::Option; +pub struct Struct_JSClass { + pub name: *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], } - -//XXXjdm JSAccessMode is an enum; uint32_t may not be correct. -pub type JSCheckAccessOp = extern "C" fn(*JSContext, **JSObject, *jsid, uint32_t, *mut JSVal) -> JSBool; - -pub type JSHasInstanceOp = extern "C" fn(*JSContext, **JSObject, *JSVal, *mut JSBool) -> JSBool; - -pub type JSTraceOp = extern "C" fn(*mut JSTracer, *JSObject); - -pub type JSTraceNamePrinter = *u8; - -pub type JSEqualityOp = *u8; - -pub type JSNative = extern "C" unsafe fn(*JSContext, c_uint, *mut JSVal) -> JSBool; - -pub type enum_JSContextOp = c_uint; -pub static JSCONTEXT_NEW: u32 = 0_u32; -pub static JSCONTEXT_DESTROY: u32 = 1_u32; - -pub type JSContextOp = enum_JSContextOp; - -pub type JSContextCallback = *u8; - -pub type enum_JSGCStatus = c_uint; -pub static JSGC_BEGIN: u32 = 0_u32; -pub static JSGC_END: u32 = 1_u32; - -pub type JSGCStatus = enum_JSGCStatus; - -pub type JSGCCallback = extern "C" fn(*JSRuntime, JSGCStatus); - -pub type enum_JSFinalizeStatus = c_uint; -pub static JSFINALIZE_START: u32 = 0_u32; -pub static JSFINALIZE_END: u32 = 1_u32; - -pub type JSFinalizeStatus = enum_JSFinalizeStatus; - -pub type JSFinalizeCallback = *u8; - -pub type JSTraceDataOp = *u8; - -pub type JSOperationCallback = *u8; - -pub type JSErrorReporter = extern "C" fn(*JSContext, *c_char, *JSErrorReport); - -pub type enum_JSExnType = c_int; -pub static JSEXN_NONE: i32 = -1_i32; -pub static JSEXN_ERR: i32 = 0_i32; -pub static JSEXN_INTERNALERR: i32 = 1_i32; -pub static JSEXN_EVALERR: i32 = 2_i32; -pub static JSEXN_RANGEERR: i32 = 3_i32; -pub static JSEXN_REFERENCEERR: i32 = 4_i32; -pub static JSEXN_SYNTAXERR: i32 = 5_i32; -pub static JSEXN_TYPEERR: i32 = 6_i32; -pub static JSEXN_URIERR: i32 = 7_i32; -pub static JSEXN_LIMIT: i32 = 8_i32; - -pub type JSExnType = enum_JSExnType; - -pub struct struct_JSErrorFormatString { - pub format: *c_char, +pub struct Struct_JSPrincipals { + refcount: c_void, +} +pub type JSSubsumesOp = + ::std::option::Option c_int>; +pub type JSCSPEvalChecker = + ::std::option::Option c_int>; +pub struct Struct_JSSecurityCallbacks { + contentSecurityPolicyAllows: JSCSPEvalChecker, + subsumes: JSSubsumesOp, +} +pub type JSDestroyPrincipalsOp = + ::std::option::Option; +pub type JSTraceCallback = + ::std::option::Option; +pub type JSTraceNamePrinter = + ::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 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 = + ::std::option::Option c_int>; +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 = + ::std::option::Option; +pub type Enum_JSFinalizeStatus = c_uint; +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 = + ::std::option::Option; +pub type JSInterruptCallback = + ::std::option::Option c_int>; +pub type JSErrorReporter = + ::std::option::Option; +pub type Enum_JSExnType = c_int; +pub static JSEXN_NONE: c_int = -1; +pub static JSEXN_ERR: c_int = 0; +pub static JSEXN_INTERNALERR: c_int = 1; +pub static JSEXN_EVALERR: c_int = 2; +pub static JSEXN_RANGEERR: c_int = 3; +pub static JSEXN_REFERENCEERR: c_int = 4; +pub static JSEXN_SYNTAXERR: c_int = 5; +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 Struct_JSErrorFormatString { + pub format: *c_schar, pub argCount: uint16_t, pub exnType: int16_t, } - -pub type JSErrorFormatString = struct_JSErrorFormatString; - -pub type JSErrorCallback = extern "C" fn(*mut c_void, *c_char, c_uint) -> *JSErrorFormatString; - -pub type JSLocaleToUpperCase = *u8; - -pub type JSLocaleToLowerCase = *u8; - -pub type JSLocaleCompare = *u8; - -pub type JSLocaleToUnicode = *u8; - -pub type JSDestroyPrincipalsOp = *u8; - -pub type JSSubsumePrincipalsOp = *u8; - -pub type JSObjectPrincipalsFinder = *u8; - -pub type JSCSPEvalChecker = *u8; - -pub type JSWrapObjectCallback = *u8; - -pub type JSPreWrapCallback = *u8; - -pub type JSSameCompartmentWrapObjectCallback = extern "C" fn(*JSContext, *JSObject) -> *JSObject; - -pub type JSDestroyCompartmentCallback = *u8; - -pub type JSCompartmentNameCallback = *u8; - -pub type ReadStructuredCloneOp = *u8; - -pub type WriteStructuredCloneOp = *u8; - -pub type StructuredCloneErrorOp = *u8; - -/* FIXME: global variable JSVAL_NULL */ - -/* FIXME: global variable JSVAL_ZERO */ - -/* FIXME: global variable JSVAL_ONE */ - -/* FIXME: global variable JSVAL_FALSE */ - -/* FIXME: global variable JSVAL_TRUE */ - -/* FIXME: global variable JSVAL_VOID */ - -pub type JSIterateCompartmentCallback = *u8; - -pub type JSEnumerateDiagnosticMemoryCallback = *u8; - -pub type enum_JSGCRootType = c_uint; -pub static JS_GC_ROOT_VALUE_PTR: u32 = 0_u32; -pub static JS_GC_ROOT_GCTHING_PTR: u32 = 1_u32; - -pub type JSGCRootType = enum_JSGCRootType; - -pub type JSGCRootMapFun = *u8; - -pub type JSTraceCallback = *u8; - -pub struct struct_JSTracer { - pub runtime: *JSRuntime, - pub callback: JSTraceCallback, - pub debugPrinter: JSTraceNamePrinter, - pub debugPrintArg: *c_void, - pub debugPrintIndex: size_t, - pub eagerlyTraceWeakMaps: JSBool, +pub type JSErrorFormatString = Struct_JSErrorFormatString; +pub type JSErrorCallback = + ::std::option::Option *JSErrorFormatString>; +pub type JSLocaleToUpperCase = + ::std::option::Option c_int>; +pub type JSLocaleToLowerCase = + ::std::option::Option c_int>; +pub type JSLocaleCompare = + ::std::option::Option c_int>; +pub type JSLocaleToUnicode = + ::std::option::Option c_int>; +pub type JSWrapObjectCallback = + ::std::option::Option *mut c_void>; +pub type JSPreWrapCallback = + ::std::option::Option *mut c_void>; +pub struct Struct_JSWrapObjectCallbacks { + wrap: JSWrapObjectCallback, + preWrap: JSPreWrapCallback, } - -pub type enum_JSGCParamKey = c_uint; -pub static JSGC_MAX_BYTES: u32 = 0_u32; -pub static JSGC_MAX_MALLOC_BYTES: u32 = 1_u32; -pub static JSGC_BYTES: u32 = 3_u32; -pub static JSGC_NUMBER: u32 = 4_u32; -pub static JSGC_MAX_CODE_CACHE_BYTES: u32 = 5_u32; -pub static JSGC_MODE: u32 = 6_u32; -pub static JSGC_UNUSED_CHUNKS: u32 = 7_u32; -pub static JSGC_TOTAL_CHUNKS: u32 = 8_u32; -pub static JSGC_SLICE_TIME_BUDGET: u32 = 9_u32; -pub static JSGC_MARK_STACK_LIMIT: u32 = 10_u32; -pub static JSGC_HIGH_FREQUENCY_TIME_LIMIT: u32 = 11_u32; -pub static JSGC_HIGH_FREQUENCY_LOW_LIMIT: u32 = 12_u32; -pub static JSGC_HIGH_FREQUENCY_HIGH_LIMIT: u32 = 13_u32; -pub static JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX: u32 = 14_u32; -pub static JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN: u32 = 15_u32; -pub static JSGC_LOW_FREQUENCY_HEAP_GROWTH: u32 = 16_u32; -pub static JSGC_DYNAMIC_HEAP_GROWTH: u32 = 17_u32; -pub static JSGC_DYNAMIC_MARK_SLICE: u32 = 18_u32; -pub static JSGC_ANALYSIS_PURGE_TRIGGER: u32 = 19_u32; - -pub type JSGCParamKey = enum_JSGCParamKey; - -pub type enum_JSGCMode = c_uint; -pub static JSGC_MODE_GLOBAL: u32 = 0_u32; -pub static JSGC_MODE_COMPARTMENT: u32 = 1_u32; -pub static JSGC_MODE_INCREMENTAL: u32 = 2_u32; - -pub type JSGCMode = enum_JSGCMode; - -pub type JSClassInternal = *u8; - -pub struct JSClass { - pub name: *c_char, - pub flags: uint32_t, - pub addProperty: Option, - pub delProperty: Option, - pub getProperty: Option, - pub setProperty: Option, - pub enumerate: Option, - pub resolve: Option, - pub convert: Option, - pub finalize: Option, - pub checkAccess: Option, - pub call: Option, - pub hasInstance: Option, - pub construct: Option, - pub trace: Option, - pub reserved: (*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void,*c_void), +pub type JSDestroyCompartmentCallback = + ::std::option::Option; +pub type JSZoneCallback = + ::std::option::Option; +pub type JSCompartmentNameCallback = + ::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 = + ::std::option::Option; +pub type JSEnumerateDiagnosticMemoryCallback = + ::std::option::Option c_int>; +pub type Enum_JSGCParamKey = c_uint; +pub static JSGC_MAX_BYTES: c_uint = 0; +pub static JSGC_MAX_MALLOC_BYTES: c_uint = 1; +pub static JSGC_BYTES: c_uint = 3; +pub static JSGC_NUMBER: c_uint = 4; +pub static JSGC_MAX_CODE_CACHE_BYTES: c_uint = 5; +pub static JSGC_MODE: c_uint = 6; +pub static JSGC_UNUSED_CHUNKS: c_uint = 7; +pub static JSGC_TOTAL_CHUNKS: c_uint = 8; +pub static JSGC_SLICE_TIME_BUDGET: c_uint = 9; +pub static JSGC_MARK_STACK_LIMIT: c_uint = 10; +pub static JSGC_HIGH_FREQUENCY_TIME_LIMIT: c_uint = 11; +pub static JSGC_HIGH_FREQUENCY_LOW_LIMIT: c_uint = 12; +pub static JSGC_HIGH_FREQUENCY_HIGH_LIMIT: c_uint = 13; +pub static JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX: c_uint = 14; +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_ALLOCATION_THRESHOLD: c_uint = 19; +pub static JSGC_DECOMMIT_THRESHOLD: c_uint = 20; +pub type JSGCParamKey = Enum_JSGCParamKey; +pub struct Struct_JSConstDoubleSpec { + dval: c_double, + name: *c_schar, + flags: uint8_t, + spare: [uint8_t, ..3u], } - -pub struct struct_JSConstDoubleSpec { - pub dval: c_double, - pub name: *c_char, - pub flags: uint8_t, - pub spare: (uint8_t,uint8_t,uint8_t), +//pub type Struct_JSJitInfo = c_void; //jdm property defn in jsfriendapi.h +pub struct Struct_JSStrictPropertyOpWrapper { + pub op: JSStrictPropertyOp, + pub info: *Struct_JSJitInfo, } - -pub type struct_JSJitInfo = c_void; - -//pub type JSJitInfo = struct_JSJitInfo; //XXXjdm - -// FIXME: We need these Clone impls for certain operations in Servo, -// but do they really make sense? -pub struct JSStrictPropertyOpWrapper { - pub op: Option, - pub info: *JSJitInfo, +pub type JSStrictPropertyOpWrapper = Struct_JSStrictPropertyOpWrapper; +pub struct Struct_JSPropertyOpWrapper { + pub op: JSPropertyOp, + pub info: *Struct_JSJitInfo, } - -impl Clone for JSStrictPropertyOpWrapper { - fn clone(&self) -> JSStrictPropertyOpWrapper { - JSStrictPropertyOpWrapper { - op: self.op, - info: self.info - } - } +pub type JSPropertyOpWrapper = Struct_JSPropertyOpWrapper; +pub struct Struct_JSNativeWrapper { + pub op: JSNative, + pub info: *Struct_JSJitInfo, } - -pub struct JSPropertyOpWrapper { - pub op: Option, - pub info: *JSJitInfo, +pub type JSNativeWrapper = Struct_JSNativeWrapper; +pub struct Struct_JSPropertySpec { + pub name: *c_schar, + pub flags: uint8_t, + 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 } - -impl Clone for JSPropertyOpWrapper { - fn clone(&self) -> JSPropertyOpWrapper { - JSPropertyOpWrapper { - op: self.op, - info: self.info - } - } +pub struct Struct_SelfHostedWrapper { + unused: *mut c_void, + funname: *c_schar, } - -pub struct JSNativeWrapper { - pub op: Option, - pub info: *JSJitInfo, +pub struct Union_Unnamed4 { + data: [u64, ..2u], } - -impl Clone for JSNativeWrapper { - fn clone(&self) -> JSNativeWrapper { - JSNativeWrapper { - op: self.op, - info: self.info - } +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) } } } - -#[deriving(Clone)] -pub struct JSPropertySpec { - pub name: *c_char, - pub tinyid: int8_t, - pub flags: uint8_t, - pub getter: JSPropertyOpWrapper, - pub setter: JSStrictPropertyOpWrapper, +pub struct Union_Unnamed5 { + data: [u64, ..2u], } - -#[deriving(Clone)] -pub struct JSFunctionSpec { - pub name: *c_char, +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) } + } +} +pub struct Struct_JSFunctionSpec { + pub name: *c_schar, pub call: JSNativeWrapper, pub nargs: uint16_t, pub flags: uint16_t, - pub selfHostedName: *c_char, + pub selfHostedName: *c_schar, } - -pub struct struct_JSPropertyDescriptor { - pub obj: *JSObject, +pub struct Struct_JSPropertyDescriptor { + pub obj: *mut c_void, pub attrs: c_uint, - pub shortid: c_uint, - pub getter: Option, - pub setter: Option, - pub value: JSVal, -} - -pub struct struct_JSPrincipals { - pub refcount: c_int, -} - -pub struct struct_JSSecurityCallbacks { - pub checkObjectAccess: JSCheckAccessOp, - pub subsumePrincipals: JSSubsumePrincipalsOp, - pub findObjectPrincipals: JSObjectPrincipalsFinder, - pub contentSecurityPolicyAllows: JSCSPEvalChecker, -} - -pub type enum_JSExecPart = c_uint; -pub static JSEXEC_PROLOG: u32 = 0_u32; -pub static JSEXEC_MAIN: u32 = 1_u32; - -pub static JS_DEFAULT_ZEAL_FREQ: u32 = 100; - -pub type JSExecPart = enum_JSExecPart; - -pub type JSONWriteCallback = *u8; - -pub struct struct_JSStructuredCloneCallbacks { - pub read: ReadStructuredCloneOp, - pub write: WriteStructuredCloneOp, - pub reportError: StructuredCloneErrorOp, + pub getter: JSPropertyOp, + pub setter: JSStrictPropertyOp, + pub value: jsval, //jdm c_void->JSVal } - -pub struct struct_JSLocaleCallbacks { - pub localeToUpperCase: JSLocaleToUpperCase, - pub localeToLowerCase: JSLocaleToLowerCase, - pub localeCompare: JSLocaleCompare, - pub localeToUnicode: JSLocaleToUnicode, - pub localeGetErrorMessage: JSErrorCallback, +pub type JSONWriteCallback = + ::std::option::Option c_int>; +pub struct Struct_JSLocaleCallbacks { + localeToUpperCase: JSLocaleToUpperCase, + localeToLowerCase: JSLocaleToLowerCase, + localeCompare: JSLocaleCompare, + localeToUnicode: JSLocaleToUnicode, + localeGetErrorMessage: JSErrorCallback, } -pub struct struct_JSErrorReport { - pub filename: *c_char, - pub originPrincipals: *JSPrincipals, +pub struct Struct_JSErrorReport { + pub filename: *c_schar, + pub originPrincipals: *mut Struct_JSPrincipals, pub lineno: c_uint, - pub linebuf: *c_char, - pub tokenptr: *c_char, + pub linebuf: *c_schar, + pub tokenptr: *c_schar, pub uclinebuf: *jschar, pub uctokenptr: *jschar, pub flags: c_uint, pub errorNumber: c_uint, pub ucmessage: *jschar, - pub messageArgs: **jschar, + pub messageArgs: *mut *jschar, pub exnType: int16_t, pub column: c_uint, } -pub struct struct_unnamed1 { - pub payload: union_unnamed2, +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; + pub static JSID_EMPTYHANDLE: HandleId; + pub fn JS_Assert(s: *c_schar, file: *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: *Struct_JSSecurityCallbacks); + pub fn JS_GetSecurityCallbacks(rt: *mut Struct_JSRuntime) -> + *Struct_JSSecurityCallbacks; + pub fn JS_SetTrustedPrincipals(rt: *mut Struct_JSRuntime, + prin: *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: *c_schar); + pub fn JS_CallIdTracer(trc: *mut c_void, idp: *mut Struct_jsid, + name: *c_schar); + pub fn JS_CallObjectTracer(trc: *mut JSTracer, objp: *mut *mut c_void, //jdm c_void->JSTracer + name: *c_schar); + pub fn JS_CallStringTracer(trc: *mut c_void, strp: *mut *mut c_void, + name: *c_schar); + pub fn JS_CallScriptTracer(trc: *mut c_void, scriptp: *mut *mut c_void, + name: *c_schar); + pub fn JS_CallHeapValueTracer(trc: *mut c_void, valuep: *mut c_void, + name: *c_schar); + pub fn JS_CallHeapIdTracer(trc: *mut c_void, idp: *mut c_void, + name: *c_schar); + pub fn JS_CallHeapObjectTracer(trc: *mut c_void, objp: *mut c_void, + name: *c_schar); + pub fn JS_CallHeapStringTracer(trc: *mut c_void, strp: *mut c_void, + name: *c_schar); + pub fn JS_CallHeapScriptTracer(trc: *mut c_void, scriptp: *mut c_void, + name: *c_schar); + pub fn JS_CallHeapFunctionTracer(trc: *mut c_void, funp: *mut c_void, + name: *c_schar); + pub fn JS_CallTenuredObjectTracer(trc: *mut c_void, objp: *mut c_void, + name: *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: c_int); + pub fn JS_StringHasBeenInterned(cx: *mut Struct_JSContext, + str: *mut c_void) -> c_int; + 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) -> + c_int; + 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: *c_schar, ...) -> c_int; + pub fn JS_ConvertArgumentsVA(cx: *mut Struct_JSContext, args: c_void, + format: *c_schar, ap: va_list) -> c_int; + pub fn JS_ConvertValue(cx: *mut Struct_JSContext, v: HandleValue, + _type: Enum_JSType, vp: MutableHandleValue) -> + c_int; + pub fn JS_ValueToObject(cx: *mut Struct_JSContext, v: HandleValue, + objp: MutableHandleObject) -> c_int; + 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) -> c_int; + 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) -> + *c_schar; + pub fn JS_StrictlyEqual(cx: *mut Struct_JSContext, v1: jsval, v2: jsval, + equal: *mut c_int) -> c_int; + pub fn JS_LooselyEqual(cx: *mut Struct_JSContext, v1: c_void, v2: c_void, + equal: *mut c_int) -> c_int; + pub fn JS_SameValue(cx: *mut Struct_JSContext, v1: jsval, v2: jsval, + same: *mut c_int) -> c_int; + pub fn JS_IsBuiltinEvalFunction(fun: *mut c_void) -> c_int; + pub fn JS_IsBuiltinFunctionConstructor(fun: *mut c_void) -> c_int; + pub fn JS_Init() -> c_int; + 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) -> c_int; + 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) -> c_int; + 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) -> *c_schar; + pub fn JS_StringToVersion(string: *c_schar) -> Enum_JSVersion; + pub fn JS_GetImplementationVersion() -> *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: + *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) + -> c_int; + pub fn JS_WrapValue(cx: *mut Struct_JSContext, vp: MutableHandleValue) -> + c_int; + pub fn JS_WrapId(cx: *mut Struct_JSContext, idp: MutableHandleId) -> + c_int; + 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) -> c_int; + pub fn JS_EnterCompartment(cx: *mut Struct_JSContext, target: *mut c_void) + -> *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 + c_int; + pub fn JS_ResolveStandardClass(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + resolved: *mut c_int) -> c_int; + pub fn JS_EnumerateStandardClasses(cx: *mut Struct_JSContext, + obj: HandleObject) -> c_int; + pub fn JS_GetClassObject(cx: *mut Struct_JSContext, key: Enum_JSProtoKey, + objp: c_void) -> c_int; + pub fn JS_GetClassPrototype(cx: *mut Struct_JSContext, + key: Enum_JSProtoKey, objp: c_void) -> c_int; + 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 c_void; + 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) -> c_int; + 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: *c_schar) -> *mut c_schar; + pub fn JS_AddExtraGCRootsTracer(rt: *mut Struct_JSRuntime, + traceOp: JSTraceDataOp, data: *mut c_void) + -> c_int; + 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) -> c_int; + pub fn JS_IsAboutToBeFinalized(objp: *mut c_void) -> c_int; + pub fn JS_IsAboutToBeFinalizedUnbarriered(objp: *mut *mut c_void) -> + c_int; + 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: *jschar, + length: size_t, + fin: *Struct_JSStringFinalizer) -> + *mut c_void; + pub fn JS_IsExternalString(str: *mut c_void) -> c_int; + pub fn JS_GetExternalStringFinalizer(str: *mut c_void) -> + *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) -> c_int; + pub fn JS_StringToId(cx: *mut Struct_JSContext, s: HandleString, + idp: MutableHandleId) -> c_int; + pub fn JS_IdToValue(cx: *mut Struct_JSContext, id: Struct_jsid, + vp: c_void) -> c_int; + pub fn JS_DefaultValue(cx: *mut Struct_JSContext, obj: c_void, + hint: Enum_JSType, vp: c_void) -> c_int; + pub fn JS_PropertyStub(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, vp: MutableHandleValue) -> c_int; + pub fn JS_StrictPropertyStub(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, strict: c_int, + vp: MutableHandleValue) -> c_int; + pub fn JS_DeletePropertyStub(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, succeeded: *mut c_int) -> + c_int; + pub fn JS_EnumerateStub(cx: *mut Struct_JSContext, obj: HandleObject) -> + c_int; + pub fn JS_ResolveStub(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId) -> c_int; + pub fn JS_ConvertStub(cx: *mut Struct_JSContext, obj: HandleObject, + _type: Enum_JSType, vp: MutableHandleValue) -> + c_int; + pub fn JS_InitClass(cx: *mut Struct_JSContext, obj: HandleObject, + parent_proto: HandleObject, clasp: *Struct_JSClass, + constructor: JSNative, nargs: c_uint, + ps: *Struct_JSPropertySpec, + fs: *Struct_JSFunctionSpec, + static_ps: *Struct_JSPropertySpec, + static_fs: *Struct_JSFunctionSpec) -> *mut c_void; + pub fn JS_LinkConstructorAndPrototype(cx: *mut Struct_JSContext, + ctor: JSHandleObject, proto: JSHandleObject) -> //jdm c_void->JSHandleObject + c_int; + pub fn JS_GetClass(obj: *mut c_void) -> *Struct_JSClass; + pub fn JS_InstanceOf(cx: *mut Struct_JSContext, obj: c_void, + clasp: *Struct_JSClass, args: *mut c_void) -> c_int; + pub fn JS_HasInstance(cx: *mut Struct_JSContext, obj: c_void, v: c_void, + bp: *mut c_int) -> c_int; + 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: *Struct_JSClass, args: *mut c_void) -> + *mut c_void; + pub fn JS_GetPrototype(cx: *mut Struct_JSContext, obj: HandleObject, + protop: MutableHandleObject) -> c_int; + pub fn JS_SetPrototype(cx: *mut Struct_JSContext, obj: HandleObject, + proto: HandleObject) -> c_int; + pub fn JS_GetParent(obj: *mut c_void) -> *mut c_void; + pub fn JS_SetParent(cx: *mut Struct_JSContext, obj: HandleObject, + parent: HandleObject) -> c_int; + pub fn JS_GetConstructor(cx: *mut Struct_JSContext, proto: c_void) -> + *mut c_void; + pub fn JS_NewGlobalObject(cx: *mut Struct_JSContext, + clasp: *Struct_JSClass, + principals: *mut Struct_JSPrincipals, + hookOption: Enum_OnNewGlobalHookOption, + options: c_void) -> *mut c_void; + pub fn JS_GlobalObjectTraceHook(trc: *mut JSTracer, global: *mut c_void); //jdm c_void->JSTracer + pub fn JS_FireOnNewGlobalObject(cx: *mut Struct_JSContext, + global: HandleObject); + pub fn JS_NewObject(cx: *mut Struct_JSContext, clasp: *Struct_JSClass, + proto: HandleObject, parent: HandleObject) -> *mut c_void; //jdm c_void->HandleObject + pub fn JS_IsExtensible(cx: *mut Struct_JSContext, obj: HandleObject, + extensible: *mut c_int) -> c_int; + pub fn JS_IsNative(obj: *mut c_void) -> c_int; + pub fn JS_GetObjectRuntime(obj: *mut c_void) -> *mut Struct_JSRuntime; + pub fn JS_NewObjectWithGivenProto(cx: *mut Struct_JSContext, + clasp: *Struct_JSClass, proto: HandleObject, //jdm c_void->HandleObject + parent: HandleObject) -> *mut c_void; //jdm c_void->HandleObject + pub fn JS_DeepFreezeObject(cx: *mut Struct_JSContext, obj: c_void) -> + c_int; + pub fn JS_FreezeObject(cx: *mut Struct_JSContext, obj: c_void) -> c_int; + pub fn JS_PreventExtensions(cx: *mut Struct_JSContext, obj: HandleObject) + -> c_int; + 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: *c_schar, clasp: *Struct_JSClass, + proto: *mut c_void, attrs: c_uint) -> *mut c_void; + pub fn JS_DefineConstDoubles(cx: *mut Struct_JSContext, obj: HandleObject, + cds: *Struct_JSConstDoubleSpec) -> c_int; + pub fn JS_DefineProperties(cx: *mut Struct_JSContext, obj: HandleObject, + ps: *Struct_JSPropertySpec) -> c_int; + pub fn JS_DefineProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar, value: HandleValue, + attrs: c_uint, getter: JSPropertyOp, + setter: JSStrictPropertyOp) -> c_int; + pub fn JS_DefinePropertyById(cx: *mut Struct_JSContext, obj: *mut c_void, + id: Struct_jsid, value: jsval, + getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: c_uint) -> + c_int; + pub fn JS_DefineOwnProperty(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, descriptor: HandleValue, + bp: *mut c_int) -> c_int; + pub fn JS_AlreadyHasOwnProperty(cx: *mut Struct_JSContext, + obj: HandleObject, name: *c_schar, + foundp: *mut c_int) -> c_int; + pub fn JS_AlreadyHasOwnPropertyById(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + foundp: *mut c_int) -> c_int; + pub fn JS_HasProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar, foundp: *mut c_int) -> c_int; + pub fn JS_HasPropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, foundp: *mut c_int) -> c_int; + pub fn JS_LookupProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar, vp: MutableHandleValue) -> c_int; + pub fn JS_LookupPropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, vp: MutableHandleValue) -> + c_int; + pub fn JS_LookupPropertyWithFlags(cx: *mut Struct_JSContext, + obj: HandleObject, name: *c_schar, + flags: c_uint, vp: MutableHandleValue) + -> c_int; + pub fn JS_LookupPropertyWithFlagsById(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + flags: c_uint, + objp: MutableHandleObject, + vp: MutableHandleValue) -> c_int; + pub fn JS_GetOwnPropertyDescriptorById(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + flags: c_uint, desc: c_void) -> + c_int; + pub fn JS_GetOwnPropertyDescriptor(cx: *mut Struct_JSContext, + obj: HandleObject, name: *c_schar, + flags: c_uint, desc: c_void) -> c_int; + pub fn JS_GetPropertyDescriptorById(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + flags: c_uint, desc: JSMutableHandle) -> c_int; //jdm c_void->JSMutableHandle + pub fn JS_GetPropertyDescriptor(cx: *mut Struct_JSContext, + obj: HandleObject, name: *c_schar, + flags: c_uint, desc: c_void) -> c_int; + pub fn JS_GetProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar, vp: MutableHandleValue) -> c_int; + pub fn JS_GetPropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, vp: MutableHandleValue) -> c_int; + pub fn JS_ForwardGetPropertyTo(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + onBehalfOf: HandleObject, + vp: MutableHandleValue) -> c_int; + pub fn JS_SetProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar, v: HandleValue) -> c_int; + pub fn JS_SetPropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: HandleId, v: HandleValue) -> c_int; + pub fn JS_DeleteProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar) -> c_int; + pub fn JS_DeleteProperty2(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar, succeeded: *mut c_int) -> c_int; + pub fn JS_DeletePropertyById(cx: *mut Struct_JSContext, obj: HandleObject, + id: Struct_jsid) -> c_int; + pub fn JS_DeletePropertyById2(cx: *mut Struct_JSContext, + obj: HandleObject, id: HandleId, + succeeded: *mut c_int) -> c_int; + pub fn JS_DefineUCProperty(cx: *mut Struct_JSContext, obj: *mut c_void, + name: *jschar, namelen: size_t, value: jsval, + getter: JSPropertyOp, + setter: JSStrictPropertyOp, attrs: c_uint) -> + c_int; + pub fn JS_AlreadyHasOwnUCProperty(cx: *mut Struct_JSContext, + obj: HandleObject, name: *jschar, + namelen: size_t, foundp: *mut c_int) -> + c_int; + pub fn JS_HasUCProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *jschar, namelen: size_t, vp: *mut c_int) -> + c_int; + pub fn JS_LookupUCProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *jschar, namelen: size_t, + vp: MutableHandleValue) -> c_int; + pub fn JS_GetUCProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *jschar, namelen: size_t, + vp: MutableHandleValue) -> c_int; + pub fn JS_SetUCProperty(cx: *mut Struct_JSContext, obj: HandleObject, + name: *jschar, namelen: size_t, v: HandleValue) -> + c_int; + pub fn JS_DeleteUCProperty2(cx: *mut Struct_JSContext, obj: HandleObject, + name: *jschar, namelen: size_t, + succeeded: *mut c_int) -> c_int; + pub fn JS_NewArrayObject(cx: *mut Struct_JSContext, length: size_t) -> + *mut c_void; + pub fn JS_IsArrayObject(cx: *mut Struct_JSContext, obj: HandleObject) -> + c_int; + pub fn JS_GetArrayLength(cx: *mut Struct_JSContext, obj: c_void, + lengthp: *mut uint32_t) -> c_int; + pub fn JS_SetArrayLength(cx: *mut Struct_JSContext, obj: c_void, + length: uint32_t) -> c_int; + pub fn JS_DefineElement(cx: *mut Struct_JSContext, obj: *mut c_void, + index: uint32_t, value: jsval, + getter: JSPropertyOp, setter: JSStrictPropertyOp, + attrs: c_uint) -> c_int; + pub fn JS_AlreadyHasOwnElement(cx: *mut Struct_JSContext, + obj: HandleObject, index: uint32_t, + foundp: *mut c_int) -> c_int; + pub fn JS_HasElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, foundp: *mut c_int) -> c_int; + pub fn JS_LookupElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, vp: MutableHandleValue) -> c_int; + pub fn JS_GetElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, vp: MutableHandleValue) -> c_int; + pub fn JS_ForwardGetElementTo(cx: *mut Struct_JSContext, + obj: HandleObject, index: uint32_t, + onBehalfOf: HandleObject, + vp: MutableHandleValue) -> c_int; + pub fn JS_SetElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, v: HandleObject) -> c_int; + pub fn JS_DeleteElement(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t) -> c_int; + pub fn JS_DeleteElement2(cx: *mut Struct_JSContext, obj: HandleObject, + index: uint32_t, succeeded: *mut c_int) -> c_int; + 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) -> c_int; + pub fn JS_GetReservedSlot(obj: *mut c_void, index: uint32_t) -> jsval; + pub fn JS_SetReservedSlot(obj: *mut c_void, 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: *c_schar) -> *mut c_void; + 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 c_void) -> *mut c_void; + 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) -> + c_int; + pub fn JS_ObjectIsCallable(cx: *mut Struct_JSContext, obj: *mut c_void) -> + c_int; + pub fn JS_IsNativeFunction(funobj: *mut c_void, call: JSNative) -> c_int; + pub fn JS_IsConstructor(fun: *mut c_void) -> c_int; + 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: *Struct_JSFunctionSpec) -> c_int; + pub fn JS_DefineFunction(cx: *mut Struct_JSContext, obj: c_void, + name: *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: *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: c_void, + parent: c_void) -> *mut c_void; + pub fn JS_BufferIsCompilableUnit(cx: *mut Struct_JSContext, obj: c_void, + utf8: *c_schar, length: size_t) -> c_int; + pub fn JS_CompileScript(cx: *mut Struct_JSContext, obj: HandleObject, + ascii: *c_schar, length: size_t, options: c_void) + -> *mut c_void; + pub fn JS_CompileUCScript(cx: *mut Struct_JSContext, obj: HandleObject, + chars: *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: *c_schar, nargs: c_uint, + argnames: **c_schar, bytes: *c_schar, + length: size_t, options: c_void) -> *mut c_void; + pub fn JS_CompileUCFunction(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar, nargs: c_uint, + argnames: **c_schar, chars: *jschar, + length: size_t, options: c_void) -> + *mut c_void; + pub fn JS_DecompileScript(cx: *mut Struct_JSContext, script: c_void, + name: *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) -> + c_int; + pub fn JS_ExecuteScriptVersion(cx: *mut Struct_JSContext, + obj: HandleObject, script: HandleScript, + rval: MutableHandleValue, + version: Enum_JSVersion) -> c_int; + pub fn JS_EvaluateScript(cx: *mut Struct_JSContext, obj: HandleObject, + bytes: *c_schar, length: c_uint, + filename: *c_schar, lineno: c_uint, + rval: MutableHandleValue) -> c_int; + pub fn JS_EvaluateUCScript(cx: *mut Struct_JSContext, obj: HandleObject, //jdm c_void->HandleObject + chars: *jschar, length: c_uint, + filename: *c_schar, lineno: c_uint, + rval: JSMutableHandleValue) -> c_int; //jdm c_void->JSMutableHandleValue + pub fn JS_CallFunction(cx: *mut Struct_JSContext, obj: HandleObject, + fun: HandleFunction, args: c_void, + rval: MutableHandleValue) -> c_int; + pub fn JS_CallFunctionName(cx: *mut Struct_JSContext, obj: HandleObject, + name: *c_schar, args: c_void, + rval: MutableHandleValue) -> c_int; + pub fn JS_CallFunctionValue(cx: *mut Struct_JSContext, obj: HandleObject, + fval: HandleValue, args: c_void, + rval: MutableHandleValue) -> c_int; + 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) -> c_int; + pub fn JS_SaveFrameChain(cx: *mut Struct_JSContext) -> c_int; + pub fn JS_RestoreFrameChain(cx: *mut Struct_JSContext); + pub fn JS_NewStringCopyN(cx: *mut Struct_JSContext, s: *c_schar, + n: size_t) -> *mut c_void; + pub fn JS_NewStringCopyZ(cx: *mut Struct_JSContext, s: *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: *c_schar, + length: size_t) -> *mut c_void; + pub fn JS_InternString(cx: *mut Struct_JSContext, s: *c_schar) -> + *mut c_void; + pub fn JS_NewUCString(cx: *mut Struct_JSContext, chars: *mut jschar, + length: size_t) -> *mut c_void; + pub fn JS_NewUCStringCopyN(cx: *mut Struct_JSContext, s: *jschar, + n: size_t) -> *mut c_void; + pub fn JS_NewUCStringCopyZ(cx: *mut Struct_JSContext, s: *jschar) -> + *mut c_void; + pub fn JS_InternUCStringN(cx: *mut Struct_JSContext, s: *jschar, + length: size_t) -> *mut c_void; + pub fn JS_InternUCString(cx: *mut Struct_JSContext, s: *jschar) -> + *mut c_void; + pub fn JS_CompareStrings(cx: *mut Struct_JSContext, str1: *mut c_void, + str2: *mut c_void, result: *mut int32_t) -> + c_int; + pub fn JS_StringEqualsAscii(cx: *mut Struct_JSContext, str: *mut c_void, + asciiBytes: *c_schar, _match: *mut c_int) -> + c_int; + 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) -> c_int; + pub fn JS_GetStringLength(str: *mut c_void) -> size_t; + pub fn JS_GetStringCharsAndLength(cx: *mut Struct_JSContext, + str: *mut c_void, length: *mut size_t) + -> *jschar; + pub fn JS_GetInternedStringChars(str: *mut c_void) -> *jschar; + pub fn JS_GetInternedStringCharsAndLength(str: *mut c_void, + length: *mut size_t) -> *jschar; + pub fn JS_GetStringCharsZ(cx: *mut Struct_JSContext, str: *mut c_void) -> + *jschar; + pub fn JS_GetStringCharsZAndLength(cx: *mut Struct_JSContext, + str: *mut c_void, length: *mut size_t) + -> *jschar; + pub fn JS_FlattenString(cx: *mut Struct_JSContext, str: *mut c_void) -> + *mut c_void; + pub fn JS_GetFlatStringChars(str: *mut c_void) -> *jschar; + pub fn JS_FlatStringEqualsAscii(str: *mut c_void, asciiBytes: *c_schar) -> + c_int; + 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: *c_schar, + srclen: size_t, dst: *mut jschar, + dstlenp: *mut size_t) -> c_int; + 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) -> + c_int; + pub fn JS_ParseJSON(cx: *mut Struct_JSContext, chars: *jschar, + len: uint32_t, vp: MutableHandleValue) -> c_int; + pub fn JS_ParseJSONWithReviver(cx: *mut Struct_JSContext, chars: *jschar, + len: uint32_t, reviver: HandleValue, + vp: MutableHandleValue) -> c_int; + pub fn JS_SetDefaultLocale(rt: *mut Struct_JSRuntime, locale: *c_schar) -> + c_int; + 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: *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 *jschar); + pub fn JS_ReportWarning(cx: *mut Struct_JSContext, format: *c_schar, ...) + -> c_int; + pub fn JS_ReportErrorFlagsAndNumber(cx: *mut Struct_JSContext, + flags: c_uint, + errorCallback: JSErrorCallback, + userRef: *mut c_void, + errorNumber: c_uint, ...) -> c_int; + pub fn JS_ReportErrorFlagsAndNumberUC(cx: *mut Struct_JSContext, + flags: c_uint, + errorCallback: JSErrorCallback, + userRef: *mut c_void, + errorNumber: c_uint, ...) -> c_int; + 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) -> + c_int; + 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: c_int); + 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: c_int, + rval: MutableHandleValue) -> c_int; + 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: c_int, rval: MutableHandleValue) -> + c_int; + pub fn JS_ObjectIsRegExp(cx: *mut Struct_JSContext, obj: HandleObject) -> + c_int; + 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) -> c_int; + pub fn JS_GetPendingException(cx: *mut Struct_JSContext, + vp: MutableHandleValue) -> c_int; + 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) -> c_int; + 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) -> c_int; + pub fn JS_IsStopIteration(v: jsval) -> c_int; + 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: *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: c_int); + pub fn JS_SetParallelIonCompilationEnabled(rt: *mut Struct_JSRuntime, + enabled: c_int); + pub fn JS_SetGlobalJitCompilerOption(rt: *mut Struct_JSRuntime, + opt: JSJitCompilerOption, + value: uint32_t); + pub fn JS_GetGlobalJitCompilerOption(rt: *mut Struct_JSRuntime, + opt: JSJitCompilerOption) -> c_int; + pub fn JS_IndexToId(cx: *mut Struct_JSContext, index: uint32_t, + arg1: MutableHandleId) -> c_int; + pub fn JS_CharsToId(cx: *mut Struct_JSContext, chars: c_void, + arg1: MutableHandleId) -> c_int; + pub fn JS_IsIdentifier(cx: *mut Struct_JSContext, str: HandleString, + isIdentifier: *mut c_int) -> c_int; + 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: *c_void, + length: uint32_t, + originPrincipals: *mut Struct_JSPrincipals) -> + *mut c_void; + pub fn JS_DecodeInterpretedFunction(cx: *mut Struct_JSContext, + data: *c_void, length: uint32_t, + originPrincipals: + *mut Struct_JSPrincipals) -> + *mut c_void; } -pub type union_unnamed2 = c_void /* FIXME: union type */; - -#[nolink] -extern { - -pub fn JS_Assert(s: *c_char, file: *c_char, ln: c_int); - -//fn JS_Abort(); - -//fn JS_CreateHandleObject(cx: *JSContext, obj: *JSObject, phandle: *JSHandleObject) -> JSBool; - -//fn JS_DestroyHandleObject(cx: *JSContext, handle: JSHandleObject); - -//fn JS_CreateMutableHandleObject(cx: *JSContext, obj: *JSObject, phandle: *JSMutableHandleObject) -> JSBool; - -//fn JS_DestroyMutableHandleObject(cx: *JSContext, handle: JSMutableHandleObject); - -//fn JS_CreateHandleId(cx: *JSContext, id: jsid, phandle: *JSHandleId) -> JSBool; - -//fn JS_DestroyHandleId(cx: *JSContext, handle: JSHandleId); - -pub fn JS_StringHasBeenInterned(cx: *JSContext, str: *JSString) -> JSBool; - -pub fn INTERNED_STRING_TO_JSID(cx: *JSContext, str: *JSString) -> jsid; - -pub fn JS_CallOnce(once_: *JSCallOnceType, func: JSInitCallback) -> JSBool; - -pub fn JS_Now() -> int64_t; - -pub fn JS_GetNaNValue(cx: *JSContext) -> JSVal; - -pub fn JS_GetNegativeInfinityValue(cx: *JSContext) -> JSVal; +/* end automatically generated code */ -pub fn JS_GetPositiveInfinityValue(cx: *JSContext) -> JSVal; - -pub fn JS_GetEmptyStringValue(cx: *JSContext) -> JSVal; - -pub fn JS_GetEmptyString(rt: *JSRuntime) -> *JSString; - -pub fn JS_ConvertArguments(cx: *JSContext, argc: c_uint, argv: *JSVal, format: *c_char/* FIXME: variadic function */) -> JSBool; - -pub fn JS_ConvertValue(cx: *JSContext, v: JSVal, _type: JSType, vp: *JSVal) -> JSBool; - -pub fn JS_ValueToObject(cx: *JSContext, v: JSVal, objp: **JSObject) -> JSBool; - -pub fn JS_ValueToFunction(cx: *JSContext, v: JSVal) -> *JSFunction; - -pub fn JS_ValueToConstructor(cx: *JSContext, v: JSVal) -> *JSFunction; - -pub fn JS_ValueToString(cx: *JSContext, v: JSVal) -> *JSString; - -pub fn JS_ValueToSource(cx: *JSContext, v: JSVal) -> *JSString; - -pub fn JS_ValueToNumber(cx: *JSContext, v: JSVal, dp: *c_double) -> JSBool; - -pub fn JS_DoubleIsInt32(d: c_double, ip: *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: *JSContext, v: JSVal, ip: *int32_t) -> JSBool; - -pub fn JS_ValueToInt64(cx: *JSContext, v: JSVal, ip: *int64_t) -> JSBool; - -pub fn JS_ValueToUint64(cx: *JSContext, v: JSVal, ip: *uint64_t) -> JSBool; - -pub fn JS_ValueToECMAUint32(cx: *JSContext, v: JSVal, ip: *uint32_t) -> JSBool; - -pub fn JS_ValueToInt32(cx: *JSContext, v: JSVal, ip: *int32_t) -> JSBool; - -pub fn JS_ValueToUint16(cx: *JSContext, v: JSVal, ip: *uint16_t) -> JSBool; - -pub fn JS_ValueToBoolean(cx: *JSContext, v: JSVal, bp: *JSBool) -> JSBool; - -pub fn JS_TypeOfValue(cx: *JSContext, v: JSVal) -> JSType; - -pub fn JS_GetTypeName(cx: *JSContext, _type: JSType) -> *c_char; - -pub fn JS_StrictlyEqual(cx: *JSContext, v1: JSVal, v2: JSVal, equal: *JSBool) -> JSBool; - -pub fn JS_LooselyEqual(cx: *JSContext, v1: JSVal, v2: JSVal, equal: *JSBool) -> JSBool; - -pub fn JS_SameValue(cx: *JSContext, v1: JSVal, v2: JSVal, same: *JSBool) -> JSBool; - -pub fn JS_IsBuiltinEvalFunction(fun: *JSFunction) -> JSBool; - -pub fn JS_IsBuiltinFunctionConstructor(fun: *JSFunction) -> JSBool; - -pub fn JS_Init(maxbytes: uint32_t) -> *JSRuntime; - -pub fn JS_Finish(rt: *JSRuntime); - -pub fn JS_ShutDown(); - -pub fn JS_GetRuntimePrivate(rt: *JSRuntime) -> *c_void; - -pub fn JS_GetRuntime(cx: *JSContext) -> *JSRuntime; - -pub fn JS_SetRuntimePrivate(rt: *JSRuntime, data: *c_void); - -pub fn JS_BeginRequest(cx: *JSContext); - -pub fn JS_EndRequest(cx: *JSContext); - -pub fn JS_YieldRequest(cx: *JSContext); - -pub fn JS_SuspendRequest(cx: *JSContext) -> c_uint; - -pub fn JS_ResumeRequest(cx: *JSContext, saveDepth: c_uint); - -pub fn JS_IsInRequest(rt: *JSRuntime) -> JSBool; - -pub fn JS_IsInSuspendedRequest(rt: *JSRuntime) -> JSBool; - -pub fn JS_SetContextCallback(rt: *JSRuntime, cxCallback: JSContextCallback) -> JSContextCallback; - -pub fn JS_NewContext(rt: *JSRuntime, stackChunkSize: size_t) -> *JSContext; - -pub fn JS_DestroyContext(cx: *JSContext); - -pub fn JS_DestroyContextNoGC(cx: *JSContext); - -pub fn JS_GetContextPrivate(cx: *JSContext) -> *c_void; - -pub fn JS_SetContextPrivate(cx: *JSContext, data: *c_void); - -pub fn JS_GetSecondContextPrivate(cx: *JSContext) -> *c_void; - -pub fn JS_SetSecondContextPrivate(cx: *JSContext, data: *c_void); - -pub fn JS_ContextIterator(rt: *JSRuntime, iterp: **JSContext) -> *JSContext; - -pub fn JS_GetVersion(cx: *JSContext) -> JSVersion; - -pub fn JS_SetVersion(cx: *JSContext, version: JSVersion) -> JSVersion; - -pub fn JS_VersionToString(version: JSVersion) -> *c_char; - -pub fn JS_StringToVersion(string: *c_char) -> JSVersion; - -pub fn JS_GetOptions(cx: *JSContext) -> uint32_t; - -pub fn JS_SetOptions(cx: *JSContext, options: uint32_t) -> uint32_t; - -pub fn JS_ToggleOptions(cx: *JSContext, options: uint32_t) -> uint32_t; - -pub fn JS_SetJitHardening(rt: *JSRuntime, enabled: JSBool); - -pub fn JS_GetImplementationVersion() -> *c_char; - -pub fn JS_SetDestroyCompartmentCallback(rt: *JSRuntime, callback: JSDestroyCompartmentCallback); - -pub fn JS_SetCompartmentNameCallback(rt: *JSRuntime, callback: JSCompartmentNameCallback); - -pub fn JS_SetWrapObjectCallbacks(rt: *JSRuntime, callback: JSWrapObjectCallback, sccallback: JSSameCompartmentWrapObjectCallback, precallback: JSPreWrapCallback) -> JSWrapObjectCallback; - -pub fn JS_EnterCrossCompartmentCall(cx: *JSContext, target: JSRawObject) -> *JSCrossCompartmentCall; - -pub fn JS_LeaveCrossCompartmentCall(call: *JSCrossCompartmentCall); - -pub fn JS_SetCompartmentPrivate(compartment: *JSCompartment, data: *c_void); - -pub fn JS_GetCompartmentPrivate(compartment: *JSCompartment) -> *c_void; - -pub fn JS_WrapObject(cx: *JSContext, objp: **JSObject) -> JSBool; - -pub fn JS_WrapValue(cx: *JSContext, vp: *JSVal) -> JSBool; - -pub fn JS_TransplantObject(cx: *JSContext, origobj: *JSObject, target: *JSObject) -> *JSObject; - -pub fn js_TransplantObjectWithWrapper(cx: *JSContext, origobj: *JSObject, origwrapper: *JSObject, targetobj: *JSObject, targetwrapper: *JSObject) -> *JSObject; - -pub fn JS_RefreshCrossCompartmentWrappers(cx: *JSContext, ob: *JSObject) -> JSBool; - -pub fn JS_IterateCompartments(rt: *JSRuntime, data: *c_void, compartmentCallback: JSIterateCompartmentCallback); - -pub fn JS_GetGlobalObject(cx: *JSContext) -> *JSObject; - -pub fn JS_SetGlobalObject(cx: *JSContext, obj: JSRawObject); - -pub fn JS_InitStandardClasses(cx: *JSContext, obj: *JSObject) -> JSBool; - -pub fn JS_ResolveStandardClass(cx: *JSContext, obj: *JSObject, id: jsid, resolved: *JSBool) -> JSBool; - -pub fn JS_EnumerateStandardClasses(cx: *JSContext, obj: *JSObject) -> JSBool; - -pub fn JS_EnumerateResolvedStandardClasses(cx: *JSContext, obj: *JSObject, ida: *JSIdArray) -> *JSIdArray; - -pub fn JS_GetClassObject(cx: *JSContext, obj: JSRawObject, key: JSProtoKey, objp: **JSObject) -> JSBool; - -pub fn JS_GetClassPrototype(cx: *JSContext, key: JSProtoKey, objp: **JSObject) -> JSBool; - -pub fn JS_IdentifyClassPrototype(cx: *JSContext, obj: *JSObject) -> JSProtoKey; - -pub fn JS_GetFunctionPrototype(cx: *JSContext, forObj: JSRawObject) -> *JSObject; - -pub fn JS_GetObjectPrototype(cx: *JSContext, forObj: JSRawObject) -> *JSObject; - -pub fn JS_GetGlobalForObject(cx: *JSContext, obj: JSRawObject) -> *JSObject; - -pub fn JS_GetGlobalForCompartmentOrNull(cx: *JSContext, c: *JSCompartment) -> *JSObject; - -pub fn JS_GetGlobalForScopeChain(cx: *JSContext) -> *JSObject; - -pub fn JS_GetScriptedGlobal(cx: *JSContext) -> *JSObject; - -pub fn JS_InitReflect(cx: *JSContext, global: *JSObject) -> *JSObject; - -pub fn JS_EnumerateDiagnosticMemoryRegions(callback: JSEnumerateDiagnosticMemoryCallback); - -// FIXME: Couldn't run on rust_stack until rust issue #6470 fixed. -//#[rust_stack] -pub fn JS_ComputeThis(cx: *JSContext, vp: *JSVal) -> JSVal; - -pub fn JS_MallocInCompartment(comp: *JSCompartment, nbytes: size_t); - -pub fn JS_FreeInCompartment(comp: *JSCompartment, nbytes: size_t); - -pub fn JS_malloc(cx: *JSContext, nbytes: size_t) -> *c_void; - -pub fn JS_realloc(cx: *JSContext, p: *c_void, nbytes: size_t) -> *c_void; - -pub fn JS_free(cx: *JSContext, p: *c_void); - -pub fn JS_freeop(fop: *JSFreeOp, p: *c_void); - -pub fn JS_GetDefaultFreeOp(rt: *JSRuntime) -> *JSFreeOp; - -pub fn JS_updateMallocCounter(cx: *JSContext, nbytes: size_t); - -pub fn JS_strdup(cx: *JSContext, s: *c_char) -> *c_char; - -pub fn JS_AddValueRoot(cx: *JSContext, vp: *JSVal) -> JSBool; - -pub fn JS_AddStringRoot(cx: *JSContext, rp: **JSString) -> JSBool; - -pub fn JS_AddObjectRoot(cx: *JSContext, rp: **JSObject) -> JSBool; - -pub fn JS_AddGCThingRoot(cx: *JSContext, rp: **c_void) -> JSBool; - -pub fn JS_AddNamedValueRoot(cx: *JSContext, vp: *JSVal, name: *c_char) -> JSBool; - -pub fn JS_AddNamedStringRoot(cx: *JSContext, rp: **JSString, name: *c_char) -> JSBool; - -pub fn JS_AddNamedObjectRoot(cx: *JSContext, rp: **JSObject, name: *c_char) -> JSBool; - -pub fn JS_AddNamedScriptRoot(cx: *JSContext, rp: **JSScript, name: *c_char) -> JSBool; - -pub fn JS_AddNamedGCThingRoot(cx: *JSContext, rp: **c_void, name: *c_char) -> JSBool; - -pub fn JS_RemoveValueRoot(cx: *JSContext, vp: *JSVal); - -pub fn JS_RemoveStringRoot(cx: *JSContext, rp: **JSString); - -pub fn JS_RemoveObjectRoot(cx: *JSContext, rp: **JSObject); - -pub fn JS_RemoveScriptRoot(cx: *JSContext, rp: **JSScript); - -pub fn JS_RemoveGCThingRoot(cx: *JSContext, rp: **c_void); - -pub fn JS_RemoveValueRootRT(rt: *JSRuntime, vp: *JSVal); - -pub fn JS_RemoveStringRootRT(rt: *JSRuntime, rp: **JSString); - -pub fn JS_RemoveObjectRootRT(rt: *JSRuntime, rp: **JSObject); - -pub fn js_AddRootRT(rt: *JSRuntime, vp: *JSVal, name: *c_char) -> JSBool; - -pub fn js_AddGCThingRootRT(rt: *JSRuntime, rp: **c_void, name: *c_char) -> JSBool; - -pub fn js_RemoveRoot(rt: *JSRuntime, rp: *c_void); - -pub fn JS_AnchorPtr(p: *c_void); - -pub fn JS_MapGCRoots(rt: *JSRuntime, map: JSGCRootMapFun, data: *c_void) -> uint32_t; - -pub fn JS_LockGCThing(cx: *JSContext, thing: *c_void) -> JSBool; - -pub fn JS_LockGCThingRT(rt: *JSRuntime, thing: *c_void) -> JSBool; - -pub fn JS_UnlockGCThing(cx: *JSContext, thing: *c_void) -> JSBool; - -pub fn JS_UnlockGCThingRT(rt: *JSRuntime, thing: *c_void) -> JSBool; - -pub fn JS_SetExtraGCRootsTracer(rt: *JSRuntime, traceOp: JSTraceDataOp, data: *c_void); - -pub fn JS_CallTracer(trc: *JSTracer, thing: *c_void, kind: JSGCTraceKind); - -pub fn JS_TracerInit(trc: *JSTracer, rt: *JSRuntime, callback: JSTraceCallback); - -pub fn JS_TraceChildren(trc: *JSTracer, thing: *c_void, kind: JSGCTraceKind); - -pub fn JS_TraceRuntime(trc: *JSTracer); - -pub fn JS_GetTraceThingInfo(buf: *c_char, bufsize: size_t, trc: *JSTracer, thing: *c_void, kind: JSGCTraceKind, includeDetails: JSBool); - -pub fn JS_GetTraceEdgeName(trc: *JSTracer, buffer: *c_char, bufferSize: c_int) -> *c_char; - -pub fn JS_GC(rt: *JSRuntime); - -pub fn JS_MaybeGC(cx: *JSContext); - -pub fn JS_SetGCZeal(cx: *JSContext, zeal: u8, frequency: u32); - -pub fn JS_InhibitGC(cx: *JSContext); - -pub fn JS_AllowGC(cx: *JSContext); - -pub fn JS_SetGCCallback(rt: *JSRuntime, cb: JSGCCallback); - -pub fn JS_SetFinalizeCallback(rt: *JSRuntime, cb: JSFinalizeCallback); - -pub fn JS_IsGCMarkingTracer(trc: *JSTracer) -> JSBool; - -pub fn JS_IsAboutToBeFinalized(thing: *c_void) -> JSBool; - -pub fn JS_SetGCParameter(rt: *JSRuntime, key: JSGCParamKey, value: uint32_t); - -pub fn JS_GetGCParameter(rt: *JSRuntime, key: JSGCParamKey) -> uint32_t; - -pub fn JS_SetGCParameterForThread(cx: *JSContext, key: JSGCParamKey, value: uint32_t); - -pub fn JS_GetGCParameterForThread(cx: *JSContext, key: JSGCParamKey) -> uint32_t; - -pub fn JS_NewExternalString(cx: *JSContext, chars: *jschar, length: size_t, fin: *JSStringFinalizer) -> *JSString; - -pub fn JS_IsExternalString(str: *JSString) -> JSBool; - -pub fn JS_GetExternalStringFinalizer(str: *JSString) -> *JSStringFinalizer; - -pub fn JS_SetNativeStackQuota(cx: *JSRuntime, stackSize: size_t); - -pub fn JS_IdArrayLength(cx: *JSContext, ida: *JSIdArray) -> c_int; - -pub fn JS_IdArrayGet(cx: *JSContext, ida: *JSIdArray, index: c_int) -> jsid; - -pub fn JS_DestroyIdArray(cx: *JSContext, ida: *JSIdArray); - -pub fn JS_ValueToId(cx: *JSContext, v: JSVal, idp: *jsid) -> JSBool; - -pub fn JS_IdToValue(cx: *JSContext, id: jsid, vp: *JSVal) -> JSBool; - -pub fn JS_DefaultValue(cx: *JSContext, obj: *JSObject, hint: JSType, vp: *JSVal) -> JSBool; - -pub fn JS_PropertyStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId, vp: JSMutableHandleValue) -> JSBool; - -pub fn JS_StrictPropertyStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId, strict: JSBool, vp: JSMutableHandleValue) -> JSBool; - -pub fn JS_EnumerateStub(cx: *JSContext, obj: JSHandleObject) -> JSBool; - -pub fn JS_ResolveStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId) -> JSBool; - -pub fn JS_ConvertStub(cx: *JSContext, obj: JSHandleObject, _type: JSType, vp: JSMutableHandleValue) -> JSBool; - -pub fn JS_InitClass(cx: *JSContext, obj: *JSObject, parent_proto: *JSObject, clasp: *JSClass, constructor: JSNative, nargs: c_uint, ps: *JSPropertySpec, fs: *JSFunctionSpec, static_ps: *JSPropertySpec, static_fs: *JSFunctionSpec) -> *JSObject; - -pub fn JS_LinkConstructorAndPrototype(cx: *JSContext, ctor: *JSObject, proto: *JSObject) -> JSBool; - -pub fn JS_GetClass(obj: JSRawObject) -> *JSClass; - -pub fn JS_InstanceOf(cx: *JSContext, obj: *JSObject, clasp: *JSClass, argv: *JSVal) -> JSBool; - -pub fn JS_HasInstance(cx: *JSContext, obj: *JSObject, v: JSVal, bp: *JSBool) -> JSBool; - -pub fn JS_GetPrivate(obj: JSRawObject) -> *c_void; - -pub fn JS_SetPrivate(obj: JSRawObject, data: *c_void); - -pub fn JS_GetInstancePrivate(cx: *JSContext, obj: *JSObject, clasp: *JSClass, argv: *JSVal) -> *c_void; - -pub fn JS_GetPrototype(obj: JSRawObject) -> *JSObject; - -pub fn JS_SetPrototype(cx: *JSContext, obj: *JSObject, proto: *JSObject) -> JSBool; - -pub fn JS_GetParent(obj: JSRawObject) -> *JSObject; - -pub fn JS_SetParent(cx: *JSContext, obj: *JSObject, parent: *JSObject) -> JSBool; - -pub fn JS_GetConstructor(cx: *JSContext, proto: *JSObject) -> *JSObject; - -pub fn JS_GetObjectId(cx: *JSContext, obj: JSRawObject, idp: *jsid) -> JSBool; - -pub fn JS_NewGlobalObject(cx: *JSContext, clasp: *JSClass, principals: *JSPrincipals) -> *JSObject; - -pub fn JS_NewObject(cx: *JSContext, clasp: *JSClass, proto: *JSObject, parent: *JSObject) -> *JSObject; - -pub fn JS_IsExtensible(obj: JSRawObject) -> JSBool; - -pub fn JS_IsNative(obj: JSRawObject) -> JSBool; - -pub fn JS_GetObjectRuntime(obj: JSRawObject) -> *JSRuntime; - -pub fn JS_NewObjectWithGivenProto(cx: *JSContext, clasp: *JSClass, proto: *JSObject, parent: *JSObject) -> *JSObject; - -pub fn JS_DeepFreezeObject(cx: *JSContext, obj: *JSObject) -> JSBool; - -pub fn JS_FreezeObject(cx: *JSContext, obj: *JSObject) -> JSBool; - -pub fn JS_New(cx: *JSContext, ctor: *JSObject, argc: c_uint, argv: *JSVal) -> *JSObject; - -pub fn JS_DefineObject(cx: *JSContext, obj: *JSObject, name: *c_char, clasp: *JSClass, proto: *JSObject, attrs: c_uint) -> *JSObject; - -pub fn JS_DefineConstDoubles(cx: *JSContext, obj: *JSObject, cds: *JSConstDoubleSpec) -> JSBool; - -pub fn JS_DefineProperties(cx: *JSContext, obj: *JSObject, ps: *JSPropertySpec) -> JSBool; - -pub fn JS_DefineProperty(cx: *JSContext, obj: *JSObject, name: *c_char, value: JSVal, getter: Option, setter: Option, attrs: c_uint) -> JSBool; - -pub fn JS_DefinePropertyById(cx: *JSContext, obj: *JSObject, id: jsid, value: JSVal, getter: Option, setter: Option, attrs: c_uint) -> JSBool; - -pub fn JS_DefineOwnProperty(cx: *JSContext, obj: *JSObject, id: jsid, descriptor: JSVal, bp: *JSBool) -> JSBool; - -pub fn JS_GetPropertyAttributes(cx: *JSContext, obj: *JSObject, name: *c_char, attrsp: *c_uint, foundp: *JSBool) -> JSBool; - -pub fn JS_GetPropertyAttrsGetterAndSetter(cx: *JSContext, obj: *JSObject, name: *c_char, attrsp: *c_uint, foundp: *JSBool, getterp: *JSPropertyOp, setterp: *JSStrictPropertyOp) -> JSBool; - -pub fn JS_GetPropertyAttrsGetterAndSetterById(cx: *JSContext, obj: *JSObject, id: jsid, attrsp: *c_uint, foundp: *JSBool, getterp: *JSPropertyOp, setterp: *JSStrictPropertyOp) -> JSBool; - -pub fn JS_SetPropertyAttributes(cx: *JSContext, obj: *JSObject, name: *c_char, attrs: c_uint, foundp: *JSBool) -> JSBool; - -pub fn JS_DefinePropertyWithTinyId(cx: *JSContext, obj: *JSObject, name: *c_char, tinyid: int8_t, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_AlreadyHasOwnProperty(cx: *JSContext, obj: *JSObject, name: *c_char, foundp: *JSBool) -> JSBool; - -pub fn JS_AlreadyHasOwnPropertyById(cx: *JSContext, obj: *JSObject, id: jsid, foundp: *JSBool) -> JSBool; - -pub fn JS_HasProperty(cx: *JSContext, obj: *JSObject, name: *c_char, foundp: *JSBool) -> JSBool; - -pub fn JS_HasPropertyById(cx: *JSContext, obj: *JSObject, id: jsid, foundp: *JSBool) -> JSBool; - -pub fn JS_LookupProperty(cx: *JSContext, obj: *JSObject, name: *c_char, vp: *JSVal) -> JSBool; - -pub fn JS_LookupPropertyById(cx: *JSContext, obj: *JSObject, id: jsid, vp: *JSVal) -> JSBool; - -pub fn JS_LookupPropertyWithFlags(cx: *JSContext, obj: *JSObject, name: *c_char, flags: c_uint, vp: *JSVal) -> JSBool; - -pub fn JS_LookupPropertyWithFlagsById(cx: *JSContext, obj: *JSObject, id: jsid, flags: c_uint, objp: **JSObject, vp: *JSVal) -> JSBool; - -pub fn JS_GetPropertyDescriptorById(cx: *JSContext, obj: *JSObject, id: jsid, flags: c_uint, desc: *JSPropertyDescriptor) -> JSBool; - -pub fn JS_GetOwnPropertyDescriptor(cx: *JSContext, obj: *JSObject, id: jsid, vp: *JSVal) -> JSBool; - -pub fn JS_GetProperty(cx: *JSContext, obj: *JSObject, name: *c_char, vp: *JSVal) -> JSBool; - -pub fn JS_GetPropertyDefault(cx: *JSContext, obj: *JSObject, name: *c_char, def: JSVal, vp: *JSVal) -> JSBool; - -pub fn JS_GetPropertyById(cx: *JSContext, obj: *JSObject, id: jsid, vp: *JSVal) -> JSBool; - -pub fn JS_GetPropertyByIdDefault(cx: *JSContext, obj: *JSObject, id: jsid, def: JSVal, vp: *JSVal) -> JSBool; - -pub fn JS_ForwardGetPropertyTo(cx: *JSContext, obj: *JSObject, id: jsid, onBehalfOf: *JSObject, vp: *JSVal) -> JSBool; - -pub fn JS_GetMethodById(cx: *JSContext, obj: *JSObject, id: jsid, objp: **JSObject, vp: *JSVal) -> JSBool; - -pub fn JS_GetMethod(cx: *JSContext, obj: *JSObject, name: *c_char, objp: **JSObject, vp: *JSVal) -> JSBool; - -pub fn JS_SetProperty(cx: *JSContext, obj: *JSObject, name: *c_char, vp: *JSVal) -> JSBool; - -pub fn JS_SetPropertyById(cx: *JSContext, obj: *JSObject, id: jsid, vp: *JSVal) -> JSBool; - -pub fn JS_DeleteProperty(cx: *JSContext, obj: *JSObject, name: *c_char) -> JSBool; - -pub fn JS_DeleteProperty2(cx: *JSContext, obj: *JSObject, name: *c_char, rval: *JSVal) -> JSBool; - -pub fn JS_DeletePropertyById(cx: *JSContext, obj: *JSObject, id: jsid) -> JSBool; - -pub fn JS_DeletePropertyById2(cx: *JSContext, obj: *JSObject, id: jsid, rval: *JSVal) -> JSBool; - -pub fn JS_DefineUCProperty(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_GetUCPropertyAttributes(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, attrsp: *c_uint, foundp: *JSBool) -> JSBool; - -pub fn JS_GetUCPropertyAttrsGetterAndSetter(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, attrsp: *c_uint, foundp: *JSBool, getterp: *JSPropertyOp, setterp: *JSStrictPropertyOp) -> JSBool; - -pub fn JS_SetUCPropertyAttributes(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, attrs: c_uint, foundp: *JSBool) -> JSBool; - -pub fn JS_DefineUCPropertyWithTinyId(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, tinyid: int8_t, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_AlreadyHasOwnUCProperty(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, foundp: *JSBool) -> JSBool; - -pub fn JS_HasUCProperty(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, vp: *JSBool) -> JSBool; - -pub fn JS_LookupUCProperty(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, vp: *JSVal) -> JSBool; - -pub fn JS_GetUCProperty(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, vp: *JSVal) -> JSBool; - -pub fn JS_SetUCProperty(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, vp: *JSVal) -> JSBool; - -pub fn JS_DeleteUCProperty2(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, rval: *JSVal) -> JSBool; - -pub fn JS_NewArrayObject(cx: *JSContext, length: c_int, vector: *JSVal) -> *JSObject; - -pub fn JS_IsArrayObject(cx: *JSContext, obj: *JSObject) -> JSBool; - -pub fn JS_GetArrayLength(cx: *JSContext, obj: *JSObject, lengthp: *uint32_t) -> JSBool; - -pub fn JS_SetArrayLength(cx: *JSContext, obj: *JSObject, length: uint32_t) -> JSBool; - -pub fn JS_DefineElement(cx: *JSContext, obj: *JSObject, index: uint32_t, value: JSVal, getter: JSPropertyOp, setter: JSStrictPropertyOp, attrs: c_uint) -> JSBool; - -pub fn JS_AlreadyHasOwnElement(cx: *JSContext, obj: *JSObject, index: uint32_t, foundp: *JSBool) -> JSBool; - -pub fn JS_HasElement(cx: *JSContext, obj: *JSObject, index: uint32_t, foundp: *JSBool) -> JSBool; - -pub fn JS_LookupElement(cx: *JSContext, obj: *JSObject, index: uint32_t, vp: *JSVal) -> JSBool; - -pub fn JS_GetElement(cx: *JSContext, obj: *JSObject, index: uint32_t, vp: *JSVal) -> JSBool; - -pub fn JS_ForwardGetElementTo(cx: *JSContext, obj: *JSObject, index: uint32_t, onBehalfOf: *JSObject, vp: *JSVal) -> JSBool; - -pub fn JS_GetElementIfPresent(cx: *JSContext, obj: *JSObject, index: uint32_t, onBehalfOf: *JSObject, vp: *JSVal, present: *JSBool) -> JSBool; - -pub fn JS_SetElement(cx: *JSContext, obj: *JSObject, index: uint32_t, vp: *JSVal) -> JSBool; - -pub fn JS_DeleteElement(cx: *JSContext, obj: *JSObject, index: uint32_t) -> JSBool; - -pub fn JS_DeleteElement2(cx: *JSContext, obj: *JSObject, index: uint32_t, rval: *JSVal) -> JSBool; - -pub fn JS_ClearScope(cx: *JSContext, obj: *JSObject); - -pub fn JS_Enumerate(cx: *JSContext, obj: *JSObject) -> *JSIdArray; - -pub fn JS_NewPropertyIterator(cx: *JSContext, obj: *JSObject) -> *JSObject; - -pub fn JS_NextProperty(cx: *JSContext, iterobj: *JSObject, idp: *jsid) -> JSBool; - -pub fn JS_ArrayIterator(cx: *JSContext, argc: c_uint, vp: *mut JSVal) -> JSBool; - -pub fn JS_CheckAccess(cx: *JSContext, obj: *JSObject, id: jsid, mode: JSAccessMode, vp: *JSVal, attrsp: *c_uint) -> JSBool; - -// FIXME: couldn't run on rust_stack until rust issue #6470 fixed. -//#[rust_stack] -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: *JSPrincipals); - -pub fn JS_DropPrincipals(rt: *JSRuntime, principals: *JSPrincipals); - -pub fn JS_SetSecurityCallbacks(rt: *JSRuntime, callbacks: *JSSecurityCallbacks); - -pub fn JS_GetSecurityCallbacks(rt: *JSRuntime) -> *JSSecurityCallbacks; - -pub fn JS_SetTrustedPrincipals(rt: *JSRuntime, prin: *JSPrincipals); - -pub fn JS_InitDestroyPrincipalsCallback(rt: *JSRuntime, destroyPrincipals: JSDestroyPrincipalsOp); - -pub fn JS_NewFunction(cx: *JSContext, call: Option, nargs: c_uint, flags: c_uint, parent: *JSObject, name: *c_char) -> *JSFunction; - -pub fn JS_NewFunctionById(cx: *JSContext, call: JSNative, nargs: c_uint, flags: c_uint, parent: *JSObject, id: jsid) -> *JSFunction; - -pub fn JS_GetFunctionObject(fun: *JSFunction) -> *JSObject; - -pub fn JS_GetFunctionId(fun: *JSFunction) -> *JSString; - -pub fn JS_GetFunctionDisplayId(fun: *JSFunction) -> *JSString; - -pub fn JS_GetFunctionFlags(fun: *JSFunction) -> c_uint; - -pub fn JS_GetFunctionArity(fun: *JSFunction) -> uint16_t; - -pub fn JS_ObjectIsFunction(cx: *JSContext, obj: JSRawObject) -> JSBool; - -pub fn JS_ObjectIsCallable(cx: *JSContext, obj: JSRawObject) -> JSBool; - -pub fn JS_IsNativeFunction(funobj: JSRawObject, call: JSNative) -> JSBool; - -pub fn JS_BindCallable(cx: *JSContext, callable: *JSObject, newThis: JSRawObject) -> *JSObject; - -pub fn JS_DefineFunctions(cx: *JSContext, obj: *JSObject, fs: *JSFunctionSpec) -> JSBool; - -pub fn JS_DefineFunction(cx: *JSContext, obj: *JSObject, name: *c_char, call: JSNative, nargs: c_uint, attrs: c_uint) -> *JSFunction; - -pub fn JS_DefineUCFunction(cx: *JSContext, obj: *JSObject, name: *jschar, namelen: size_t, call: JSNative, nargs: c_uint, attrs: c_uint) -> *JSFunction; - -pub fn JS_DefineFunctionById(cx: *JSContext, obj: *JSObject, id: jsid, call: JSNative, nargs: c_uint, attrs: c_uint) -> *JSFunction; - -pub fn JS_CloneFunctionObject(cx: *JSContext, funobj: *JSObject, parent: JSRawObject) -> *JSObject; - -pub fn JS_BufferIsCompilableUnit(cx: *JSContext, bytes_are_utf8: JSBool, obj: *JSObject, bytes: *c_char, length: size_t) -> JSBool; - -pub fn JS_CompileScript(cx: *JSContext, obj: *JSObject, bytes: *c_char, length: size_t, filename: *c_char, lineno: c_uint) -> *JSScript; - -pub fn JS_CompileScriptForPrincipals(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, bytes: *c_char, length: size_t, filename: *c_char, lineno: c_uint) -> *JSScript; - -pub fn JS_CompileScriptForPrincipalsVersion(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, bytes: *c_char, length: size_t, filename: *c_char, lineno: c_uint, version: JSVersion) -> *JSScript; - -pub fn JS_CompileUCScript(cx: *JSContext, obj: *JSObject, chars: *jschar, length: size_t, filename: *c_char, lineno: c_uint) -> *JSScript; - -pub fn JS_CompileUCScriptForPrincipals(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, chars: *jschar, length: size_t, filename: *c_char, lineno: c_uint) -> *JSScript; - -pub fn JS_CompileUCScriptForPrincipalsVersion(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, chars: *jschar, length: size_t, filename: *c_char, lineno: c_uint, version: JSVersion) -> *JSScript; - -pub fn JS_CompileUCScriptForPrincipalsVersionOrigin(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, originPrincipals: *JSPrincipals, chars: *jschar, length: size_t, filename: *c_char, lineno: c_uint, version: JSVersion) -> *JSScript; - -pub fn JS_CompileUTF8File(cx: *JSContext, obj: *JSObject, filename: *c_char) -> *JSScript; - -pub fn JS_CompileUTF8FileHandle(cx: *JSContext, obj: *JSObject, filename: *c_char, fh: *FILE) -> *JSScript; - -pub fn JS_CompileUTF8FileHandleForPrincipals(cx: *JSContext, obj: *JSObject, filename: *c_char, fh: *FILE, principals: *JSPrincipals) -> *JSScript; - -pub fn JS_CompileUTF8FileHandleForPrincipalsVersion(cx: *JSContext, obj: *JSObject, filename: *c_char, fh: *FILE, principals: *JSPrincipals, version: JSVersion) -> *JSScript; - -pub fn JS_GetGlobalFromScript(script: *JSScript) -> *JSObject; - -pub fn JS_CompileFunction(cx: *JSContext, obj: *JSObject, name: *c_char, nargs: c_uint, argnames: **c_char, bytes: *c_char, length: size_t, filename: *c_char, lineno: c_uint) -> *JSFunction; - -pub fn JS_CompileFunctionForPrincipals(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, name: *c_char, nargs: c_uint, argnames: **c_char, bytes: *c_char, length: size_t, filename: *c_char, lineno: c_uint) -> *JSFunction; - -pub fn JS_CompileUCFunction(cx: *JSContext, obj: *JSObject, name: *c_char, nargs: c_uint, argnames: **c_char, chars: *jschar, length: size_t, filename: *c_char, lineno: c_uint) -> *JSFunction; - -pub fn JS_CompileUCFunctionForPrincipals(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, name: *c_char, nargs: c_uint, argnames: **c_char, chars: *jschar, length: size_t, filename: *c_char, lineno: c_uint) -> *JSFunction; - -pub fn JS_CompileUCFunctionForPrincipalsVersion(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, name: *c_char, nargs: c_uint, argnames: **c_char, chars: *jschar, length: size_t, filename: *c_char, lineno: c_uint, version: JSVersion) -> *JSFunction; - -pub fn JS_DecompileScript(cx: *JSContext, script: *JSScript, name: *c_char, indent: c_uint) -> *JSString; - -pub fn JS_DecompileFunction(cx: *JSContext, fun: *JSFunction, indent: c_uint) -> *JSString; - -pub fn JS_DecompileFunctionBody(cx: *JSContext, fun: *JSFunction, indent: c_uint) -> *JSString; - -pub fn JS_ExecuteScript(cx: *JSContext, obj: *JSObject, script: *JSScript, rval: *JSVal) -> JSBool; - -pub fn JS_ExecuteScriptVersion(cx: *JSContext, obj: *JSObject, script: *JSScript, rval: *JSVal, version: JSVersion) -> JSBool; - -pub fn JS_EvaluateScript(cx: *JSContext, obj: *JSObject, bytes: *c_char, length: c_uint, filename: *c_char, lineno: c_uint, rval: *JSVal) -> JSBool; - -pub fn JS_EvaluateScriptForPrincipals(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, bytes: *c_char, length: c_uint, filename: *c_char, lineno: c_uint, rval: *JSVal) -> JSBool; - -pub fn JS_EvaluateScriptForPrincipalsVersion(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, bytes: *c_char, length: c_uint, filename: *c_char, lineno: c_uint, rval: *JSVal, version: JSVersion) -> JSBool; - -pub fn JS_EvaluateUCScript(cx: *JSContext, obj: *JSObject, chars: *jschar, length: c_uint, filename: *c_char, lineno: c_uint, rval: *JSVal) -> JSBool; - -pub fn JS_EvaluateUCScriptForPrincipals(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, chars: *jschar, length: c_uint, filename: *c_char, lineno: c_uint, rval: *JSVal) -> JSBool; - -pub fn JS_EvaluateUCScriptForPrincipalsVersion(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, chars: *jschar, length: c_uint, filename: *c_char, lineno: c_uint, rval: *JSVal, version: JSVersion) -> JSBool; - -pub fn JS_EvaluateUCScriptForPrincipalsVersionOrigin(cx: *JSContext, obj: *JSObject, principals: *JSPrincipals, originPrincipals: *JSPrincipals, chars: *jschar, length: c_uint, filename: *c_char, lineno: c_uint, rval: *JSVal, version: JSVersion) -> JSBool; - -pub fn JS_CallFunction(cx: *JSContext, obj: *JSObject, fun: *JSFunction, argc: c_uint, argv: *JSVal, rval: *JSVal) -> JSBool; - -pub fn JS_CallFunctionName(cx: *JSContext, obj: *JSObject, name: *c_char, argc: c_uint, argv: *JSVal, rval: *JSVal) -> JSBool; - -pub fn JS_CallFunctionValue(cx: *JSContext, obj: *JSObject, fval: JSVal, argc: c_uint, argv: *JSVal, rval: *JSVal) -> JSBool; - -pub fn JS_SetOperationCallback(cx: *JSContext, callback: JSOperationCallback) -> JSOperationCallback; - -pub fn JS_GetOperationCallback(cx: *JSContext) -> JSOperationCallback; - -pub fn JS_TriggerOperationCallback(rt: *JSRuntime); - -pub fn JS_IsRunning(cx: *JSContext) -> JSBool; - -pub fn JS_SaveFrameChain(cx: *JSContext) -> JSBool; - -pub fn JS_RestoreFrameChain(cx: *JSContext); - -pub fn JS_NewStringCopyN(cx: *JSContext, s: *c_char, n: size_t) -> *JSString; - -pub fn JS_NewStringCopyZ(cx: *JSContext, s: *c_char) -> *JSString; - -pub fn JS_InternJSString(cx: *JSContext, str: *JSString) -> *JSString; - -pub fn JS_InternStringN(cx: *JSContext, s: *c_char, length: size_t) -> *JSString; - -pub fn JS_InternString(cx: *JSContext, s: *c_char) -> *JSString; - -pub fn JS_NewUCString(cx: *JSContext, chars: *jschar, length: size_t) -> *JSString; - -pub fn JS_NewUCStringCopyN(cx: *JSContext, s: *jschar, n: size_t) -> *JSString; - -pub fn JS_NewUCStringCopyZ(cx: *JSContext, s: *jschar) -> *JSString; - -pub fn JS_InternUCStringN(cx: *JSContext, s: *jschar, length: size_t) -> *JSString; - -pub fn JS_InternUCString(cx: *JSContext, s: *jschar) -> *JSString; - -pub fn JS_CompareStrings(cx: *JSContext, str1: *JSString, str2: *JSString, result: *int32_t) -> JSBool; - -pub fn JS_StringEqualsAscii(cx: *JSContext, str: *JSString, asciiBytes: *c_char, _match: *JSBool) -> JSBool; - -pub fn JS_PutEscapedString(cx: *JSContext, buffer: *c_char, size: size_t, str: *JSString, quote: c_char) -> size_t; - -pub fn JS_FileEscapedString(fp: *FILE, str: *JSString, quote: c_char) -> JSBool; - -pub fn JS_GetStringLength(str: *JSString) -> size_t; - -pub fn JS_GetStringCharsAndLength(cx: *JSContext, str: *JSString, length: *size_t) -> *jschar; - -pub fn JS_GetInternedStringChars(str: *JSString) -> *jschar; - -pub fn JS_GetInternedStringCharsAndLength(str: *JSString, length: *size_t) -> *jschar; - -pub fn JS_GetStringCharsZ(cx: *JSContext, str: *JSString) -> *jschar; - -pub fn JS_GetStringCharsZAndLength(cx: *JSContext, str: *JSString, length: *size_t) -> *jschar; - -pub fn JS_FlattenString(cx: *JSContext, str: *JSString) -> *JSFlatString; - -pub fn JS_GetFlatStringChars(str: *JSFlatString) -> *jschar; - -pub fn JS_FlatStringEqualsAscii(str: *JSFlatString, asciiBytes: *c_char) -> JSBool; - -pub fn JS_PutEscapedFlatString(buffer: *c_char, size: size_t, str: *JSFlatString, quote: c_char) -> size_t; - -pub fn JS_NewGrowableString(cx: *JSContext, chars: *jschar, length: size_t) -> *JSString; - -pub fn JS_NewDependentString(cx: *JSContext, str: *JSString, start: size_t, length: size_t) -> *JSString; - -pub fn JS_ConcatStrings(cx: *JSContext, left: *JSString, right: *JSString) -> *JSString; - -pub fn JS_UndependString(cx: *JSContext, str: *JSString) -> *jschar; - -pub fn JS_MakeStringImmutable(cx: *JSContext, str: *JSString) -> JSBool; - -pub fn JS_CStringsAreUTF8() -> JSBool; - -pub fn JS_SetCStringsAreUTF8(); - -pub fn JS_EncodeCharacters(cx: *JSContext, src: *jschar, srclen: size_t, dst: *c_char, dstlenp: *size_t) -> JSBool; - -pub fn JS_DecodeBytes(cx: *JSContext, src: *c_char, srclen: size_t, dst: *jschar, dstlenp: *size_t) -> JSBool; - -pub fn JS_DecodeUTF8(cx: *JSContext, src: *c_char, srclen: size_t, dst: *jschar, dstlenp: *size_t) -> JSBool; - -pub fn JS_EncodeString(cx: *JSContext, str: *JSString) -> *c_char; - -pub fn JS_GetStringEncodingLength(cx: *JSContext, str: *JSString) -> size_t; - -pub fn JS_EncodeStringToBuffer(str: *JSString, buffer: *c_char, length: size_t) -> size_t; - -pub fn JS_Stringify(cx: *JSContext, vp: *JSVal, replacer: *JSObject, space: JSVal, callback: JSONWriteCallback, data: *c_void) -> JSBool; - -pub fn JS_ParseJSON(cx: *JSContext, chars: *jschar, len: uint32_t, vp: *JSVal) -> JSBool; - -pub fn JS_ParseJSONWithReviver(cx: *JSContext, chars: *jschar, len: uint32_t, reviver: JSVal, vp: *JSVal) -> JSBool; - -pub fn JS_ReadStructuredClone(cx: *JSContext, data: *uint64_t, nbytes: size_t, version: uint32_t, vp: *JSVal, optionalCallbacks: *JSStructuredCloneCallbacks, closure: *c_void) -> JSBool; - -pub fn JS_WriteStructuredClone(cx: *JSContext, v: JSVal, datap: **uint64_t, nbytesp: *size_t, optionalCallbacks: *JSStructuredCloneCallbacks, closure: *c_void) -> JSBool; - -pub fn JS_StructuredClone(cx: *JSContext, v: JSVal, vp: *JSVal, optionalCallbacks: *JSStructuredCloneCallbacks, closure: *c_void) -> JSBool; - -pub fn JS_SetStructuredCloneCallbacks(rt: *JSRuntime, callbacks: *JSStructuredCloneCallbacks); - -pub fn JS_ReadUint32Pair(r: *JSStructuredCloneReader, p1: *uint32_t, p2: *uint32_t) -> JSBool; - -pub fn JS_ReadBytes(r: *JSStructuredCloneReader, p: *c_void, len: size_t) -> JSBool; - -pub fn JS_ReadTypedArray(r: *JSStructuredCloneReader, vp: *JSVal) -> JSBool; - -pub fn JS_WriteUint32Pair(w: *JSStructuredCloneWriter, tag: uint32_t, data: uint32_t) -> JSBool; - -pub fn JS_WriteBytes(w: *JSStructuredCloneWriter, p: *c_void, len: size_t) -> JSBool; - -pub fn JS_WriteTypedArray(w: *JSStructuredCloneWriter, v: JSVal) -> JSBool; - -pub fn JS_SetLocaleCallbacks(cx: *JSContext, callbacks: *JSLocaleCallbacks); - -pub fn JS_GetLocaleCallbacks(cx: *JSContext) -> *JSLocaleCallbacks; - -pub fn JS_ReportError(cx: *JSContext, format: *c_char/* FIXME: variadic function */); - -pub fn JS_ReportErrorNumber(cx: *JSContext, errorCallback: JSErrorCallback, userRef: *c_void, errorNumber: c_uint, ...); - -pub fn JS_ReportErrorNumberUC(cx: *JSContext, errorCallback: JSErrorCallback, userRef: *c_void, errorNumber: c_uint/* FIXME: variadic function */); - -pub fn JS_ReportWarning(cx: *JSContext, format: *c_char/* FIXME: variadic function */) -> JSBool; - -pub fn JS_ReportErrorFlagsAndNumber(cx: *JSContext, flags: c_uint, errorCallback: JSErrorCallback, userRef: *c_void, errorNumber: c_uint/* FIXME: variadic function */) -> JSBool; - -pub fn JS_ReportErrorFlagsAndNumberUC(cx: *JSContext, flags: c_uint, errorCallback: JSErrorCallback, userRef: *c_void, errorNumber: c_uint/* FIXME: variadic function */) -> JSBool; - -pub fn JS_ReportOutOfMemory(cx: *JSContext); - -pub fn JS_ReportAllocationOverflow(cx: *JSContext); - -pub fn JS_GetErrorReporter(cx: *JSContext) -> JSErrorReporter; - -pub fn JS_SetErrorReporter(cx: *JSContext, er: JSErrorReporter) -> JSErrorReporter; - -pub fn JS_NewDateObject(cx: *JSContext, year: c_int, mon: c_int, mday: c_int, hour: c_int, min: c_int, sec: c_int) -> *JSObject; - -pub fn JS_NewDateObjectMsec(cx: *JSContext, msec: c_double) -> *JSObject; - -pub fn JS_ObjectIsDate(cx: *JSContext, obj: JSRawObject) -> JSBool; - -pub fn JS_ClearDateCaches(cx: *JSContext); - -pub fn JS_NewRegExpObject(cx: *JSContext, obj: *JSObject, bytes: *c_char, length: size_t, flags: c_uint) -> *JSObject; - -pub fn JS_NewUCRegExpObject(cx: *JSContext, obj: *JSObject, chars: *jschar, length: size_t, flags: c_uint) -> *JSObject; - -pub fn JS_SetRegExpInput(cx: *JSContext, obj: *JSObject, input: *JSString, multiline: JSBool); - -pub fn JS_ClearRegExpStatics(cx: *JSContext, obj: *JSObject); - -pub fn JS_ExecuteRegExp(cx: *JSContext, obj: *JSObject, reobj: *JSObject, chars: *jschar, length: size_t, indexp: *size_t, test: JSBool, rval: *JSVal) -> JSBool; - -pub fn JS_NewRegExpObjectNoStatics(cx: *JSContext, bytes: *c_char, length: size_t, flags: c_uint) -> *JSObject; - -pub fn JS_NewUCRegExpObjectNoStatics(cx: *JSContext, chars: *jschar, length: size_t, flags: c_uint) -> *JSObject; - -pub fn JS_ExecuteRegExpNoStatics(cx: *JSContext, reobj: *JSObject, chars: *jschar, length: size_t, indexp: *size_t, test: JSBool, rval: *JSVal) -> JSBool; - -pub fn JS_ObjectIsRegExp(cx: *JSContext, obj: *JSObject) -> JSBool; - -pub fn JS_GetRegExpFlags(cx: *JSContext, obj: *JSObject) -> c_uint; - -pub fn JS_GetRegExpSource(cx: *JSContext, obj: *JSObject) -> *JSString; - -pub fn JS_IsExceptionPending(cx: *JSContext) -> JSBool; - -pub fn JS_GetPendingException(cx: *JSContext, vp: *JSVal) -> JSBool; - -pub fn JS_SetPendingException(cx: *JSContext, v: JSVal); - -pub fn JS_ClearPendingException(cx: *JSContext); - -pub fn JS_ReportPendingException(cx: *JSContext) -> JSBool; - -pub fn JS_SaveExceptionState(cx: *JSContext) -> *JSExceptionState; - -pub fn JS_RestoreExceptionState(cx: *JSContext, state: *JSExceptionState); - -pub fn JS_DropExceptionState(cx: *JSContext, state: *JSExceptionState); - -pub fn JS_ErrorFromException(cx: *JSContext, v: JSVal) -> *JSErrorReport; - -pub fn JS_ThrowReportedError(cx: *JSContext, message: *c_char, reportp: *JSErrorReport) -> JSBool; - -pub fn JS_ThrowStopIteration(cx: *JSContext) -> JSBool; - -pub fn JS_GetCurrentThread(/* FIXME: variadic function */) -> intptr_t; - -pub fn JS_AbortIfWrongThread(rt: *JSRuntime); - -pub fn JS_ClearRuntimeThread(rt: *JSRuntime); - -pub fn JS_SetRuntimeThread(rt: *JSRuntime); - -pub fn JS_SetNativeStackBounds(rt: *JSRuntime, stackBase: uintptr_t, stackEnd: uintptr_t); - -pub fn JS_NewObjectForConstructor(cx: *JSContext, clasp: *JSClass, vp: *JSVal) -> *JSObject; - -pub fn JS_IndexToId(cx: *JSContext, index: uint32_t, id: *jsid) -> JSBool; - -pub fn JS_IsIdentifier(cx: *JSContext, str: *JSString, isIdentifier: *JSBool) -> JSBool; - -pub fn JS_DescribeScriptedCaller(cx: *JSContext, script: **JSScript, lineno: *c_uint) -> JSBool; - -pub fn JS_EncodeScript(cx: *JSContext, script: *JSScript, lengthp: *uint32_t) -> *c_void; - -pub fn JS_EncodeInterpretedFunction(cx: *JSContext, funobj: JSRawObject, lengthp: *uint32_t) -> *c_void; - -pub fn JS_DecodeScript(cx: *JSContext, data: *c_void, length: uint32_t, principals: *JSPrincipals, originPrincipals: *JSPrincipals) -> *JSScript; - -pub fn JS_DecodeInterpretedFunction(cx: *JSContext, data: *c_void, length: uint32_t, principals: *JSPrincipals, originPrincipals: *JSPrincipals) -> *JSObject; +pub struct JSTracer(c_void); +pub type JSRuntime = c_void; +pub type JSContext = c_void; +pub type JSObject = c_void; +//pub type jsid = ptrdiff_t; +pub type jsid = Struct_jsid; +pub type JSFunctionSpec = Struct_JSFunctionSpec; +pub type JSPropertyDescriptor = Struct_JSPropertyDescriptor; +pub type JSBool = c_int; +pub type JSFunction = c_void; +pub type JSFreeOp = Struct_JSFreeOp; +pub type JSString = c_void; +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 HandleObject = JSHandleObject; +pub type HandleId = JSHandleId; +pub type HandleString = JSHandleString; +pub type MutableHandleValue = JSMutableHandleValue; +pub type MutableHandleObject = JSMutableHandleObject; +pub type Struct_Zone = c_void; +pub type va_list = c_void; +pub type Enum_OnNewGlobalHookOption = uint; +pub type JSVersion = Enum_JSVersion; +pub type MutableHandleId = JSMutableHandleId; +pub type HandleValue = JSHandleValue; +pub type HandleScript = JSHandleScript; +pub type HandleFunction = JSHandleFunction; +pub type JSScript = c_void; +pub type jsval = Union_jsval_layout; +pub type JSPrincipals = Struct_JSPrincipals; +pub type Struct_JSJitInfo = JSJitInfo; +pub struct JSHandleObject { + pub unnamed_field1: **mut JSObject, +} +pub struct JSHandleValue { + pub unnamed_field1: *jsval, +} +pub struct JSHandleString { + pub unnamed_field1: **mut JSString, +} +pub struct JSMutableHandleObject { + pub unnamed_field1: *mut *mut JSObject, +} +impl JSMutableHandleObject { + pub fn immut(&self) -> JSHandleObject { + unsafe { ::std::cast::transmute(*self) } + } +} +pub struct JSHandleId { + pub unnamed_field1: *jsid, +} +pub struct JSMutableHandleId { + pub unnamed_field1: *mut jsid, +} +pub struct JSMutableHandleValue { + pub unnamed_field1: *mut jsval, +} +pub struct JSHandleScript { + pub unnamed_field1: *JSScript, +} +pub struct JSHandleFunction { + pub unnamed_field1: *JSFunction, } diff --git a/jsfriendapi.rs b/jsfriendapi.rs index 3b0f30caa..c181eaec4 100644 --- a/jsfriendapi.rs +++ b/jsfriendapi.rs @@ -4,24 +4,30 @@ pub type JSJitPropertyOp = *u8; +pub enum OpType { + Getter = 0, + Setter = 1, + Method = 2, +} + 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, } //pub type JSJitInfo = JSJitInfo_struct; -#[nolink] pub mod bindgen { - use jsapi::{JSContext, JSObject, JSClass, JSRuntime}; + use jsapi::{JSContext, JSObject, JSClass, JSRuntime, JSHandleObject}; use libc::uintptr_t; extern { - pub fn JS_NewObjectWithUniqueType(cx: *JSContext, clasp: *JSClass, - proto: *JSObject, parent: *JSObject) -> *JSObject; - pub fn JS_GetAddressableObject(rt: *JSRuntime, candidateObj: uintptr_t) -> *JSObject; + pub fn JS_NewObjectWithUniqueType(cx: *mut JSContext, clasp: *JSClass, + proto: JSHandleObject, parent: JSHandleObject) -> *mut JSObject; + pub fn JS_GetAddressableObject(rt: *mut JSRuntime, candidateObj: uintptr_t) -> *mut JSObject; } } diff --git a/jsglue.cpp b/jsglue.cpp index c55bfb4d6..334b864e9 100644 --- a/jsglue.cpp +++ b/jsglue.cpp @@ -2,271 +2,259 @@ * 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 "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); + 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*/; -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); } /* 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) : - DirectWrapper::has(cx, proxy, id, bp); + DirectProxyHandler::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) : - DirectWrapper::hasOwn(cx, proxy, id, bp); + DirectProxyHandler::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) : - DirectWrapper::get(cx, proxy, receiver, id, vp); + DirectProxyHandler::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) : - DirectWrapper::set(cx, proxy, receiver, id, strict, vp); + DirectProxyHandler::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) : - DirectWrapper::keys(cx, proxy, props); + DirectProxyHandler::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) : - DirectWrapper::iterate(cx, proxy, flags, vp); + DirectProxyHandler::iterate(cx, proxy, flags, vp); } /* Spidermonkey extensions. */ - virtual bool call(JSContext *cx, JSObject *proxy, unsigned argc, JS::Value *vp) + virtual bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible) + { + return mTraps.isExtensible ? + mTraps.isExtensible(cx, proxy, extensible) : + DirectProxyHandler::isExtensible(cx, proxy, extensible); + } + + virtual bool call(JSContext *cx, JS::HandleObject proxy, const JS::CallArgs &args) { return mTraps.call ? - mTraps.call(cx, proxy, argc, vp) : - DirectWrapper::call(cx, proxy, argc, vp); + mTraps.call(cx, proxy, args.length(), args[0]) : + DirectProxyHandler::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) : - DirectWrapper::construct(cx, proxy, argc, argv, rval); + mTraps.construct(cx, proxy, args.length(), args[0], args.rval()) : + DirectProxyHandler::construct(cx, proxy, args); } virtual bool nativeCall(JSContext *cx, JS::IsAcceptableThis test, JS::NativeImpl impl, JS::CallArgs args) { return mTraps.nativeCall ? mTraps.nativeCall(cx, test, impl, args) : - DirectWrapper::nativeCall(cx, test, impl, args); + DirectProxyHandler::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) : - DirectWrapper::hasInstance(cx, proxy, vp, bp); + mTraps.hasInstance(cx, proxy, v, bp) : + DirectProxyHandler::hasInstance(cx, proxy, v, bp); } - virtual JSType typeOf(JSContext *cx, JSObject *proxy) - { - return mTraps.typeOf ? - mTraps.typeOf(cx, proxy) : - DirectWrapper::typeOf(cx, proxy); - } - - 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) : - DirectWrapper::objectClassIs(obj, classValue, cx); + DirectProxyHandler::objectClassIs(obj, classValue, cx); } - virtual JSString *obj_toString(JSContext *cx, JSObject *proxy) - { - return mTraps.obj_toString ? - mTraps.obj_toString(cx, proxy) : - DirectWrapper::obj_toString(cx, proxy); - } - - virtual JSString *fun_toString(JSContext *cx, JSObject *proxy, unsigned indent) + virtual JSString *fun_toString(JSContext *cx, JS::HandleObject proxy, unsigned indent) { return mTraps.fun_toString ? mTraps.fun_toString(cx, proxy, indent) : - DirectWrapper::fun_toString(cx, proxy, indent); + DirectProxyHandler::fun_toString(cx, proxy, indent); } /*virtual bool regexp_toShared(JSContext *cx, JSObject *proxy, RegExpGuard *g) { return mTraps.regexp_toShared ? mTraps.regexp_toShared(cx, proxy, g) : - DirectWrapper::regexp_toShared(cx, proxy, g); + DirectProxyHandler::regexp_toShared(cx, proxy, g); }*/ - 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) : - DirectWrapper::defaultValue(cx, obj, hint, vp); - } - - virtual bool iteratorNext(JSContext *cx, JSObject *proxy, JS::Value *vp) - { - return mTraps.iteratorNext ? - mTraps.iteratorNext(cx, proxy, vp) : - DirectWrapper::iteratorNext(cx, proxy, vp); + DirectProxyHandler::defaultValue(cx, obj, hint, vp); } virtual void finalize(JSFreeOp *fop, JSObject *proxy) { - return mTraps.finalize ? - mTraps.finalize(fop, proxy) : - DirectWrapper::finalize(fop, proxy); + if (mTraps.finalize) { + mTraps.finalize(fop, proxy); + } else { + DirectProxyHandler::finalize(fop, proxy); + } } - virtual bool getElementIfPresent(JSContext *cx, JSObject *obj, JSObject *receiver, - uint32_t index, JS::Value *vp, bool *present) - { - return mTraps.getElementIfPresent ? - mTraps.getElementIfPresent(cx, obj, receiver, index, vp, present) : - DirectWrapper::getElementIfPresent(cx, obj, receiver, index, vp, present); - } - - 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) : - DirectWrapper::getPrototypeOf(cx, proxy, proto); + DirectProxyHandler::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) : - DirectWrapper::trace(trc, proxy); + DirectProxyHandler::trace(trc, proxy); } }; @@ -282,82 +270,89 @@ 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.preventExtensions(cx, proxy); + } + + virtual bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, + JS::MutableHandle desc, + unsigned flags) { - return mTraps.getPropertyDescriptor(cx, proxy, id, set, desc); + return mTraps.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(cx, proxy, id, set, desc); + return mTraps.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(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); } /* 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) : BaseProxyHandler::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) : BaseProxyHandler::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) : BaseProxyHandler::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) : BaseProxyHandler::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) : BaseProxyHandler::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) : @@ -365,18 +360,23 @@ class ForwardingProxyHandler : public js::BaseProxyHandler } /* Spidermonkey extensions. */ - virtual bool call(JSContext *cx, JSObject *proxy, unsigned argc, JS::Value *vp) + virtual bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible) + { + return mTraps.isExtensible(cx, proxy, extensible); + } + + virtual bool call(JSContext *cx, JS::HandleObject proxy, const JS::CallArgs &args) { return mTraps.call ? - mTraps.call(cx, proxy, argc, vp) : - BaseProxyHandler::call(cx, proxy, argc, vp); + mTraps.call(cx, proxy, args.length(), args[0]) : + BaseProxyHandler::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) : - BaseProxyHandler::construct(cx, proxy, argc, argv, rval); + mTraps.construct(cx, proxy, args.length(), args[0], args.rval()) : + BaseProxyHandler::construct(cx, proxy, args); } virtual bool nativeCall(JSContext *cx, JS::IsAcceptableThis test, JS::NativeImpl impl, JS::CallArgs args) @@ -386,85 +386,58 @@ class ForwardingProxyHandler : public js::BaseProxyHandler BaseProxyHandler::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, const JS::MutableHandleValue vp, bool *bp) { return mTraps.hasInstance ? mTraps.hasInstance(cx, proxy, vp, bp) : BaseProxyHandler::hasInstance(cx, proxy, vp, bp); } - virtual JSType typeOf(JSContext *cx, JSObject *proxy) - { - return mTraps.typeOf ? - mTraps.typeOf(cx, proxy) : - BaseProxyHandler::typeOf(cx, proxy); - } - - 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) : BaseProxyHandler::objectClassIs(obj, classValue, cx); } - virtual JSString *obj_toString(JSContext *cx, JSObject *proxy) - { - return mTraps.obj_toString ? - mTraps.obj_toString(cx, proxy) : - BaseProxyHandler::obj_toString(cx, proxy); - } - - virtual JSString *fun_toString(JSContext *cx, JSObject *proxy, unsigned indent) + virtual JSString *fun_toString(JSContext *cx, JS::HandleObject proxy, unsigned indent) { return mTraps.fun_toString ? mTraps.fun_toString(cx, proxy, indent) : BaseProxyHandler::fun_toString(cx, proxy, indent); } - /*virtual bool regexp_toShared(JSContext *cx, JSObject *proxy, RegExpGuard *g) + /*virtual bool regexp_toShared(JSContext *cx, JS::HandleObject proxy, RegExpGuard *g) { return mTraps.regexp_toShared ? mTraps.regexp_toShared(cx, proxy, g) : BaseProxyHandler::regexp_toShared(cx, proxy, g); }*/ - 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) : BaseProxyHandler::defaultValue(cx, obj, hint, vp); } - virtual bool iteratorNext(JSContext *cx, JSObject *proxy, JS::Value *vp) - { - return mTraps.iteratorNext ? - mTraps.iteratorNext(cx, proxy, vp) : - BaseProxyHandler::iteratorNext(cx, proxy, vp); - } - - virtual void finalize(JSFreeOp *fop, JSObject *proxy) + virtual void finalize(JSFreeOp *fop, JS::HandleObject proxy) { - return mTraps.finalize ? - mTraps.finalize(fop, proxy) : - BaseProxyHandler::finalize(fop, proxy); + if (mTraps.finalize) { + mTraps.finalize(fop, proxy); + } else { + BaseProxyHandler::finalize(fop, proxy); + } } - virtual bool getElementIfPresent(JSContext *cx, JSObject *obj, JSObject *receiver, - uint32_t index, JS::Value *vp, bool *present) - { - return mTraps.getElementIfPresent ? - mTraps.getElementIfPresent(cx, obj, receiver, index, vp, present) : - BaseProxyHandler::getElementIfPresent(cx, obj, receiver, index, vp, present); - } - - 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) : BaseProxyHandler::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) : @@ -474,16 +447,16 @@ class ForwardingProxyHandler : public js::BaseProxyHandler extern "C" { -JSBool +bool InvokeGetOwnPropertyDescriptor( void* handler, - JSContext *cx, JSObject *proxy, - jsid id, JSBool 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); + id, desc, + flags); } jsval @@ -498,22 +471,44 @@ RUST_FUNCTION_VALUE_TO_JITINFO(jsval v) return FUNCTION_VALUE_TO_JITINFO(v); } -JSBool -CallJitPropertyOp(JSJitInfo *info, JSContext* cx, JSObject* thisObj, void *specializedThis, jsval *vp) +typedef bool +(* JSJitGetterOp2)(JSContext *cx, JS::HandleObject thisObj, + void *specializedThis, JS::Value *vp); +typedef bool +(* JSJitSetterOp2)(JSContext *cx, JS::HandleObject thisObj, + void *specializedThis, JS::Value *vp); +typedef bool +(* JSJitMethodOp2)(JSContext *cx, JS::HandleObject thisObj, + void *specializedThis, unsigned argc, JS::Value *vp); + +bool +CallJitGetterOp(JSJitInfo *info, JSContext* cx, JSObject* thisObj, void *specializedThis, unsigned argc, JS::Value* vp) { struct { JSObject** obj; } tmp = { &thisObj }; - return ((JSJitPropertyOp)info->op)(cx, *reinterpret_cast(&tmp), specializedThis, vp); + //JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + return ((JSJitGetterOp2)info->getter)(cx, *reinterpret_cast(&tmp), specializedThis, vp); } -JSBool -CallJitMethodOp(JSJitInfo *info, JSContext* cx, JSObject* thisObj, void *specializedThis, uint32_t argc, jsval *vp) +bool +CallJitSetterOp(JSJitInfo *info, JSContext* cx, JSObject* thisObj, void *specializedThis, unsigned 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 ((JSJitSetterOp2)info->setter)(cx, *reinterpret_cast(&tmp), specializedThis, vp); +} + +bool +CallJitMethodOp(JSJitInfo *info, JSContext* cx, JSObject* thisObj, void *specializedThis, uint32_t argc, JS::Value* vp) +{ + struct { + JSObject** obj; + } tmp = { &thisObj }; + //JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + return ((JSJitMethodOp2)info->method)(cx, *reinterpret_cast(&tmp), specializedThis, argc, vp); } void @@ -541,19 +536,27 @@ 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, void* aHandler, js::Class* clasp, JS::HandleValue priv, + JSObject* proto, JSObject* parent) { - const js::Value &priv = aPriv ? *aPriv : JS::NullValue(); + clasp->trace = js::proxy_Trace; + js::ProxyOptions options; + options.setClass(clasp); return js::NewProxyObject(aCx, (js::BaseProxyHandler*)aHandler, priv, proto, - parent, call, construct); + 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; + 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 @@ -574,10 +577,10 @@ SetProxyExtra(JSObject* obj, uint32_t slot, jsval val) return js::SetProxyExtra(obj, slot, val); } -JSObject* -GetObjectProto(JSObject* obj) +bool +GetObjectProto(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject proto) { - return js::GetObjectProto(obj); + js::GetObjectProto(cx, obj, proto); } JSObject* @@ -586,7 +589,7 @@ GetObjectParent(JSObject* obj) return js::GetObjectParent(obj); } -JSBool +bool RUST_JSID_IS_INT(jsid id) { return JSID_IS_INT(id); @@ -598,7 +601,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); @@ -627,7 +630,7 @@ DefineFunctionWithReserved(JSContext* cx, JSObject* obj, char* name, JSNative ca return js::DefineFunctionWithReserved(cx, obj, name, call, nargs, attrs); } -JSClass* +const JSClass* GetObjectJSClass(JSObject* obj) { return js::GetObjectJSClass(obj); @@ -639,18 +642,6 @@ RUST_js_GetErrorMessage(void* userRef, 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) -{ - return js::IsFunctionProxyClass(js::GetObjectClass(obj)); -} - bool IsProxyHandlerFamily(JSObject* obj) { @@ -690,16 +681,287 @@ 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); +} + +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::UnwrapObject(obj, stopAtOuter, flags); + return js::proxy_Slice(cx, proxy, begin, end, result); } } // extern "C" diff --git a/jsval.rs b/jsval.rs index 478cfc54e..f1b6972a2 100644 --- a/jsval.rs +++ b/jsval.rs @@ -2,10 +2,10 @@ * 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::{JSObject, JSString}; +use jsapi::{JSObject, JSString, Struct_Unnamed1}; -use libc::c_void; use std::cast; +use libc::{c_void, uint64_t, c_double, size_t, uintptr_t}; static JSVAL_TAG_SHIFT: int = 47; @@ -54,17 +54,37 @@ enum ValueShiftedTag { 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(Eq,Clone)] -pub struct JSVal { - pub v: u64 +pub struct Union_jsval_layout { + pub data: u64, } +impl Union_jsval_layout { + pub fn asBits(&mut self) -> *mut uint64_t { + unsafe { ::std::cast::transmute(self) } + } + pub fn s(&mut self) -> *mut Struct_Unnamed1 { + unsafe { ::std::cast::transmute(self) } + } + pub fn asDouble(&mut self) -> *mut c_double { + unsafe { ::std::cast::transmute(self) } + } + pub fn asPtr(&mut self) -> *mut *mut c_void { + unsafe { ::std::cast::transmute(self) } + } + pub fn asWord(&mut self) -> *mut size_t { + unsafe { ::std::cast::transmute(self) } + } + pub fn asUIntPtr(&mut self) -> *mut uintptr_t { + unsafe { ::std::cast::transmute(self) } + } +} + +pub type JSVal = Union_jsval_layout; #[inline(always)] fn BuildJSVal(tag: ValueTag, payload: u64) -> JSVal { - JSVal { - v: ((tag as u32 as u64) << JSVAL_TAG_SHIFT) | payload + Union_jsval_layout { + data: ((tag as u32 as u64) << JSVAL_TAG_SHIFT) | payload } } @@ -88,8 +108,8 @@ pub fn Int32Value(i: i32) -> JSVal { pub fn DoubleValue(f: f64) -> JSVal { let bits: u64 = unsafe { cast::transmute(f) }; assert!(bits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE as u64) - JSVal { - v: bits + Union_jsval_layout { + data: bits } } @@ -122,7 +142,7 @@ pub fn ObjectValue(o: &JSObject) -> JSVal { } #[inline(always)] -pub fn ObjectOrNullValue(o: *JSObject) -> JSVal { +pub fn ObjectOrNullValue(o: *mut JSObject) -> JSVal { if o.is_null() { NullValue() } else { @@ -134,18 +154,18 @@ pub fn ObjectOrNullValue(o: *JSObject) -> JSVal { pub fn PrivateValue(o: *c_void) -> JSVal { let ptrBits = o as uint as u64; assert!((ptrBits & 1) == 0); - JSVal { - v: ptrBits >> 1 + Union_jsval_layout { + data: ptrBits >> 1 } } -impl JSVal { +impl Union_jsval_layout { pub fn is_undefined(&self) -> bool { - self.v == JSVAL_SHIFTED_TAG_UNDEFINED as u64 + self.data == JSVAL_SHIFTED_TAG_UNDEFINED as u64 } pub fn is_null(&self) -> bool { - self.v == JSVAL_SHIFTED_TAG_NULL as u64 + self.data == JSVAL_SHIFTED_TAG_NULL as u64 } pub fn is_null_or_undefined(&self) -> bool { @@ -153,57 +173,57 @@ impl JSVal { } pub fn is_double(&self) -> bool { - self.v <= JSVAL_SHIFTED_TAG_MAX_DOUBLE as u64 + self.data <= JSVAL_SHIFTED_TAG_MAX_DOUBLE as u64 } pub fn is_primitive(&self) -> bool { static JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET: u64 = JSVAL_SHIFTED_TAG_OBJECT as u64; - self.v < JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET + self.data < JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET } pub fn is_string(&self) -> bool { - (self.v >> JSVAL_TAG_SHIFT) == JSVAL_TAG_STRING as u64 + (self.data >> JSVAL_TAG_SHIFT) == JSVAL_TAG_STRING as u64 } pub fn is_object(&self) -> bool { - assert!((self.v >> JSVAL_TAG_SHIFT) <= JSVAL_TAG_OBJECT as u64); - self.v >= JSVAL_SHIFTED_TAG_OBJECT as u64 + assert!((self.data >> JSVAL_TAG_SHIFT) <= JSVAL_TAG_OBJECT as u64); + self.data >= JSVAL_SHIFTED_TAG_OBJECT as u64 } - pub fn to_object(&self) -> *JSObject { + pub fn to_object(&self) -> *mut JSObject { assert!(self.is_object()); self.to_object_or_null() } pub fn is_object_or_null(&self) -> bool { static JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET: u64 = JSVAL_SHIFTED_TAG_NULL as u64; - assert!((self.v >> JSVAL_TAG_SHIFT) <= JSVAL_TAG_OBJECT as u64); - self.v >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET + assert!((self.data >> JSVAL_TAG_SHIFT) <= JSVAL_TAG_OBJECT as u64); + self.data >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET } - pub fn to_object_or_null(&self) -> *JSObject { + pub fn to_object_or_null(&self) -> *mut JSObject { assert!(self.is_object_or_null()); - let ptrBits = self.v & JSVAL_PAYLOAD_MASK; + let ptrBits = self.data & JSVAL_PAYLOAD_MASK; assert!((ptrBits & 0x7) == 0); - ptrBits as uint as *JSObject + ptrBits as uint as *mut JSObject } pub fn to_private(&self) -> *c_void { assert!(self.is_double()); - assert!((self.v & 0x8000000000000000u64) == 0); - (self.v << 1) as uint as *c_void + assert!((self.data & 0x8000000000000000u64) == 0); + (self.data << 1) as uint as *c_void } pub fn is_gcthing(&self) -> bool { static JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET: u64 = JSVAL_SHIFTED_TAG_STRING as u64; - self.v >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET + self.data >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET } - pub fn to_gcthing(&self) -> *c_void { + pub fn to_gcthing(&self) -> *mut c_void { assert!(self.is_gcthing()); - let ptrBits = self.v & JSVAL_PAYLOAD_MASK; + let ptrBits = self.data & JSVAL_PAYLOAD_MASK; assert!((ptrBits & 0x7) == 0); - ptrBits as *c_void + ptrBits as *mut c_void } pub fn is_markable(&self) -> bool { diff --git a/linkhack.rs b/linkhack.rs index 17e7c3692..005f27eec 100644 --- a/linkhack.rs +++ b/linkhack.rs @@ -6,6 +6,7 @@ #[cfg(target_os = "linux")] #[link(name = "pthread")] +#[link(name = "jsglue")] #[link(name = "js_static")] #[link(name = "stdc++")] #[link(name = "z")] diff --git a/rust.rs b/rust.rs index 70332efb2..efddf9f41 100644 --- a/rust.rs +++ b/rust.rs @@ -4,21 +4,30 @@ #![doc = "Rust wrappers around the raw JS apis"] +use libc; use libc::types::os::arch::c95::{size_t, c_uint}; use libc::c_char; use std::cmp; +use std::ptr; use std::rc; use std::rt::Runtime; -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::{JSMutableHandleValue, JS_DestroyRuntime}; +use jsapi::{JS_SetGlobalJitCompilerOption, JSJITCOMPILER_BASELINE_ENABLE}; +use jsapi::{JSJITCOMPILER_PARALLEL_COMPILATION_ENABLE, JSHandleObject}; 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 std::ptr::mut_null; use std::str::raw::from_c_str; -use green::task::GreenTask; // ___________________________________________________________________________ // friendly Rustic API to runtimes @@ -26,18 +35,18 @@ use green::task::GreenTask; pub type rt = rc::Rc; pub struct rt_rsrc { - pub ptr : *JSRuntime, + pub ptr : *mut JSRuntime, } impl Drop for rt_rsrc { fn drop(&mut self) { unsafe { - JS_Finish(self.ptr); + JS_DestroyRuntime(self.ptr); } } } -pub fn new_runtime(p: *JSRuntime) -> rt { +pub fn new_runtime(p: *mut JSRuntime) -> rt { return rc::Rc::new(rt_rsrc { ptr: p }) @@ -56,22 +65,23 @@ impl RtUtils for rc::Rc { } } -extern fn gc_callback(rt: *JSRuntime, _status: JSGCStatus) { +extern fn gc_callback(rt: *mut JSRuntime, _status: JSGCStatus, _data: *mut libc::c_void) { use std::rt::local::Local; use std::rt::task::Task; unsafe { let mut task = Local::borrow(None::); - let green_task: ~GreenTask = task.get().maybe_take_runtime().unwrap(); - let (start, end) = green_task.stack_bounds(); + let (start, end) = task.get().stack_bounds(); JS_SetNativeStackBounds(rt, cmp::min(start, end), cmp::max(start, end)); - task.get().put_runtime(green_task); } } pub fn rt() -> rt { unsafe { - let runtime = JS_Init(default_heapsize); - JS_SetGCCallback(runtime, gc_callback); + let runtime = JS_NewRuntime(default_heapsize, JS_NO_HELPER_THREADS, ptr::mut_null()); + JS_SetGCCallback(runtime, Some(gc_callback), ptr::mut_null()); + 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); } } @@ -80,7 +90,7 @@ pub fn rt() -> rt { // contexts pub struct Cx { - pub ptr: *JSContext, + pub ptr: *mut JSContext, pub rt: rt, } @@ -93,7 +103,7 @@ impl Drop for Cx { } } -pub fn new_context(ptr: *JSContext, rt: rt) -> rc::Rc { +pub fn new_context(ptr: *mut JSContext, rt: rt) -> rc::Rc { return rc::Rc::new(Cx { ptr: ptr, rt: rt, @@ -102,46 +112,41 @@ pub fn new_context(ptr: *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: i32) { unsafe { - JS_SetVersion(self.ptr, v); + ContextOptions_SetVarObjFix(self.ptr, true); + //CompartmentOptions_SetVersion(self.ptr, JSVERSION_LATEST); } } pub fn set_logging_error_reporter(&self) { unsafe { - JS_SetErrorReporter(self.ptr, reportError); + JS_SetErrorReporter(self.ptr, Some(reportError)); } } - pub fn set_error_reporter(&self, reportfn: extern "C" fn(*JSContext, *c_char, *JSErrorReport)) { + pub fn set_error_reporter(&self, reportfn: extern "C" fn(*mut JSContext, *c_char, *mut JSErrorReport)) { unsafe { - JS_SetErrorReporter(self.ptr, reportfn); + JS_SetErrorReporter(self.ptr, Some(reportfn)); } } - pub fn evaluate_script(&self, glob: *JSObject, script: ~str, filename: ~str, line_num: uint) + pub fn evaluate_script(&self, glob: *mut JSObject, script: ~str, filename: ~str, line_num: uint) -> Result<(),()> { let script_utf16 = script.to_utf16(); filename.to_c_str().with_ref(|filename_cstr| { - let rval: JSVal = NullValue(); + let mut rval: JSVal = NullValue(); debug!("Evaluating script from {:s} with content {}", filename, script); unsafe { - if ERR == JS_EvaluateUCScript(self.ptr, glob, + let globhandle = JSHandleObject { + unnamed_field1: &glob, + }; + let rvalhandle = JSMutableHandleValue { + unnamed_field1: &mut rval, + }; + if ERR == JS_EvaluateUCScript(self.ptr, globhandle, script_utf16.as_ptr(), script_utf16.len() as c_uint, filename_cstr, line_num as c_uint, - &rval) { + rvalhandle) { debug!("...err!"); Err(()) } else { @@ -155,7 +160,7 @@ impl Cx { } } -pub extern fn reportError(_cx: *JSContext, msg: *c_char, report: *JSErrorReport) { +pub extern fn reportError(_cx: *mut JSContext, msg: *c_char, report: *mut JSErrorReport) { unsafe { let fnptr = (*report).filename; let fname = if fnptr.is_not_null() {from_c_str(fnptr)} else {"none".to_owned()}; @@ -165,15 +170,62 @@ pub extern fn reportError(_cx: *JSContext, msg: *c_char, report: *JSErrorReport) } } -pub fn with_compartment(cx: *JSContext, object: *JSObject, cb: || -> R) -> R { +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;