diff --git a/.travis.yml b/.travis.yml index 746954843..b429a2026 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,32 @@ language: rust -sudo: 9000 -dist: trusty rust: - nightly + - beta + - stable +sudo: 9000 +dist: trusty os: - linux - osx +osx_image: xcode9.3 + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-5.0 + packages: + - autoconf2.13 + - g++-6 + - clang-5.0 env: - FEATURES="" - FEATURES="--features debugmozjs" -before_install: -- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install ccache yasm; fi +before_script: + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CC=gcc-6; export CXX=g++-6; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install autoconf@2.13 ccache yasm; fi script: - ccache -z diff --git a/Cargo.toml b/Cargo.toml index c02ce0385..9f922d68f 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.7.2" +version = "0.8.0" authors = ["The Servo Project Developers"] build = "build.rs" license = "MPL-2.0" @@ -31,6 +31,8 @@ name = "runtime" [[test]] name = "typedarray" [[test]] +name = "typedarray_panic" +[[test]] name = "stack_limit" [[test]] name = "vec_conversion" @@ -40,11 +42,10 @@ doctest = false [features] debugmozjs = ['mozjs_sys/debugmozjs'] -promises = ['mozjs_sys/promises'] [dependencies] lazy_static = "1" libc = "0.2" log = "0.4" num-traits = "0.2" -mozjs_sys = "0.51.1" +mozjs_sys = "0.60.0" diff --git a/README.md b/README.md index f2aeb525d..217b3a2f5 100644 --- a/README.md +++ b/README.md @@ -4,30 +4,4 @@ Rust bindings to SpiderMonkey [Documentation](http://doc.servo.org/mozjs/) -## Setting up your environment - -### Rust - -This project requires Rust nightly-2018-03-25 or greater. -For installation of the Rust toolchain see [`https://rustup.rs/`](https://rustup.rs/). - -### Other dependencies - -#### macOS -#### On macOS (Homebrew) - -```sh -brew install automake pkg-config python2 cmake yasm -``` - -## Building the project - -```sh -cargo build -``` - -## Testing the project - -```sh -cargo test -``` +See https://github.com/servo/mozjs/blob/master/README.md for build instructions. diff --git a/appveyor.yml b/appveyor.yml index 38b1d47c0..172e0e897 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,5 @@ version: 1.0.{build} +image: Visual Studio 2017 environment: # The appveyor image we use has a pretty huge set of things installed... we make the @@ -25,9 +26,6 @@ environment: C:\\Program Files\\Git\\cmd;\ C:\\Program Files\\Git\\usr\\bin;\ C:\\Program Files\\AppVeyor\\BuildAgent;" - RUST_BACKTRACE: "1" - matrix: - - TARGET: nightly-x86_64-pc-windows-msvc # Uncomment to enable RDP & wait for exit. Connection info will be printed in the log. #init: @@ -37,18 +35,17 @@ environment: # called after cloning, before building install: + - set BUILD_ENV=msvc + - set TARGET=nightly-x86_64-pc-windows-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 - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:TARGET}.exe" -FileName "rust-install.exe" - ps: .\rust-install.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null - ps: $env:PATH="$env:PATH;C:\rust\bin" -# I can't make this work with a multi-line script (e.g. via |+ etc.), so we copy the if before every command - - if %TARGET:*-msvc=msvc%==msvc set BUILD_ENV=msvc - - if %BUILD_ENV%==msvc call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat" - - if %BUILD_ENV%==msvc copy C:\mozilla-build\yasm\yasm.exe C:\mozilla-build\msys\bin - - if %BUILD_ENV%==msvc copy C:\mozilla-build\mozmake\mozmake.exe C:\mozilla-build\msys\bin - - if %BUILD_ENV%==msvc set MOZTOOLS_PATH=C:\mozilla-build\msys\bin - - if %BUILD_ENV%==msvc set NATIVE_WIN32_PYTHON=C:/Python27/python.exe + - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" + - set MOZTOOLS_PATH=C:\mozilla-build\msys\bin;C:\mozilla-build\mozmake;C:\mozilla-build\yasm + - set NATIVE_WIN32_PYTHON=C:/Python27/python.exe + - set AUTOCONF=C:/mozilla-build/msys/local/bin/autoconf-2.13 - rustc -vV - cargo -vV @@ -56,4 +53,4 @@ build_script: - echo PATH %PATH% - echo VSINSTALLDIR %VSINSTALLDIR% - echo MOZTOOLS_PATH %MOZTOOLS_PATH% - - if %BUILD_ENV%==msvc cd %APPVEYOR_BUILD_FOLDER% && cargo build && cargo test + - cd %APPVEYOR_BUILD_FOLDER% && cargo build --verbose --verbose && cargo test diff --git a/build.rs b/build.rs index f53624511..9a0e56237 100644 --- a/build.rs +++ b/build.rs @@ -44,7 +44,7 @@ fn main() { } else { build.flag("-fPIC"); build.flag("-fno-rtti"); - build.flag("-std=c++11"); + build.flag("-std=c++14"); build.define("JS_NO_JSVAL_JSID_STRUCT_TYPES", ""); build.flag("-include"); build.flag(&confdefs_path.to_string_lossy()); diff --git a/etc/README b/etc/README deleted file mode 100644 index 1cee003a9..000000000 --- a/etc/README +++ /dev/null @@ -1,44 +0,0 @@ -Building bindings requires rust-bindgen checked out and built in ../../rust-bindgen -(it expects to find the binary in ../../rust-bindgen/target/debug/bindgen). - -=== Windows === - -rust-bindgen must be built using a rust for the pc-windows-gnu target, not msvc, even -when generating msvc bindings. Within a MINGW64 env, install mingw-w64-x86_64-clang -then build rust-bindgen with 'LIBCLANG_PATH=c:/msys64/mingw64/bin cargo build' (replace -c:/msys64 with the root of your msys2-64 install directory). - -==== MSVC bindings ==== - -Now, build rust-mozjs using a pc-windows-msvc rust. Note that you'll need to be in an -environment that has the Visual C++ env vars already set up for your compiler -- the msys -package http://people.mozilla.org/~vladimir/misc/moz-vs-0.1.2-any.pkg.tar.xz can help -with this (install with pacman -U moz-vs-0.1.2-any.pkg.tar.xz). After installation, running -"moz_vs" will set up env vars for the current shell for the given target (2015 or 2013). -This command is additive to the env -- it doesn't "switch", a new shell is required to use -a different compiler. - -To generate VC14 (VS2015) bindings, in rust-mozjs: - -moz_vs 2015 -cargo build -[wait for everything to build; if bindings are out of date, it'll error out at the end -- that's okay] -./etc/bindings.sh msvc14 -cp out.rs src/jsapi_windows_msvc14_64.rs -cargo build # make sure the build finishes - -The debug bindings: - -cargo clean -cargo build --features debugmozjs -[wait for everything to build] -./etc/bindings.sh msvc14 -cp out.rs src/jsapi_windows_msvc14_64_debug.rs -cargo build --features debugmozjs - -If you get errors about "static_assert expression is not an integral constant expression", -additional static_assert(offsetof(...)) sites need to be #if 0'd out (this ends up being -a non-constant-expression according to clang when built with the MSVC headers). - -For generating the bindings with MSVC, only MSVC 2013 and 2015 are -supported (VC12 and 14). Run 'bindings.sh msvc12' and/or 'bindings.sh msvc14'. diff --git a/etc/bindings-all.py b/etc/bindings-all.py deleted file mode 100755 index 662182e4f..000000000 --- a/etc/bindings-all.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python3 - -import os, subprocess, sys - -def usage_and_exit(): - print("") - print("Usage:") - print(" bindings-all.py ") - print("") - print(" Regenerates both debugmozjs and non-debugmozjs bindings and") - print(" tests them.") - print("") - print(" One of 'linux_32', 'linux_64', 'macos_64',") - print(" 'freebsd_32', 'freebsd_64',") - print(" 'windows_gcc_64', or 'windows_msvc14_64'.") - print("") - print(" The path to bindgen") - print("") - print(" The path to the directory of clang library files") - sys.exit(1) - -# Validate arguments. - -if len(sys.argv) != 4: - usage_and_exit() - -[platform, bindgen, clang_lib_path] = sys.argv[1:] - -try: - ["linux_32", "linux_64", "freebsd_32", "freebsd_64", "macos_64", "windows_gcc_64", "windows_msvc14_64"].index(platform) -except ValueError: - print("error: {} is not a valid platform".format(platform)) - usage_and_exit() - -bindgen = os.path.abspath(bindgen) -if not (os.path.isfile(bindgen) and os.access(bindgen, os.X_OK)): - print("error: {} is not executable".format(bindgen)) - usage_and_exit() - -clang_lib_path = os.path.abspath(clang_lib_path) -if not os.path.isdir(clang_lib_path): - print("error: {} is not a directory".format(clang_lib_path)) - -# Go to the root of our repo. -os.chdir(os.path.dirname(sys.argv[0])) -os.chdir("..") - -def run(cmd, **kwargs): - """Run the given shell command. - - Pass through kwargs (like env=...) to `subprocess.Popen`. Wait for the - subprocess to complete, and throw an exception if it didn't exit with 0. - - """ - print("{}: Running".format(sys.argv[0]), cmd) - proc = subprocess.Popen(cmd, **kwargs) - proc.wait() - if proc.returncode != 0: - raise subprocess.CalledProcessError(proc.returncode, cmd) - -# Set up the environment needed to run bindgen. -bindgen_env = os.environ.copy() -bindgen_env["LIBCLANG_PATH"] = clang_lib_path -bindgen_env["BINDGEN"] = bindgen -if platform.startswith("macos"): - bindgen_env["DYLD_LIBRARY_PATH"] = clang_lib_path -else: - bindgen_env["LD_LIBRARY_PATH"] = clang_lib_path - -# Run our builds. - -BUILDS = [ - # Release build - ("", []), - # DEBUG build - ("_debug", ["--features", "debugmozjs"]) -] - -for (build_modifier, extra_cargo_flags) in BUILDS: - run(["cargo", "clean"]) - run(["cargo", "build", "-p", "mozjs_sys"] + extra_cargo_flags) - run(["./etc/bindings.sh"], env=bindgen_env) - run(["mv", "out.rs", "src/jsapi_{}{}.rs".format(platform, build_modifier)]) - run(["cargo", "test"] + extra_cargo_flags) diff --git a/etc/bindings.sh b/etc/bindings.sh deleted file mode 100755 index 448c2867c..000000000 --- a/etc/bindings.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")" - -EXTRA_FLAGS= -EXTRA_CLANG_FLAGS= -if [[ "$1" == "msvc14" ]] ; then - EXTRA_FLAGS="--use-msvc-mangling" - EXTRA_CLANG_FLAGS="--target=x86_64-pc-win32 -DWIN32=1" - EXTRA_CLANG_FLAGS="$EXTRA_CLANG_FLAGS -fms-compatibility-version=19.00" - EXTRA_CLANG_FLAGS="$EXTRA_CLANG_FLAGS -DEXPORT_JS_API=1 -D_CRT_USE_BUILTIN_OFFSETOF" - EXTRA_CLANG_FLAGS="$EXTRA_CLANG_FLAGS -fvisibility=hidden" -fi - -: ${BINDGEN:=../../rust-bindgen/target/debug/bindgen} - -if [[ ! -x "$BINDGEN" ]]; then - echo "error: BINDGEN does not exist or isn't executable!" - echo "error: with BINDGEN=$BINDGEN" - exit 1 -fi - -$BINDGEN \ - ${EXTRA_FLAGS} \ - --no-class-constants \ - --no-type-renaming \ - --blacklist-type DefaultHasher \ - --blacklist-type Heap \ - --blacklist-type AutoHashMapRooter \ - --blacklist-type AutoHashSetRooter \ - --blacklist-type TypeIsGCThing \ - --blacklist-type HashMap \ - --blacklist-type HashSet \ - --blacklist-type HashTable \ - --blacklist-type HashTableEntry \ - --blacklist-type AutoStableStringChars \ - --blacklist-type ErrorReport \ - --blacklist-type MemProfiler \ - --opaque-type RuntimeStats \ - --opaque-type EnumeratedArray \ - --opaque-type HashMap \ - --opaque-type AutoAssertGCCallback \ - --opaque-type CompileOptions \ - --opaque-type OwningCompileOptions \ - --opaque-type ReadOnlyCompileOptions \ - --allow-unknown-types \ - --match wrapper.h \ - --match jsapi.h \ - --match jsfriendapi.h \ - --match jsalloc.h \ - --match jsbytecode.h \ - --match jspubtd.h \ - --match AllocPolicy.h \ - --match CallArgs.h \ - --match CallNonGenericMethod.h \ - --match CharacterEncoding.h \ - --match Class.h \ - --match Conversions.h \ - --match Date.h \ - --match Debug.h \ - --match EnumeratedArray.h \ - --match GCAPI.h \ - --match GCAnnotations.h \ - --match GCPolicyAPI.h \ - --match GCVariant.h \ - --match GCVector.h \ - --match HashTable.h \ - --match HeapAPI.h \ - --match Id.h \ - --match Initialization.h \ - --match LinkedList.h \ - --match LegacyIntTypes.h \ - --match MemoryMetrics.h \ - --match MemoryReporting.h \ - --match Opaque.h \ - --match Principals.h \ - --match ProfilingFrameIterator.h \ - --match ProfilingStack.h \ - --match Promise.h \ - --match Proxy.h \ - --match Range.h \ - --match RangedPtr.h \ - --match RequiredDefines.h \ - --match RootingAPI.h \ - --match SliceBudget.h \ - --match StructuredClone.h \ - --match TraceKind.h \ - --match TracingAPI.h \ - --match TrackedOptimizationInfo.h \ - --match TypeDecls.h \ - --match UbiNode.h \ - --match UbiNodeBreadthFirst.h \ - --match UbiNodeCensus.h \ - --match UbiNodeDominatorTree.h \ - --match UbiNodePostOrder.h \ - --match UbiNodeShortestPaths.h \ - --match Value.h \ - --match Vector.h \ - --match WeakMapPtr.h \ - -o ../out.rs \ - wrapper.h \ - -- \ - $EXTRA_CLANG_FLAGS \ - -DRUST_BINDGEN=1 \ - -x c++ \ - --std=c++11 \ - -I ../target/debug/build/mozjs_sys-*/out/dist/include diff --git a/etc/wrapper.h b/etc/wrapper.h deleted file mode 100644 index f7083afa5..000000000 --- a/etc/wrapper.h +++ /dev/null @@ -1,11 +0,0 @@ -#include -#ifndef _MSC_VER -#include -#endif - -typedef uint32_t HashNumber; - -#include "jsfriendapi.h" -#include "js/Conversions.h" -#include "js/Initialization.h" -#include "js/MemoryMetrics.h" diff --git a/src/consts.rs b/src/consts.rs index 5891881f5..4f340845f 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -15,7 +15,7 @@ pub const JSCLASS_RESERVED_SLOTS_MASK: c_uint = (1 << JSCLASS_RESERVED_SLOTS_WIDTH) - 1; pub const JSCLASS_HIGH_FLAGS_SHIFT: c_uint = - JSCLASS_RESERVED_SLOTS_SHIFT + JSCLASS_RESERVED_SLOTS_WIDTH; + (JSCLASS_RESERVED_SLOTS_SHIFT as c_uint) + JSCLASS_RESERVED_SLOTS_WIDTH; pub const JSCLASS_IS_GLOBAL: c_uint = 1 << (JSCLASS_HIGH_FLAGS_SHIFT + 1); diff --git a/src/conversions.rs b/src/conversions.rs index 44e300bb9..a9d20cb1d 100644 --- a/src/conversions.rs +++ b/src/conversions.rs @@ -34,7 +34,7 @@ use jsapi::{ForOfIterator, ForOfIterator_NonIterableBehavior}; use jsapi::{Heap, JS_DefineElement, JS_GetLatin1StringCharsAndLength}; use jsapi::{JS_GetTwoByteStringCharsAndLength, JS_NewArrayObject1}; use jsapi::{JS_NewUCStringCopyN, JSPROP_ENUMERATE, JS_StringHasLatin1Chars}; -use jsapi::{JSContext, JSObject, JSString, RootedObject}; +use jsapi::{JSContext, JSObject, JSString, RootedObject, RootedValue}; use jsval::{BooleanValue, Int32Value, NullValue, UInt32Value, UndefinedValue}; use jsval::{JSVal, ObjectValue, ObjectOrNullValue, StringValue}; use rust::{ToBoolean, ToInt32, ToInt64, ToNumber, ToUint16, ToUint32, ToUint64}; @@ -370,7 +370,7 @@ impl FromJSValConvertible for u32 { impl ToJSValConvertible for i64 { #[inline] unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { - rval.set(RUST_JS_NumberValue(*self as f64)); + RUST_JS_NumberValue(*self as f64, &mut *rval); } } @@ -389,7 +389,7 @@ impl FromJSValConvertible for i64 { impl ToJSValConvertible for u64 { #[inline] unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { - rval.set(RUST_JS_NumberValue(*self as f64)); + RUST_JS_NumberValue(*self as f64, &mut *rval); } } @@ -408,7 +408,7 @@ impl FromJSValConvertible for u64 { impl ToJSValConvertible for f32 { #[inline] unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { - rval.set(RUST_JS_NumberValue(*self as f64)); + RUST_JS_NumberValue(*self as f64, &mut *rval); } } @@ -425,7 +425,7 @@ impl FromJSValConvertible for f32 { impl ToJSValConvertible for f64 { #[inline] unsafe fn to_jsval(&self, _cx: *mut JSContext, mut rval: MutableHandleValue) { - rval.set(RUST_JS_NumberValue(*self)); + RUST_JS_NumberValue(*self, &mut *rval); } } @@ -548,7 +548,7 @@ impl ToJSValConvertible for [T] { obj.to_jsval(cx, val.handle_mut()); assert!(JS_DefineElement(cx, js_array.handle().into(), - index as u32, val.handle().into(), JSPROP_ENUMERATE, None, None)); + index as u32, val.handle().into(), JSPROP_ENUMERATE as u32)); } rval.set(ObjectValue(js_array.handle().get())); @@ -597,9 +597,14 @@ impl> FromJSValConvertible for Vec Result>, ()> { + if !value.is_object() { + return Ok(ConversionResult::Failure("Value is not an object".into())); + } + let mut iterator = ForOfIterator { cx_: cx, iterator: RootedObject::new_unrooted(), + nextMethod: RootedValue::new_unrooted(), index: ::std::u32::MAX, // NOT_ARRAY }; let iterator = ForOfIteratorGuard::new(cx, &mut iterator); diff --git a/src/error.rs b/src/error.rs index 3f69f7321..f33b545c1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,7 +6,7 @@ #![deny(missing_docs)] -use jsapi::{JSContext, JSErrorFormatString, JSExnType, JS_ReportErrorNumber}; +use jsapi::{JSContext, JSErrorFormatString, JSExnType, JS_ReportErrorNumberUTF8}; use libc; use std::ffi::CString; use std::{mem, os, ptr}; @@ -55,11 +55,11 @@ unsafe extern "C" fn get_error_message(_user_ref: *mut os::raw::c_void, /// c_uint is u32, so this cast is safe, as is casting to/from i32 from there. unsafe fn throw_js_error(cx: *mut JSContext, error: &str, error_number: u32) { let error = CString::new(error).unwrap(); - JS_ReportErrorNumber(cx, - Some(get_error_message), - ptr::null_mut(), - error_number, - error.as_ptr()); + JS_ReportErrorNumberUTF8(cx, + Some(get_error_message), + ptr::null_mut(), + error_number, + error.as_ptr()); } /// Throw a `TypeError` with the given message. diff --git a/src/generate_wrappers.sh b/src/generate_wrappers.sh index d8a2481ba..8d12de7be 100755 --- a/src/generate_wrappers.sh +++ b/src/generate_wrappers.sh @@ -13,9 +13,14 @@ grep_heur() { grep 'pub fn' | \ grep Handle | \ grep -v roxyHandler | \ + grep -v '\bIdVector\b' | # name clash between rust::IdVector and JS::IdVector \ grep -v 'pub fn Unbox' | # this function seems to be platform specific \ + sed 's/root:://g' | + sed 's/JS:://g' | + sed 's/js:://g' | + sed 's/mozilla:://g' | sed 's/Handle<\*mut JSObject>/HandleObject/g' } -grep_heur jsapi_linux_64.rs | sed 's/\(.*\)/wrap!(jsapi: \1);/g' > jsapi_wrappers.in +grep_heur ../target/debug/build/mozjs_sys-*/out/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 75b6a8796..6be05d9c9 100644 --- a/src/glue.rs +++ b/src/glue.rs @@ -42,9 +42,8 @@ pub struct ProxyTraps { -> bool>, pub enumerate: ::std::option::Option bool>, + proxy: HandleObject) + -> *mut JSObject>, pub getPrototypeIfOrdinary: ::std::option::Option *mut JSString>, pub boxedValue_unbox: ::std::option::Option, pub objectMoved: ::std::option::Option, + old: *mut JSObject) + -> usize>, pub isCallable: ::std::option::Option bool>, pub isConstructor: ::std::option::Option bool; - pub fn RUST_JS_NumberValue(d: f64) -> Value; + pub fn RUST_JS_NumberValue(d: f64, dest: *mut JS::Value); pub fn RUST_FUNCTION_VALUE_TO_JITINFO(v: Value) -> *const JSJitInfo; pub fn CreateCallArgsFromVp(argc: u32, v: *mut Value) -> CallArgs; pub fn CallJitGetterOp(info: *const JSJitInfo, cx: *mut JSContext, @@ -225,20 +225,26 @@ extern "C" { pub fn WrapperNew(aCx: *mut JSContext, aObj: HandleObject, aHandler: *const ::libc::c_void, aClass: *const JSClass, aSingleton: bool) - -> *mut JSObject; + -> *mut JSObject; + + + pub fn NewWindowProxy(aCx: *mut JSContext, aObj: HandleObject, aHandler: *const ::libc::c_void) -> *mut JSObject; pub fn GetWindowProxyClass() -> *const Class; - pub fn GetProxyExtra(obj: *mut JSObject, slot: u32) -> Value; - pub fn GetProxyPrivate(obj: *mut JSObject) -> Value; - pub fn SetProxyExtra(obj: *mut JSObject, slot: u32, val: *const Value); + 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); + pub fn SetProxyPrivate(obj: *mut JSObject, expando: *const JS::Value); + pub fn RUST_JSID_IS_INT(id: HandleId) -> bool; pub fn RUST_JSID_TO_INT(id: HandleId) -> i32; pub fn int_to_jsid(i: i32) -> jsid; pub fn RUST_JSID_IS_STRING(id: HandleId) -> bool; pub fn RUST_JSID_TO_STRING(id: HandleId) -> *mut JSString; pub fn RUST_SYMBOL_TO_JSID(sym: *mut Symbol) -> jsid; + pub fn SetBuildId(buildId: *mut JS::BuildIdCharVector, chars: *const u8, len: usize) -> bool; pub fn RUST_SET_JITINFO(func: *mut JSFunction, info: *const JSJitInfo); pub fn RUST_INTERNED_STRING_TO_JSID(cx: *mut JSContext, str: *mut JSString) -> jsid; @@ -261,7 +267,7 @@ extern "C" { pub fn AppendToAutoObjectVector(v: *mut AutoObjectVector, obj: *mut JSObject) -> bool; pub fn DeleteAutoObjectVector(v: *mut AutoObjectVector); - pub fn CollectServoSizes(rt: *mut JSRuntime, sizes: *mut ServoSizes, get_size: Option usize>) -> bool; + 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, name: *const ::libc::c_char); @@ -326,4 +332,20 @@ extern "C" { length: *mut u32, isSharedMemory: *mut bool, data: *mut *mut f64); + + pub fn NewJSAutoStructuredCloneBuffer(scope: JS::StructuredCloneScope, + callbacks: *const JSStructuredCloneCallbacks) -> + *mut JSAutoStructuredCloneBuffer; + pub fn DeleteJSAutoStructuredCloneBuffer(buf: *mut JSAutoStructuredCloneBuffer); + pub fn GetLengthOfJSStructuredCloneData(data: *mut JSStructuredCloneData) -> usize; + pub fn CopyJSStructuredCloneData(src: *const JSStructuredCloneData, dest: *mut u8); + pub fn WriteBytesToJSStructuredCloneData(src: *const u8, len: usize, dest: *mut JSStructuredCloneData); + pub fn JS_ComputeThis (cx: *mut JSContext , vp: *mut JS::Value, dest: *mut JS::Value); + pub fn JS_GetModuleHostDefinedField (module: *mut JSObject, dest: *mut JS::Value); + pub fn JS_GetPromiseResult (promise: JS::HandleObject, dest: *mut JS::Value); + pub fn JS_THIS (cx: *mut JSContext , vp: *mut JS::Value, dest: *mut JS::Value); + pub fn JS_GetNaNValue (cx: *mut JSContext, dest: *mut JS::Value); + pub fn JS_GetPositiveInfinityValue (cx: *mut JSContext, dest: *mut JS::Value); + pub fn JS_GetEmptyStringValue (cx: *mut JSContext, dest: *mut JS::Value); + pub fn JS_GetReservedSlot (obj: *mut JSObject , index: u32, dest: *mut JS::Value); } diff --git a/src/glue_wrappers.in b/src/glue_wrappers.in index 9959600f0..af5bf2bd2 100644 --- a/src/glue_wrappers.in +++ b/src/glue_wrappers.in @@ -10,3 +10,4 @@ wrap!(glue: pub fn RUST_JSID_IS_INT(id: HandleId) -> bool); wrap!(glue: pub fn RUST_JSID_TO_INT(id: HandleId) -> i32); wrap!(glue: pub fn RUST_JSID_IS_STRING(id: HandleId) -> bool); wrap!(glue: pub fn RUST_JSID_TO_STRING(id: HandleId) -> *mut JSString); +wrap!(glue: pub fn JS_GetPromiseResult (promise: HandleObject, dest: *mut Value)); diff --git a/src/jsapi_wrappers.in b/src/jsapi_wrappers.in index e616817a7..a17236596 100644 --- a/src/jsapi_wrappers.in +++ b/src/jsapi_wrappers.in @@ -1,7 +1,170 @@ wrap!(jsapi: pub fn IsArray(cx: *mut JSContext, obj: HandleObject, isArray: *mut bool) -> bool); wrap!(jsapi: pub fn IsArray1(cx: *mut JSContext, obj: HandleObject, answer: *mut IsArrayAnswer) -> bool); -wrap!(jsapi: pub fn JS_ReadStructuredClone(cx: *mut JSContext, data: *mut u64, nbytes: usize, version: u32, vp: MutableHandleValue, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void) -> bool); -wrap!(jsapi: pub fn JS_WriteStructuredClone(cx: *mut JSContext, v: HandleValue, datap: *mut *mut u64, nbytesp: *mut usize, optionalCallbacks: *const JSStructuredCloneCallbacks, closure: *mut ::std::os::raw::c_void, transferable: HandleValue) -> bool); +wrap!(jsapi: pub fn GetRealmGlobalOrNull(realm: Handle<*mut Realm>) -> *mut JSObject); +wrap!(jsapi: pub fn NewReadableDefaultStreamObject(cx: *mut JSContext, underlyingSource: HandleObject, size: HandleFunction, highWaterMark: f64, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn NewReadableByteStreamObject(cx: *mut JSContext, underlyingSource: HandleObject, highWaterMark: f64, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn NewReadableExternalSourceStreamObject(cx: *mut JSContext, underlyingSource: *mut ::std::os::raw::c_void, flags: u8, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn ReadableStreamGetExternalUnderlyingSource(cx: *mut JSContext, stream: HandleObject, source: *mut *mut ::std::os::raw::c_void) -> bool); +wrap!(jsapi: pub fn ReadableStreamUpdateDataAvailableFromSource(cx: *mut JSContext, stream: HandleObject, availableData: u32) -> bool); +wrap!(jsapi: pub fn ReadableStreamCancel(cx: *mut JSContext, stream: HandleObject, reason: HandleValue) -> *mut JSObject); +wrap!(jsapi: pub fn ReadableStreamGetReader(cx: *mut JSContext, stream: HandleObject, mode: ReadableStreamReaderMode) -> *mut JSObject); +wrap!(jsapi: pub fn ReadableStreamTee(cx: *mut JSContext, stream: HandleObject, branch1Stream: MutableHandleObject, branch2Stream: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn ReadableStreamClose(cx: *mut JSContext, stream: HandleObject) -> bool); +wrap!(jsapi: pub fn ReadableStreamEnqueue(cx: *mut JSContext, stream: HandleObject, chunk: HandleValue) -> bool); +wrap!(jsapi: pub fn ReadableByteStreamEnqueueBuffer(cx: *mut JSContext, stream: HandleObject, buffer: HandleObject) -> bool); +wrap!(jsapi: pub fn ReadableStreamError(cx: *mut JSContext, stream: HandleObject, error: HandleValue) -> bool); +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 ReadableStreamBYOBReaderRead(cx: *mut JSContext, reader: HandleObject, view: HandleObject) -> *mut JSObject); +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); +wrap!(jsapi: pub fn ObjectToCompletePropertyDescriptor(cx: *mut JSContext, obj: HandleObject, descriptor: HandleValue, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn FromPropertyDescriptor(cx: *mut JSContext, desc: Handle, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Call(cx: *mut JSContext, thisv: HandleValue, fun: HandleValue, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Construct(cx: *mut JSContext, fun: HandleValue, newTarget: HandleObject, args: *const HandleValueArray, objp: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn Construct1(cx: *mut JSContext, fun: HandleValue, args: *const HandleValueArray, objp: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn IsMapObject(cx: *mut JSContext, obj: HandleObject, isMap: *mut bool) -> bool); +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 Compile(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn Compile1(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn Compile2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const u16, length: usize, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn Compile3(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, file: *mut FILE, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn Compile4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope1(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const u16, length: usize, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope3(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, file: *mut FILE, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn CompileForNonSyntacticScope4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn FinishMultiOffThreadScriptsDecoder(cx: *mut JSContext, token: *mut ::std::os::raw::c_void, scripts: MutableHandle) -> bool); +wrap!(jsapi: pub fn CompileFunction(cx: *mut JSContext, envChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, chars: *const u16, length: usize, fun: MutableHandleFunction) -> bool); +wrap!(jsapi: pub fn CompileFunction1(cx: *mut JSContext, envChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, srcBuf: *mut SourceBufferHolder, fun: MutableHandleFunction) -> bool); +wrap!(jsapi: pub fn CompileFunction2(cx: *mut JSContext, envChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, bytes: *const ::std::os::raw::c_char, length: usize, fun: MutableHandleFunction) -> bool); +wrap!(jsapi: pub fn InitScriptSourceElement(cx: *mut JSContext, script: HandleScript, element: HandleObject, elementAttrName: HandleString) -> bool); +wrap!(jsapi: pub fn ExposeScriptToDebugger(cx: *mut JSContext, script: HandleScript)); +wrap!(jsapi: pub fn CloneAndExecuteScript(cx: *mut JSContext, script: Handle<*mut JSScript>, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn CloneAndExecuteScript1(cx: *mut JSContext, envChain: *mut AutoObjectVector, script: Handle<*mut JSScript>, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate1(cx: *mut JSContext, envChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const u16, length: usize, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate3(cx: *mut JSContext, envChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, chars: *const u16, length: usize, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn Evaluate5(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetModuleResolveHook(cx: *mut JSContext, func: HandleFunction)); +wrap!(jsapi: pub fn CompileModule(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, moduleRecord: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn 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 NewPromiseObject(cx: *mut JSContext, executor: HandleObject, proto: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn IsPromiseObject(obj: HandleObject) -> bool); +wrap!(jsapi: pub fn GetPromiseState(promise: HandleObject) -> PromiseState); +wrap!(jsapi: pub fn GetPromiseID(promise: HandleObject) -> u64); +wrap!(jsapi: pub fn GetPromiseResult(promise: HandleObject) -> Value); +wrap!(jsapi: pub fn GetPromiseAllocationSite(promise: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn GetPromiseResolutionSite(promise: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn CallOriginalPromiseResolve(cx: *mut JSContext, resolutionValue: HandleValue) -> *mut JSObject); +wrap!(jsapi: pub fn CallOriginalPromiseReject(cx: *mut JSContext, rejectionValue: HandleValue) -> *mut JSObject); +wrap!(jsapi: pub fn ResolvePromise(cx: *mut JSContext, promiseObj: HandleObject, resolutionValue: HandleValue) -> bool); +wrap!(jsapi: pub fn RejectPromise(cx: *mut JSContext, promiseObj: HandleObject, rejectionValue: HandleValue) -> bool); +wrap!(jsapi: pub fn CallOriginalPromiseThen(cx: *mut JSContext, promise: HandleObject, onResolve: HandleObject, onReject: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn AddPromiseReactions(cx: *mut JSContext, promise: HandleObject, onResolve: HandleObject, onReject: HandleObject) -> bool); +wrap!(jsapi: pub fn NewAddonId(cx: *mut JSContext, str: HandleString) -> *mut JSAddonId); +wrap!(jsapi: pub fn NewSymbol(cx: *mut JSContext, description: HandleString) -> *mut Symbol); +wrap!(jsapi: pub fn GetSymbolFor(cx: *mut JSContext, key: HandleString) -> *mut Symbol); +wrap!(jsapi: pub fn GetSymbolDescription(symbol: HandleSymbol) -> *mut JSString); +wrap!(jsapi: pub fn GetSymbolCode(symbol: Handle<*mut Symbol>) -> SymbolCode); +wrap!(jsapi: pub fn PropertySpecNameEqualsId(name: *const ::std::os::raw::c_char, id: HandleId) -> bool); +wrap!(jsapi: pub fn ToJSONMaybeSafely(cx: *mut JSContext, input: HandleObject, callback: JSONWriteCallback, data: *mut ::std::os::raw::c_void) -> bool); +wrap!(jsapi: pub fn CreateError(cx: *mut JSContext, type_: JSExnType, stack: HandleObject, fileName: HandleString, lineNumber: u32, columnNumber: u32, report: *mut JSErrorReport, message: HandleString, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn GetWeakMapEntry(cx: *mut JSContext, mapObj: HandleObject, key: HandleObject, val: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetWeakMapEntry(cx: *mut JSContext, mapObj: HandleObject, key: HandleObject, val: HandleValue) -> bool); +wrap!(jsapi: pub fn MapSize(cx: *mut JSContext, obj: HandleObject) -> u32); +wrap!(jsapi: pub fn MapGet(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn MapHas(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); +wrap!(jsapi: pub fn MapSet(cx: *mut JSContext, obj: HandleObject, key: HandleValue, val: HandleValue) -> bool); +wrap!(jsapi: pub fn MapDelete(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); +wrap!(jsapi: pub fn MapClear(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn MapKeys(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn MapValues(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn MapEntries(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn MapForEach(cx: *mut JSContext, obj: HandleObject, callbackFn: HandleValue, thisVal: HandleValue) -> bool); +wrap!(jsapi: pub fn SetSize(cx: *mut JSContext, obj: HandleObject) -> u32); +wrap!(jsapi: pub fn SetHas(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); +wrap!(jsapi: pub fn SetDelete(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); +wrap!(jsapi: pub fn SetAdd(cx: *mut JSContext, obj: HandleObject, key: HandleValue) -> bool); +wrap!(jsapi: pub fn SetClear(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn SetKeys(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetValues(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetEntries(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn SetForEach(cx: *mut JSContext, obj: HandleObject, callbackFn: HandleValue, thisVal: HandleValue) -> bool); +wrap!(jsapi: pub fn ExceptionStackOrNull(obj: HandleObject) -> *mut JSObject); +wrap!(jsapi: pub fn EncodeScript(cx: *mut JSContext, buffer: *mut TranscodeBuffer, script: HandleScript) -> TranscodeResult); +wrap!(jsapi: pub fn EncodeInterpretedFunction(cx: *mut JSContext, buffer: *mut TranscodeBuffer, funobj: HandleObject) -> TranscodeResult); +wrap!(jsapi: pub fn DecodeScript(cx: *mut JSContext, buffer: *mut TranscodeBuffer, scriptp: MutableHandleScript, cursorIndex: usize) -> TranscodeResult); +wrap!(jsapi: pub fn DecodeScript1(cx: *mut JSContext, range: *const TranscodeRange, scriptp: MutableHandleScript) -> TranscodeResult); +wrap!(jsapi: pub fn DecodeInterpretedFunction(cx: *mut JSContext, buffer: *mut TranscodeBuffer, funp: MutableHandleFunction, cursorIndex: usize) -> TranscodeResult); +wrap!(jsapi: pub fn StartIncrementalEncoding(cx: *mut JSContext, script: HandleScript) -> bool); +wrap!(jsapi: pub fn FinishIncrementalEncoding(cx: *mut JSContext, script: HandleScript, buffer: *mut TranscodeBuffer) -> bool); +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 CopyAsyncStack(cx: *mut JSContext, asyncStack: HandleObject, asyncCause: HandleString, stackp: MutableHandleObject, maxFrameCount: *const u8) -> bool); +wrap!(jsapi: pub fn GetSavedFrameSource(cx: *mut JSContext, savedFrame: HandleObject, sourcep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameLine(cx: *mut JSContext, savedFrame: HandleObject, linep: *mut u32, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameColumn(cx: *mut JSContext, savedFrame: HandleObject, columnp: *mut u32, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameFunctionDisplayName(cx: *mut JSContext, savedFrame: HandleObject, namep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameAsyncCause(cx: *mut JSContext, savedFrame: HandleObject, asyncCausep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameAsyncParent(cx: *mut JSContext, savedFrame: HandleObject, asyncParentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn GetSavedFrameParent(cx: *mut JSContext, savedFrame: HandleObject, parentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); +wrap!(jsapi: pub fn BuildStackString(cx: *mut JSContext, stack: HandleObject, stringp: MutableHandleString, indent: usize, stackFormat: StackFormat) -> bool); +wrap!(jsapi: pub fn ForceLexicalInitialization(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn OrdinaryToPrimitive(cx: *mut JSContext, obj: HandleObject, type_: JSType, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn AddSizeOfTab(cx: *mut JSContext, obj: HandleObject, mallocSizeOf: MallocSizeOf, opv: *mut ObjectPrivateVisitor, sizes: *mut TabSizes) -> bool); +wrap!(jsapi: pub fn GetBuiltinClass(cx: *mut JSContext, obj: HandleObject, cls: *mut ESClass) -> bool); +wrap!(jsapi: pub fn ObjectClassName(cx: *mut JSContext, obj: HandleObject) -> *const ::std::os::raw::c_char); +wrap!(jsapi: pub fn 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 GetOriginalEval(cx: *mut JSContext, scope: HandleObject, eval: MutableHandleObject) -> bool); +wrap!(jsapi: pub fn GetPropertyKeys(cx: *mut JSContext, obj: HandleObject, flags: ::std::os::raw::c_uint, props: *mut AutoIdVector) -> bool); +wrap!(jsapi: pub fn RegExpToSharedNonInline(cx: *mut JSContext, regexp: HandleObject) -> *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, scope: HandleObject, closure: *mut ScriptEnvironmentPreparer_Closure)); +wrap!(jsapi: pub fn GetElementsWithAdder(cx: *mut JSContext, obj: HandleObject, receiver: HandleObject, begin: u32, end: u32, adder: *mut ElementAdder) -> bool); +wrap!(jsapi: pub fn SetPropertyIgnoringNamedGetter(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, ownDesc: Handle, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn ExecuteInGlobalAndReturnScope(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 GetFirstSubsumedSavedFrame(cx: *mut JSContext, savedFrame: HandleObject, selfHosted: SavedFrameSelfHosted) -> *mut JSObject); +wrap!(jsapi: pub fn GetFirstSubsumedSavedFrame1(cx: *mut JSContext, principals: *mut JSPrincipals, savedFrame: HandleObject, selfHosted: SavedFrameSelfHosted) -> *mut JSObject); +wrap!(jsapi: pub fn ReportIsNotFunction(cx: *mut JSContext, v: HandleValue) -> bool); +wrap!(jsapi: pub fn SetWindowProxy(cx: *mut JSContext, global: HandleObject, windowProxy: HandleObject)); +wrap!(jsapi: pub fn AddMozDateTimeFormatConstructor(cx: *mut JSContext, intl: HandleObject) -> bool); +wrap!(jsapi: pub fn AddRelativeTimeFormatConstructor(cx: *mut JSContext, intl: HandleObject) -> bool); +wrap!(jsapi: pub fn SetCompartmentValidAccessPtr(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 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_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); wrap!(jsapi: pub fn JS_WriteString(w: *mut JSStructuredCloneWriter, str: HandleString) -> bool); @@ -22,9 +185,9 @@ wrap!(jsapi: pub fn JS_RefreshCrossCompartmentWrappers(cx: *mut JSContext, obj: wrap!(jsapi: pub fn JS_InitStandardClasses(cx: *mut JSContext, obj: HandleObject) -> bool); wrap!(jsapi: pub fn JS_ResolveStandardClass(cx: *mut JSContext, obj: HandleObject, id: HandleId, resolved: *mut bool) -> bool); wrap!(jsapi: pub fn JS_EnumerateStandardClasses(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_NewEnumerateStandardClasses(cx: *mut JSContext, obj: HandleObject, properties: *mut AutoIdVector, 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 ProtoKeyToId(cx: *mut JSContext, key: JSProtoKey, idp: MutableHandleId)); wrap!(jsapi: pub fn JS_IdToProtoKey(cx: *mut JSContext, id: HandleId) -> JSProtoKey); wrap!(jsapi: pub fn JS_GetFunctionPrototype(cx: *mut JSContext, forObj: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_GetObjectPrototype(cx: *mut JSContext, forObj: HandleObject) -> *mut JSObject); @@ -35,9 +198,6 @@ wrap!(jsapi: pub fn JS_DefineDebuggerObject(cx: *mut JSContext, obj: HandleObjec wrap!(jsapi: pub fn JS_ValueToId(cx: *mut JSContext, v: HandleValue, idp: MutableHandleId) -> bool); wrap!(jsapi: pub fn JS_StringToId(cx: *mut JSContext, s: HandleString, idp: MutableHandleId) -> bool); wrap!(jsapi: pub fn JS_IdToValue(cx: *mut JSContext, id: jsid, vp: MutableHandle) -> bool); -wrap!(jsapi: pub fn ToPrimitive(cx: *mut JSContext, obj: HandleObject, hint: JSType, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_PropertyStub(cx: *mut JSContext, obj: HandleObject, id: HandleId, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_StrictPropertyStub(cx: *mut JSContext, obj: HandleObject, id: HandleId, vp: MutableHandleValue, result: *mut ObjectOpResult) -> bool); wrap!(jsapi: pub fn JS_InitClass(cx: *mut JSContext, obj: HandleObject, parent_proto: HandleObject, clasp: *const JSClass, constructor: JSNative, nargs: ::std::os::raw::c_uint, ps: *const JSPropertySpec, fs: *const JSFunctionSpec, static_ps: *const JSPropertySpec, static_fs: *const JSFunctionSpec) -> *mut JSObject); wrap!(jsapi: pub fn JS_LinkConstructorAndPrototype(cx: *mut JSContext, ctor: HandleObject, proto: HandleObject) -> bool); wrap!(jsapi: pub fn JS_InstanceOf(cx: *mut JSContext, obj: HandleObject, clasp: *const JSClass, args: *mut CallArgs) -> bool); @@ -48,8 +208,6 @@ wrap!(jsapi: pub fn JS_FireOnNewGlobalObject(cx: *mut JSContext, global: HandleO wrap!(jsapi: pub fn JS_NewObjectWithGivenProto(cx: *mut JSContext, clasp: *const JSClass, proto: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_DeepFreezeObject(cx: *mut JSContext, obj: HandleObject) -> bool); wrap!(jsapi: pub fn JS_FreezeObject(cx: *mut JSContext, obj: HandleObject) -> bool); -wrap!(jsapi: pub fn ObjectToCompletePropertyDescriptor(cx: *mut JSContext, obj: HandleObject, descriptor: HandleValue, desc: MutableHandle) -> bool); -wrap!(jsapi: pub fn FromPropertyDescriptor(cx: *mut JSContext, desc: Handle, vp: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_GetPrototype(cx: *mut JSContext, obj: HandleObject, result: MutableHandleObject) -> bool); wrap!(jsapi: pub fn JS_GetPrototypeIfOrdinary(cx: *mut JSContext, obj: HandleObject, isOrdinary: *mut bool, result: MutableHandleObject) -> bool); wrap!(jsapi: pub fn JS_SetPrototype(cx: *mut JSContext, obj: HandleObject, proto: HandleObject) -> bool); @@ -58,40 +216,44 @@ wrap!(jsapi: pub fn JS_PreventExtensions(cx: *mut JSContext, obj: HandleObject, wrap!(jsapi: pub fn JS_SetImmutablePrototype(cx: *mut JSContext, obj: HandleObject, succeeded: *mut bool) -> bool); wrap!(jsapi: pub fn JS_GetOwnPropertyDescriptorById(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_GetOwnPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, desc: MutableHandle) -> bool); -wrap!(jsapi: pub fn JS_GetOwnUCPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, desc: MutableHandle) -> bool); +wrap!(jsapi: pub fn JS_GetOwnUCPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const u16, desc: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_GetPropertyDescriptorById(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_GetPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, desc: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_DefinePropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: Handle, result: *mut ObjectOpResult) -> bool); wrap!(jsapi: pub fn JS_DefinePropertyById1(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: Handle) -> bool); -wrap!(jsapi: pub fn JS_DefinePropertyById2(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleValue, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefinePropertyById3(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleObject, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefinePropertyById4(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleString, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefinePropertyById5(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: i32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefinePropertyById6(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: u32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefinePropertyById7(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: f64, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleValue, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineProperty1(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleObject, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineProperty2(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleString, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineProperty3(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: i32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineProperty4(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: u32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineProperty5(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: f64, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, desc: Handle, result: *mut ObjectOpResult) -> bool); -wrap!(jsapi: pub fn JS_DefineUCProperty1(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, desc: Handle) -> bool); -wrap!(jsapi: pub fn JS_DefineUCProperty2(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: HandleValue, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineUCProperty3(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: HandleObject, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineUCProperty4(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: HandleString, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineUCProperty5(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: i32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineUCProperty6(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: u32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineUCProperty7(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, value: f64, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineElement(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleValue, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineElement1(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleObject, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineElement2(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleString, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineElement3(cx: *mut JSContext, obj: HandleObject, index: u32, value: i32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineElement4(cx: *mut JSContext, obj: HandleObject, index: u32, value: u32, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); -wrap!(jsapi: pub fn JS_DefineElement5(cx: *mut JSContext, obj: HandleObject, index: u32, value: f64, attrs: ::std::os::raw::c_uint, getter: JSNative, setter: JSNative) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById2(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleValue, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById3(cx: *mut JSContext, obj: HandleObject, id: HandleId, getter: JSNative, setter: JSNative, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById4(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleObject, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById5(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: HandleString, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById6(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: i32, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById7(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: u32, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefinePropertyById8(cx: *mut JSContext, obj: HandleObject, id: HandleId, value: f64, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleValue, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty1(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, getter: JSNative, setter: JSNative, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty2(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleObject, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty3(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: HandleString, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty4(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: i32, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty5(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: u32, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineProperty6(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, value: f64, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, desc: Handle, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty1(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, desc: Handle) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty2(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, value: HandleValue, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty3(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, getter: JSNative, setter: JSNative, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty4(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, value: HandleObject, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty5(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, value: HandleString, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty6(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, value: i32, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty7(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, value: u32, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineUCProperty8(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, value: f64, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineElement(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleValue, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineElement1(cx: *mut JSContext, obj: HandleObject, index: u32, getter: JSNative, setter: JSNative, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineElement2(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleObject, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineElement3(cx: *mut JSContext, obj: HandleObject, index: u32, value: HandleString, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineElement4(cx: *mut JSContext, obj: HandleObject, index: u32, value: i32, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineElement5(cx: *mut JSContext, obj: HandleObject, index: u32, value: u32, attrs: ::std::os::raw::c_uint) -> bool); +wrap!(jsapi: pub fn JS_DefineElement6(cx: *mut JSContext, obj: HandleObject, index: u32, value: f64, attrs: ::std::os::raw::c_uint) -> bool); wrap!(jsapi: pub fn JS_HasPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, foundp: *mut bool) -> bool); wrap!(jsapi: pub fn JS_HasProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, foundp: *mut bool) -> bool); -wrap!(jsapi: pub fn JS_HasUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, vp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_HasUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, vp: *mut bool) -> bool); wrap!(jsapi: pub fn JS_HasElement(cx: *mut JSContext, obj: HandleObject, index: u32, foundp: *mut bool) -> bool); wrap!(jsapi: pub fn JS_HasOwnPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, foundp: *mut bool) -> bool); wrap!(jsapi: pub fn JS_HasOwnProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, foundp: *mut bool) -> bool); @@ -99,12 +261,12 @@ wrap!(jsapi: pub fn JS_ForwardGetPropertyTo(cx: *mut JSContext, obj: HandleObjec wrap!(jsapi: pub fn JS_ForwardGetElementTo(cx: *mut JSContext, obj: HandleObject, index: u32, receiver: HandleObject, vp: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_GetPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, vp: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_GetProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_GetUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_GetUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, vp: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_GetElement(cx: *mut JSContext, obj: HandleObject, index: u32, vp: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_ForwardSetPropertyTo(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, result: *mut ObjectOpResult) -> bool); wrap!(jsapi: pub fn JS_SetPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue) -> bool); wrap!(jsapi: pub fn JS_SetProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, v: HandleValue) -> bool); -wrap!(jsapi: pub fn JS_SetUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, v: HandleValue) -> bool); +wrap!(jsapi: pub fn JS_SetUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, v: HandleValue) -> bool); wrap!(jsapi: pub fn JS_SetElement(cx: *mut JSContext, obj: HandleObject, index: u32, v: HandleValue) -> bool); wrap!(jsapi: pub fn JS_SetElement1(cx: *mut JSContext, obj: HandleObject, index: u32, v: HandleObject) -> bool); wrap!(jsapi: pub fn JS_SetElement2(cx: *mut JSContext, obj: HandleObject, index: u32, v: HandleString) -> bool); @@ -113,7 +275,7 @@ wrap!(jsapi: pub fn JS_SetElement4(cx: *mut JSContext, obj: HandleObject, index: wrap!(jsapi: pub fn JS_SetElement5(cx: *mut JSContext, obj: HandleObject, index: u32, v: f64) -> bool); wrap!(jsapi: pub fn JS_DeletePropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, result: *mut ObjectOpResult) -> bool); wrap!(jsapi: pub fn JS_DeleteProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, result: *mut ObjectOpResult) -> bool); -wrap!(jsapi: pub fn JS_DeleteUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, result: *mut ObjectOpResult) -> bool); +wrap!(jsapi: pub fn JS_DeleteUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, result: *mut ObjectOpResult) -> bool); wrap!(jsapi: pub fn JS_DeleteElement(cx: *mut JSContext, obj: HandleObject, index: u32, result: *mut ObjectOpResult) -> bool); wrap!(jsapi: pub fn JS_DeletePropertyById1(cx: *mut JSContext, obj: HandleObject, id: jsid) -> bool); wrap!(jsapi: pub fn JS_DeleteProperty1(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char) -> bool); @@ -121,9 +283,6 @@ wrap!(jsapi: pub fn JS_DeleteElement1(cx: *mut JSContext, obj: HandleObject, ind wrap!(jsapi: pub fn JS_CallFunctionValue(cx: *mut JSContext, obj: HandleObject, fval: HandleValue, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_CallFunction(cx: *mut JSContext, obj: HandleObject, fun: HandleFunction, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_CallFunctionName(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn Call(cx: *mut JSContext, thisv: HandleValue, fun: HandleValue, args: *const HandleValueArray, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn Construct(cx: *mut JSContext, fun: HandleValue, newTarget: HandleObject, args: *const HandleValueArray, objp: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn Construct1(cx: *mut JSContext, fun: HandleValue, args: *const HandleValueArray, objp: MutableHandleObject) -> bool); wrap!(jsapi: pub fn JS_New(cx: *mut JSContext, ctor: HandleObject, args: *const HandleValueArray) -> *mut JSObject); wrap!(jsapi: pub fn JS_DefineObject(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, clasp: *const JSClass, attrs: ::std::os::raw::c_uint) -> *mut JSObject); wrap!(jsapi: pub fn JS_DefineConstDoubles(cx: *mut JSContext, obj: HandleObject, cds: *const JSConstDoubleSpec) -> bool); @@ -131,7 +290,7 @@ wrap!(jsapi: pub fn JS_DefineConstIntegers(cx: *mut JSContext, obj: HandleObject wrap!(jsapi: pub fn JS_DefineProperties(cx: *mut JSContext, obj: HandleObject, ps: *const JSPropertySpec) -> bool); wrap!(jsapi: pub fn JS_AlreadyHasOwnPropertyById(cx: *mut JSContext, obj: HandleObject, id: HandleId, foundp: *mut bool) -> bool); wrap!(jsapi: pub fn JS_AlreadyHasOwnProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, foundp: *mut bool) -> bool); -wrap!(jsapi: pub fn JS_AlreadyHasOwnUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, foundp: *mut bool) -> bool); +wrap!(jsapi: pub fn JS_AlreadyHasOwnUCProperty(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, foundp: *mut bool) -> bool); wrap!(jsapi: pub fn JS_AlreadyHasOwnElement(cx: *mut JSContext, obj: HandleObject, index: u32, foundp: *mut bool) -> bool); wrap!(jsapi: pub fn JS_NewArrayObject(cx: *mut JSContext, contents: *const HandleValueArray) -> *mut JSObject); wrap!(jsapi: pub fn JS_IsArrayObject(cx: *mut JSContext, value: HandleValue, isArray: *mut bool) -> bool); @@ -139,128 +298,44 @@ wrap!(jsapi: pub fn JS_IsArrayObject1(cx: *mut JSContext, obj: HandleObject, isA wrap!(jsapi: pub fn JS_GetArrayLength(cx: *mut JSContext, obj: HandleObject, lengthp: *mut u32) -> bool); wrap!(jsapi: pub fn JS_SetArrayLength(cx: *mut JSContext, obj: HandleObject, length: u32) -> bool); wrap!(jsapi: pub fn JS_StealArrayBufferContents(cx: *mut JSContext, obj: HandleObject) -> *mut ::std::os::raw::c_void); -wrap!(jsapi: pub fn GetSelfHostedFunction(cx: *mut JSContext, selfHostedName: *const ::std::os::raw::c_char, id: HandleId, nargs: ::std::os::raw::c_uint) -> *mut JSFunction); -wrap!(jsapi: pub fn NewFunctionFromSpec(cx: *mut JSContext, fs: *const JSFunctionSpec, id: HandleId) -> *mut JSFunction); +wrap!(jsapi: pub fn JS_ExternalizeArrayBufferContents(cx: *mut JSContext, obj: HandleObject) -> *mut ::std::os::raw::c_void); wrap!(jsapi: pub fn JS_DefineFunctions(cx: *mut JSContext, obj: HandleObject, fs: *const JSFunctionSpec) -> bool); wrap!(jsapi: pub fn JS_DefineFunction(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_char, call: JSNative, nargs: ::std::os::raw::c_uint, attrs: ::std::os::raw::c_uint) -> *mut JSFunction); -wrap!(jsapi: pub fn JS_DefineUCFunction(cx: *mut JSContext, obj: HandleObject, name: *const ::std::os::raw::c_ushort, namelen: usize, call: JSNative, nargs: ::std::os::raw::c_uint, attrs: ::std::os::raw::c_uint) -> *mut JSFunction); +wrap!(jsapi: pub fn JS_DefineUCFunction(cx: *mut JSContext, obj: HandleObject, name: *const u16, namelen: usize, call: JSNative, nargs: ::std::os::raw::c_uint, attrs: ::std::os::raw::c_uint) -> *mut JSFunction); wrap!(jsapi: pub fn JS_DefineFunctionById(cx: *mut JSContext, obj: HandleObject, id: Handle, call: JSNative, nargs: ::std::os::raw::c_uint, attrs: ::std::os::raw::c_uint) -> *mut JSFunction); -wrap!(jsapi: pub fn CloneFunctionObject(cx: *mut JSContext, funobj: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn CloneFunctionObject1(cx: *mut JSContext, funobj: HandleObject, scopeChain: *mut AutoObjectVector) -> *mut JSObject); wrap!(jsapi: pub fn JS_BufferIsCompilableUnit(cx: *mut JSContext, obj: HandleObject, utf8: *const ::std::os::raw::c_char, length: usize) -> bool); wrap!(jsapi: pub fn JS_CompileScript(cx: *mut JSContext, ascii: *const ::std::os::raw::c_char, length: usize, options: *const CompileOptions, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn JS_CompileUCScript(cx: *mut JSContext, chars: *const ::std::os::raw::c_ushort, length: usize, options: *const CompileOptions, script: MutableHandleScript) -> bool); +wrap!(jsapi: pub fn JS_CompileUCScript(cx: *mut JSContext, chars: *const u16, length: usize, options: *const CompileOptions, script: MutableHandleScript) -> bool); wrap!(jsapi: pub fn JS_GetFunctionScript(cx: *mut JSContext, fun: HandleFunction) -> *mut JSScript); -wrap!(jsapi: pub fn Compile(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn Compile1(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn Compile2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const ::std::os::raw::c_ushort, length: usize, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn Compile3(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, file: *mut FILE, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn Compile4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn CompileForNonSyntacticScope(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn CompileForNonSyntacticScope1(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn CompileForNonSyntacticScope2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const ::std::os::raw::c_ushort, length: usize, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn CompileForNonSyntacticScope3(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, file: *mut FILE, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn CompileForNonSyntacticScope4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, script: MutableHandleScript) -> bool); -wrap!(jsapi: pub fn CompileFunction(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, chars: *const ::std::os::raw::c_ushort, length: usize, fun: MutableHandleFunction) -> bool); -wrap!(jsapi: pub fn CompileFunction1(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, srcBuf: *mut SourceBufferHolder, fun: MutableHandleFunction) -> bool); -wrap!(jsapi: pub fn CompileFunction2(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, name: *const ::std::os::raw::c_char, nargs: ::std::os::raw::c_uint, argnames: *const *const ::std::os::raw::c_char, bytes: *const ::std::os::raw::c_char, length: usize, fun: MutableHandleFunction) -> bool); -wrap!(jsapi: pub fn JS_DecompileScript(cx: *mut JSContext, script: Handle<*mut JSScript>, name: *const ::std::os::raw::c_char, indent: ::std::os::raw::c_uint) -> *mut JSString); -wrap!(jsapi: pub fn JS_DecompileFunction(cx: *mut JSContext, fun: Handle<*mut JSFunction>, indent: ::std::os::raw::c_uint) -> *mut JSString); +wrap!(jsapi: pub fn JS_DecompileScript(cx: *mut JSContext, script: Handle<*mut JSScript>) -> *mut JSString); +wrap!(jsapi: pub fn JS_DecompileFunction(cx: *mut JSContext, fun: Handle<*mut JSFunction>) -> *mut JSString); wrap!(jsapi: pub fn JS_ExecuteScript(cx: *mut JSContext, script: HandleScript, rval: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_ExecuteScript1(cx: *mut JSContext, script: HandleScript) -> bool); -wrap!(jsapi: pub fn JS_ExecuteScript2(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, script: HandleScript, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_ExecuteScript3(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, script: HandleScript) -> bool); -wrap!(jsapi: pub fn CloneAndExecuteScript(cx: *mut JSContext, script: Handle<*mut JSScript>) -> bool); -wrap!(jsapi: pub fn Evaluate(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn Evaluate1(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn Evaluate2(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, chars: *const ::std::os::raw::c_ushort, length: usize, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn Evaluate3(cx: *mut JSContext, scopeChain: *mut AutoObjectVector, options: *const ReadOnlyCompileOptions, chars: *const ::std::os::raw::c_ushort, length: usize, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn Evaluate4(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, bytes: *const ::std::os::raw::c_char, length: usize, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn Evaluate5(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, filename: *const ::std::os::raw::c_char, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn SetModuleResolveHook(cx: *mut JSContext, func: HandleFunction)); -wrap!(jsapi: pub fn CompileModule(cx: *mut JSContext, options: *const ReadOnlyCompileOptions, srcBuf: *mut SourceBufferHolder, moduleRecord: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn ModuleDeclarationInstantiation(cx: *mut JSContext, moduleRecord: HandleObject) -> bool); -wrap!(jsapi: pub fn ModuleEvaluation(cx: *mut JSContext, moduleRecord: HandleObject) -> bool); -wrap!(jsapi: pub fn GetRequestedModules(cx: *mut JSContext, moduleRecord: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn GetModuleScript(cx: *mut JSContext, moduleRecord: HandleObject) -> *mut JSScript); -wrap!(jsapi: pub fn NewPromiseObject(cx: *mut JSContext, executor: HandleObject, proto: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn IsPromiseObject(obj: HandleObject) -> bool); -wrap!(jsapi: pub fn GetPromiseState(promise: HandleObject) -> PromiseState); -wrap!(jsapi: pub fn GetPromiseID(promise: HandleObject) -> u64); -wrap!(jsapi: pub fn GetPromiseResult(promise: HandleObject) -> Value); -wrap!(jsapi: pub fn GetPromiseAllocationSite(promise: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn GetPromiseResolutionSite(promise: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn CallOriginalPromiseResolve(cx: *mut JSContext, resolutionValue: HandleValue) -> *mut JSObject); -wrap!(jsapi: pub fn CallOriginalPromiseReject(cx: *mut JSContext, rejectionValue: HandleValue) -> *mut JSObject); -wrap!(jsapi: pub fn ResolvePromise(cx: *mut JSContext, promise: HandleObject, resolutionValue: HandleValue) -> bool); -wrap!(jsapi: pub fn RejectPromise(cx: *mut JSContext, promise: HandleObject, rejectionValue: HandleValue) -> bool); -wrap!(jsapi: pub fn CallOriginalPromiseThen(cx: *mut JSContext, promise: HandleObject, onResolve: HandleObject, onReject: HandleObject) -> *mut JSObject); -wrap!(jsapi: pub fn AddPromiseReactions(cx: *mut JSContext, promise: HandleObject, onResolve: HandleObject, onReject: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_ExecuteScript2(cx: *mut JSContext, envChain: *mut AutoObjectVector, script: HandleScript, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ExecuteScript3(cx: *mut JSContext, envChain: *mut AutoObjectVector, script: HandleScript) -> bool); wrap!(jsapi: pub fn JS_AtomizeAndPinJSString(cx: *mut JSContext, str: HandleString) -> *mut JSString); wrap!(jsapi: pub fn JS_NewDependentString(cx: *mut JSContext, str: HandleString, start: usize, length: usize) -> *mut JSString); wrap!(jsapi: pub fn JS_ConcatStrings(cx: *mut JSContext, left: HandleString, right: HandleString) -> *mut JSString); wrap!(jsapi: pub fn JS_EncodeStringToUTF8(cx: *mut JSContext, str: HandleString) -> *mut ::std::os::raw::c_char); -wrap!(jsapi: pub fn NewAddonId(cx: *mut JSContext, str: HandleString) -> *mut JSAddonId); -wrap!(jsapi: pub fn NewSymbol(cx: *mut JSContext, description: HandleString) -> *mut Symbol); -wrap!(jsapi: pub fn GetSymbolFor(cx: *mut JSContext, key: HandleString) -> *mut Symbol); -wrap!(jsapi: pub fn GetSymbolDescription(symbol: HandleSymbol) -> *mut JSString); -wrap!(jsapi: pub fn GetSymbolCode(symbol: Handle<*mut Symbol>) -> SymbolCode); -wrap!(jsapi: pub fn PropertySpecNameEqualsId(name: *const ::std::os::raw::c_char, id: HandleId) -> bool); wrap!(jsapi: pub fn JS_Stringify(cx: *mut JSContext, value: MutableHandleValue, replacer: HandleObject, space: HandleValue, callback: JSONWriteCallback, data: *mut ::std::os::raw::c_void) -> bool); -wrap!(jsapi: pub fn ToJSONMaybeSafely(cx: *mut JSContext, input: HandleObject, callback: JSONWriteCallback, data: *mut ::std::os::raw::c_void) -> bool); -wrap!(jsapi: pub fn JS_ParseJSON(cx: *mut JSContext, chars: *const ::std::os::raw::c_ushort, len: u32, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ParseJSON(cx: *mut JSContext, chars: *const u16, len: u32, vp: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_ParseJSON1(cx: *mut JSContext, str: HandleString, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_ParseJSONWithReviver(cx: *mut JSContext, chars: *const ::std::os::raw::c_ushort, len: u32, reviver: HandleValue, vp: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_ParseJSONWithReviver(cx: *mut JSContext, chars: *const u16, len: u32, reviver: HandleValue, vp: MutableHandleValue) -> bool); wrap!(jsapi: pub fn JS_ParseJSONWithReviver1(cx: *mut JSContext, str: HandleString, reviver: HandleValue, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn CreateError(cx: *mut JSContext, type_: JSExnType, stack: HandleObject, fileName: HandleString, lineNumber: u32, columnNumber: u32, report: *mut JSErrorReport, message: HandleString, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn GetWeakMapEntry(cx: *mut JSContext, mapObj: HandleObject, key: HandleObject, val: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn SetWeakMapEntry(cx: *mut JSContext, mapObj: HandleObject, key: HandleObject, val: HandleValue) -> bool); -wrap!(jsapi: pub fn MapSize(cx: *mut JSContext, obj: HandleObject) -> u32); -wrap!(jsapi: pub fn MapGet(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn MapHas(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); -wrap!(jsapi: pub fn MapSet(cx: *mut JSContext, obj: HandleObject, key: HandleValue, val: HandleValue) -> bool); -wrap!(jsapi: pub fn MapDelete(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); -wrap!(jsapi: pub fn MapClear(cx: *mut JSContext, obj: HandleObject) -> bool); -wrap!(jsapi: pub fn MapKeys(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn MapValues(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn MapEntries(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn MapForEach(cx: *mut JSContext, obj: HandleObject, callbackFn: HandleValue, thisVal: HandleValue) -> bool); -wrap!(jsapi: pub fn SetSize(cx: *mut JSContext, obj: HandleObject) -> u32); -wrap!(jsapi: pub fn SetHas(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); -wrap!(jsapi: pub fn SetDelete(cx: *mut JSContext, obj: HandleObject, key: HandleValue, rval: *mut bool) -> bool); -wrap!(jsapi: pub fn SetAdd(cx: *mut JSContext, obj: HandleObject, key: HandleValue) -> bool); -wrap!(jsapi: pub fn SetClear(cx: *mut JSContext, obj: HandleObject) -> bool); -wrap!(jsapi: pub fn SetKeys(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn SetValues(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn SetEntries(cx: *mut JSContext, obj: HandleObject, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn SetForEach(cx: *mut JSContext, obj: HandleObject, callbackFn: HandleValue, thisVal: HandleValue) -> bool); wrap!(jsapi: pub fn JS_ObjectIsDate(cx: *mut JSContext, obj: HandleObject, isDate: *mut bool) -> bool); wrap!(jsapi: pub fn JS_SetRegExpInput(cx: *mut JSContext, obj: HandleObject, input: HandleString) -> bool); wrap!(jsapi: pub fn JS_ClearRegExpStatics(cx: *mut JSContext, obj: HandleObject) -> bool); -wrap!(jsapi: pub fn JS_ExecuteRegExp(cx: *mut JSContext, obj: HandleObject, reobj: HandleObject, chars: *mut ::std::os::raw::c_ushort, length: usize, indexp: *mut usize, test: bool, rval: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn JS_ExecuteRegExpNoStatics(cx: *mut JSContext, reobj: HandleObject, chars: *mut ::std::os::raw::c_ushort, length: usize, indexp: *mut usize, test: bool, rval: MutableHandleValue) -> bool); +wrap!(jsapi: pub fn JS_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_ErrorFromException(cx: *mut JSContext, obj: HandleObject) -> *mut JSErrorReport); -wrap!(jsapi: pub fn ExceptionStackOrNull(obj: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_IndexToId(cx: *mut JSContext, index: u32, arg1: MutableHandleId) -> bool); wrap!(jsapi: pub fn JS_CharsToId(cx: *mut JSContext, chars: TwoByteChars, arg1: MutableHandleId) -> bool); wrap!(jsapi: pub fn JS_IsIdentifier(cx: *mut JSContext, str: HandleString, isIdentifier: *mut bool) -> bool); -wrap!(jsapi: pub fn JS_EncodeScript(cx: *mut JSContext, script: HandleScript, lengthp: *mut u32) -> *mut ::std::os::raw::c_void); -wrap!(jsapi: pub fn JS_EncodeInterpretedFunction(cx: *mut JSContext, funobj: HandleObject, lengthp: *mut u32) -> *mut ::std::os::raw::c_void); -wrap!(jsapi: pub fn CaptureCurrentStack(cx: *mut JSContext, stackp: MutableHandleObject, maxFrameCount: ::std::os::raw::c_uint) -> bool); -wrap!(jsapi: pub fn CopyAsyncStack(cx: *mut JSContext, asyncStack: HandleObject, asyncCause: HandleString, stackp: MutableHandleObject, maxFrameCount: ::std::os::raw::c_uint) -> bool); -wrap!(jsapi: pub fn GetSavedFrameSource(cx: *mut JSContext, savedFrame: HandleObject, sourcep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); -wrap!(jsapi: pub fn GetSavedFrameLine(cx: *mut JSContext, savedFrame: HandleObject, linep: *mut u32, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); -wrap!(jsapi: pub fn GetSavedFrameColumn(cx: *mut JSContext, savedFrame: HandleObject, columnp: *mut u32, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); -wrap!(jsapi: pub fn GetSavedFrameFunctionDisplayName(cx: *mut JSContext, savedFrame: HandleObject, namep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); -wrap!(jsapi: pub fn GetSavedFrameAsyncCause(cx: *mut JSContext, savedFrame: HandleObject, asyncCausep: MutableHandleString, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); -wrap!(jsapi: pub fn GetSavedFrameAsyncParent(cx: *mut JSContext, savedFrame: HandleObject, asyncParentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); -wrap!(jsapi: pub fn GetSavedFrameParent(cx: *mut JSContext, savedFrame: HandleObject, parentp: MutableHandleObject, selfHosted: SavedFrameSelfHosted) -> SavedFrameResult); -wrap!(jsapi: pub fn BuildStackString(cx: *mut JSContext, stack: HandleObject, stringp: MutableHandleString, indent: usize) -> bool); wrap!(jsapi: pub fn JS_FindCompilationScope(cx: *mut JSContext, obj: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_SplicePrototype(cx: *mut JSContext, obj: HandleObject, proto: HandleObject) -> bool); wrap!(jsapi: pub fn JS_NewObjectWithUniqueType(cx: *mut JSContext, clasp: *const JSClass, proto: HandleObject) -> *mut JSObject); @@ -271,32 +346,10 @@ wrap!(jsapi: pub fn JS_NondeterministicGetWeakSetKeys(cx: *mut JSContext, obj: H wrap!(jsapi: pub fn JS_CloneObject(cx: *mut JSContext, obj: HandleObject, proto: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_InitializePropertiesFromCompatibleNativeObject(cx: *mut JSContext, dst: HandleObject, src: HandleObject) -> bool); wrap!(jsapi: pub fn JS_BasicObjectToString(cx: *mut JSContext, obj: HandleObject) -> *mut JSString); -wrap!(jsapi: pub fn GetBuiltinClass(cx: *mut JSContext, obj: HandleObject, cls: *mut ESClass) -> bool); -wrap!(jsapi: pub fn ObjectClassName(cx: *mut JSContext, obj: HandleObject) -> *const ::std::os::raw::c_char); -wrap!(jsapi: pub fn ForceLexicalInitialization(cx: *mut JSContext, obj: HandleObject) -> bool); wrap!(jsapi: pub fn JS_CopyPropertiesFrom(cx: *mut JSContext, target: HandleObject, obj: HandleObject) -> bool); wrap!(jsapi: pub fn JS_CopyPropertyFrom(cx: *mut JSContext, id: HandleId, target: HandleObject, obj: HandleObject, copyBehavior: PropertyCopyBehavior) -> bool); wrap!(jsapi: pub fn JS_WrapPropertyDescriptor(cx: *mut JSContext, desc: MutableHandle) -> bool); wrap!(jsapi: pub fn JS_DefineFunctionsWithHelp(cx: *mut JSContext, obj: HandleObject, fs: *const JSFunctionSpecWithHelp) -> bool); -wrap!(jsapi: pub fn proxy_LookupProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, objp: MutableHandleObject, propp: MutableHandle<*mut Shape>) -> bool); -wrap!(jsapi: pub fn proxy_DefineProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: Handle, result: *mut ObjectOpResult) -> bool); -wrap!(jsapi: pub fn proxy_HasProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, foundp: *mut bool) -> bool); -wrap!(jsapi: pub fn proxy_GetProperty(cx: *mut JSContext, obj: HandleObject, receiver: HandleValue, id: HandleId, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn proxy_SetProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, bp: HandleValue, receiver: HandleValue, result: *mut ObjectOpResult) -> bool); -wrap!(jsapi: pub fn proxy_GetOwnPropertyDescriptor(cx: *mut JSContext, obj: HandleObject, id: HandleId, desc: MutableHandle) -> bool); -wrap!(jsapi: pub fn proxy_DeleteProperty(cx: *mut JSContext, obj: HandleObject, id: HandleId, result: *mut ObjectOpResult) -> bool); -wrap!(jsapi: pub fn proxy_Convert(cx: *mut JSContext, proxy: HandleObject, hint: JSType, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn proxy_HasInstance(cx: *mut JSContext, proxy: HandleObject, v: MutableHandleValue, bp: *mut bool) -> bool); -wrap!(jsapi: pub fn proxy_Watch(cx: *mut JSContext, obj: HandleObject, id: HandleId, callable: HandleObject) -> bool); -wrap!(jsapi: pub fn proxy_Unwatch(cx: *mut JSContext, obj: HandleObject, id: HandleId) -> bool); -wrap!(jsapi: pub fn proxy_GetElements(cx: *mut JSContext, proxy: HandleObject, begin: u32, end: u32, adder: *mut ElementAdder) -> bool); -wrap!(jsapi: pub fn proxy_FunToString(cx: *mut JSContext, proxy: HandleObject, indent: ::std::os::raw::c_uint) -> *mut JSString); -wrap!(jsapi: pub fn GetObjectProto(cx: *mut JSContext, obj: HandleObject, proto: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn GetOriginalEval(cx: *mut JSContext, scope: HandleObject, eval: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn GetPropertyKeys(cx: *mut JSContext, obj: HandleObject, flags: ::std::os::raw::c_uint, props: *mut AutoIdVector) -> bool); -wrap!(jsapi: pub fn RegExpToSharedNonInline(cx: *mut JSContext, regexp: HandleObject, shared: *mut RegExpGuard) -> bool); -wrap!(jsapi: pub fn DateIsValid(cx: *mut JSContext, obj: HandleObject, isValid: *mut bool) -> bool); -wrap!(jsapi: pub fn DateGetMsecSinceEpoch(cx: *mut JSContext, obj: HandleObject, msecSinceEpoch: *mut f64) -> bool); wrap!(jsapi: pub fn JS_NewInt8ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_NewUint8ArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); wrap!(jsapi: pub fn JS_NewUint8ClampedArrayFromArray(cx: *mut JSContext, array: HandleObject) -> *mut JSObject); @@ -316,28 +369,7 @@ wrap!(jsapi: pub fn JS_NewUint32ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: wrap!(jsapi: pub fn JS_NewFloat32ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); wrap!(jsapi: pub fn JS_NewFloat64ArrayWithBuffer(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, length: i32) -> *mut JSObject); wrap!(jsapi: pub fn JS_GetArrayBufferViewBuffer(cx: *mut JSContext, obj: HandleObject, isSharedMemory: *mut bool) -> *mut JSObject); -wrap!(jsapi: pub fn JS_DetachArrayBuffer(cx: *mut JSContext, obj: HandleObject, changeData: DetachDataDisposition) -> bool); -wrap!(jsapi: pub fn JS_NewDataView(cx: *mut JSContext, arrayBuffer: HandleObject, byteOffset: u32, byteLength: i32) -> *mut JSObject); -wrap!(jsapi: pub fn WatchGuts(cx: *mut JSContext, obj: HandleObject, id: HandleId, callable: HandleObject) -> bool); -wrap!(jsapi: pub fn UnwatchGuts(cx: *mut JSContext, obj: HandleObject, id: HandleId) -> bool); -wrap!(jsapi: pub fn PrepareScriptEnvironmentAndInvoke(cx: *mut JSContext, scope: HandleObject, closure: *mut ScriptEnvironmentPreparer_Closure)); -wrap!(jsapi: pub fn GetElementsWithAdder(cx: *mut JSContext, obj: HandleObject, receiver: HandleObject, begin: u32, end: u32, adder: *mut ElementAdder) -> bool); -wrap!(jsapi: pub fn SetPropertyIgnoringNamedGetter(cx: *mut JSContext, obj: HandleObject, id: HandleId, v: HandleValue, receiver: HandleValue, ownDesc: Handle, result: *mut ObjectOpResult) -> bool); -wrap!(jsapi: pub fn ReportErrorWithId(cx: *mut JSContext, msg: *const ::std::os::raw::c_char, id: HandleId)); -wrap!(jsapi: pub fn ExecuteInGlobalAndReturnScope(cx: *mut JSContext, obj: HandleObject, script: HandleScript, scope: MutableHandleObject) -> bool); -wrap!(jsapi: pub fn GetFirstSubsumedSavedFrame(cx: *mut JSContext, savedFrame: HandleObject, selfHosted: SavedFrameSelfHosted) -> *mut JSObject); -wrap!(jsapi: pub fn ReportIsNotFunction(cx: *mut JSContext, v: HandleValue) -> bool); -wrap!(jsapi: pub fn SetWindowProxy(cx: *mut JSContext, global: HandleObject, windowProxy: HandleObject)); -wrap!(jsapi: pub fn ToBooleanSlow(v: HandleValue) -> bool); -wrap!(jsapi: pub fn ToInt8Slow(cx: *mut JSContext, v: HandleValue, out: *mut i8) -> bool); -wrap!(jsapi: pub fn ToUint8Slow(cx: *mut JSContext, v: HandleValue, out: *mut u8) -> bool); -wrap!(jsapi: pub fn ToInt16Slow(cx: *mut JSContext, v: HandleValue, out: *mut i16) -> bool); -wrap!(jsapi: pub fn ToInt32Slow(cx: *mut JSContext, v: HandleValue, out: *mut i32) -> bool); -wrap!(jsapi: pub fn ToUint32Slow(cx: *mut JSContext, v: HandleValue, out: *mut u32) -> bool); -wrap!(jsapi: pub fn ToUint16Slow(cx: *mut JSContext, v: HandleValue, out: *mut u16) -> bool); -wrap!(jsapi: pub fn ToInt64Slow(cx: *mut JSContext, v: HandleValue, out: *mut i64) -> bool); -wrap!(jsapi: pub fn ToUint64Slow(cx: *mut JSContext, v: HandleValue, out: *mut u64) -> bool); -wrap!(jsapi: pub fn ToStringSlow(cx: *mut JSContext, v: HandleValue) -> *mut JSString); -wrap!(jsapi: pub fn ToObjectSlow(cx: *mut JSContext, v: HandleValue, reportScanStack: bool) -> *mut JSObject); -wrap!(jsapi: pub fn OrdinaryToPrimitive(cx: *mut JSContext, obj: HandleObject, type_: JSType, vp: MutableHandleValue) -> bool); -wrap!(jsapi: pub fn AddSizeOfTab(rt: *mut JSRuntime, obj: HandleObject, mallocSizeOf: MallocSizeOf, opv: *mut ObjectPrivateVisitor, sizes: *mut TabSizes) -> bool); +wrap!(jsapi: pub fn JS_DetachArrayBuffer(cx: *mut JSContext, obj: HandleObject) -> bool); +wrap!(jsapi: pub fn JS_NewDataView(cx: *mut JSContext, buffer: HandleObject, byteOffset: u32, byteLength: i32) -> *mut JSObject); +wrap!(jsapi: pub fn JS_ForOfIteratorInit(iterator: *mut ForOfIterator, iterable: HandleValue, nonIterableBehavior: ForOfIterator_NonIterableBehavior) -> bool); +wrap!(jsapi: pub fn JS_ForOfIteratorNext(iterator: *mut ForOfIterator, val: MutableHandleValue, done: *mut bool) -> bool); diff --git a/src/jsglue.cpp b/src/jsglue.cpp index 17c18b52a..3fbf8f7bc 100644 --- a/src/jsglue.cpp +++ b/src/jsglue.cpp @@ -16,9 +16,9 @@ #include "jsfriendapi.h" #include "js/Proxy.h" #include "js/Class.h" -#include "jswrapper.h" #include "js/MemoryMetrics.h" #include "js/Principals.h" +#include "js/Wrapper.h" #include "assert.h" typedef bool(*WantToMeasure)(JSObject *obj); @@ -42,8 +42,7 @@ struct ProxyTraps { bool (*delete_)(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult &result); - bool (*enumerate)(JSContext *cx, JS::HandleObject proxy, - JS::MutableHandleObject objp); + JSObject* (*enumerate)(JSContext *cx, JS::HandleObject proxy); bool (*getPrototypeIfOrdinary)(JSContext *cx, JS::HandleObject proxy, bool *isOrdinary, JS::MutableHandleObject protop); @@ -83,21 +82,19 @@ struct ProxyTraps { bool (*objectClassIs)(JS::HandleObject obj, js::ESClass classValue, JSContext *cx); const char *(*className)(JSContext *cx, JS::HandleObject proxy); - JSString *(*fun_toString)(JSContext *cx, JS::HandleObject proxy, - unsigned indent); + JSString* (*fun_toString)(JSContext *cx, JS::HandleObject proxy, + bool isToString); //bool (*regexp_toShared)(JSContext *cx, JS::HandleObject proxy, RegExpGuard *g); bool (*boxedValue_unbox)(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleValue vp); bool (*defaultValue)(JSContext *cx, JS::HandleObject obj, JSType hint, JS::MutableHandleValue vp); void (*trace)(JSTracer *trc, JSObject *proxy); void (*finalize)(JSFreeOp *fop, JSObject *proxy); - void (*objectMoved)(JSObject *proxy, const JSObject *old); + size_t (*objectMoved)(JSObject *proxy, JSObject *old); bool (*isCallable)(JSObject *obj); bool (*isConstructor)(JSObject *obj); - // watch - // unwatch // getElements // weakmapKeyDelegate @@ -108,21 +105,13 @@ static int HandlerFamily; #define DEFER_TO_TRAP_OR_BASE_CLASS(_base) \ \ - virtual bool enter(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, \ - _base::Action action, bool *bp) const override \ - { \ - return mTraps.enter \ - ? mTraps.enter(cx, proxy, id, action, bp) \ - : _base::enter(cx, proxy, id, action, bp); \ - } \ - \ /* Standard internal methods. */ \ - virtual bool enumerate(JSContext *cx, JS::HandleObject proxy, \ - JS::MutableHandleObject objp) const override \ + virtual JSObject* enumerate(JSContext *cx, \ + JS::HandleObject proxy) const override \ { \ return mTraps.enumerate \ - ? mTraps.enumerate(cx, proxy, objp) \ - : _base::enumerate(cx, proxy, objp); \ + ? mTraps.enumerate(cx, proxy) \ + : _base::enumerate(cx, proxy); \ } \ \ virtual bool has(JSContext* cx, JS::HandleObject proxy, \ @@ -134,7 +123,7 @@ static int HandlerFamily; } \ \ virtual bool get(JSContext* cx, JS::HandleObject proxy, \ - JS::HandleValue receiver, \ + JS::HandleValue receiver, \ JS::HandleId id, JS::MutableHandleValue vp) const override \ { \ return mTraps.get \ @@ -211,11 +200,11 @@ static int HandlerFamily; } \ \ virtual JSString* fun_toString(JSContext* cx, JS::HandleObject proxy, \ - unsigned indent) const override \ + bool isToString) const override \ { \ return mTraps.fun_toString \ - ? mTraps.fun_toString(cx, proxy, indent) \ - : _base::fun_toString(cx, proxy, indent); \ + ? mTraps.fun_toString(cx, proxy, isToString) \ + : _base::fun_toString(cx, proxy, isToString); \ } \ \ virtual bool boxedValue_unbox(JSContext* cx, JS::HandleObject proxy, \ @@ -240,12 +229,11 @@ static int HandlerFamily; : _base::finalize(fop, proxy); \ } \ \ - virtual void objectMoved(JSObject* proxy, \ - const JSObject *old) const override \ + virtual size_t objectMoved(JSObject* proxy, JSObject *old) const override \ { \ - mTraps.objectMoved \ - ? mTraps.objectMoved(proxy, old) \ - : _base::objectMoved(proxy, old); \ + return mTraps.objectMoved \ + ? mTraps.objectMoved(proxy, old) \ + : _base::objectMoved(proxy, old); \ } \ \ virtual bool isCallable(JSObject* obj) const override \ @@ -269,7 +257,7 @@ class WrapperProxyHandler : public js::Wrapper WrapperProxyHandler(const ProxyTraps& aTraps) : js::Wrapper(0), mTraps(aTraps) {} - virtual bool finalizeInBackground(JS::Value priv) const override + virtual bool finalizeInBackground(const JS::Value& priv) const override { return false; } @@ -344,7 +332,7 @@ class RustJSPrincipal : public JSPrincipals bool (*writeCallback)(JSContext* cx, JSStructuredCloneWriter* writer); public: - RustJSPrincipal(const void* origin, + RustJSPrincipal(const void* origin, void (*destroy)(JSPrincipals *principal), bool (*write)(JSContext* cx, JSStructuredCloneWriter* writer)) : JSPrincipals() { @@ -381,7 +369,7 @@ class ForwardingProxyHandler : public js::BaseProxyHandler return mExtra; } - virtual bool finalizeInBackground(JS::Value priv) const override + virtual bool finalizeInBackground(const JS::Value& priv) const override { return false; } @@ -515,10 +503,10 @@ InvokeHasOwn( hasOwn(cx, proxy, id, bp); } -JS::Value -RUST_JS_NumberValue(double d) +void +RUST_JS_NumberValue(double d, JS::Value* dest) { - return JS_NumberValue(d); + *dest = JS_NumberValue(d); } const JSJitInfo* @@ -589,7 +577,6 @@ NewCompileOptions(JSContext* aCx, const char* aFile, unsigned aLine) { JS::OwningCompileOptions *opts = new JS::OwningCompileOptions(aCx); opts->setFileAndLine(aCx, aFile, aLine); - opts->setVersion(JSVERSION_DEFAULT); return opts; } @@ -621,19 +608,9 @@ WrapperNew(JSContext* aCx, JS::HandleObject aObj, const void* aHandler, return js::Wrapper::New(aCx, aObj, (const js::Wrapper*)aHandler, options); } -void WindowProxyObjectMoved(JSObject*, const JSObject*) -{ - abort(); -} - -static const js::ClassExtension WindowProxyClassExtension = PROXY_MAKE_EXT( - WindowProxyObjectMoved -); - -const js::Class WindowProxyClass = PROXY_CLASS_WITH_EXT( +const js::Class WindowProxyClass = PROXY_CLASS_DEF( "Proxy", - 0, /* additional class flags */ - &WindowProxyClassExtension); + JSCLASS_HAS_RESERVED_SLOTS(1)); /* additional class flags */ const js::Class* GetWindowProxyClass() @@ -647,22 +624,28 @@ NewWindowProxy(JSContext* aCx, JS::HandleObject aObj, const void* aHandler) return WrapperNew(aCx, aObj, aHandler, Jsvalify(&WindowProxyClass), true); } -JS::Value -GetProxyExtra(JSObject* obj, uint32_t slot) +void +GetProxyReservedSlot(JSObject* obj, uint32_t slot, JS::Value* dest) +{ + *dest = js::GetProxyReservedSlot(obj, slot); +} + +void +GetProxyPrivate(JSObject* obj, JS::Value* dest) { - return js::GetProxyExtra(obj, slot); + *dest = js::GetProxyPrivate(obj); } -JS::Value -GetProxyPrivate(JSObject* obj) +void +SetProxyReservedSlot(JSObject* obj, uint32_t slot, const JS::Value* val) { - return js::GetProxyPrivate(obj); + js::SetProxyReservedSlot(obj, slot, *val); } void -SetProxyExtra(JSObject* obj, uint32_t slot, const JS::Value& val) +SetProxyPrivate(JSObject* obj, const JS::Value* expando) { - js::SetProxyExtra(obj, slot, val); + js::SetProxyPrivate(obj, *expando); } bool @@ -701,6 +684,12 @@ RUST_SYMBOL_TO_JSID(JS::Symbol* sym) return SYMBOL_TO_JSID(sym); } +bool +SetBuildId(JS::BuildIdCharVector* buildId, const char* chars, size_t len) { + buildId->clear(); + return buildId->append(chars, len); +} + void RUST_SET_JITINFO(JSFunction* func, const JSJitInfo* info) { SET_JITINFO(func, info); @@ -720,7 +709,8 @@ RUST_js_GetErrorMessage(void* userRef, uint32_t errorNumber) bool IsProxyHandlerFamily(JSObject* obj) { - return js::GetProxyHandler(obj)->family() == &HandlerFamily; + auto family = js::GetProxyHandler(obj)->family(); + return family == &HandlerFamily; } const void* @@ -746,14 +736,25 @@ GetProxyHandler(JSObject* obj) } void -ReportError(JSContext* aCx, const char* aError) +ReportErrorASCII(JSContext* aCx, const char* aError) +{ +#ifdef DEBUG + for (const char* p = aError; *p; ++p) { + assert(*p != '%'); + } +#endif + JS_ReportErrorASCII(aCx, "%s", aError); +} + +void +ReportErrorUTF8(JSContext* aCx, const char* aError) { #ifdef DEBUG for (const char* p = aError; *p; ++p) { assert(*p != '%'); } #endif - JS_ReportError(aCx, aError); + JS_ReportErrorUTF8(aCx, "%s", aError); } bool @@ -822,8 +823,6 @@ DeleteAutoObjectVector(JS::AutoObjectVector* v) #include #elif defined(__APPLE__) #include -#elif defined(__FreeBSD__) - #include #elif defined(__MINGW32__) || defined(__MINGW64__) // nothing needed here #elif defined(_MSC_VER) @@ -835,7 +834,7 @@ DeleteAutoObjectVector(JS::AutoObjectVector* v) // SpiderMonkey-in-Rust currently uses system malloc, not jemalloc. static size_t MallocSizeOf(const void* aPtr) { -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) return malloc_usable_size((void*)aPtr); #elif defined(__APPLE__) return malloc_size((void*)aPtr); @@ -849,13 +848,13 @@ static size_t MallocSizeOf(const void* aPtr) } bool -CollectServoSizes(JSRuntime *rt, JS::ServoSizes *sizes, GetSize gs) +CollectServoSizes(JSContext* cx, JS::ServoSizes *sizes, GetSize gs) { mozilla::PodZero(sizes); ServoDOMVisitor sdv(gs, ShouldMeasureObject); - return JS::AddServoSizeOf(rt, MallocSizeOf, &sdv, sizes); + return JS::AddServoSizeOf(cx, MallocSizeOf, &sdv, sizes); } void @@ -917,6 +916,16 @@ CallValueRootTracer(JSTracer* trc, JS::Value* valp, const char* name) JS::UnsafeTraceRoot(trc, valp, name); } +bool +IsDebugBuild() +{ +#ifdef JS_DEBUG + return true; +#else + return false; +#endif +} + #define JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Type, type) \ void \ Get ## Type ## ArrayLengthAndData(JSObject* obj, uint32_t* length, \ @@ -938,4 +947,108 @@ JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Float64, double) #undef JS_DEFINE_DATA_AND_LENGTH_ACCESSOR +JSAutoStructuredCloneBuffer* +NewJSAutoStructuredCloneBuffer(JS::StructuredCloneScope scope, + const JSStructuredCloneCallbacks* callbacks) +{ + return js_new(scope, callbacks, nullptr); +} + +void +DeleteJSAutoStructuredCloneBuffer(JSAutoStructuredCloneBuffer* buf) +{ + js_delete(buf); +} + +size_t +GetLengthOfJSStructuredCloneData(JSStructuredCloneData* data) +{ + assert(data != nullptr); + + size_t len = 0; + + auto iter = data->Iter(); + while (!iter.Done()) { + size_t len_of_this_segment = iter.RemainingInSegment(); + len += len_of_this_segment; + iter.Advance(*data, len_of_this_segment); + } + + return len; +} + +void +CopyJSStructuredCloneData(JSStructuredCloneData* src, uint8_t* dest) +{ + assert(src != nullptr); + assert(dest != nullptr); + + size_t bytes_copied = 0; + + auto iter = src->Iter(); + while (!iter.Done()) { + size_t len_of_this_segment = iter.RemainingInSegment(); + memcpy(dest + bytes_copied, iter.Data(), len_of_this_segment); + bytes_copied += len_of_this_segment; + iter.Advance(*src, len_of_this_segment); + } +} + +bool +WriteBytesToJSStructuredCloneData(const uint8_t* src, size_t len, JSStructuredCloneData* dest) +{ + assert(src != nullptr); + assert(dest != nullptr); + + return dest->WriteBytes(reinterpret_cast(src), len); +} + +// MSVC uses a different calling conventions for functions +// that return non-POD values. Unfortunately, this includes anything +// with a constructor, such as JS::Value, so we can't call these +// from Rust. These wrapper functions are only here to +// ensure the calling convention is right. +// https://docs.microsoft.com/en-us/cpp/build/return-values-cpp +// https://mozilla.logbot.info/jsapi/20180622#c14918658 + +void +JS_ComputeThis(JSContext* cx, JS::Value* vp, JS::Value* dest) { + *dest = JS::detail::ComputeThis(cx, vp); +} + +void +JS_GetModuleHostDefinedField(JSObject* module, JS::Value* dest) { + *dest = JS::GetModuleHostDefinedField(module); +} + +void +JS_GetPromiseResult(JS::HandleObject promise, JS::Value* dest) { + *dest = JS::GetPromiseResult(promise); +} + +void +JS_THIS(JSContext* cx, JS::Value* vp, JS::Value* dest) { + *dest = JS_THIS(cx, vp); +} + +void +JS_GetNaNValue(JSContext* cx, JS::Value* dest) { + *dest = JS_GetNaNValue(cx); +} + +void +JS_GetPositiveInfinityValue(JSContext* cx, JS::Value* dest) { + *dest = JS_GetPositiveInfinityValue(cx); +} + +void +JS_GetEmptyStringValue(JSContext* cx, JS::Value* dest) { + *dest = JS_GetEmptyStringValue(cx); +} + +void +JS_GetReservedSlot(JSObject* obj, uint32_t index, JS::Value* dest) { + *dest = JS_GetReservedSlot(obj, index); +} + } // extern "C" diff --git a/src/lib.rs b/src/lib.rs index b13cebddd..9d6b010a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,9 +20,11 @@ pub mod jsapi { pub use mozjs_sys::jsapi::JS::*; pub use mozjs_sys::jsapi::js::*; pub use mozjs_sys::jsapi::js::detail::*; + pub use mozjs_sys::jsapi::JS::detail::*; pub use mozjs_sys::jsapi::js::shadow::{Object, ObjectGroup}; pub use mozjs_sys::jsapi::js::Scalar::{Type}; pub use mozjs_sys::jsapi::mozilla::{MallocSizeOf}; + pub use mozjs_sys::jsapi::glue::*; } #[macro_use] diff --git a/src/rust.rs b/src/rust.rs index a1f2b9603..fefed6ef7 100644 --- a/src/rust.rs +++ b/src/rust.rs @@ -5,7 +5,7 @@ //! Rust wrappers around the raw JS apis -use libc::{size_t, c_uint, c_char, c_void}; +use libc::{size_t, c_uint}; use mozjs_sys::jsgc::CustomAutoRooterVFTable; use mozjs_sys::jsgc::RootKind; @@ -16,12 +16,14 @@ use std::char; use std::ffi; use std::ptr; use std::slice; +use std::str; use std::u32; use std::default::Default; use std::ops::{Deref, DerefMut}; +use std::os::raw::c_void; use std::cell::Cell; use std::marker::PhantomData; -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering}; use consts::{JSCLASS_RESERVED_SLOTS_MASK, JSCLASS_GLOBAL_SLOT_COUNT}; use consts::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; @@ -29,26 +31,28 @@ use consts::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; use conversions::jsstr_to_string; use jsapi; -use jsapi::{AutoGCRooter, AutoGCRooter_CUSTOM, AutoIdVector, AutoObjectVector, ContextFriendFields}; -use jsapi::{Evaluate2, HandleValueArray, Heap}; +use jsapi::{AutoGCRooter, AutoGCRooter_CUSTOM, AutoIdVector, AutoObjectVector}; +use jsapi::{ContextOptionsRef, Evaluate2, HandleValueArray, Heap}; use jsapi::{InitSelfHostedCode, IsWindowSlow, JS_BeginRequest}; -use jsapi::{JS_DefineFunctions, JS_DefineProperties, JS_DestroyRuntime, JS_EndRequest, JS_ShutDown}; -use jsapi::{JS_EnumerateStandardClasses, JS_GetContext, JS_GlobalObjectTraceHook}; -use jsapi::{JS_Init, JS_MayResolveStandardClass, JS_NewRuntime, JS_ResolveStandardClass}; +use jsapi::{JS_DefineFunctions, JS_DefineProperties, JS_DestroyContext, JS_EndRequest, JS_ShutDown}; +use jsapi::{JS_EnumerateStandardClasses, JS_GetRuntime, JS_GlobalObjectTraceHook}; +use jsapi::{JS_MayResolveStandardClass, JS_NewContext, JS_ResolveStandardClass}; use jsapi::{JS_SetGCParameter, JS_SetNativeStackQuota, JS_WrapValue, JSAutoCompartment}; use jsapi::{JSClass, JSCLASS_RESERVED_SLOTS_SHIFT, JSClassOps, JSCompartment, JSContext}; use jsapi::{JSErrorReport, JSFunction, JSFunctionSpec, JSGCParamKey}; use jsapi::{JSObject, JSPropertySpec, JSRuntime, JSScript}; use jsapi::{JSString, JSTracer}; -use jsapi::{Object, ObjectGroup,ReadOnlyCompileOptions, Rooted}; -use jsapi::{RuntimeOptionsRef, SetWarningReporter, Symbol, ToBooleanSlow}; +use jsapi::{Object, ObjectGroup,ReadOnlyCompileOptions, Rooted, RootingContext}; +use jsapi::{SetWarningReporter, Symbol, ToBooleanSlow}; use jsapi::{ToInt32Slow, ToInt64Slow, ToNumberSlow, ToStringSlow, ToUint16Slow}; -use jsapi::{ToUint32Slow, ToUint64Slow, ToWindowProxyIfWindow}; +use jsapi::{ToUint32Slow, ToUint64Slow, ToWindowProxyIfWindowSlow}; use jsapi::{Value, jsid}; -use jsapi::{CaptureCurrentStack, BuildStackString, IsSavedFrame}; +use jsapi::{CaptureCurrentStack, BuildStackString, IsSavedFrame, StackFormat}; +use jsapi::{JS_StackCapture_AllFrames, JS_StackCapture_MaxFrames}; use jsapi::Handle as RawHandle; use jsapi::MutableHandle as RawMutableHandle; use jsapi::HandleValue as RawHandleValue; +use jsapi::glue::JS_Init; #[cfg(feature = "debugmozjs")] use jsapi::mozilla::detail::GuardObjectNotificationReceiver; @@ -121,13 +125,13 @@ impl ToResult for bool { thread_local!(static CONTEXT: Cell<*mut JSContext> = Cell::new(ptr::null_mut())); lazy_static! { + static ref PARENT: AtomicPtr = AtomicPtr::new(ptr::null_mut()); static ref OUTSTANDING_RUNTIMES: AtomicUsize = AtomicUsize::new(0); static ref SHUT_DOWN: AtomicBool = AtomicBool::new(false); } -/// A wrapper for the `JSRuntime` and `JSContext` structures in SpiderMonkey. +/// A wrapper for the `JSContext` structure in SpiderMonkey. pub struct Runtime { - rt: *mut JSRuntime, cx: *mut JSContext, } @@ -141,36 +145,34 @@ impl Runtime { cx } - /// Creates a new `JSRuntime` and `JSContext`. + /// Creates a new `JSContext`. pub fn new() -> Result { - if SHUT_DOWN.load(Ordering::SeqCst) { - return Err(()); - } - - OUTSTANDING_RUNTIMES.fetch_add(1, Ordering::SeqCst); - unsafe { - struct TopRuntime(*mut JSRuntime); - unsafe impl Sync for TopRuntime {} - - lazy_static! { - static ref PARENT: TopRuntime = { - unsafe { - assert!(JS_Init()); - let runtime = JS_NewRuntime( - default_heapsize, ChunkSize as u32, ptr::null_mut()); - assert!(!runtime.is_null()); - let context = JS_GetContext(runtime); - assert!(!context.is_null()); - InitSelfHostedCode(context); - TopRuntime(runtime) - } - }; + if SHUT_DOWN.load(Ordering::SeqCst) { + return Err(()); } - let js_runtime = - JS_NewRuntime(default_heapsize, ChunkSize as u32, PARENT.0); - assert!(!js_runtime.is_null()); + let outstanding = OUTSTANDING_RUNTIMES.fetch_add(1, Ordering::SeqCst); + + let js_context = if outstanding == 0 { + // We are creating the first JSContext, so we need to initialize + // the runtime. + assert!(JS_Init()); + let js_context = JS_NewContext(default_heapsize, ChunkSize as u32, ptr::null_mut()); + let parent_runtime = JS_GetRuntime(js_context); + assert!(!parent_runtime.is_null()); + let old_runtime = PARENT.compare_and_swap(ptr::null_mut(), parent_runtime, Ordering::SeqCst); + assert!(old_runtime.is_null()); + // TODO: should we use the internal job queues or not? + // assert!(UseInternalJobQueues(js_context, false)); + js_context + } else { + let parent_runtime = PARENT.load(Ordering::SeqCst); + assert!(!parent_runtime.is_null()); + 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 // triggering GC too often if operating continuously near an arbitrary @@ -178,17 +180,14 @@ impl Runtime { // still in effect to cause periodical, and we hope hygienic, // last-ditch GCs from within the GC's allocator. JS_SetGCParameter( - js_runtime, JSGCParamKey::JSGC_MAX_BYTES, u32::MAX); + js_context, JSGCParamKey::JSGC_MAX_BYTES, u32::MAX); JS_SetNativeStackQuota( - js_runtime, + js_context, STACK_QUOTA, STACK_QUOTA - SYSTEM_CODE_BUFFER, STACK_QUOTA - SYSTEM_CODE_BUFFER - TRUSTED_SCRIPT_BUFFER); - let js_context = JS_GetContext(js_runtime); - assert!(!js_context.is_null()); - CONTEXT.with(|context| { assert!(context.get().is_null()); context.set(js_context); @@ -196,17 +195,16 @@ impl Runtime { InitSelfHostedCode(js_context); - let runtimeopts = RuntimeOptionsRef(js_runtime); - (*runtimeopts).set_baseline_(true); - (*runtimeopts).set_ion_(true); - (*runtimeopts).set_nativeRegExp_(true); + let contextopts = ContextOptionsRef(js_context); + (*contextopts).set_baseline_(true); + (*contextopts).set_ion_(true); + (*contextopts).set_nativeRegExp_(true); - SetWarningReporter(js_runtime, Some(report_warning)); + SetWarningReporter(js_context, Some(report_warning)); JS_BeginRequest(js_context); Ok(Runtime { - rt: js_runtime, cx: js_context, }) } @@ -214,7 +212,7 @@ impl Runtime { /// Returns the `JSRuntime` object. pub fn rt(&self) -> *mut JSRuntime { - self.rt + PARENT.load(Ordering::SeqCst) } /// Returns the `JSContext` object. @@ -258,7 +256,7 @@ impl Drop for Runtime { fn drop(&mut self) { unsafe { JS_EndRequest(self.cx); - JS_DestroyRuntime(self.rt); + JS_DestroyContext(self.cx); CONTEXT.with(|context| { assert_eq!(context.get(), self.cx); @@ -266,6 +264,7 @@ impl Drop for Runtime { }); if OUTSTANDING_RUNTIMES.fetch_sub(1, Ordering::SeqCst) == 1 { + PARENT.store(ptr::null_mut(), Ordering::SeqCst); SHUT_DOWN.store(true, Ordering::SeqCst); JS_ShutDown(); } @@ -461,6 +460,7 @@ impl CustomAutoRooter { /// so provide trace logic via vftable when creating an object on Rust side. unsafe trait CustomAutoTraceable: Sized { const vftable: CustomAutoRooterVFTable = CustomAutoRooterVFTable { + padding: CustomAutoRooterVFTable::PADDING, trace: Self::trace, }; @@ -807,7 +807,7 @@ pub unsafe fn ToNumber(cx: *mut JSContext, v: HandleValue) -> Result { } let mut out = Default::default(); - if ToNumberSlow(cx, val, &mut out) { + if ToNumberSlow(cx, v.into_handle(), &mut out) { Ok(out) } else { Err(()) @@ -872,12 +872,20 @@ pub unsafe fn ToString(cx: *mut JSContext, v: HandleValue) -> *mut JSString { ToStringSlow(cx, v.into()) } -pub unsafe extern fn report_warning(_cx: *mut JSContext, _: *const c_char, report: *mut JSErrorReport) { +pub unsafe fn ToWindowProxyIfWindow(obj: *mut JSObject) -> *mut JSObject { + if is_window(obj) { + ToWindowProxyIfWindowSlow(obj) + } else { + obj + } +} + +pub unsafe extern fn report_warning(_cx: *mut JSContext, report: *mut JSErrorReport) { fn latin1_to_string(bytes: &[u8]) -> String { bytes.iter().map(|c| char::from_u32(*c as u32).unwrap()).collect() } - let fnptr = (*report).filename; + let fnptr = (*report)._base.filename; let fname = if !fnptr.is_null() { let c_str = ffi::CStr::from_ptr(fnptr); latin1_to_string(c_str.to_bytes()) @@ -885,13 +893,13 @@ pub unsafe extern fn report_warning(_cx: *mut JSContext, _: *const c_char, repor "none".to_string() }; - let lineno = (*report).lineno; - let column = (*report).column; + let lineno = (*report)._base.lineno; + let column = (*report)._base.column; - let msg_ptr = (*report).ucmessage; + let msg_ptr = (*report)._base.message_.data_ as *const u8; let msg_len = (0usize..).find(|&i| *msg_ptr.offset(i as isize) == 0).unwrap(); let msg_slice = slice::from_raw_parts(msg_ptr, msg_len); - let msg = String::from_utf16_lossy(msg_slice); + let msg = str::from_utf8_unchecked(msg_slice); warn!("Warning at {}:{}:{}: {}\n", fname, lineno, column, msg); } @@ -981,9 +989,7 @@ pub unsafe fn define_properties(cx: *mut JSContext, obj: HandleObject, -> Result<(), ()> { assert!({ match properties.last() { - Some(&JSPropertySpec { name, flags, getter, setter }) => { - name.is_null() && flags == 0 && getter.is_zeroed() && setter.is_zeroed() - }, + Some(spec) => spec.is_zeroed(), None => false, } }); @@ -994,9 +1000,8 @@ pub unsafe fn define_properties(cx: *mut JSContext, obj: HandleObject, static SIMPLE_GLOBAL_CLASS_OPS: JSClassOps = JSClassOps { addProperty: None, delProperty: None, - getProperty: None, - setProperty: None, enumerate: Some(JS_EnumerateStandardClasses), + newEnumerate: None, resolve: Some(JS_ResolveStandardClass), mayResolve: Some(JS_MayResolveStandardClass), finalize: None, @@ -1033,7 +1038,7 @@ pub unsafe fn get_object_compartment(obj: *mut JSObject) -> *mut JSCompartment { #[inline] pub unsafe fn get_context_compartment(cx: *mut JSContext) -> *mut JSCompartment { - let cx = cx as *mut ContextFriendFields; + let cx = cx as *mut RootingContext; (*cx).compartment_ } @@ -1056,7 +1061,7 @@ pub unsafe fn is_window(obj: *mut JSObject) -> bool { pub unsafe fn try_to_outerize(mut rval: MutableHandleValue) { let obj = rval.to_object(); if is_window(obj) { - let obj = ToWindowProxyIfWindow(obj); + let obj = ToWindowProxyIfWindowSlow(obj); assert!(!obj.is_null()); rval.set(ObjectValue(&mut *obj)); } @@ -1129,10 +1134,14 @@ impl<'a> CapturedJSStack<'a> { pub unsafe fn new(cx: *mut JSContext, mut guard: RootedGuard<'a, *mut JSObject>, max_frame_count: Option) -> Option { - if !CaptureCurrentStack(cx, guard.handle_mut().raw(), max_frame_count.unwrap_or(0)) { + let ref mut stack_capture = match max_frame_count { + None => JS_StackCapture_AllFrames(), + Some(count) => JS_StackCapture_MaxFrames(count), + }; + + if !CaptureCurrentStack(cx, guard.handle_mut().raw(), stack_capture) { None - } - else { + } else { Some(CapturedJSStack { cx: cx, stack: guard, @@ -1140,7 +1149,7 @@ impl<'a> CapturedJSStack<'a> { } } - pub fn as_string(&self, indent: Option) -> Option { + pub fn as_string(&self, indent: Option, format: StackFormat) -> Option { unsafe { let stack_handle = self.stack.handle(); rooted!(in(self.cx) let mut js_string = ptr::null_mut::()); @@ -1150,7 +1159,12 @@ impl<'a> CapturedJSStack<'a> { return None; } - if !BuildStackString(self.cx, stack_handle.into(), string_handle.raw(), indent.unwrap_or(0)) { + if !BuildStackString(self.cx, + stack_handle.into(), + string_handle.raw(), + indent.unwrap_or(0), + format) + { return None; } @@ -1196,7 +1210,7 @@ pub mod wrappers { (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: MutableHandle, $($rest:tt)*) => { wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); }; - (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: HandleFunction , $($rest:tt)*) => { + (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: HandleFunction , $($rest:tt)*) => { wrap!(@inner $saved <> ($($acc,)* $arg.into(),) <> $($rest)*); }; (@inner $saved:tt <> ($($acc:expr,)*) <> $arg:ident: HandleId , $($rest:tt)*) => { @@ -1257,17 +1271,20 @@ pub mod wrappers { use jsapi; use glue; - use jsapi::{IsArrayAnswer, PropertyDescriptor, ElementAdder, DetachDataDisposition}; + use jsapi::{IsArrayAnswer, PropertyDescriptor, ElementAdder}; use jsapi::{JSStructuredCloneCallbacks, JSStructuredCloneReader, JSStructuredCloneWriter}; - use jsapi::{JSNative, JSObject, JSContext, JSFunction, JSRuntime, JSString}; + use jsapi::{JSNative, JSObject, JSContext, JSFunction, JSString}; 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::CompileOptions; use jsapi::ESClass; + use jsapi::ForOfIterator; + use jsapi::ForOfIterator_NonIterableBehavior; use jsapi::JSAddonId; use jsapi::JSClass; use jsapi::JSConstDoubleSpec; @@ -1276,23 +1293,34 @@ pub mod wrappers { use jsapi::JSExnType; use jsapi::JSFunctionSpec; use jsapi::JSFunctionSpecWithHelp; - use jsapi::jsid; + use jsapi::JSJitInfo; use jsapi::JSONWriteCallback; + use jsapi::JSPrincipals; use jsapi::JSPropertySpec; use jsapi::JSProtoKey; use jsapi::JSScript; + use jsapi::JSStructuredCloneData; use jsapi::PromiseState; use jsapi::PropertyCopyBehavior; use jsapi::ReadOnlyCompileOptions; - use jsapi::RegExpGuard; + use jsapi::ReadableStreamReaderMode; + use jsapi::Realm; + use jsapi::RefPtr; + use jsapi::RegExpShared; use jsapi::ScriptEnvironmentPreparer_Closure; - use jsapi::Shape; use jsapi::SourceBufferHolder; + use jsapi::StackCapture; + use jsapi::StructuredCloneScope; use jsapi::Symbol; use jsapi::SymbolCode; + use jsapi::TranscodeBuffer; + use jsapi::TranscodeResult; + use jsapi::TranscodeRange; use jsapi::TwoByteChars; use jsapi::Value; - use jsapi::JSJitInfo; + use jsapi::WasmModule; + use jsapi::jsid; + use jsapi::JS::ScriptVector; use libc::FILE; use super::*; include!("jsapi_wrappers.in"); @@ -1386,17 +1414,20 @@ pub mod jsapi_wrapped { use jsapi; use glue; - use jsapi::{IsArrayAnswer, PropertyDescriptor, ElementAdder, DetachDataDisposition}; + use jsapi::{IsArrayAnswer, PropertyDescriptor, ElementAdder}; use jsapi::{JSStructuredCloneCallbacks, JSStructuredCloneReader, JSStructuredCloneWriter}; - use jsapi::{JSNative, JSObject, JSContext, JSFunction, JSRuntime, JSString}; + use jsapi::{JSNative, JSObject, JSContext, JSFunction, JSString}; 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::CompileOptions; use jsapi::ESClass; + use jsapi::ForOfIterator; + use jsapi::ForOfIterator_NonIterableBehavior; use jsapi::JSAddonId; use jsapi::JSClass; use jsapi::JSConstDoubleSpec; @@ -1405,23 +1436,33 @@ pub mod jsapi_wrapped { use jsapi::JSExnType; use jsapi::JSFunctionSpec; use jsapi::JSFunctionSpecWithHelp; - use jsapi::jsid; + use jsapi::JSJitInfo; use jsapi::JSONWriteCallback; + use jsapi::JSPrincipals; use jsapi::JSPropertySpec; use jsapi::JSProtoKey; use jsapi::JSScript; + use jsapi::JSStructuredCloneData; use jsapi::PromiseState; use jsapi::PropertyCopyBehavior; use jsapi::ReadOnlyCompileOptions; - use jsapi::RegExpGuard; + use jsapi::ReadableStreamReaderMode; + use jsapi::Realm; + use jsapi::RefPtr; + use jsapi::RegExpShared; use jsapi::ScriptEnvironmentPreparer_Closure; - use jsapi::Shape; use jsapi::SourceBufferHolder; + use jsapi::StackCapture; + use jsapi::StructuredCloneScope; use jsapi::Symbol; use jsapi::SymbolCode; + use jsapi::TranscodeBuffer; + use jsapi::TranscodeResult; + use jsapi::TranscodeRange; use jsapi::TwoByteChars; use jsapi::Value; - use jsapi::JSJitInfo; + use jsapi::WasmModule; + use jsapi::JS::ScriptVector; use libc::FILE; use super::*; include!("jsapi_wrappers.in"); diff --git a/tests/callback.rs b/tests/callback.rs index f8bc4337a..93acde6e8 100644 --- a/tests/callback.rs +++ b/tests/callback.rs @@ -13,7 +13,7 @@ use mozjs::jsapi::JSContext; use mozjs::jsapi::JS_DefineFunction; use mozjs::jsapi::JS_EncodeStringToUTF8; use mozjs::jsapi::JS_NewGlobalObject; -use mozjs::jsapi::JS_ReportError; +use mozjs::jsapi::JS_ReportErrorASCII; use mozjs::jsapi::OnNewGlobalHookOption; use mozjs::jsapi::Value; use mozjs::jsval::UndefinedValue; @@ -48,7 +48,7 @@ unsafe extern "C" fn puts(context: *mut JSContext, argc: u32, vp: *mut Value) -> let args = CallArgs::from_vp(vp, argc); if args.argc_ != 1 { - JS_ReportError(context, b"puts() requires exactly 1 argument\0".as_ptr() as *const libc::c_char); + JS_ReportErrorASCII(context, b"puts() requires exactly 1 argument\0".as_ptr() as *const libc::c_char); return false; } diff --git a/tests/capture_stack.rs b/tests/capture_stack.rs index b2a9c57a2..42161f93a 100644 --- a/tests/capture_stack.rs +++ b/tests/capture_stack.rs @@ -13,6 +13,7 @@ use mozjs::jsapi::JSContext; use mozjs::jsapi::JS_DefineFunction; use mozjs::jsapi::JS_NewGlobalObject; use mozjs::jsapi::OnNewGlobalHookOption; +use mozjs::jsapi::StackFormat; use mozjs::jsapi::Value; use mozjs::jsval::UndefinedValue; use mozjs::rust::{Runtime, SIMPLE_GLOBAL_CLASS}; @@ -53,9 +54,9 @@ unsafe extern "C" fn print_stack(context: *mut JSContext, argc: u32, vp: *mut Va let args = CallArgs::from_vp(vp, argc); capture_stack!(in(context) let stack); - let str_stack = stack.unwrap().as_string(None).unwrap(); + let str_stack = stack.unwrap().as_string(None, StackFormat::SpiderMonkey).unwrap(); println!("{}", str_stack); - assert_eq!("foo/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:13\n".to_string(), str_stack); args.rval().set(UndefinedValue()); return true; diff --git a/tests/custom_auto_rooter.rs b/tests/custom_auto_rooter.rs index de2f8730d..2db9f6287 100644 --- a/tests/custom_auto_rooter.rs +++ b/tests/custom_auto_rooter.rs @@ -32,12 +32,12 @@ unsafe impl CustomTrace for TraceCheck { #[test] fn virtual_trace_called() { let rt = Runtime::new().unwrap(); - let (rt, cx) = (rt.rt(), rt.cx()); + let cx = rt.cx(); let mut rooter = CustomAutoRooter::new(TraceCheck::new()); let guard = rooter.root(cx); - unsafe { JS_GC(rt); } + unsafe { JS_GC(cx); } assert!(guard.trace_was_called.get()); } diff --git a/tests/custom_auto_rooter_macro.rs b/tests/custom_auto_rooter_macro.rs index f8f8a9ef6..848f5ff09 100644 --- a/tests/custom_auto_rooter_macro.rs +++ b/tests/custom_auto_rooter_macro.rs @@ -29,11 +29,11 @@ unsafe impl CustomTrace for TraceCheck { #[test] fn custom_auto_rooter_macro() { let rt = Runtime::new().unwrap(); - let (rt, cx) = (rt.rt(), rt.cx()); + let cx = rt.cx(); auto_root!(in(cx) let vec = vec![TraceCheck::new(), TraceCheck::new()]); - unsafe { JS_GC(rt); } + unsafe { JS_GC(cx); } vec.iter().for_each(|elem| assert!(elem.trace_was_called.get())); } diff --git a/tests/rooting.rs b/tests/rooting.rs index e6370e85e..b2f558094 100644 --- a/tests/rooting.rs +++ b/tests/rooting.rs @@ -2,8 +2,6 @@ * 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/. */ -#![feature(const_fn)] -#![feature(const_ptr_null)] #![cfg(feature = "debugmozjs")] #[macro_use] @@ -30,9 +28,9 @@ use std::ptr; fn rooting() { unsafe { let runtime = Runtime::new().unwrap(); - JS_SetGCZeal(runtime.rt(), 2, 1); - let cx = runtime.cx(); + JS_SetGCZeal(cx, 2, 1); + let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook; let c_option = CompartmentOptions::default(); @@ -57,32 +55,26 @@ 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, - call: JSNativeWrapper { op: Some(generic_method), info: ptr::null() }, + 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, - call: JSNativeWrapper { op: Some(generic_method), info: ptr::null() }, + 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, - call: JSNativeWrapper { op: Some(generic_method), info: ptr::null() }, + call: JSNativeWrapper { op: Some(generic_method), info: 0 as *const _ }, nargs: 1, flags: JSPROP_ENUMERATE as u16, selfHostedName: 0 as *const libc::c_char }, - JSFunctionSpec { - name: ptr::null(), - call: JSNativeWrapper { op: None, info: ptr::null() }, - nargs: 0, - flags: 0, - selfHostedName: ptr::null() - } + JSFunctionSpec::ZERO, ]; static CLASS: JSClass = JSClass { diff --git a/tests/runtime.rs b/tests/runtime.rs index 9dd8f1197..99e37d1ed 100644 --- a/tests/runtime.rs +++ b/tests/runtime.rs @@ -9,6 +9,7 @@ extern crate libc; use mozjs::jsapi::CompartmentOptions; use mozjs::jsapi::JSAutoCompartment; use mozjs::jsapi::JSClass; +use mozjs::jsapi::JSCLASS_FOREGROUND_FINALIZE; use mozjs::jsapi::JSClassOps; use mozjs::jsapi::JSFreeOp; use mozjs::jsapi::JS_NewGlobalObject; @@ -46,9 +47,8 @@ unsafe extern fn finalize(_fop: *mut JSFreeOp, _object: *mut JSObject) { static CLASS_OPS: JSClassOps = JSClassOps { addProperty: None, delProperty: None, - getProperty: None, - setProperty: None, enumerate: None, + newEnumerate: None, resolve: None, mayResolve: None, finalize: Some(finalize), @@ -60,7 +60,7 @@ static CLASS_OPS: JSClassOps = JSClassOps { static CLASS: JSClass = JSClass { name: b"EventTargetPrototype\0" as *const u8 as *const libc::c_char, - flags: 0, + flags: JSCLASS_FOREGROUND_FINALIZE, cOps: &CLASS_OPS as *const JSClassOps, reserved: [0 as *mut _; 3] }; diff --git a/tests/typedarray.rs b/tests/typedarray.rs index 96368aca6..b59b364a0 100644 --- a/tests/typedarray.rs +++ b/tests/typedarray.rs @@ -79,24 +79,3 @@ fn typedarray() { assert_eq!(view.unwrap().get_array_type(), Type::Uint32); } } - -#[test] -#[should_panic] -fn typedarray_update_panic() { - let rt = Runtime_::new().unwrap(); - let cx = rt.cx(); - - unsafe { - rooted!(in(cx) let global = - JS_NewGlobalObject(cx, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(), - OnNewGlobalHookOption::FireOnNewGlobalHook, - &CompartmentOptions::default()) - ); - - let _ac = JSAutoCompartment::new(cx, global.get()); - rooted!(in(cx) let mut rval = ptr::null_mut::()); - let _ = Uint32Array::create(cx, CreateWith::Slice(&[1, 2, 3, 4, 5]), rval.handle_mut()); - typedarray!(in(cx) let mut array: Uint32Array = rval.get()); - array.as_mut().unwrap().update(&[0, 2, 4, 6, 8, 10]); - } -} diff --git a/tests/typedarray_panic.rs b/tests/typedarray_panic.rs new file mode 100644 index 000000000..b5bcf049c --- /dev/null +++ b/tests/typedarray_panic.rs @@ -0,0 +1,37 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#[macro_use] +extern crate mozjs; + +use mozjs::jsapi::CompartmentOptions; +use mozjs::jsapi::JSAutoCompartment; +use mozjs::jsapi::JSObject; +use mozjs::jsapi::JS_NewGlobalObject; +use mozjs::jsapi::OnNewGlobalHookOption; +use mozjs::rust::Runtime as Runtime_; +use mozjs::rust::SIMPLE_GLOBAL_CLASS; +use mozjs::typedarray::{CreateWith, Uint32Array}; +use std::ptr; + +#[test] +#[should_panic] +fn typedarray_update_panic() { + let rt = Runtime_::new().unwrap(); + let cx = rt.cx(); + + unsafe { + rooted!(in(cx) let global = + JS_NewGlobalObject(cx, &SIMPLE_GLOBAL_CLASS, ptr::null_mut(), + OnNewGlobalHookOption::FireOnNewGlobalHook, + &CompartmentOptions::default()) + ); + + let _ac = JSAutoCompartment::new(cx, global.get()); + rooted!(in(cx) let mut rval = ptr::null_mut::()); + let _ = Uint32Array::create(cx, CreateWith::Slice(&[1, 2, 3, 4, 5]), rval.handle_mut()); + typedarray!(in(cx) let mut array: Uint32Array = rval.get()); + array.as_mut().unwrap().update(&[0, 2, 4, 6, 8, 10]); + } +}