diff --git a/.travis.yml b/.travis.yml index eba9c5a96..e7acb98ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,10 @@ addons: apt: sources: - ubuntu-toolchain-r-test + - llvm-toolchain-xenial-8 packages: - autoconf2.13 - - clang + - clang-8 homebrew: update: true packages: diff --git a/Cargo.toml b/Cargo.toml index 4c448c448..f71c67a18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mozjs" description = "Rust bindings to the Mozilla SpiderMonkey JavaScript engine." repository = "https://github.com/servo/rust-mozjs" -version = "0.12.1" +version = "0.13.0" authors = ["The Servo Project Developers"] build = "build.rs" license = "MPL-2.0" @@ -53,4 +53,4 @@ lazy_static = "1" libc = "0.2" log = "0.4" num-traits = "0.2" -mozjs_sys = { git = "https://github.com/servo/mozjs", rev = "bc4935b668171863e537d3fb0d911001a6742013" } +mozjs_sys = { git = "https://github.com/servo/mozjs", rev = "30772ebe8cdfd56645fe27828def51cb92d95c0a" } diff --git a/appveyor.yml b/appveyor.yml index b2c4e4a9e..d2c973e7e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,7 @@ matrix: fast_finish: true environment: + LINKER: "lld-link.exe" PYTHON3: "C:\\Python37-x64\\python.exe" # The appveyor image we use has a pretty huge set of things installed... we make the # initial PATH something sane so we know what to expect @@ -30,9 +31,9 @@ environment: C:\\Program Files\\Git\\cmd;\ C:\\Program Files\\Git\\usr\\bin;\ C:\\Program Files\\AppVeyor\\BuildAgent;" + CC: "clang-cl.exe" CXX: "clang-cl.exe" - LINKER: "lld-link.exe" VCVARSALL_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build @@ -40,6 +41,8 @@ environment: - TARGET: i686-pc-windows-msvc CROSS_COMPILE: 1 - TARGET: x86_64-pc-windows-msvc + - TARGET: x86_64-pc-windows-msvc + FEATURES: "--features debugmozjs" # Uncomment to enable RDP & wait for exit. Connection info will be printed in the log. #init: @@ -52,6 +55,7 @@ install: - set BUILD_ENV=msvc - ps: Start-FileDownload "http://servo-rust.s3.amazonaws.com/build/MozillaBuildSetup-2.2.0.exe" - ps: .\MozillaBuildSetup-2.2.0.exe /S | Out-Null + - appveyor-retry choco install llvm --version=8.0.1 - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - rustup-init.exe -y --default-host=x86_64-pc-windows-msvc - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin @@ -66,5 +70,6 @@ build_script: - echo PATH %PATH% - echo MOZTOOLS_PATH %MOZTOOLS_PATH% - cd %APPVEYOR_BUILD_FOLDER% - - cargo build --verbose --verbose --target %TARGET% - - if "%CROSS_COMPILE%" == "" cargo test --verbose --verbose --target %TARGET% + - set MOZJS_FORCE_RERUN=1 + - cargo build --verbose --verbose --target %TARGET% %FEATURES% + - if "%CROSS_COMPILE%" == "" cargo test --verbose --verbose --target %TARGET% %FEATURES% diff --git a/build.rs b/build.rs index 08974d9b4..1daf7589d 100644 --- a/build.rs +++ b/build.rs @@ -14,20 +14,17 @@ fn main() { build.cpp(true) .file("src/jsglue.cpp") + .flag("-DSTATIC_JS_API") .include(include_path); if env::var("CARGO_FEATURE_DEBUGMOZJS").is_ok() { build.define("DEBUG", ""); - build.define("_DEBUG", ""); if cfg!(target_os = "windows") { - build.flag("-MDd"); build.flag("-Od"); } else { build.flag("-g"); build.flag("-O0"); } - } else if cfg!(target_os = "windows") { - build.flag("-MD"); } if env::var("CARGO_FEATURE_PROFILEMOZJS").is_ok() { diff --git a/src/consts.rs b/src/consts.rs index c1403ac25..4d1e1a9de 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -2,26 +2,17 @@ * 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::{JSCLASS_GLOBAL_APPLICATION_SLOTS, JSCLASS_RESERVED_SLOTS_SHIFT}; -use jsapi::{JSCLASS_RESERVED_SLOTS_WIDTH, JSProtoKey}; -use libc::c_uint; - pub const default_heapsize: u32 = 32_u32 * 1024_u32 * 1024_u32; -pub const JSCLASS_IS_DOMJSCLASS: c_uint = 1 << 4; -pub const JSCLASS_USERBIT1: c_uint = 1 << 7; +pub use jsapi::JSCLASS_IS_DOMJSCLASS; +pub use jsapi::JSCLASS_USERBIT1; -pub const JSCLASS_RESERVED_SLOTS_MASK: c_uint = - (1 << JSCLASS_RESERVED_SLOTS_WIDTH) - 1; +pub use jsapi::JSCLASS_RESERVED_SLOTS_MASK; -pub const JSCLASS_HIGH_FLAGS_SHIFT: c_uint = - (JSCLASS_RESERVED_SLOTS_SHIFT as c_uint) + JSCLASS_RESERVED_SLOTS_WIDTH; +pub use jsapi::JSCLASS_HIGH_FLAGS_SHIFT; -pub const JSCLASS_IS_GLOBAL: c_uint = - 1 << (JSCLASS_HIGH_FLAGS_SHIFT + 1); +pub use jsapi::JSCLASS_IS_GLOBAL; -pub const JSCLASS_IS_PROXY: c_uint = - 1 << (JSCLASS_HIGH_FLAGS_SHIFT + 4); +pub use jsapi::JSCLASS_IS_PROXY; -pub const JSCLASS_GLOBAL_SLOT_COUNT: c_uint = - JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProtoKey::JSProto_LIMIT as c_uint * 2 + 38; +pub use jsapi::JSCLASS_GLOBAL_SLOT_COUNT; diff --git a/src/conversions.rs b/src/conversions.rs index f8630344c..a3b47a424 100644 --- a/src/conversions.rs +++ b/src/conversions.rs @@ -92,7 +92,6 @@ impl_as!(u64, u64); /// A trait to convert Rust types to `JSVal`s. pub trait ToJSValConvertible { /// Convert `self` to a `JSVal`. JSAPI failure causes a panic. - #[inline] unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue); } diff --git a/src/generate_wrappers.sh b/src/generate_wrappers.sh index 4a1444fdc..bfa026c30 100755 --- a/src/generate_wrappers.sh +++ b/src/generate_wrappers.sh @@ -23,5 +23,5 @@ grep_heur() { sed 's/Handle<\*mut JSObject>/HandleObject/g' } -grep_heur ../target/debug/build/mozjs_sys-*/out/jsapi.rs | sed 's/\(.*\)/wrap!(jsapi: \1);/g' > jsapi_wrappers.in +grep_heur ../target/debug/build/mozjs_sys-*/out/build/jsapi.rs | sed 's/\(.*\)/wrap!(jsapi: \1);/g' > jsapi_wrappers.in grep_heur glue.rs | sed 's/\(.*\)/wrap!(glue: \1);/g' > glue_wrappers.in diff --git a/src/glue.rs b/src/glue.rs index 195f85745..051b4917e 100644 --- a/src/glue.rs +++ b/src/glue.rs @@ -48,7 +48,7 @@ pub struct ProxyTraps { pub ownPropertyKeys: ::std::option::Option bool>, pub delete_: ::std::option::Option bool>, pub getPrototypeIfOrdinary: ::std::option::Option bool>, pub nativeCall: ::std::option::Option *const ::libc::c_void; pub fn CreateWrapperProxyHandler(aTraps: *const ProxyTraps) -> *const ::libc::c_void; - pub fn CreateRustJSPrincipal(origin: *const ::libc::c_void, - destroy: Option, - write: Option bool>) - -> *mut JSPrincipals; - pub fn GetPrincipalOrigin(principal: *const JSPrincipals) - -> *const ::libc::c_void; pub fn GetCrossCompartmentWrapper() -> *const ::libc::c_void; pub fn GetSecurityWrapper() -> *const ::libc::c_void; pub fn NewCompileOptions(aCx: *mut JSContext, aFile: *const ::libc::c_char, @@ -240,7 +230,7 @@ extern "C" { pub fn NewWindowProxy(aCx: *mut JSContext, aObj: HandleObject, aHandler: *const ::libc::c_void) -> *mut JSObject; - pub fn GetWindowProxyClass() -> *const Class; + pub fn GetWindowProxyClass() -> *const JSClass; pub fn GetProxyReservedSlot(obj: *mut JSObject, slot: u32, dest: *mut JS::Value); pub fn GetProxyPrivate(obj: *mut JSObject, dest: *mut JS::Value); pub fn SetProxyReservedSlot(obj: *mut JSObject, slot: u32, val: *const JS::Value); @@ -269,15 +259,17 @@ extern "C" { pub fn UnwrapObjectStatic(obj: *mut JSObject) -> *mut JSObject; pub fn UnwrapObjectDynamic(obj: *mut JSObject, cx: *mut JSContext, stopAtOuter: u8) -> *mut JSObject; pub fn UncheckedUnwrapObject(obj: *mut JSObject, stopAtOuter: u8) -> *mut JSObject; - pub fn CreateAutoIdVector(cx: *mut JSContext) -> *mut AutoIdVector; - pub fn AppendToAutoIdVector(v: *mut AutoIdVector, id: HandleId) -> bool; - pub fn SliceAutoIdVector(v: *const AutoIdVector, length: *mut usize) -> *const jsid; - pub fn DestroyAutoIdVector(v: *mut AutoIdVector); - pub fn CreateAutoObjectVector(aCx: *mut JSContext) - -> *mut AutoObjectVector; - pub fn AppendToAutoObjectVector(v: *mut AutoObjectVector, + pub fn CreateRootedIdVector(cx: *mut JSContext) -> *mut PersistentRootedIdVector; + pub fn GetIdVectorAddress(v: *mut PersistentRootedIdVector) -> *mut ::libc::c_void; + pub fn SliceRootedIdVector(v: *const PersistentRootedIdVector, length: *mut usize) -> *const jsid; + pub fn AppendToIdVector(v: MutableHandleIdVector, id: HandleId) -> bool; + pub fn DestroyRootedIdVector(v: *mut PersistentRootedIdVector); + pub fn CreateRootedObjectVector(aCx: *mut JSContext) + -> *mut PersistentRootedObjectVector; + pub fn AppendToRootedObjectVector(v: *mut PersistentRootedObjectVector, obj: *mut JSObject) -> bool; - pub fn DeleteAutoObjectVector(v: *mut AutoObjectVector); + pub fn GetObjectVectorAddress(v: *mut PersistentRootedObjectVector) -> *mut ::libc::c_void; + pub fn DeleteRootedObjectVector(v: *mut PersistentRootedObjectVector); pub fn CollectServoSizes(cx: *mut JSContext, sizes: *mut ServoSizes, get_size: Option usize>) -> bool; pub fn InitializeMemoryReporter(want_to_measure: Option bool>); pub fn CallIdTracer(trc: *mut JSTracer, idp: *mut Heap, diff --git a/src/glue_wrappers.in b/src/glue_wrappers.in index 5ebd2664d..32fd82d54 100644 --- a/src/glue_wrappers.in +++ b/src/glue_wrappers.in @@ -8,11 +8,13 @@ wrap!(glue: pub fn WrapperNew(aCx: *mut JSContext, aObj: HandleObject, aHandler: wrap!(glue: pub fn NewWindowProxy(aCx: *mut JSContext, aObj: HandleObject, aHandler: *const ::libc::c_void) -> *mut JSObject); wrap!(glue: pub fn RUST_JSID_IS_INT(id: HandleId) -> bool); wrap!(glue: pub fn RUST_JSID_TO_INT(id: HandleId) -> i32); +wrap!(glue: pub fn int_to_jsid(i: i32, id: MutableHandleId)); wrap!(glue: pub fn RUST_JSID_IS_STRING(id: HandleId) -> bool); wrap!(glue: pub fn RUST_JSID_TO_STRING(id: HandleId) -> *mut JSString); wrap!(glue: pub fn RUST_SYMBOL_TO_JSID(sym: *mut Symbol, id: MutableHandleId)); -wrap!(glue: pub fn int_to_jsid(i: i32, id: MutableHandleId)); +wrap!(glue: pub fn RUST_JSID_IS_VOID(id: HandleId) -> bool); wrap!(glue: pub fn RUST_INTERNED_STRING_TO_JSID(cx: *mut JSContext, str: *mut JSString, id: MutableHandleId)); -wrap!(glue: pub fn AppendToAutoIdVector(v: *mut AutoIdVector, id: HandleId) -> bool); +wrap!(glue: pub fn GetIdVectorAddress(v: *mut PersistentRootedIdVector) -> *mut ::libc::c_void); +wrap!(glue: pub fn AppendToIdVector(v: MutableHandleIdVector, id: HandleId) -> bool); wrap!(glue: pub fn JS_GetPromiseResult (promise: HandleObject, dest: MutableHandleValue)); wrap!(glue: pub fn EncodeStringToUTF8(cx: *mut JSContext, str: HandleString, cb: fn(*const c_char))); diff --git a/src/jsapi_wrappers.in b/src/jsapi_wrappers.in index cc7b9873d..ef4c6e9d7 100644 --- a/src/jsapi_wrappers.in +++ b/src/jsapi_wrappers.in @@ -1,4 +1,43 @@ +wrap!(jsapi: pub fn GetBuiltinClass(cx: *mut JSContext, obj: HandleObject, cls: *mut ESClass) -> bool); +wrap!(jsapi: pub fn IsArgumentsObject(obj: HandleObject) -> bool); +wrap!(jsapi: pub fn ObjectClassName(cx: *mut JSContext, obj: HandleObject) -> *const ::std::os::raw::c_char); +wrap!(jsapi: pub fn EnqueueJob(cx: *mut JSContext, job: HandleObject) -> bool); +wrap!(jsapi: pub fn AssertSameCompartment1(cx: *mut JSContext, v: HandleValue)); +wrap!(jsapi: pub fn GetObjectProto(cx: *mut JSContext, obj: HandleObject, proto: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn GetRealmOriginalEval(cx: *mut JSContext, eval: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn GetPropertyKeys(cx: *mut JSContext, obj: HandleObject, flags: ::std::os::raw::c_uint, props: MutableHandleIdVector) -> bool); +wrap!(jsapi: pub fn AppendUnique(cx: *mut JSContext, base: MutableHandleIdVector, others: HandleIdVector) -> bool); +wrap!(jsapi: pub fn RegExpToSharedNonInline(cx: *mut JSContext, regexp: HandleObject) -> *mut RegExpShared); +wrap!(jsapi: pub fn DateIsValid(cx: *mut JSContext, obj: HandleObject, isValid: *mut bool) -> bool); +wrap!(jsapi: pub fn DateGetMsecSinceEpoch(cx: *mut JSContext, obj: HandleObject, msecSinceEpoch: *mut f64) -> bool); +wrap!(jsapi: pub fn PrepareScriptEnvironmentAndInvoke(cx: *mut JSContext, global: HandleObject, closure: *mut ScriptEnvironmentPreparer_Closure)); +wrap!(jsapi: pub fn GetElementsWithAdder(cx: *mut JSContext, obj: HandleObject, receiver: HandleObject, begin: u32, end: u32, adder: *mut ElementAdder) -> bool); +wrap!(jsapi: pub fn SetPropertyIgnoringNamedGetter(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, ownDesc: Handle, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn ExecuteInFrameScriptEnvironment(cx: *mut JSContext, obj: HandleObject, script: HandleScript, scope: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn ExecuteInJSMEnvironment(cx: *mut JSContext, script: HandleScript, jsmEnv: HandleObject) -> bool); +wrap!(jsapi: pub fn ExecuteInJSMEnvironment1(cx: *mut JSContext, script: HandleScript, jsmEnv: HandleObject, targetObj: HandleObjectVector) -> bool); +wrap!(jsapi: pub fn ReportIsNotFunction(cx: *mut JSContext, v: HandleValue) -> bool); +wrap!(jsapi: pub fn SetWindowProxy(cx: *mut JSContext, global: HandleObject, windowProxy: HandleObject)); +wrap!(jsapi: pub fn AddMozDateTimeFormatConstructor(cx: *mut JSContext, intl: HandleObject) -> bool); +wrap!(jsapi: pub fn AddLocaleConstructor(cx: *mut JSContext, intl: HandleObject) -> bool); +wrap!(jsapi: pub fn AddListFormatConstructor(cx: *mut JSContext, intl: HandleObject) -> bool); +wrap!(jsapi: pub fn SetRealmValidAccessPtr(cx: *mut JSContext, global: HandleObject, accessp: *mut bool)); +wrap!(jsapi: pub fn RemapRemoteWindowProxies(cx: *mut JSContext, callback: *mut CompartmentTransplantCallback, newTarget: MutableHandleObject)); +wrap!(jsapi: pub fn ToBooleanSlow(v: HandleValue) -> bool); +wrap!(jsapi: pub fn ToNumberSlow(cx: *mut JSContext, v: HandleValue, dp: *mut f64) -> bool); +wrap!(jsapi: pub fn ToInt8Slow(cx: *mut JSContext, v: HandleValue, out: *mut i8) -> bool); +wrap!(jsapi: pub fn ToUint8Slow(cx: *mut JSContext, v: HandleValue, out: *mut u8) -> bool); +wrap!(jsapi: pub fn ToInt16Slow(cx: *mut JSContext, v: HandleValue, out: *mut i16) -> bool); +wrap!(jsapi: pub fn ToInt32Slow(cx: *mut JSContext, v: HandleValue, out: *mut i32) -> bool); +wrap!(jsapi: pub fn ToUint32Slow(cx: *mut JSContext, v: HandleValue, out: *mut u32) -> bool); +wrap!(jsapi: pub fn ToUint16Slow(cx: *mut JSContext, v: HandleValue, out: *mut u16) -> bool); +wrap!(jsapi: pub fn ToInt64Slow(cx: *mut JSContext, v: HandleValue, out: *mut i64) -> bool); +wrap!(jsapi: pub fn ToUint64Slow(cx: *mut JSContext, v: HandleValue, out: *mut u64) -> bool); +wrap!(jsapi: pub fn ToStringSlow(cx: *mut JSContext, v: HandleValue) -> *mut JSString); +wrap!(jsapi: pub fn ToObjectSlow(cx: *mut JSContext, v: HandleValue, reportScanStack: bool) -> *mut JSObject); +wrap!(jsapi: pub fn GetFirstSubsumedSavedFrame(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, selfHosted: SavedFrameSelfHosted) -> *mut JSObject); wrap!(jsapi: pub fn GetRealmGlobalOrNull(realm: Handle<*mut Realm>) -> *mut JSObject); +wrap!(jsapi: pub fn GetFunctionRealm(cx: *mut JSContext, objArg: HandleObject) -> *mut Realm); wrap!(jsapi: pub fn ComputeThis(cx: *mut JSContext, vp: *mut Value, thisObject: MutableHandleObject) -> bool); wrap!(jsapi: pub fn IsArray(cx: *mut JSContext, obj: HandleObject, isArray: *mut bool) -> bool); wrap!(jsapi: pub fn IsArray1(cx: *mut JSContext, obj: HandleObject, answer: *mut IsArrayAnswer) -> bool); @@ -11,6 +50,10 @@ wrap!(jsapi: pub fn StartIncrementalEncoding(cx: *mut JSContext, script: Handle< wrap!(jsapi: pub fn FinishIncrementalEncoding(cx: *mut JSContext, script: Handle<*mut JSScript>, buffer: *mut TranscodeBuffer) -> bool); wrap!(jsapi: pub fn ObjectToCompletePropertyDescriptor(cx: *mut JSContext, obj: HandleObject, descriptor: Handle, desc: MutableHandle) -> bool); wrap!(jsapi: pub fn FromPropertyDescriptor(cx: *mut JSContext, desc: Handle, vp: MutableHandle) -> bool); +wrap!(jsapi: pub fn NewSymbol(cx: *mut JSContext, description: Handle<*mut JSString>) -> *mut Symbol); +wrap!(jsapi: pub fn GetSymbolFor(cx: *mut JSContext, key: Handle<*mut JSString>) -> *mut Symbol); +wrap!(jsapi: pub fn GetSymbolDescription(symbol: Handle<*mut Symbol>) -> *mut JSString); +wrap!(jsapi: pub fn GetSymbolCode(symbol: Handle<*mut Symbol>) -> SymbolCode); wrap!(jsapi: pub fn ProtoKeyToId(cx: *mut JSContext, key: JSProtoKey, idp: MutableHandleId)); wrap!(jsapi: pub fn ToPrimitive(cx: *mut JSContext, obj: HandleObject, hint: JSType, vp: MutableHandleValue) -> bool); wrap!(jsapi: pub fn OrdinaryHasInstance(cx: *mut JSContext, objArg: HandleObject, v: HandleValue, bp: *mut bool) -> bool); @@ -22,17 +65,7 @@ wrap!(jsapi: pub fn IsMapObject(cx: *mut JSContext, obj: HandleObject, isMap: *m wrap!(jsapi: pub fn IsSetObject(cx: *mut JSContext, obj: HandleObject, isSet: *mut bool) -> bool); wrap!(jsapi: pub fn GetSelfHostedFunction(cx: *mut JSContext, selfHostedName: *const ::std::os::raw::c_char, id: HandleId, nargs: ::std::os::raw::c_uint) -> *mut JSFunction); wrap!(jsapi: pub fn NewFunctionFromSpec(cx: *mut JSContext, fs: *const JSFunctionSpec, id: HandleId) -> *mut JSFunction); -wrap!(jsapi: pub fn CloneFunctionObject(cx: *mut JSContext, funobj: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn CloneFunctionObject1(cx: *mut JSContext, funobj: HandleObject, scopeChain: *mut AutoObjectVector) -> *mut JSObject); -wrap!(jsapi: pub fn FinishDynamicModuleImport(cx: *mut JSContext, referencingPrivate: HandleValue, specifier: HandleString, promise: HandleObject) -> bool); -wrap!(jsapi: pub fn CompileModule(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, moduleRecord: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn ModuleInstantiate(cx: *mut JSContext, moduleRecord: HandleObject) -> bool); -wrap!(jsapi: pub fn ModuleEvaluate(cx: *mut JSContext, moduleRecord: HandleObject) -> bool); -wrap!(jsapi: pub fn GetRequestedModules(cx: *mut JSContext, moduleRecord: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn GetRequestedModuleSpecifier(cx: *mut JSContext, requestedModuleObject: HandleValue) -> *mut JSString); -wrap!(jsapi: pub fn GetRequestedModuleSourcePos(cx: *mut JSContext, requestedModuleObject: HandleValue, lineNumber: *mut u32, columnNumber: *mut u32)); -wrap!(jsapi: pub fn GetModuleScript(moduleRecord: HandleObject) -> *mut JSScript); -wrap!(jsapi: pub fn PropertySpecNameEqualsId(name: *const ::std::os::raw::c_char, id: HandleId) -> bool); +wrap!(jsapi: pub fn PropertySpecNameEqualsId(name: JSPropertySpec_Name, id: HandleId) -> bool); wrap!(jsapi: pub fn CreateError(cx: *mut JSContext, type_: JSExnType, stack: HandleObject, fileName: HandleString, lineNumber: u32, columnNumber: u32, report: *mut JSErrorReport, message: HandleString, rval: MutableHandleValue) -> bool); wrap!(jsapi: pub fn GetWeakMapEntry(cx: *mut JSContext, mapObj: HandleObject, key: HandleObject, val: MutableHandleValue) -> bool); wrap!(jsapi: pub fn SetWeakMapEntry(cx: *mut JSContext, mapObj: HandleObject, key: HandleObject, val: HandleValue) -> bool); @@ -55,32 +88,28 @@ wrap!(jsapi: pub fn SetKeys(cx: *mut JSContext, obj: HandleObject, rval: Mutable wrap!(jsapi: pub fn SetValues(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); wrap!(jsapi: pub fn SetEntries(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); wrap!(jsapi: pub fn SetForEach(cx: *mut JSContext, obj: HandleObject, callbackFn: HandleValue, thisVal: HandleValue) -> bool); +wrap!(jsapi: pub fn SetPendingExceptionAndStack(cx: *mut JSContext, value: HandleValue, stack: HandleObject)); wrap!(jsapi: pub fn ExceptionStackOrNull(obj: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn ExceptionTimeWarpTarget(exn: HandleValue) -> u64); wrap!(jsapi: pub fn IsWasmModuleObject(obj: HandleObject) -> bool); wrap!(jsapi: pub fn GetWasmModule(obj: HandleObject) -> RefPtr); wrap!(jsapi: pub fn CaptureCurrentStack(cx: *mut JSContext, stackp: MutableHandleObject, capture: *mut StackCapture) -> bool); wrap!(jsapi: pub fn BuildStackString(cx: *mut JSContext, principals: *mut JSPrincipals, stack: HandleObject, stringp: MutableHandleString, indent: usize, stackFormat: StackFormat) -> bool); +wrap!(jsapi: pub fn CleanupQueuedFinalizationGroup(cx: *mut JSContext, group: HandleObject) -> bool); wrap!(jsapi: pub fn ForceLexicalInitialization(cx: *mut JSContext, obj: HandleObject) -> bool); wrap!(jsapi: pub fn DetachArrayBuffer(cx: *mut JSContext, obj: HandleObject) -> bool); wrap!(jsapi: pub fn StealArrayBufferContents(cx: *mut JSContext, obj: HandleObject) -> *mut ::std::os::raw::c_void); wrap!(jsapi: pub fn CloneAndExecuteScript(cx: *mut JSContext, script: Handle<*mut JSScript>, rval: MutableHandle) -> bool); -wrap!(jsapi: pub fn CloneAndExecuteScript1(cx: *mut JSContext, envChain: *mut u8, script: Handle<*mut JSScript>, rval: MutableHandle) -> bool); +wrap!(jsapi: pub fn CloneAndExecuteScript1(cx: *mut JSContext, envChain: HandleObjectVector, script: Handle<*mut JSScript>, rval: MutableHandle) -> bool); wrap!(jsapi: pub fn Evaluate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, rval: MutableHandle) -> bool); -wrap!(jsapi: pub fn Evaluate1(cx: *mut JSContext, envChain: *mut u8, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, rval: MutableHandle) -> bool); -wrap!(jsapi: pub fn EvaluateUtf8(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, rval: MutableHandle) -> bool); +wrap!(jsapi: pub fn Evaluate1(cx: *mut JSContext, envChain: HandleObjectVector, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, rval: MutableHandle) -> bool); +wrap!(jsapi: pub fn Evaluate2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, rval: MutableHandle) -> bool); +wrap!(jsapi: pub fn EvaluateDontInflate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, rval: MutableHandle) -> bool); wrap!(jsapi: pub fn EvaluateUtf8Path(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, rval: MutableHandle) -> bool); -wrap!(jsapi: pub fn Compile(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileDontInflate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileUtf8(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileUtf8DontInflate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileUtf8File(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, file: *mut FILE, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileUtf8FileDontInflate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, file: *mut FILE, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileUtf8Path(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileForNonSyntacticScope(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceText, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileUtf8ForNonSyntacticScope(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn CompileFunction(cx: *mut JSContext, envChain: *mut u8, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, srcBuf: *mut SourceText, fun: MutableHandle<*mut JSFunction>) -> bool); -wrap!(jsapi: pub fn CompileFunctionUtf8(cx: *mut JSContext, envChain: *mut u8, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, utf8: *const ::std::os::raw::c_char, length: usize, fun: MutableHandle<*mut JSFunction>) -> bool); +wrap!(jsapi: pub fn EvaluateUtf8PathDontInflate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, rval: MutableHandle) -> bool); +wrap!(jsapi: pub fn CompileFunction(cx: *mut JSContext, envChain: HandleObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, srcBuf: *mut SourceText) -> *mut JSFunction); +wrap!(jsapi: pub fn CompileFunction1(cx: *mut JSContext, envChain: HandleObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, srcBuf: *mut SourceText) -> *mut JSFunction); +wrap!(jsapi: pub fn CompileFunctionUtf8(cx: *mut JSContext, envChain: HandleObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, utf8: *const ::std::os::raw::c_char, length: usize) -> *mut JSFunction); wrap!(jsapi: pub fn InitScriptSourceElement(cx: *mut JSContext, script: Handle<*mut JSScript>, element: HandleObject, elementAttrName: Handle<*mut JSString>) -> bool); wrap!(jsapi: pub fn ExposeScriptToDebugger(cx: *mut JSContext, script: Handle<*mut JSScript>)); wrap!(jsapi: pub fn OrdinaryToPrimitive(cx: *mut JSContext, obj: HandleObject, type_: JSType, vp: MutableHandleValue) -> bool); @@ -90,7 +119,14 @@ wrap!(jsapi: pub fn LooselyEqual(cx: *mut JSContext, v1: Handle, v2: Hand wrap!(jsapi: pub fn SameValue(cx: *mut JSContext, v1: Handle, v2: Handle, same: *mut bool) -> bool); wrap!(jsapi: pub fn ToJSONMaybeSafely(cx: *mut JSContext, input: HandleObject, callback: JSONWriteCallback, data: *mut ::std::os::raw::c_void) -> bool); wrap!(jsapi: pub fn AddSizeOfTab(cx: *mut JSContext, obj: HandleObject, mallocSizeOf: MallocSizeOf, opv: *mut ObjectPrivateVisitor, sizes: *mut TabSizes) -> bool); -wrap!(jsapi: pub fn NewPromiseObject(cx: *mut JSContext, executor: HandleObject, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn FinishDynamicModuleImport(cx: *mut JSContext, referencingPrivate: Handle, specifier: Handle<*mut JSString>, promise: HandleObject) -> bool); +wrap!(jsapi: pub fn ModuleInstantiate(cx: *mut JSContext, moduleRecord: HandleObject) -> bool); +wrap!(jsapi: pub fn ModuleEvaluate(cx: *mut JSContext, moduleRecord: HandleObject) -> bool); +wrap!(jsapi: pub fn GetRequestedModules(cx: *mut JSContext, moduleRecord: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn GetRequestedModuleSpecifier(cx: *mut JSContext, requestedModuleObject: Handle) -> *mut JSString); +wrap!(jsapi: pub fn GetRequestedModuleSourcePos(cx: *mut JSContext, requestedModuleObject: Handle, lineNumber: *mut u32, columnNumber: *mut u32)); +wrap!(jsapi: pub fn GetModuleScript(moduleRecord: HandleObject) -> *mut JSScript); +wrap!(jsapi: pub fn NewPromiseObject(cx: *mut JSContext, executor: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn IsPromiseObject(obj: HandleObject) -> bool); wrap!(jsapi: pub fn GetPromiseState(promise: HandleObject) -> PromiseState); wrap!(jsapi: pub fn GetPromiseID(promise: HandleObject) -> u64); @@ -106,6 +142,7 @@ wrap!(jsapi: pub fn CallOriginalPromiseThen(cx: *mut JSContext, promise: HandleO wrap!(jsapi: pub fn AddPromiseReactions(cx: *mut JSContext, promise: HandleObject, onFulfilled: HandleObject, onRejected: HandleObject) -> bool); wrap!(jsapi: pub fn GetPromiseUserInputEventHandlingState(promise: HandleObject) -> PromiseUserInputEventHandlingState); wrap!(jsapi: pub fn SetPromiseUserInputEventHandlingState(promise: HandleObject, state: PromiseUserInputEventHandlingState) -> bool); +wrap!(jsapi: pub fn GetWaitForAllPromise(cx: *mut JSContext, promises: HandleObjectVector) -> *mut JSObject); wrap!(jsapi: pub fn GetSavedFrameSource(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, sourcep: MutableHandle<*mut JSString>, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); wrap!(jsapi: pub fn GetSavedFrameSourceId(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, sourceIdp: *mut u32, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); wrap!(jsapi: pub fn GetSavedFrameLine(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, linep: *mut u32, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); @@ -114,8 +151,9 @@ wrap!(jsapi: pub fn GetSavedFrameFunctionDisplayName(cx: *mut JSContext, princip wrap!(jsapi: pub fn GetSavedFrameAsyncCause(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, asyncCausep: MutableHandle<*mut JSString>, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); wrap!(jsapi: pub fn GetSavedFrameAsyncParent(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, asyncParentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); wrap!(jsapi: pub fn GetSavedFrameParent(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, parentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn ConvertSavedFrameToPlainObject(cx: *mut JSContext, savedFrame: HandleObject, selfHosted: SavedFrameSelfHosted) -> *mut JSObject); wrap!(jsapi: pub fn NewReadableDefaultStreamObject(cx: *mut JSContext, underlyingSource: HandleObject, size: HandleFunction, highWaterMark: f64, proto: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn NewReadableExternalSourceStreamObject(cx: *mut JSContext, underlyingSource: *mut ReadableStreamUnderlyingSource, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn NewReadableExternalSourceStreamObject(cx: *mut JSContext, underlyingSource: *mut ReadableStreamUnderlyingSource, nsISupportsObject_alreadyAddreffed: *mut ::std::os::raw::c_void, proto: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn ReadableStreamGetExternalUnderlyingSource(cx: *mut JSContext, stream: HandleObject, source: *mut *mut ReadableStreamUnderlyingSource) -> bool); wrap!(jsapi: pub fn ReadableStreamReleaseExternalUnderlyingSource(cx: *mut JSContext, stream: HandleObject) -> bool); wrap!(jsapi: pub fn ReadableStreamUpdateDataAvailableFromSource(cx: *mut JSContext, stream: HandleObject, availableData: u32) -> bool); @@ -133,44 +171,6 @@ wrap!(jsapi: pub fn ReadableStreamError(cx: *mut JSContext, stream: HandleObject wrap!(jsapi: pub fn ReadableStreamReaderCancel(cx: *mut JSContext, reader: HandleObject, reason: HandleValue) -> bool); wrap!(jsapi: pub fn ReadableStreamReaderReleaseLock(cx: *mut JSContext, reader: HandleObject) -> bool); wrap!(jsapi: pub fn ReadableStreamDefaultReaderRead(cx: *mut JSContext, reader: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn NewSymbol(cx: *mut JSContext, description: Handle<*mut JSString>) -> *mut Symbol); -wrap!(jsapi: pub fn GetSymbolFor(cx: *mut JSContext, key: Handle<*mut JSString>) -> *mut Symbol); -wrap!(jsapi: pub fn GetSymbolDescription(symbol: Handle<*mut Symbol>) -> *mut JSString); -wrap!(jsapi: pub fn GetSymbolCode(symbol: Handle<*mut Symbol>) -> SymbolCode); -wrap!(jsapi: pub fn GetBuiltinClass(cx: *mut JSContext, obj: HandleObject, cls: *mut ESClass) -> bool); -wrap!(jsapi: pub fn IsArgumentsObject(obj: HandleObject) -> bool); -wrap!(jsapi: pub fn ObjectClassName(cx: *mut JSContext, obj: HandleObject) -> *const ::std::os::raw::c_char); -wrap!(jsapi: pub fn EnqueueJob(cx: *mut JSContext, job: HandleObject) -> bool); -wrap!(jsapi: pub fn AssertSameCompartment1(cx: *mut JSContext, v: HandleValue)); -wrap!(jsapi: pub fn GetObjectProto(cx: *mut JSContext, obj: HandleObject, proto: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn GetRealmOriginalEval(cx: *mut JSContext, eval: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn GetPropertyKeys(cx: *mut JSContext, obj: HandleObject, flags: ::std::os::raw::c_uint, props: *mut AutoIdVector) -> bool); -wrap!(jsapi: pub fn RegExpToSharedNonInline(cx: *mut JSContext, regexp: HandleObject) -> *mut RegExpShared); -wrap!(jsapi: pub fn DateIsValid(cx: *mut JSContext, obj: HandleObject, isValid: *mut bool) -> bool); -wrap!(jsapi: pub fn DateGetMsecSinceEpoch(cx: *mut JSContext, obj: HandleObject, msecSinceEpoch: *mut f64) -> bool); -wrap!(jsapi: pub fn PrepareScriptEnvironmentAndInvoke(cx: *mut JSContext, global: HandleObject, closure: *mut ScriptEnvironmentPreparer_Closure)); -wrap!(jsapi: pub fn GetElementsWithAdder(cx: *mut JSContext, obj: HandleObject, receiver: HandleObject, begin: u32, end: u32, adder: *mut ElementAdder) -> bool); -wrap!(jsapi: pub fn SetPropertyIgnoringNamedGetter(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, ownDesc: Handle, result: *mut ObjectOpResult) -> bool); -wrap!(jsapi: pub fn ExecuteInFrameScriptEnvironment(cx: *mut JSContext, obj: HandleObject, script: HandleScript, scope: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn ExecuteInJSMEnvironment(cx: *mut JSContext, script: HandleScript, jsmEnv: HandleObject) -> bool); -wrap!(jsapi: pub fn ExecuteInJSMEnvironment1(cx: *mut JSContext, script: HandleScript, jsmEnv: HandleObject, targetObj: *mut AutoObjectVector) -> bool); -wrap!(jsapi: pub fn ReportIsNotFunction(cx: *mut JSContext, v: HandleValue) -> bool); -wrap!(jsapi: pub fn SetWindowProxy(cx: *mut JSContext, global: HandleObject, windowProxy: HandleObject)); -wrap!(jsapi: pub fn AddMozDateTimeFormatConstructor(cx: *mut JSContext, intl: HandleObject) -> bool); -wrap!(jsapi: pub fn SetRealmValidAccessPtr(cx: *mut JSContext, global: HandleObject, accessp: *mut bool)); -wrap!(jsapi: pub fn ToBooleanSlow(v: HandleValue) -> bool); -wrap!(jsapi: pub fn ToNumberSlow(cx: *mut JSContext, v: HandleValue, dp: *mut f64) -> bool); -wrap!(jsapi: pub fn ToInt8Slow(cx: *mut JSContext, v: HandleValue, out: *mut i8) -> bool); -wrap!(jsapi: pub fn ToUint8Slow(cx: *mut JSContext, v: HandleValue, out: *mut u8) -> bool); -wrap!(jsapi: pub fn ToInt16Slow(cx: *mut JSContext, v: HandleValue, out: *mut i16) -> bool); -wrap!(jsapi: pub fn ToInt32Slow(cx: *mut JSContext, v: HandleValue, out: *mut i32) -> bool); -wrap!(jsapi: pub fn ToUint32Slow(cx: *mut JSContext, v: HandleValue, out: *mut u32) -> bool); -wrap!(jsapi: pub fn ToUint16Slow(cx: *mut JSContext, v: HandleValue, out: *mut u16) -> bool); -wrap!(jsapi: pub fn ToInt64Slow(cx: *mut JSContext, v: HandleValue, out: *mut i64) -> bool); -wrap!(jsapi: pub fn ToUint64Slow(cx: *mut JSContext, v: HandleValue, out: *mut u64) -> bool); -wrap!(jsapi: pub fn ToStringSlow(cx: *mut JSContext, v: HandleValue) -> *mut JSString); -wrap!(jsapi: pub fn ToObjectSlow(cx: *mut JSContext, v: HandleValue, reportScanStack: bool) -> *mut JSObject); -wrap!(jsapi: pub fn GetFirstSubsumedSavedFrame(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, selfHosted: SavedFrameSelfHosted) -> *mut JSObject); wrap!(jsapi: pub fn JS_EncodeStringToUTF8(cx: *mut JSContext, str: Handle<*mut JSString>) -> UniqueChars); wrap!(jsapi: pub fn JS_ValueToObject(cx: *mut JSContext, v: HandleValue, objp: MutableHandleObject) -> bool); wrap!(jsapi: pub fn JS_ValueToFunction(cx: *mut JSContext, v: HandleValue) -> *mut JSFunction); @@ -183,8 +183,8 @@ wrap!(jsapi: pub fn JS_TransplantObject(cx: *mut JSContext, origobj: HandleObjec wrap!(jsapi: pub fn JS_RefreshCrossCompartmentWrappers(cx: *mut JSContext, obj: HandleObject) -> bool); wrap!(jsapi: pub fn JS_ResolveStandardClass(cx: *mut JSContext, obj: HandleObject, id: HandleId, resolved: *mut bool) -> bool); wrap!(jsapi: pub fn JS_EnumerateStandardClasses(cx: *mut JSContext, obj: HandleObject) -> bool); -wrap!(jsapi: pub fn JS_NewEnumerateStandardClasses(cx: *mut JSContext, obj: HandleObject, properties: *mut AutoIdVector, enumerableOnly: bool) -> bool); -wrap!(jsapi: pub fn JS_NewEnumerateStandardClassesIncludingResolved(cx: *mut JSContext, obj: HandleObject, properties: *mut AutoIdVector, enumerableOnly: bool) -> bool); +wrap!(jsapi: pub fn JS_NewEnumerateStandardClasses(cx: *mut JSContext, obj: HandleObject, properties: MutableHandleIdVector, enumerableOnly: bool) -> bool); +wrap!(jsapi: pub fn JS_NewEnumerateStandardClassesIncludingResolved(cx: *mut JSContext, obj: HandleObject, properties: MutableHandleIdVector, enumerableOnly: bool) -> bool); wrap!(jsapi: pub fn JS_GetClassObject(cx: *mut JSContext, key: JSProtoKey, objp: MutableHandleObject) -> bool); wrap!(jsapi: pub fn JS_GetClassPrototype(cx: *mut JSContext, key: JSProtoKey, objp: MutableHandleObject) -> bool); wrap!(jsapi: pub fn JS_IdToProtoKey(cx: *mut JSContext, id: HandleId) -> JSProtoKey); @@ -297,6 +297,7 @@ wrap!(jsapi: pub fn JS_IsArrayObject(cx: *mut JSContext, value: HandleValue, isA wrap!(jsapi: pub fn JS_IsArrayObject1(cx: *mut JSContext, obj: HandleObject, isArray: *mut bool) -> bool); wrap!(jsapi: pub fn JS_GetArrayLength(cx: *mut JSContext, obj: HandleObject, lengthp: *mut u32) -> bool); wrap!(jsapi: pub fn JS_SetArrayLength(cx: *mut JSContext, obj: HandleObject, length: u32) -> bool); +wrap!(jsapi: pub fn JS_SetAllNonReservedSlotsToUndefined(obj: HandleObject)); wrap!(jsapi: pub fn JS_GetFunctionLength(cx: *mut JSContext, fun: HandleFunction, length: *mut u16) -> bool); wrap!(jsapi: pub fn JS_DefineFunctions(cx: *mut JSContext, obj: HandleObject, fs: *const JSFunctionSpec) -> bool); wrap!(jsapi: pub fn JS_DefineFunction(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, call: JSNative, nargs: ::std::os::raw::c_uint, attrs: ::std::os::raw::c_uint) -> *mut JSFunction); @@ -308,15 +309,8 @@ wrap!(jsapi: pub fn JS_DecompileFunction(cx: *mut JSContext, fun: Handle<*mut JS wrap!(jsapi: pub fn JS_AtomizeAndPinJSString(cx: *mut JSContext, str: HandleString) -> *mut JSString); wrap!(jsapi: pub fn JS_NewDependentString(cx: *mut JSContext, str: HandleString, start: usize, length: usize) -> *mut JSString); wrap!(jsapi: pub fn JS_ConcatStrings(cx: *mut JSContext, left: HandleString, right: HandleString) -> *mut JSString); -wrap!(jsapi: pub fn JS_SetRegExpInput(cx: *mut JSContext, obj: HandleObject, input: HandleString) -> bool); -wrap!(jsapi: pub fn JS_ClearRegExpStatics(cx: *mut JSContext, obj: HandleObject) -> bool); -wrap!(jsapi: pub fn JS_ExecuteRegExp(cx: *mut JSContext, obj: HandleObject, reobj: HandleObject, chars: *mut u16, length: usize, indexp: *mut usize, test: bool, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_ExecuteRegExpNoStatics(cx: *mut JSContext, reobj: HandleObject, chars: *mut u16, length: usize, indexp: *mut usize, test: bool, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_ObjectIsRegExp(cx: *mut JSContext, obj: HandleObject, isRegExp: *mut bool) -> bool); -wrap!(jsapi: pub fn JS_GetRegExpFlags(cx: *mut JSContext, obj: HandleObject) -> ::std::os::raw::c_uint); -wrap!(jsapi: pub fn JS_GetRegExpSource(cx: *mut JSContext, obj: HandleObject) -> *mut JSString); wrap!(jsapi: pub fn JS_GetPendingException(cx: *mut JSContext, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_SetPendingException(cx: *mut JSContext, v: HandleValue)); +wrap!(jsapi: pub fn JS_SetPendingException(cx: *mut JSContext, v: HandleValue, behavior: ExceptionStackBehavior)); wrap!(jsapi: pub fn JS_ErrorFromException(cx: *mut JSContext, obj: HandleObject) -> *mut JSErrorReport); wrap!(jsapi: pub fn JS_IndexToId(cx: *mut JSContext, index: u32, arg1: MutableHandleId) -> bool); wrap!(jsapi: pub fn JS_CharsToId(cx: *mut JSContext, chars: TwoByteChars, arg1: MutableHandleId) -> bool); @@ -327,6 +321,7 @@ wrap!(jsapi: pub fn JS_NewObjectWithUniqueType(cx: *mut JSContext, clasp: *const wrap!(jsapi: pub fn JS_NewObjectWithoutMetadata(cx: *mut JSContext, clasp: *const JSClass, proto: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_NondeterministicGetWeakMapKeys(cx: *mut JSContext, obj: HandleObject, ret: MutableHandleObject) -> bool); wrap!(jsapi: pub fn JS_NondeterministicGetWeakSetKeys(cx: *mut JSContext, obj: HandleObject, ret: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn JS_ReportFirstCompileTime(script: HandleScript, parse: *mut TimeDuration, emit: *mut TimeDuration)); wrap!(jsapi: pub fn JS_CloneObject(cx: *mut JSContext, obj: HandleObject, proto: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_InitializePropertiesFromCompatibleNativeObject(cx: *mut JSContext, dst: HandleObject, src: HandleObject) -> bool); wrap!(jsapi: pub fn JS_CopyPropertiesFrom(cx: *mut JSContext, target: HandleObject, obj: HandleObject) -> bool); @@ -349,6 +344,8 @@ wrap!(jsapi: pub fn JS_NewInt16ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: wrap!(jsapi: pub fn JS_NewUint16ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); wrap!(jsapi: pub fn JS_NewInt32ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); wrap!(jsapi: pub fn JS_NewUint32ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewBigInt64ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_NewBigUint64ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); wrap!(jsapi: pub fn JS_NewFloat32ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); wrap!(jsapi: pub fn JS_NewFloat64ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); wrap!(jsapi: pub fn JS_GetArrayBufferViewBuffer(cx: *mut JSContext, obj: HandleObject, isSharedMemory: *mut bool) -> *mut JSObject); @@ -356,14 +353,14 @@ wrap!(jsapi: pub fn JS_NewDataView(cx: *mut JSContext, buffer: HandleObject, byt wrap!(jsapi: pub fn JS_Utf8BufferIsCompilableUnit(cx: *mut JSContext, obj: HandleObject, utf8: *const ::std::os::raw::c_char, length: usize) -> bool); wrap!(jsapi: pub fn JS_ExecuteScript(cx: *mut JSContext, script: Handle<*mut JSScript>, rval: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_ExecuteScript1(cx: *mut JSContext, script: Handle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn JS_ExecuteScript2(cx: *mut JSContext, envChain: *mut u8, script: Handle<*mut JSScript>, rval: MutableHandle) -> bool); -wrap!(jsapi: pub fn JS_ExecuteScript3(cx: *mut JSContext, envChain: *mut u8, script: Handle<*mut JSScript>) -> bool); +wrap!(jsapi: pub fn JS_ExecuteScript2(cx: *mut JSContext, envChain: HandleObjectVector, script: Handle<*mut JSScript>, rval: MutableHandle) -> bool); +wrap!(jsapi: pub fn JS_ExecuteScript3(cx: *mut JSContext, envChain: HandleObjectVector, script: Handle<*mut JSScript>) -> bool); wrap!(jsapi: pub fn JS_Stringify(cx: *mut JSContext, value: MutableHandle, replacer: HandleObject, space: Handle, callback: JSONWriteCallback, data: *mut ::std::os::raw::c_void) -> bool); wrap!(jsapi: pub fn JS_ParseJSON(cx: *mut JSContext, chars: *const u16, len: u32, vp: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_ParseJSON1(cx: *mut JSContext, str: Handle<*mut JSString>, vp: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_ParseJSONWithReviver(cx: *mut JSContext, chars: *const u16, len: u32, reviver: Handle, vp: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_ParseJSONWithReviver1(cx: *mut JSContext, str: Handle<*mut JSString>, reviver: Handle, vp: MutableHandle) -> bool); -wrap!(jsapi: pub fn JS_ReadStructuredClone(cx: *mut JSContext, data: *mut JSStructuredCloneData, version: u32, scope: StructuredCloneScope, vp: MutableHandleValue, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void) -> bool); +wrap!(jsapi: pub fn JS_ReadStructuredClone(cx: *mut JSContext, data: *mut JSStructuredCloneData, version: u32, scope: StructuredCloneScope, vp: MutableHandleValue, cloneDataPolicy: CloneDataPolicy, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void) -> bool); wrap!(jsapi: pub fn JS_WriteStructuredClone(cx: *mut JSContext, v: HandleValue, data: *mut JSStructuredCloneData, scope: StructuredCloneScope, cloneDataPolicy: CloneDataPolicy, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void, transferable: HandleValue) -> bool); wrap!(jsapi: pub fn JS_StructuredClone(cx: *mut JSContext, v: HandleValue, vp: MutableHandleValue, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void) -> bool); wrap!(jsapi: pub fn JS_ReadTypedArray(r: *mut JSStructuredCloneReader, vp: MutableHandleValue) -> bool); diff --git a/src/jsglue.cpp b/src/jsglue.cpp index 9adad7e49..e59bf2f43 100644 --- a/src/jsglue.cpp +++ b/src/jsglue.cpp @@ -4,6 +4,7 @@ #define __STDC_LIMIT_MACROS #include +#include #include "js-config.h" @@ -87,11 +88,11 @@ struct ProxyTraps { JS::Handle desc, JS::ObjectOpResult &result); bool (*ownPropertyKeys)(JSContext *cx, JS::HandleObject proxy, - JS::AutoIdVector &props); + JS::MutableHandleIdVector props); bool (*delete_)(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult &result); - bool (*enumerate)(JSContext *cx, JS::HandleObject proxy, js::AutoIdVector& props); + bool (*enumerate)(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleIdVector props); bool (*getPrototypeIfOrdinary)(JSContext *cx, JS::HandleObject proxy, bool *isOrdinary, JS::MutableHandleObject protop); @@ -120,7 +121,7 @@ struct ProxyTraps { bool (*hasOwn)(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp); bool (*getOwnEnumerablePropertyKeys)(JSContext *cx, JS::HandleObject proxy, - JS::AutoIdVector &props); + JS::MutableHandleIdVector props); bool (*nativeCall)(JSContext *cx, JS::IsAcceptableThis test, JS::NativeImpl impl, JS::CallArgs args); bool (*hasInstance)(JSContext *cx, JS::HandleObject proxy, @@ -149,152 +150,152 @@ struct ProxyTraps { static int HandlerFamily; -#define DEFER_TO_TRAP_OR_BASE_CLASS(_base) \ - \ - /* Standard internal methods. */ \ - virtual bool enumerate(JSContext *cx, \ - JS::HandleObject proxy, \ - js::AutoIdVector& props) const override \ - { \ - return mTraps.enumerate \ - ? mTraps.enumerate(cx, proxy, props) \ - : _base::enumerate(cx, proxy, props); \ - } \ - \ - virtual bool has(JSContext* cx, JS::HandleObject proxy, \ - JS::HandleId id, bool *bp) const override \ - { \ - return mTraps.has \ - ? mTraps.has(cx, proxy, id, bp) \ - : _base::has(cx, proxy, id, bp); \ - } \ - \ - virtual bool get(JSContext* cx, JS::HandleObject proxy, \ - JS::HandleValue receiver, \ - JS::HandleId id, JS::MutableHandleValue vp) const override \ - { \ - return mTraps.get \ - ? mTraps.get(cx, proxy, receiver, id, vp) \ - : _base::get(cx, proxy, receiver, id, vp); \ - } \ - \ - virtual bool set(JSContext* cx, JS::HandleObject proxy, \ - JS::HandleId id, JS::HandleValue v, \ - JS::HandleValue receiver, \ - JS::ObjectOpResult &result) const override \ - { \ - return mTraps.set \ - ? mTraps.set(cx, proxy, id, v, receiver, result) \ - : _base::set(cx, proxy, id, v, receiver, result); \ - } \ - \ - virtual bool call(JSContext* cx, JS::HandleObject proxy, \ - const JS::CallArgs &args) const override \ - { \ - return mTraps.call \ - ? mTraps.call(cx, proxy, args) \ - : _base::call(cx, proxy, args); \ - } \ - \ - virtual bool construct(JSContext* cx, JS::HandleObject proxy, \ - const JS::CallArgs &args) const override \ - { \ - return mTraps.construct \ - ? mTraps.construct(cx, proxy, args) \ - : _base::construct(cx, proxy, args); \ - } \ - \ - /* Spidermonkey extensions. */ \ - virtual bool hasOwn(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, \ - bool* bp) const override \ - { \ - return mTraps.hasOwn \ - ? mTraps.hasOwn(cx, proxy, id, bp) \ - : _base::hasOwn(cx, proxy, id, bp); \ - } \ - \ - virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, \ - JS::HandleObject proxy, \ - JS::AutoIdVector &props) const override \ - { \ - return mTraps.getOwnEnumerablePropertyKeys \ - ? mTraps.getOwnEnumerablePropertyKeys(cx, proxy, props) \ - : _base::getOwnEnumerablePropertyKeys(cx, proxy, props); \ - } \ - \ - virtual bool nativeCall(JSContext* cx, JS::IsAcceptableThis test, \ - JS::NativeImpl impl, \ - const JS::CallArgs& args) const override \ - { \ - return mTraps.nativeCall \ - ? mTraps.nativeCall(cx, test, impl, args) \ - : _base::nativeCall(cx, test, impl, args); \ - } \ - \ - virtual bool hasInstance(JSContext* cx, JS::HandleObject proxy, \ - JS::MutableHandleValue v, bool* bp) const override \ - { \ - return mTraps.hasInstance \ - ? mTraps.hasInstance(cx, proxy, v, bp) \ - : _base::hasInstance(cx, proxy, v, bp); \ - } \ - \ - virtual const char *className(JSContext *cx, JS::HandleObject proxy) const override\ - { \ - return mTraps.className \ - ? mTraps.className(cx, proxy) \ - : _base::className(cx, proxy); \ - } \ - \ - virtual JSString* fun_toString(JSContext* cx, JS::HandleObject proxy, \ - bool isToString) const override \ - { \ - return mTraps.fun_toString \ - ? mTraps.fun_toString(cx, proxy, isToString) \ - : _base::fun_toString(cx, proxy, isToString); \ - } \ - \ - virtual bool boxedValue_unbox(JSContext* cx, JS::HandleObject proxy, \ - JS::MutableHandleValue vp) const override \ - { \ - return mTraps.boxedValue_unbox \ - ? mTraps.boxedValue_unbox(cx, proxy, vp) \ - : _base::boxedValue_unbox(cx, proxy, vp); \ - } \ - \ - virtual void trace(JSTracer* trc, JSObject* proxy) const override \ - { \ - mTraps.trace \ - ? mTraps.trace(trc, proxy) \ - : _base::trace(trc, proxy); \ - } \ - \ - virtual void finalize(JSFreeOp* fop, JSObject* proxy) const override \ - { \ - mTraps.finalize \ - ? mTraps.finalize(fop, proxy) \ - : _base::finalize(fop, proxy); \ - } \ - \ - virtual size_t objectMoved(JSObject* proxy, JSObject *old) const override \ - { \ - return mTraps.objectMoved \ - ? mTraps.objectMoved(proxy, old) \ - : _base::objectMoved(proxy, old); \ - } \ - \ - virtual bool isCallable(JSObject* obj) const override \ - { \ - return mTraps.isCallable \ - ? mTraps.isCallable(obj) \ - : _base::isCallable(obj); \ - } \ - \ - virtual bool isConstructor(JSObject* obj) const override \ - { \ - return mTraps.isConstructor \ - ? mTraps.isConstructor(obj) \ - : _base::isConstructor(obj); \ +#define DEFER_TO_TRAP_OR_BASE_CLASS(_base) \ + \ + /* Standard internal methods. */ \ + virtual bool enumerate(JSContext *cx, \ + JS::HandleObject proxy, \ + JS::MutableHandleIdVector props) const override \ + { \ + return mTraps.enumerate \ + ? mTraps.enumerate(cx, proxy, props) \ + : _base::enumerate(cx, proxy, props); \ + } \ + \ + virtual bool has(JSContext *cx, JS::HandleObject proxy, \ + JS::HandleId id, bool *bp) const override \ + { \ + return mTraps.has \ + ? mTraps.has(cx, proxy, id, bp) \ + : _base::has(cx, proxy, id, bp); \ + } \ + \ + virtual bool get(JSContext *cx, JS::HandleObject proxy, \ + JS::HandleValue receiver, \ + JS::HandleId id, JS::MutableHandleValue vp) const override \ + { \ + return mTraps.get \ + ? mTraps.get(cx, proxy, receiver, id, vp) \ + : _base::get(cx, proxy, receiver, id, vp); \ + } \ + \ + virtual bool set(JSContext *cx, JS::HandleObject proxy, \ + JS::HandleId id, JS::HandleValue v, \ + JS::HandleValue receiver, \ + JS::ObjectOpResult &result) const override \ + { \ + return mTraps.set \ + ? mTraps.set(cx, proxy, id, v, receiver, result) \ + : _base::set(cx, proxy, id, v, receiver, result); \ + } \ + \ + virtual bool call(JSContext *cx, JS::HandleObject proxy, \ + const JS::CallArgs &args) const override \ + { \ + return mTraps.call \ + ? mTraps.call(cx, proxy, args) \ + : _base::call(cx, proxy, args); \ + } \ + \ + virtual bool construct(JSContext *cx, JS::HandleObject proxy, \ + const JS::CallArgs &args) const override \ + { \ + return mTraps.construct \ + ? mTraps.construct(cx, proxy, args) \ + : _base::construct(cx, proxy, args); \ + } \ + \ + /* Spidermonkey extensions. */ \ + virtual bool hasOwn(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, \ + bool *bp) const override \ + { \ + return mTraps.hasOwn \ + ? mTraps.hasOwn(cx, proxy, id, bp) \ + : _base::hasOwn(cx, proxy, id, bp); \ + } \ + \ + virtual bool getOwnEnumerablePropertyKeys(JSContext *cx, \ + JS::HandleObject proxy, \ + JS::MutableHandleIdVector props) const override \ + { \ + return mTraps.getOwnEnumerablePropertyKeys \ + ? mTraps.getOwnEnumerablePropertyKeys(cx, proxy, props) \ + : _base::getOwnEnumerablePropertyKeys(cx, proxy, props); \ + } \ + \ + virtual bool nativeCall(JSContext *cx, JS::IsAcceptableThis test, \ + JS::NativeImpl impl, \ + const JS::CallArgs &args) const override \ + { \ + return mTraps.nativeCall \ + ? mTraps.nativeCall(cx, test, impl, args) \ + : _base::nativeCall(cx, test, impl, args); \ + } \ + \ + virtual bool hasInstance(JSContext *cx, JS::HandleObject proxy, \ + JS::MutableHandleValue v, bool *bp) const override \ + { \ + return mTraps.hasInstance \ + ? mTraps.hasInstance(cx, proxy, v, bp) \ + : _base::hasInstance(cx, proxy, v, bp); \ + } \ + \ + virtual const char *className(JSContext *cx, JS::HandleObject proxy) const override \ + { \ + return mTraps.className \ + ? mTraps.className(cx, proxy) \ + : _base::className(cx, proxy); \ + } \ + \ + virtual JSString *fun_toString(JSContext *cx, JS::HandleObject proxy, \ + bool isToString) const override \ + { \ + return mTraps.fun_toString \ + ? mTraps.fun_toString(cx, proxy, isToString) \ + : _base::fun_toString(cx, proxy, isToString); \ + } \ + \ + virtual bool boxedValue_unbox(JSContext *cx, JS::HandleObject proxy, \ + JS::MutableHandleValue vp) const override \ + { \ + return mTraps.boxedValue_unbox \ + ? mTraps.boxedValue_unbox(cx, proxy, vp) \ + : _base::boxedValue_unbox(cx, proxy, vp); \ + } \ + \ + virtual void trace(JSTracer *trc, JSObject *proxy) const override \ + { \ + mTraps.trace \ + ? mTraps.trace(trc, proxy) \ + : _base::trace(trc, proxy); \ + } \ + \ + virtual void finalize(JSFreeOp *fop, JSObject *proxy) const override \ + { \ + mTraps.finalize \ + ? mTraps.finalize(fop, proxy) \ + : _base::finalize(fop, proxy); \ + } \ + \ + virtual size_t objectMoved(JSObject *proxy, JSObject *old) const override \ + { \ + return mTraps.objectMoved \ + ? mTraps.objectMoved(proxy, old) \ + : _base::objectMoved(proxy, old); \ + } \ + \ + virtual bool isCallable(JSObject *obj) const override \ + { \ + return mTraps.isCallable \ + ? mTraps.isCallable(obj) \ + : _base::isCallable(obj); \ + } \ + \ + virtual bool isConstructor(JSObject *obj) const override \ + { \ + return mTraps.isConstructor \ + ? mTraps.isConstructor(obj) \ + : _base::isConstructor(obj); \ } class WrapperProxyHandler : public js::Wrapper @@ -331,7 +332,7 @@ class WrapperProxyHandler : public js::Wrapper } virtual bool ownPropertyKeys(JSContext *cx, JS::HandleObject proxy, - JS::AutoIdVector &props) const override + JS::MutableHandleIdVector props) const override { return mTraps.ownPropertyKeys ? mTraps.ownPropertyKeys(cx, proxy, props) @@ -363,38 +364,6 @@ class WrapperProxyHandler : public js::Wrapper } }; -class RustJSPrincipal : public JSPrincipals -{ - const void* origin; //box with origin in it - void (*destroyCallback)(JSPrincipals *principal); - bool (*writeCallback)(JSContext* cx, JSStructuredCloneWriter* writer); - - public: - RustJSPrincipal(const void* origin, - void (*destroy)(JSPrincipals *principal), - bool (*write)(JSContext* cx, JSStructuredCloneWriter* writer)) - : JSPrincipals() { - this->origin = origin; - this->destroyCallback = destroy; - this->writeCallback = write; - } - - virtual const void* getOrigin() { - return origin; - } - - virtual void destroy() { - if(this->destroyCallback) - this->destroyCallback(this); - } - - bool write(JSContext* cx, JSStructuredCloneWriter* writer) { - return this->writeCallback - ? this->writeCallback(cx, writer) - : false; - } -}; - class ForwardingProxyHandler : public js::BaseProxyHandler { ProxyTraps mTraps; @@ -430,7 +399,7 @@ class ForwardingProxyHandler : public js::BaseProxyHandler } virtual bool ownPropertyKeys(JSContext *cx, JS::HandleObject proxy, - JS::AutoIdVector &props) const override + JS::MutableHandleIdVector props) const override { return mTraps.ownPropertyKeys(cx, proxy, props); } @@ -502,18 +471,6 @@ ShouldMeasureObject(JSObject* obj, nsISupports** iface) { extern "C" { -JSPrincipals* -CreateRustJSPrincipal(const void* origin, - void (*destroy)(JSPrincipals *principal), - bool (*write)(JSContext* cx, JSStructuredCloneWriter *writer)){ - return new RustJSPrincipal(origin, destroy, write); -} - -const void* -GetPrincipalOrigin(JSPrincipals* principal) { - return static_cast(principal)->getOrigin(); -} - bool InvokeGetOwnPropertyDescriptor( const void *handler, @@ -603,20 +560,36 @@ GetSecurityWrapper() return &js::CrossCompartmentSecurityWrapper::singleton; } -JS::ReadOnlyCompileOptions* -NewCompileOptions(JSContext* aCx, const char* aFile, unsigned aLine) -{ - JS::OwningCompileOptions *opts = new JS::OwningCompileOptions(aCx); - mozilla::Unused << opts->setFileAndLine(aCx, aFile, aLine); - return opts; -} - void DeleteCompileOptions(JS::ReadOnlyCompileOptions *aOpts) { delete static_cast(aOpts); } +JS::ReadOnlyCompileOptions * +NewCompileOptions( + JSContext *aCx, + const char *aFile, + unsigned aLine) +{ + JS::CompileOptions opts(aCx); + opts.setFileAndLine(aFile, aLine); + + JS::OwningCompileOptions *owned = new JS::OwningCompileOptions(aCx); + if (!owned) + { + return nullptr; + } + + if (!owned->copy(aCx, opts)) + { + DeleteCompileOptions(owned); + return nullptr; + } + + return owned; +} + JSObject* NewProxyObject(JSContext* aCx, const void* aHandler, JS::HandleValue aPriv, JSObject* proto) @@ -632,17 +605,17 @@ WrapperNew(JSContext* aCx, JS::HandleObject aObj, const void* aHandler, { js::WrapperOptions options; if (aClass) { - options.setClass(js::Valueify(aClass)); + options.setClass(aClass); } options.setSingleton(aSingleton); return js::Wrapper::New(aCx, aObj, (const js::Wrapper*)aHandler, options); } -const js::Class WindowProxyClass = PROXY_CLASS_DEF( +const JSClass WindowProxyClass = PROXY_CLASS_DEF( "Proxy", JSCLASS_HAS_RESERVED_SLOTS(1)); /* additional class flags */ -const js::Class* +const JSClass* GetWindowProxyClass() { return &WindowProxyClass; @@ -651,7 +624,7 @@ GetWindowProxyClass() JSObject* NewWindowProxy(JSContext* aCx, JS::HandleObject aObj, const void* aHandler) { - return WrapperNew(aCx, aObj, aHandler, Jsvalify(&WindowProxyClass), true); + return WrapperNew(aCx, aObj, aHandler, &WindowProxyClass, true); } void @@ -817,46 +790,55 @@ UncheckedUnwrapObject(JSObject* obj, bool stopAtOuter) return js::UncheckedUnwrap(obj, stopAtOuter); } -JS::AutoIdVector* -CreateAutoIdVector(JSContext* cx) +JS::PersistentRootedIdVector* +CreateRootedIdVector(JSContext* cx) { - return new JS::AutoIdVector(cx); + return new JS::PersistentRootedIdVector(cx); } -bool -AppendToAutoIdVector(JS::AutoIdVector* v, JS::HandleId id) +void* GetIdVectorAddress(JS::PersistentRootedIdVector *v) { - return v->append(id.get()); + return v->address(); } -const jsid* -SliceAutoIdVector(const JS::AutoIdVector* v, size_t* length) +const jsid * +SliceRootedIdVector(const JS::PersistentRootedIdVector *v, size_t *length) { *length = v->length(); return v->begin(); } +bool AppendToIdVector(JS::MutableHandleIdVector v, JS::HandleId id) +{ + return v.append(id.get()); +} + void -DestroyAutoIdVector(JS::AutoIdVector* v) +DestroyRootedIdVector(JS::PersistentRootedIdVector* v) { delete v; } -JS::AutoObjectVector* -CreateAutoObjectVector(JSContext* aCx) +JS::PersistentRootedObjectVector* +CreateRootedObjectVector(JSContext* aCx) { - JS::AutoObjectVector* vec = new JS::AutoObjectVector(aCx); + JS::PersistentRootedObjectVector* vec = new JS::PersistentRootedObjectVector(aCx); return vec; } +void *GetObjectVectorAddress(JS::PersistentRootedObjectVector *v) +{ + return v->address(); +} + bool -AppendToAutoObjectVector(JS::AutoObjectVector* v, JSObject* obj) +AppendToRootedObjectVector(JS::PersistentRootedObjectVector* v, JSObject* obj) { return v->append(obj); } void -DeleteAutoObjectVector(JS::AutoObjectVector* v) +DeleteRootedObjectVector(JS::PersistentRootedObjectVector* v) { delete v; } @@ -1048,12 +1030,12 @@ JS_GetPromiseResult(JS::HandleObject promise, JS::MutableHandleValue dest) { void JS_GetNaNValue(JSContext* cx, JS::Value* dest) { - *dest = JS_GetNaNValue(cx); + *dest = JS::NaNValue(); } void JS_GetPositiveInfinityValue(JSContext* cx, JS::Value* dest) { - *dest = JS_GetPositiveInfinityValue(cx); + *dest = JS::InfinityValue(); } void diff --git a/src/rust.rs b/src/rust.rs index 57565700d..7355c1bee 100644 --- a/src/rust.rs +++ b/src/rust.rs @@ -4,7 +4,7 @@ //! Rust wrappers around the raw JS apis -use libc::{size_t, c_uint}; +use libc::c_uint; use mozjs_sys::jsgc::CustomAutoRooterVFTable; use mozjs_sys::jsgc::RootKind; @@ -31,8 +31,8 @@ use consts::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; use conversions::jsstr_to_string; use jsapi; -use jsapi::{AutoGCRooter, AutoGCRooter_Tag, AutoIdVector, AutoObjectVector}; -use jsapi::{ContextOptionsRef, EvaluateUtf8, HandleValueArray, Heap}; +use jsapi::{AutoGCRooter, AutoGCRooter_Tag}; +use jsapi::{Evaluate2, HandleValueArray, Heap}; use jsapi::{InitSelfHostedCode, IsWindowSlow}; use jsapi::{JS_DefineFunctions, JS_DefineProperties, JS_DestroyContext, JS_ShutDown}; use jsapi::{JS_EnumerateStandardClasses, JS_GetRuntime, JS_GlobalObjectTraceHook}; @@ -41,28 +41,30 @@ use jsapi::{JS_SetGCParameter, JS_SetNativeStackQuota, JS_WrapValue, JSAutoRealm use jsapi::{JSClass, JSCLASS_RESERVED_SLOTS_SHIFT, JSClassOps, Realm, JSContext}; use jsapi::{JSErrorReport, JSFunction, JSFunctionSpec, JSGCParamKey}; use jsapi::{JSObject, JSPropertySpec, JSRuntime, JSScript}; -use jsapi::{JSString, JSTracer}; -use jsapi::{Object, ObjectGroup,ReadOnlyCompileOptions, Rooted, RootingContext}; -use jsapi::{SetWarningReporter, Symbol, ToBooleanSlow}; +use jsapi::{JSString, JSTracer, Object, ObjectGroup, PersistentRootedIdVector}; +use jsapi::{PersistentRootedObjectVector, ReadOnlyCompileOptions, Rooted, RootingContext}; +use jsapi::{SetWarningReporter, SourceText, Symbol, ToBooleanSlow}; use jsapi::{ToInt32Slow, ToInt64Slow, ToNumberSlow, ToStringSlow, ToUint16Slow}; use jsapi::{ToUint32Slow, ToUint64Slow, ToWindowProxyIfWindowSlow}; use jsapi::{Value, jsid}; use jsapi::{CaptureCurrentStack, BuildStackString, StackFormat}; use jsapi::{JS_StackCapture_AllFrames, JS_StackCapture_MaxFrames}; use jsapi::Handle as RawHandle; -use jsapi::MutableHandle as RawMutableHandle; +use jsapi::HandleObjectVector as RawHandleObjectVector; use jsapi::HandleValue as RawHandleValue; +use jsapi::MutableHandle as RawMutableHandle; +use jsapi::MutableHandleIdVector as RawMutableHandleIdVector; use jsapi::glue::{JS_Init, JS_NewRealmOptions, DeleteRealmOptions}; #[cfg(feature = "debugmozjs")] use jsapi::mozilla::detail::GuardObjectNotificationReceiver; use jsval::ObjectValue; -use glue::{AppendToAutoObjectVector, CallFunctionTracer, CallIdTracer, CallObjectTracer}; -use glue::{CallScriptTracer, CallStringTracer, CallValueTracer, CreateAutoIdVector}; -use glue::{CreateAutoObjectVector, DeleteAutoObjectVector}; -use glue::{DestroyAutoIdVector, DeleteCompileOptions, NewCompileOptions, SliceAutoIdVector}; -use glue::{CallObjectRootTracer, CallValueRootTracer}; +use glue::{AppendToRootedObjectVector, CallFunctionTracer, CallIdTracer, CallObjectRootTracer}; +use glue::{CallObjectTracer, CallScriptTracer, CallStringTracer, CallValueRootTracer}; +use glue::{CallValueTracer, CreateRootedIdVector, CreateRootedObjectVector}; +use glue::{DeleteCompileOptions, DeleteRootedObjectVector, DestroyRootedIdVector}; +use glue::{GetIdVectorAddress, GetObjectVectorAddress, NewCompileOptions, SliceRootedIdVector}; use panic::maybe_resume_unwind; @@ -323,7 +325,7 @@ impl Runtime { ptr::null_mut(), |r| r.parent, ); - let js_context = JS_NewContext(default_heapsize, ChunkSize as u32, parent_runtime); + let js_context = JS_NewContext(default_heapsize + (ChunkSize as u32), parent_runtime); assert!(!js_context.is_null()); // Unconstrain the runtime's threshold on nominal heap size, to avoid @@ -347,11 +349,6 @@ impl Runtime { InitSelfHostedCode(js_context); - let contextopts = ContextOptionsRef(js_context); - (*contextopts).set_baseline_(true); - (*contextopts).set_ion_(true); - (*contextopts).set_nativeRegExp_(true); - SetWarningReporter(js_context, Some(report_warning)); Runtime { @@ -379,19 +376,20 @@ impl Runtime { -> Result<(),()> { let filename_cstr = ffi::CString::new(filename.as_bytes()).unwrap(); debug!("Evaluating script from {} with content {}", filename, script); - // SpiderMonkey does not approve of null pointers. - let (ptr, len) = if script.len() == 0 { - static empty: &'static [u8] = &[]; - (empty.as_ptr(), 0) - } else { - (script.as_bytes().as_ptr(), script.len() as c_uint) - }; - assert!(!ptr.is_null()); + let _ac = JSAutoRealm::new(self.cx(), glob.get()); - let options = CompileOptionsWrapper::new(self.cx(), filename_cstr.as_ptr(), line_num); + let options = unsafe { + CompileOptionsWrapper::new(self.cx(), filename_cstr.as_ptr(), line_num) + }; unsafe { - if !EvaluateUtf8(self.cx(), options.ptr, ptr as *const _, len as size_t, rval.into()) { + let mut source = SourceText { + units_: script.as_ptr() as *const _, + length_: script.len() as u32, + ownsUnits_: false, + _phantom_0: std::marker::PhantomData, + }; + if !Evaluate2(self.cx(), options.ptr, &mut source, rval.into()) { debug!("...err!"); maybe_resume_unwind(); Err(()) @@ -873,29 +871,35 @@ const ChunkLocationOffset: usize = ChunkSize - 2 * 4 - 8; // ___________________________________________________________________________ // Wrappers around things in jsglue.cpp -pub struct AutoObjectVectorWrapper { - pub ptr: *mut AutoObjectVector +pub struct RootedObjectVectorWrapper { + pub ptr: *mut PersistentRootedObjectVector } -impl AutoObjectVectorWrapper { - pub fn new(cx: *mut JSContext) -> AutoObjectVectorWrapper { - AutoObjectVectorWrapper { +impl RootedObjectVectorWrapper { + pub fn new(cx: *mut JSContext) -> RootedObjectVectorWrapper { + RootedObjectVectorWrapper { ptr: unsafe { - CreateAutoObjectVector(cx) + CreateRootedObjectVector(cx) } } } pub fn append(&self, obj: *mut JSObject) -> bool { unsafe { - AppendToAutoObjectVector(self.ptr, obj) + AppendToRootedObjectVector(self.ptr, obj) + } + } + + pub fn handle(&self) -> RawHandleObjectVector { + RawHandleObjectVector { + ptr: unsafe { GetObjectVectorAddress(self.ptr) } } } } -impl Drop for AutoObjectVectorWrapper { +impl Drop for RootedObjectVectorWrapper { fn drop(&mut self) { - unsafe { DeleteAutoObjectVector(self.ptr) } + unsafe { DeleteRootedObjectVector(self.ptr) } } } @@ -904,10 +908,10 @@ pub struct CompileOptionsWrapper { } impl CompileOptionsWrapper { - pub fn new(cx: *mut JSContext, file: *const ::libc::c_char, line: c_uint) -> CompileOptionsWrapper { - CompileOptionsWrapper { - ptr: unsafe { NewCompileOptions(cx, file, line) } - } + pub unsafe fn new(cx: *mut JSContext, file: *const ::libc::c_char, line: c_uint) -> Self { + let ptr = NewCompileOptions(cx, file, line); + assert!(!ptr.is_null()); + Self { ptr } } } @@ -1053,24 +1057,26 @@ pub unsafe extern fn report_warning(_cx: *mut JSContext, report: *mut JSErrorRep warn!("Warning at {}:{}:{}: {}\n", fname, lineno, column, msg); } -pub struct IdVector(*mut AutoIdVector); +pub struct IdVector(*mut PersistentRootedIdVector); impl IdVector { pub unsafe fn new(cx: *mut JSContext) -> IdVector { - let vector = CreateAutoIdVector(cx); + let vector = CreateRootedIdVector(cx); assert!(!vector.is_null()); IdVector(vector) } - pub fn get(&self) -> *mut AutoIdVector { - self.0 + pub fn handle_mut(&mut self) -> RawMutableHandleIdVector { + RawMutableHandleIdVector { + ptr: unsafe { GetIdVectorAddress(self.0) } + } } } impl Drop for IdVector { fn drop(&mut self) { unsafe { - DestroyAutoIdVector(self.0) + DestroyRootedIdVector(self.0) } } } @@ -1081,7 +1087,7 @@ impl Deref for IdVector { fn deref(&self) -> &[jsid] { unsafe { let mut length = 0; - let pointer = SliceAutoIdVector(self.0 as *const _, &mut length); + let pointer = SliceRootedIdVector(self.0, &mut length); slice::from_raw_parts(pointer, length) } } @@ -1108,7 +1114,7 @@ pub unsafe fn define_methods(cx: *mut JSContext, obj: HandleObject, assert!({ match methods.last() { Some(&JSFunctionSpec { name, call, nargs, flags, selfHostedName }) => { - name.is_null() && call.is_zeroed() && nargs == 0 && flags == 0 && + name.string_.is_null() && call.is_zeroed() && nargs == 0 && flags == 0 && selfHostedName.is_null() }, None => false, @@ -1165,7 +1171,9 @@ pub static SIMPLE_GLOBAL_CLASS: JSClass = JSClass { name: b"Global\0" as *const u8 as *const _, flags: JSCLASS_IS_GLOBAL | ((JSCLASS_GLOBAL_SLOT_COUNT & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT), cOps: &SIMPLE_GLOBAL_CLASS_OPS as *const JSClassOps, - reserved: [0 as *mut _; 3] + spec: ptr::null(), + ext: ptr::null(), + oOps: ptr::null(), }; #[inline] @@ -1423,13 +1431,15 @@ pub mod wrappers { use jsapi::{JSType}; use jsapi::{SavedFrameResult, SavedFrameSelfHosted}; use jsapi::{MallocSizeOf, ObjectPrivateVisitor, ObjectOpResult, TabSizes}; - use jsapi::AutoIdVector; - use jsapi::AutoObjectVector; - use jsapi::CloneDataPolicy; use jsapi::CallArgs; + use jsapi::CloneDataPolicy; + use jsapi::CompartmentTransplantCallback; use jsapi::ESClass; + use jsapi::ExceptionStackBehavior; use jsapi::ForOfIterator; use jsapi::ForOfIterator_NonIterableBehavior; + use jsapi::HandleIdVector; + use jsapi::HandleObjectVector; use jsapi::JSClass; use jsapi::JSConstDoubleSpec; use jsapi::JSConstIntegerSpec; @@ -1441,9 +1451,12 @@ pub mod wrappers { use jsapi::JSONWriteCallback; use jsapi::JSPrincipals; use jsapi::JSPropertySpec; + use jsapi::JSPropertySpec_Name; use jsapi::JSProtoKey; use jsapi::JSScript; use jsapi::JSStructuredCloneData; + use jsapi::MutableHandleIdVector; + use jsapi::PersistentRootedIdVector; use jsapi::PromiseState; use jsapi::PromiseUserInputEventHandlingState; use jsapi::PropertyCopyBehavior; @@ -1465,11 +1478,11 @@ pub mod wrappers { use jsapi::TranscodeRange; use jsapi::TwoByteChars; use jsapi::UniqueChars; + use jsapi::mozilla::TimeDuration; use jsapi::mozilla::Utf8Unit; use jsapi::Value; use jsapi::WasmModule; use jsapi::jsid; - use libc::FILE; use std::os::raw::c_char; use super::*; include!("jsapi_wrappers.in"); @@ -1569,13 +1582,15 @@ pub mod jsapi_wrapped { use jsapi::{JSType}; use jsapi::{SavedFrameResult, SavedFrameSelfHosted}; use jsapi::{MallocSizeOf, ObjectPrivateVisitor, ObjectOpResult, TabSizes}; - use jsapi::AutoIdVector; - use jsapi::AutoObjectVector; - use jsapi::CloneDataPolicy; use jsapi::CallArgs; + use jsapi::CloneDataPolicy; + use jsapi::CompartmentTransplantCallback; use jsapi::ESClass; + use jsapi::ExceptionStackBehavior; use jsapi::ForOfIterator; use jsapi::ForOfIterator_NonIterableBehavior; + use jsapi::HandleIdVector; + use jsapi::HandleObjectVector; use jsapi::JSClass; use jsapi::JSConstDoubleSpec; use jsapi::JSConstIntegerSpec; @@ -1587,9 +1602,12 @@ pub mod jsapi_wrapped { use jsapi::JSONWriteCallback; use jsapi::JSPrincipals; use jsapi::JSPropertySpec; + use jsapi::JSPropertySpec_Name; use jsapi::JSProtoKey; use jsapi::JSScript; use jsapi::JSStructuredCloneData; + use jsapi::MutableHandleIdVector; + use jsapi::PersistentRootedIdVector; use jsapi::PromiseState; use jsapi::PromiseUserInputEventHandlingState; use jsapi::PropertyCopyBehavior; @@ -1611,10 +1629,10 @@ pub mod jsapi_wrapped { use jsapi::TranscodeRange; use jsapi::TwoByteChars; use jsapi::UniqueChars; + use jsapi::mozilla::TimeDuration; use jsapi::mozilla::Utf8Unit; use jsapi::Value; use jsapi::WasmModule; - use libc::FILE; use std::os::raw::c_char; use super::*; include!("jsapi_wrappers.in"); diff --git a/tests/capture_stack.rs b/tests/capture_stack.rs index a6a65d873..dbb0eb377 100644 --- a/tests/capture_stack.rs +++ b/tests/capture_stack.rs @@ -56,7 +56,7 @@ unsafe extern "C" fn print_stack(context: *mut JSContext, argc: u32, vp: *mut Va capture_stack!(in(context) let stack); let str_stack = stack.unwrap().as_string(None, StackFormat::SpiderMonkey).unwrap(); println!("{}", str_stack); - assert_eq!("bar@test.js:3:21\nfoo@test.js:5:17\n@test.js:8:13\n".to_string(), str_stack); + assert_eq!("bar@test.js:3:21\nfoo@test.js:5:17\n@test.js:8:16\n".to_string(), str_stack); args.rval().set(UndefinedValue()); return true; diff --git a/tests/enumerate.rs b/tests/enumerate.rs index 0f8111c62..3d6ca855f 100644 --- a/tests/enumerate.rs +++ b/tests/enumerate.rs @@ -40,8 +40,8 @@ fn enumerate() { assert!(rval.is_object()); rooted!(in(cx) let object = rval.to_object()); - let ids = IdVector::new(cx); - assert!(GetPropertyKeys(cx, object.handle().into(), JSITER_OWNONLY, ids.get())); + let mut ids = IdVector::new(cx); + assert!(GetPropertyKeys(cx, object.handle().into(), JSITER_OWNONLY, ids.handle_mut())); assert_eq!(ids.len(), 1); rooted!(in(cx) let id = ids[0]); diff --git a/tests/rooting.rs b/tests/rooting.rs index ac65c0660..d9d24fa60 100644 --- a/tests/rooting.rs +++ b/tests/rooting.rs @@ -14,6 +14,7 @@ use mozjs::jsapi::JSClass; use mozjs::jsapi::JSContext; use mozjs::jsapi::JSFunctionSpec; use mozjs::jsapi::JSNativeWrapper; +use mozjs::jsapi::JSPropertySpec_Name; use mozjs::jsapi::JS_NewGlobalObject; use mozjs::jsapi::JS_NewObjectWithUniqueType; use mozjs::jsapi::JSPROP_ENUMERATE; @@ -68,21 +69,21 @@ unsafe extern "C" fn generic_method(_: *mut JSContext, _: u32, _: *mut Value) -> const METHODS: &'static [JSFunctionSpec] = &[ JSFunctionSpec { - name: b"addEventListener\0" as *const u8 as *const libc::c_char, + name: JSPropertySpec_Name { string_: b"addEventListener\0" as *const u8 as *const libc::c_char }, call: JSNativeWrapper { op: Some(generic_method), info: 0 as *const _ }, nargs: 2, flags: JSPROP_ENUMERATE as u16, selfHostedName: 0 as *const libc::c_char }, JSFunctionSpec { - name: b"removeEventListener\0" as *const u8 as *const libc::c_char, + name: JSPropertySpec_Name { string_: b"removeEventListener\0" as *const u8 as *const libc::c_char }, call: JSNativeWrapper { op: Some(generic_method), info: 0 as *const _ }, nargs: 2, flags: JSPROP_ENUMERATE as u16, selfHostedName: 0 as *const libc::c_char }, JSFunctionSpec { - name: b"dispatchEvent\0" as *const u8 as *const libc::c_char, + name: JSPropertySpec_Name { string_: b"dispatchEvent\0" as *const u8 as *const libc::c_char }, call: JSNativeWrapper { op: Some(generic_method), info: 0 as *const _ }, nargs: 1, flags: JSPROP_ENUMERATE as u16, @@ -95,5 +96,7 @@ static CLASS: JSClass = JSClass { name: b"EventTargetPrototype\0" as *const u8 as *const libc::c_char, flags: 0, cOps: 0 as *const _, - reserved: [0 as *mut _; 3] + spec: ptr::null(), + ext: ptr::null(), + oOps: ptr::null(), }; diff --git a/tests/runtime.rs b/tests/runtime.rs index 8220b0c8e..e47990985 100644 --- a/tests/runtime.rs +++ b/tests/runtime.rs @@ -72,5 +72,7 @@ static CLASS: JSClass = JSClass { name: b"EventTargetPrototype\0" as *const u8 as *const libc::c_char, flags: JSCLASS_FOREGROUND_FINALIZE, cOps: &CLASS_OPS as *const JSClassOps, - reserved: [0 as *mut _; 3] + spec: ptr::null(), + ext: ptr::null(), + oOps: ptr::null(), };