mirror of
https://github.com/oven-sh/bun
synced 2026-02-03 15:38:46 +00:00
Compare commits
33 Commits
dylan/move
...
jarred/esc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab04e82f55 | ||
|
|
5aa196b361 | ||
|
|
9f640ffb51 | ||
|
|
af6859acc2 | ||
|
|
e5322eb63b | ||
|
|
102553dca6 | ||
|
|
549e5bbbcd | ||
|
|
57ad68a4b0 | ||
|
|
e5eabc0658 | ||
|
|
121c2960de | ||
|
|
a96a2a8b12 | ||
|
|
6e8a30e999 | ||
|
|
7b455492d3 | ||
|
|
f9710e270a | ||
|
|
515da14621 | ||
|
|
b735de0d3f | ||
|
|
bf28afad1d | ||
|
|
73ad5c4f67 | ||
|
|
73ec79fa8e | ||
|
|
3083718e3f | ||
|
|
17cdc0fee6 | ||
|
|
26c890d3a1 | ||
|
|
564b6d12f0 | ||
|
|
f4aa3a8c34 | ||
|
|
ed63b22f7a | ||
|
|
b18b0efb8b | ||
|
|
7f3bc2b9e6 | ||
|
|
c362729186 | ||
|
|
f0e58fec49 | ||
|
|
9fcc5f27e8 | ||
|
|
ab2d25bfec | ||
|
|
3e55023819 | ||
|
|
4fb9354439 |
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -4,3 +4,4 @@ src/api/schema.js linguist-generated
|
||||
src/javascript/jsc/bindings/sqlite/sqlite3.c linguist-vendored
|
||||
src/javascript/jsc/bindings/sqlite/sqlite3_local.h linguist-vendored
|
||||
*.lockb binary diff=lockb
|
||||
*.zig text eol=lf
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -99,3 +99,6 @@ packages/bun-wasm/*.d.ts
|
||||
|
||||
src/fallback.version
|
||||
src/runtime.version
|
||||
*.sqlite
|
||||
*.database
|
||||
*.db
|
||||
|
||||
116
Makefile
116
Makefile
@@ -32,7 +32,7 @@ endif
|
||||
AR=
|
||||
|
||||
|
||||
|
||||
CXX_VERSION=c++2a
|
||||
TRIPLET = $(OS_NAME)-$(ARCH_NAME)
|
||||
PACKAGE_NAME = bun-$(TRIPLET)
|
||||
PACKAGES_REALPATH = $(realpath packages)
|
||||
@@ -49,6 +49,7 @@ PRETTIER ?= $(shell which prettier || echo "./node_modules/.bin/prettier")
|
||||
DSYMUTIL ?= $(shell which dsymutil || which dsymutil-13)
|
||||
WEBKIT_DIR ?= $(realpath src/javascript/jsc/WebKit)
|
||||
WEBKIT_RELEASE_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Release
|
||||
WEBKIT_RELEASE_DIR_LTO ?= $(WEBKIT_DIR)/WebKitBuild/ReleaseLTO
|
||||
|
||||
NPM_CLIENT ?= $(shell which bun || which npm)
|
||||
ZIG ?= $(shell which zig || echo -e "error: Missing zig. Please make sure zig is in PATH. Or set ZIG=/path/to-zig-executable")
|
||||
@@ -97,7 +98,7 @@ LIBTOOL=libtoolize
|
||||
ifeq ($(OS_NAME),darwin)
|
||||
LIBTOOL=glibtoolize
|
||||
AR=$(LLVM_PREFIX)/bin/llvm-ar
|
||||
BITCODE_OR_SECTIONS=
|
||||
BITCODE_OR_SECTIONS=-fembed-bitcode
|
||||
endif
|
||||
|
||||
ifeq ($(OS_NAME),linux)
|
||||
@@ -120,22 +121,28 @@ USE_BMALLOC ?= DEFAULT_USE_BMALLOC
|
||||
JSC_BASE_DIR ?= ${HOME}/webkit-build
|
||||
|
||||
DEFAULT_JSC_LIB :=
|
||||
DEFAULT_JSC_LIB_DEBUG :=
|
||||
|
||||
ifeq ($(OS_NAME),linux)
|
||||
DEFAULT_JSC_LIB = $(JSC_BASE_DIR)/lib
|
||||
DEFAULT_JSC_LIB_DEBUG = $(DEFAULT_JSC_LIB)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_NAME),darwin)
|
||||
DEFAULT_JSC_LIB = $(BUN_DEPS_DIR)
|
||||
DEFAULT_JSC_LIB = $(WEBKIT_RELEASE_DIR_LTO)/lib
|
||||
DEFAULT_JSC_LIB_DEBUG = $(WEBKIT_RELEASE_DIR)/lib
|
||||
endif
|
||||
|
||||
JSC_LIB ?= $(DEFAULT_JSC_LIB)
|
||||
JSC_LIB_DEBUG ?= $(DEFAULT_JSC_LIB_DEBUG)
|
||||
|
||||
JSC_INCLUDE_DIR ?= $(JSC_BASE_DIR)/include
|
||||
ZLIB_INCLUDE_DIR ?= $(BUN_DEPS_DIR)/zlib
|
||||
ZLIB_LIB_DIR ?= $(BUN_DEPS_DIR)/zlib
|
||||
|
||||
JSC_FILES := $(JSC_LIB)/libJavaScriptCore.a $(JSC_LIB)/libWTF.a $(JSC_LIB)/libbmalloc.a
|
||||
JSC_FILES := $(JSC_LIB)/libJavaScriptCore.a $(JSC_LIB)/libWTF.a $(JSC_LIB)/libbmalloc.a $(JSC_LIB)/libLowLevelInterpreterLib.a
|
||||
JSC_FILES_DEBUG := $(JSC_LIB_DEBUG)/libJavaScriptCore.a $(JSC_LIB_DEBUG)/libWTF.a $(JSC_LIB_DEBUG)/libbmalloc.a $(JSC_LIB_DEBUG)/libLowLevelInterpreterLib.a
|
||||
|
||||
|
||||
ENABLE_MIMALLOC ?= 1
|
||||
|
||||
@@ -260,11 +267,12 @@ endif
|
||||
BORINGSSL_PACKAGE = --pkg-begin boringssl $(BUN_DEPS_DIR)/boringssl.zig --pkg-end
|
||||
|
||||
CLANG_FLAGS = $(INCLUDE_DIRS) \
|
||||
-std=gnu++17 \
|
||||
-std=$(CXX_VERSION) \
|
||||
-DSTATICALLY_LINKED_WITH_JavaScriptCore=1 \
|
||||
-DSTATICALLY_LINKED_WITH_WTF=1 \
|
||||
-DSTATICALLY_LINKED_WITH_BMALLOC=1 \
|
||||
-DBUILDING_WITH_CMAKE=1 \
|
||||
-DBUN_SINGLE_THREADED_PER_VM_ENTRY_SCOPE=1 \
|
||||
-DNDEBUG=1 \
|
||||
-DNOMINMAX \
|
||||
-DIS_BUILD \
|
||||
@@ -293,7 +301,8 @@ endif
|
||||
|
||||
SHARED_LIB_EXTENSION = .so
|
||||
|
||||
JSC_BINDINGS = $(JSC_FILES) $(BINDINGS_OBJ)
|
||||
JSC_BINDINGS = $(BINDINGS_OBJ) $(JSC_FILES)
|
||||
JSC_BINDINGS_DEBUG = $(BINDINGS_OBJ) $(JSC_FILES_DEBUG)
|
||||
|
||||
RELEASE_FLAGS=
|
||||
DEBUG_FLAGS=
|
||||
@@ -350,11 +359,14 @@ BUN_LLD_FLAGS_WITHOUT_JSC = $(ARCHIVE_FILES) \
|
||||
$(LIBICONV_PATH) \
|
||||
$(CLANG_FLAGS) \
|
||||
$(DEFAULT_LINKER_FLAGS) \
|
||||
$(PLATFORM_LINKER_FLAGS)
|
||||
$(PLATFORM_LINKER_FLAGS) \
|
||||
$(SQLITE_OBJECT) ${ICU_FLAGS}
|
||||
|
||||
|
||||
|
||||
BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_BINDINGS) $(SQLITE_OBJECT) ${ICU_FLAGS}
|
||||
BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES) $(BINDINGS_OBJ)
|
||||
|
||||
BUN_LLD_FLAGS_DEBUG = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES_DEBUG) $(BINDINGS_OBJ)
|
||||
|
||||
CLANG_VERSION = $(shell $(CC) --version | awk '/version/ {for(i=1; i<=NF; i++){if($$i=="version"){split($$(i+1),v,".");print v[1]}}}')
|
||||
|
||||
@@ -364,8 +376,8 @@ bun:
|
||||
base64:
|
||||
cd src/base64 && \
|
||||
rm -rf src/base64/*.{o,ll,bc} && \
|
||||
$(CC) $(CFLAGS) $(OPTIMIZATION_LEVEL) -g -fPIC -c *.c -I$(SRC_DIR)/base64 -emit-llvm && \
|
||||
$(CXX) $(CXXFLAGS) $(CFLAGS) -c neonbase64.cc -g -fPIC -emit-llvm && \
|
||||
$(CC) $(CFLAGS) $(OPTIMIZATION_LEVEL) -g -fPIC -c *.c -I$(SRC_DIR)/base64 $(BITCODE_OR_SECTIONS) && \
|
||||
$(CXX) $(CXXFLAGS) $(CFLAGS) -c neonbase64.cc -g -fPIC $(BITCODE_OR_SECTIONS) && \
|
||||
$(AR) rcvs $(BUN_DEPS_OUT_DIR)/libbase64.a ./*.bc
|
||||
|
||||
# Prevent dependency on libtcc1 so it doesn't do filesystem lookups
|
||||
@@ -379,7 +391,7 @@ tinycc:
|
||||
cp $(TINYCC_DIR)/*.a $(BUN_DEPS_OUT_DIR)
|
||||
|
||||
generate-builtins:
|
||||
rm -f src/javascript/jsc/bindings/WebCoreBuiltins.cpp src/javascript/jsc/bindings/WebCoreBuiltins.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/WebCore*Builtins* || echo ""
|
||||
rm -f src/javascript/jsc/bindings/WebCoreBuiltins.cpp src/javascript/jsc/bindings/WebCoreBuiltins.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/*Strategy*Builtins* src/javascript/jsc/bindings/*Stream*Builtins* src/javascript/jsc/bindings/WebCore*Builtins* || echo ""
|
||||
$(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src/javascript/jsc/bindings/builtins/js) -o $(realpath src/javascript/jsc/bindings) --framework WebCore --force
|
||||
$(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src/javascript/jsc/bindings/builtins/js) -o $(realpath src/javascript/jsc/bindings) --framework WebCore --wrappers-only
|
||||
echo '//clang-format off' > /tmp/1.h
|
||||
@@ -393,9 +405,6 @@ generate-builtins:
|
||||
cat /tmp/1.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h > src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h.1
|
||||
mv src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h.1 src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
|
||||
$(SED) -i -e 's/class JSDOMGlobalObject/using JSDOMGlobalObject = Zig::GlobalObject/' src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
|
||||
# Since we don't currently support web streams, we don't need this line
|
||||
# so we comment it out
|
||||
$(SED) -i -e 's/globalObject.addStaticGlobals/\/\/globalObject.addStaticGlobals/' src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp
|
||||
# We delete this file because our script already builds all .cpp files
|
||||
# We will get duplicate symbols if we don't delete it
|
||||
rm src/javascript/jsc/bindings/WebCoreJSBuiltins.cpp
|
||||
@@ -551,7 +560,7 @@ build-obj-safe:
|
||||
$(ZIG) build obj -Drelease-safe
|
||||
|
||||
UWS_CC_FLAGS = -pthread -DLIBUS_USE_OPENSSL=1 -DUWS_HTTPRESPONSE_NO_WRITEMARK=1 -DLIBUS_USE_BORINGSSL=1 -DWITH_BORINGSSL=1 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion $(UWS_INCLUDE) -DUWS_WITH_PROXY
|
||||
UWS_CXX_FLAGS = $(UWS_CC_FLAGS) -std=gnu++17 -fno-exceptions
|
||||
UWS_CXX_FLAGS = $(UWS_CC_FLAGS) -std=$(CXX_VERSION) -fno-exceptions
|
||||
UWS_LDFLAGS = -I$(BUN_DEPS_DIR)/boringssl/include -I$(ZLIB_INCLUDE_DIR)
|
||||
USOCKETS_DIR = $(BUN_DEPS_DIR)/uws/uSockets/
|
||||
USOCKETS_SRC_DIR = $(BUN_DEPS_DIR)/uws/uSockets/src/
|
||||
@@ -562,7 +571,7 @@ usockets:
|
||||
cd $(USOCKETS_DIR) && $(CXX) $(MACOS_MIN_FLAG) -fPIC $(CXXFLAGS) $(UWS_CXX_FLAGS) -save-temps -flto -I$(BUN_DEPS_DIR)/uws/uSockets/src $(UWS_LDFLAGS) -g $(DEFAULT_LINKER_FLAGS) $(PLATFORM_LINKER_FLAGS) $(OPTIMIZATION_LEVEL) -g -c $(wildcard $(USOCKETS_SRC_DIR)/*.cpp) $(wildcard $(USOCKETS_SRC_DIR)/**/*.cpp)
|
||||
cd $(USOCKETS_DIR) && $(AR) rcvs $(BUN_DEPS_OUT_DIR)/libusockets.a *.o *.ii *.bc *.i
|
||||
uws: usockets
|
||||
$(CXX) -emit-llvm -fPIC -I$(BUN_DEPS_DIR)/uws/uSockets/src $(CLANG_FLAGS) $(CFLAGS) $(UWS_CXX_FLAGS) $(UWS_LDFLAGS) $(PLATFORM_LINKER_FLAGS) -c -I$(BUN_DEPS_DIR) $(BUN_DEPS_OUT_DIR)/libusockets.a $(BUN_DEPS_DIR)/libuwsockets.cpp -o $(BUN_DEPS_OUT_DIR)/libuwsockets.o
|
||||
$(CXX) $(BITCODE_OR_SECTIONS) -fPIC -I$(BUN_DEPS_DIR)/uws/uSockets/src $(CLANG_FLAGS) $(CFLAGS) $(UWS_CXX_FLAGS) $(UWS_LDFLAGS) $(PLATFORM_LINKER_FLAGS) -c -I$(BUN_DEPS_DIR) $(BUN_DEPS_OUT_DIR)/libusockets.a $(BUN_DEPS_DIR)/libuwsockets.cpp -o $(BUN_DEPS_OUT_DIR)/libuwsockets.o
|
||||
|
||||
|
||||
|
||||
@@ -698,7 +707,7 @@ jsc-bindings-headers:
|
||||
touch src/javascript/jsc/bindings/headers.zig
|
||||
mkdir -p src/javascript/jsc/bindings-obj/
|
||||
$(ZIG) build headers-obj
|
||||
$(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES) ${ICU_FLAGS} $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc;
|
||||
$(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc;
|
||||
/tmp/build-jsc-headers
|
||||
$(ZIG) translate-c src/javascript/jsc/bindings/headers.h > src/javascript/jsc/bindings/headers.zig
|
||||
$(ZIG) run misctools/headers-cleaner.zig -lc
|
||||
@@ -926,6 +935,36 @@ jsc-copy-headers:
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/LazyPropertyInlines.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/LazyPropertyInlines.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSTypedArrayViewPrototype.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSTypedArrayPrototypes.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JIT.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JIT.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StructureStubInfo.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StructureStubInfo.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PolymorphicAccess.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PolymorphicAccess.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/AccessCase.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/AccessCase.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/ObjectPropertyConditionSet.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/ObjectPropertyConditionSet.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PolyProtoAccessChain.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PolyProtoAccessChain.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PutKind.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PutKind.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StructureStubClearingWatchpoint.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StructureStubClearingWatchpoint.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/AdaptiveInferredPropertyValueWatchpointBase.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/AdaptiveInferredPropertyValueWatchpointBase.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StubInfoSummary.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StubInfoSummary.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/CommonSlowPaths.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/CommonSlowPaths.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/DirectArguments.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/DirectArguments.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/GenericArguments.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/GenericArguments.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/ScopedArguments.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/ScopedArguments.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSLexicalEnvironment.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITDisassembler.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITDisassembler.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITInlineCacheGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITInlineCacheGenerator.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITMathIC.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITMathIC.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITAddGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITAddGenerator.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITMathICInlineResult.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITMathICInlineResult.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/SnippetOperand.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/SnippetOperand.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITMulGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITMulGenerator.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITNegGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITNegGenerator.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITSubGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITSubGenerator.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/Repatch.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/Repatch.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITRightShiftGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITRightShiftGenerator.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITBitBinaryOpGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITBitBinaryOpGenerator.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JSInterfaceJIT.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSInterfaceJIT.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/llint/LLIntData.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/LLIntData.h
|
||||
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/FunctionCodeBlock.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/FunctionCodeBlock.h
|
||||
find $(WEBKIT_RELEASE_DIR)/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/ \;
|
||||
|
||||
# This is a workaround for a JSC bug that impacts aarch64
|
||||
@@ -934,7 +973,6 @@ jsc-force-fastjit:
|
||||
$(SED) -i "s/USE(PTHREAD_JIT_PERMISSIONS_API)/CPU(ARM64)/g" $(WEBKIT_DIR)/Source/JavaScriptCore/jit/ExecutableAllocator.h
|
||||
$(SED) -i "s/USE(PTHREAD_JIT_PERMISSIONS_API)/CPU(ARM64)/g" $(WEBKIT_DIR)/Source/JavaScriptCore/assembler/FastJITPermissions.h
|
||||
$(SED) -i "s/USE(PTHREAD_JIT_PERMISSIONS_API)/CPU(ARM64)/g" $(WEBKIT_DIR)/Source/JavaScriptCore/jit/ExecutableAllocator.cpp
|
||||
$(SED) -i "s/GIGACAGE_ENABLED/0/g" $(WEBKIT_DIR)/Source/WTF/wtf/Gigacage.h
|
||||
|
||||
jsc-build-mac-compile:
|
||||
mkdir -p $(WEBKIT_RELEASE_DIR) $(WEBKIT_DIR);
|
||||
@@ -943,21 +981,43 @@ jsc-build-mac-compile:
|
||||
cmake \
|
||||
-DPORT="JSCOnly" \
|
||||
-DENABLE_STATIC_JSC=ON \
|
||||
-DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DUSE_THIN_ARCHIVES=OFF \
|
||||
-DENABLE_FTL_JIT=ON \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-G Ninja \
|
||||
$(CMAKE_FLAGS_WITHOUT_RELEASE) \
|
||||
-DPTHREAD_JIT_PERMISSIONS_API=1 \
|
||||
-DUSE_PTHREAD_JIT_PERMISSIONS_API=ON \
|
||||
-DENABLE_REMOTE_INSPECTOR=ON \
|
||||
-DUSE_VISIBILITY_ATTRIBUTE=1 \
|
||||
$(WEBKIT_DIR) \
|
||||
$(WEBKIT_RELEASE_DIR) && \
|
||||
CFLAGS="$(CFLAGS) -emit-llvm -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -emit-llvm -ffat-lto-objects" \
|
||||
CFLAGS="$(CFLAGS) $(BITCODE_OR_SECTIONS) -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) $(BITCODE_OR_SECTIONS) -ffat-lto-objects" \
|
||||
cmake --build $(WEBKIT_RELEASE_DIR) --config Release --target jsc
|
||||
|
||||
jsc-build-mac-compile-lto:
|
||||
mkdir -p $(WEBKIT_RELEASE_DIR_LTO) $(WEBKIT_DIR);
|
||||
cd $(WEBKIT_RELEASE_DIR_LTO) && \
|
||||
ICU_INCLUDE_DIRS="$(HOMEBREW_PREFIX)opt/icu4c/include" \
|
||||
cmake \
|
||||
-DPORT="JSCOnly" \
|
||||
-DENABLE_STATIC_JSC=ON \
|
||||
-DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DUSE_THIN_ARCHIVES=OFF \
|
||||
-DCMAKE_C_FLAGS="-flto=full" \
|
||||
-DCMAKE_CXX_FLAGS="-flto=full" \
|
||||
-DENABLE_FTL_JIT=ON \
|
||||
-G Ninja \
|
||||
$(CMAKE_FLAGS_WITHOUT_RELEASE) \
|
||||
-DPTHREAD_JIT_PERMISSIONS_API=1 \
|
||||
-DUSE_PTHREAD_JIT_PERMISSIONS_API=ON \
|
||||
-DENABLE_REMOTE_INSPECTOR=ON \
|
||||
$(WEBKIT_DIR) \
|
||||
$(WEBKIT_RELEASE_DIR_LTO) && \
|
||||
CFLAGS="$(CFLAGS) -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -ffat-lto-objects" \
|
||||
cmake --build $(WEBKIT_RELEASE_DIR_LTO) --config Release --target jsc
|
||||
|
||||
jsc-build-mac-compile-debug:
|
||||
mkdir -p $(WEBKIT_RELEASE_DIR) $(WEBKIT_DIR);
|
||||
cd $(WEBKIT_RELEASE_DIR) && \
|
||||
@@ -977,7 +1037,7 @@ jsc-build-mac-compile-debug:
|
||||
-DUSE_VISIBILITY_ATTRIBUTE=1 \
|
||||
$(WEBKIT_DIR) \
|
||||
$(WEBKIT_RELEASE_DIR) && \
|
||||
CFLAGS="$(CFLAGS) -emit-llvm -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -ffat-lto-objects" \
|
||||
CFLAGS="$(CFLAGS) -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -ffat-lto-objects" \
|
||||
cmake --build $(WEBKIT_RELEASE_DIR) --config Debug --target jsc
|
||||
|
||||
jsc-build-linux-compile-config:
|
||||
@@ -1014,6 +1074,7 @@ jsc-build-linux: jsc-build-linux-compile-config jsc-build-linux-compile-build js
|
||||
|
||||
jsc-build-mac-copy:
|
||||
cp $(WEBKIT_RELEASE_DIR)/lib/libJavaScriptCore.a $(BUN_DEPS_OUT_DIR)/libJavaScriptCore.a
|
||||
cp $(WEBKIT_RELEASE_DIR)/lib/libLowLevelInterpreterLib.a $(BUN_DEPS_OUT_DIR)/libLowLevelInterpreterLib.a
|
||||
cp $(WEBKIT_RELEASE_DIR)/lib/libWTF.a $(BUN_DEPS_OUT_DIR)/libWTF.a
|
||||
cp $(WEBKIT_RELEASE_DIR)/lib/libbmalloc.a $(BUN_DEPS_OUT_DIR)/libbmalloc.a
|
||||
|
||||
@@ -1073,7 +1134,7 @@ mimalloc:
|
||||
-DMI_USE_CXX=ON \
|
||||
-DMI_OVERRIDE=ON \
|
||||
-DCMAKE_C_FLAGS="$(CFLAGS)" \
|
||||
-DCMAKE_CXX_FLAGS="$(CFLAGS)" \
|
||||
-DCMAKE_CXX_FLAGS="$(CFLAGS) -fno-exceptions -fno-rtti" \
|
||||
${MIMALLOC_OVERRIDE_FLAG} \
|
||||
.\
|
||||
&& make -j $(CPUS);
|
||||
@@ -1085,7 +1146,7 @@ mimalloc-wasm:
|
||||
cp $(BUN_DEPS_DIR)/mimalloc/$(MIMALLOC_INPUT_PATH) $(BUN_DEPS_OUT_DIR)/$(MIMALLOC_FILE).wasm
|
||||
|
||||
bun-link-lld-debug:
|
||||
$(CXX) $(BUN_LLD_FLAGS) $(DEBUG_FLAGS) $(SYMBOLS) \
|
||||
$(CXX) $(BUN_LLD_FLAGS_DEBUG) $(DEBUG_FLAGS) $(SYMBOLS) \
|
||||
-g \
|
||||
$(DEBUG_BIN)/bun-debug.o \
|
||||
-W \
|
||||
@@ -1124,7 +1185,7 @@ ifeq ($(OS_NAME),darwin)
|
||||
bun-link-lld-release-dsym:
|
||||
$(DSYMUTIL) -o $(BUN_RELEASE_BIN).dSYM $(BUN_RELEASE_BIN)
|
||||
-$(STRIP) $(BUN_RELEASE_BIN)
|
||||
mv $(BUN_RELEASE_BIN).o /tmp/bun-$(PACKAGE_JSON_VERSION).o
|
||||
cp $(BUN_RELEASE_BIN).o /tmp/bun-$(PACKAGE_JSON_VERSION).o
|
||||
|
||||
copy-to-bun-release-dir-dsym:
|
||||
gzip --keep -c $(PACKAGE_DIR)/bun.dSYM > $(BUN_RELEASE_DIR)/bun.dSYM.gz
|
||||
@@ -1145,7 +1206,7 @@ wasm-return1:
|
||||
|
||||
|
||||
|
||||
EMIT_LLVM_FOR_RELEASE= -emit-llvm
|
||||
EMIT_LLVM_FOR_RELEASE=-emit-llvm -flto="full"
|
||||
EMIT_LLVM_FOR_DEBUG=
|
||||
EMIT_LLVM=$(EMIT_LLVM_FOR_RELEASE)
|
||||
|
||||
@@ -1156,6 +1217,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
$(MACOS_MIN_FLAG) \
|
||||
$(OPTIMIZATION_LEVEL) \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
$(EMIT_LLVM) \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1165,6 +1227,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
|
||||
$(MACOS_MIN_FLAG) \
|
||||
$(OPTIMIZATION_LEVEL) \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
$(EMIT_LLVM) \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1174,6 +1237,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
|
||||
$(MACOS_MIN_FLAG) \
|
||||
$(OPTIMIZATION_LEVEL) \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
$(EMIT_LLVM) \
|
||||
-g3 -c -o $@ $<
|
||||
|
||||
1
bench/ffi/plus100/plus100-napi
Submodule
1
bench/ffi/plus100/plus100-napi
Submodule
Submodule bench/ffi/plus100/plus100-napi added at 485de94d06
108
bench/snippets/escapeHTML.js
Normal file
108
bench/snippets/escapeHTML.js
Normal file
@@ -0,0 +1,108 @@
|
||||
import { group } from "mitata";
|
||||
import { bench, run } from "mitata";
|
||||
import { encode as htmlEntityEncode } from "html-entities";
|
||||
import { escape as heEscape } from "he";
|
||||
|
||||
var bunEscapeHTML_ = globalThis.escapeHTML || Bun.escapeHTML;
|
||||
var bunEscapeHTML = bunEscapeHTML_;
|
||||
|
||||
const matchHtmlRegExp = /["'&<>]/;
|
||||
|
||||
/**
|
||||
* Escapes special characters and HTML entities in a given html string.
|
||||
*
|
||||
* @param {string} string HTML string to escape for later insertion
|
||||
* @return {string}
|
||||
* @public
|
||||
*/
|
||||
|
||||
const FIXTURE = require("fs")
|
||||
.readFileSync(import.meta.dir + "/_fixture.txt", "utf8")
|
||||
.split("")
|
||||
.map((a) => {
|
||||
if (a.charCodeAt(0) > 127) {
|
||||
return "a";
|
||||
}
|
||||
return a;
|
||||
})
|
||||
.join("");
|
||||
|
||||
const FIXTURE_WITH_UNICODE = require("fs").readFileSync(
|
||||
import.meta.dir + "/_fixture.txt",
|
||||
"utf8"
|
||||
);
|
||||
|
||||
function reactEscapeHtml(string) {
|
||||
const str = "" + string;
|
||||
const match = matchHtmlRegExp.exec(str);
|
||||
|
||||
if (!match) {
|
||||
return str;
|
||||
}
|
||||
|
||||
let escape;
|
||||
let html = "";
|
||||
let index;
|
||||
let lastIndex = 0;
|
||||
|
||||
for (index = match.index; index < str.length; index++) {
|
||||
switch (str.charCodeAt(index)) {
|
||||
case 34: // "
|
||||
escape = """;
|
||||
break;
|
||||
case 38: // &
|
||||
escape = "&";
|
||||
break;
|
||||
case 39: // '
|
||||
escape = "'"; // modified from escape-html; used to be '''
|
||||
break;
|
||||
case 60: // <
|
||||
escape = "<";
|
||||
break;
|
||||
case 62: // >
|
||||
escape = ">";
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lastIndex !== index) {
|
||||
html += str.substring(lastIndex, index);
|
||||
}
|
||||
|
||||
lastIndex = index + 1;
|
||||
html += escape;
|
||||
}
|
||||
|
||||
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
||||
}
|
||||
|
||||
for (let input of [
|
||||
"<script>alert('xss')</script>",
|
||||
`long string, nothing to escape... `.repeat(9999),
|
||||
`long utf16 string, no esc 🤔🤔🤔🤔🤔` + "tex".repeat(4000),
|
||||
`smol`,
|
||||
// `medium string with <script>alert('xss')</script>`,
|
||||
|
||||
FIXTURE,
|
||||
// "[unicode]" + FIXTURE_WITH_UNICODE,
|
||||
]) {
|
||||
group(
|
||||
{
|
||||
summary: true,
|
||||
name:
|
||||
`"` +
|
||||
input.substring(0, Math.min(input.length, 32)) +
|
||||
`"` +
|
||||
` (${input.length} chars)`,
|
||||
},
|
||||
() => {
|
||||
bench(`ReactDOM.escapeHTML`, () => reactEscapeHtml(input));
|
||||
bench(`html-entities.encode`, () => htmlEntityEncode(input));
|
||||
bench(`he.escape`, () => heEscape(input));
|
||||
bench(`Bun.escapeHTML`, () => bunEscapeHTML(input));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
await run();
|
||||
17
bench/snippets/noop.js
Normal file
17
bench/snippets/noop.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { bench, run } from "mitata";
|
||||
|
||||
var noop = globalThis[Symbol.for("Bun.lazy")]("noop");
|
||||
|
||||
bench("function", function () {
|
||||
noop.function();
|
||||
});
|
||||
|
||||
bench("setter", function () {
|
||||
noop.getterSetter = 1;
|
||||
});
|
||||
|
||||
bench("getter", function () {
|
||||
noop.getterSetter;
|
||||
});
|
||||
|
||||
run();
|
||||
94
integration/bunjs-only-snippets/bun-jsc.test.js
Normal file
94
integration/bunjs-only-snippets/bun-jsc.test.js
Normal file
@@ -0,0 +1,94 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import {
|
||||
describe as jscDescribe,
|
||||
describeArray,
|
||||
gcAndSweep,
|
||||
fullGC,
|
||||
edenGC,
|
||||
heapSize,
|
||||
heapStats,
|
||||
memoryUsage,
|
||||
getRandomSeed,
|
||||
setRandomSeed,
|
||||
isRope,
|
||||
callerSourceOrigin,
|
||||
noFTL,
|
||||
noOSRExitFuzzing,
|
||||
optimizeNextInvocation,
|
||||
numberOfDFGCompiles,
|
||||
releaseWeakRefs,
|
||||
totalCompileTime,
|
||||
reoptimizationRetryCount,
|
||||
drainMicrotasks,
|
||||
} from "bun:jsc";
|
||||
|
||||
describe("bun:jsc", () => {
|
||||
function count() {
|
||||
var j = 0;
|
||||
for (var i = 0; i < 999999; i++) {
|
||||
j += i + 2;
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
it("describe", () => {
|
||||
jscDescribe([]);
|
||||
});
|
||||
it("describeArray", () => {
|
||||
describeArray([1, 2, 3]);
|
||||
});
|
||||
it("gcAndSweep", () => {
|
||||
gcAndSweep();
|
||||
});
|
||||
it("fullGC", () => {
|
||||
fullGC();
|
||||
});
|
||||
it("edenGC", () => {
|
||||
edenGC();
|
||||
});
|
||||
it("heapSize", () => {
|
||||
expect(heapSize() > 0).toBe(true);
|
||||
});
|
||||
it("heapStats", () => {
|
||||
heapStats();
|
||||
});
|
||||
it("memoryUsage", () => {
|
||||
memoryUsage();
|
||||
});
|
||||
it("getRandomSeed", () => {
|
||||
getRandomSeed(2);
|
||||
});
|
||||
it("setRandomSeed", () => {
|
||||
setRandomSeed(2);
|
||||
});
|
||||
it("isRope", () => {
|
||||
expect(isRope("a" + 123 + "b")).toBe(true);
|
||||
expect(isRope("abcdefgh")).toBe(false);
|
||||
});
|
||||
it("callerSourceOrigin", () => {
|
||||
expect(callerSourceOrigin()).toBe(import.meta.url);
|
||||
});
|
||||
it("noFTL", () => {});
|
||||
it("noOSRExitFuzzing", () => {});
|
||||
it("optimizeNextInvocation", () => {
|
||||
count();
|
||||
optimizeNextInvocation(count);
|
||||
count();
|
||||
});
|
||||
it("numberOfDFGCompiles", () => {
|
||||
expect(numberOfDFGCompiles(count)).toBe(3);
|
||||
});
|
||||
it("releaseWeakRefs", () => {
|
||||
releaseWeakRefs();
|
||||
});
|
||||
it("totalCompileTime", () => {
|
||||
totalCompileTime(count);
|
||||
});
|
||||
it("reoptimizationRetryCount", () => {
|
||||
reoptimizationRetryCount(count);
|
||||
});
|
||||
it("drainMicrotasks", () => {
|
||||
drainMicrotasks();
|
||||
});
|
||||
});
|
||||
104
integration/bunjs-only-snippets/escapeHTML.test.js
Normal file
104
integration/bunjs-only-snippets/escapeHTML.test.js
Normal file
@@ -0,0 +1,104 @@
|
||||
import { describe, it, expect } from "bun:test";
|
||||
import { gcTick } from "./gc";
|
||||
|
||||
describe("escapeHTML", () => {
|
||||
// The matrix of cases we need to test for:
|
||||
// 1. Works with short strings
|
||||
// 2. Works with long strings
|
||||
// 3. Works with latin1 strings
|
||||
// 4. Works with utf16 strings
|
||||
// 5. Works when the text to escape is somewhere in the middle
|
||||
// 6. Works when the text to escape is in the beginning
|
||||
// 7. Works when the text to escape is in the end
|
||||
// 8. Returns the same string when there's no need to escape
|
||||
it("works", () => {
|
||||
expect(escapeHTML("absolutely nothing to do here")).toBe(
|
||||
"absolutely nothing to do here"
|
||||
);
|
||||
expect(escapeHTML("<script>alert(1)</script>")).toBe(
|
||||
"<script>alert(1)</script>"
|
||||
);
|
||||
expect(escapeHTML("<")).toBe("<");
|
||||
expect(escapeHTML(">")).toBe(">");
|
||||
expect(escapeHTML("&")).toBe("&");
|
||||
expect(escapeHTML("'")).toBe("'");
|
||||
expect(escapeHTML('"')).toBe(""");
|
||||
expect(escapeHTML("\n")).toBe("\n");
|
||||
expect(escapeHTML("\r")).toBe("\r");
|
||||
expect(escapeHTML("\t")).toBe("\t");
|
||||
expect(escapeHTML("\f")).toBe("\f");
|
||||
expect(escapeHTML("\v")).toBe("\v");
|
||||
expect(escapeHTML("\b")).toBe("\b");
|
||||
expect(escapeHTML("\u00A0")).toBe("\u00A0");
|
||||
expect(escapeHTML("<script>ab")).toBe("<script>ab");
|
||||
expect(escapeHTML("<script>")).toBe("<script>");
|
||||
expect(escapeHTML("<script><script>")).toBe("<script><script>");
|
||||
|
||||
expect(escapeHTML("lalala" + "<script>alert(1)</script>" + "lalala")).toBe(
|
||||
"lalala<script>alert(1)</script>lalala"
|
||||
);
|
||||
|
||||
expect(escapeHTML("<script>alert(1)</script>" + "lalala")).toBe(
|
||||
"<script>alert(1)</script>lalala"
|
||||
);
|
||||
expect(escapeHTML("lalala" + "<script>alert(1)</script>")).toBe(
|
||||
"lalala" + "<script>alert(1)</script>"
|
||||
);
|
||||
|
||||
expect(escapeHTML("What does 😊 mean?")).toBe("What does 😊 mean?");
|
||||
const output = escapeHTML("<What does 😊");
|
||||
expect(output).toBe("<What does 😊");
|
||||
expect(escapeHTML("<div>What does 😊 mean in text?")).toBe(
|
||||
"<div>What does 😊 mean in text?"
|
||||
);
|
||||
|
||||
expect(
|
||||
escapeHTML(
|
||||
("lalala" + "<script>alert(1)</script>" + "lalala").repeat(900)
|
||||
)
|
||||
).toBe("lalala<script>alert(1)</script>lalala".repeat(900));
|
||||
expect(
|
||||
escapeHTML(("<script>alert(1)</script>" + "lalala").repeat(900))
|
||||
).toBe("<script>alert(1)</script>lalala".repeat(900));
|
||||
expect(
|
||||
escapeHTML(("lalala" + "<script>alert(1)</script>").repeat(900))
|
||||
).toBe(("lalala" + "<script>alert(1)</script>").repeat(900));
|
||||
|
||||
// the positions of the unicode codepoint are important
|
||||
// our simd code for U16 is at 8 bytes, so we need to especially check the boundaries
|
||||
expect(
|
||||
escapeHTML("😊lalala" + "<script>alert(1)</script>" + "lalala")
|
||||
).toBe("😊lalala<script>alert(1)</script>lalala");
|
||||
expect(escapeHTML("<script>😊alert(1)</script>" + "lalala")).toBe(
|
||||
"<script>😊alert(1)</script>lalala"
|
||||
);
|
||||
expect(escapeHTML("<script>alert(1)😊</script>" + "lalala")).toBe(
|
||||
"<script>alert(1)😊</script>lalala"
|
||||
);
|
||||
expect(escapeHTML("<script>alert(1)</script>" + "😊lalala")).toBe(
|
||||
"<script>alert(1)</script>😊lalala"
|
||||
);
|
||||
expect(escapeHTML("<script>alert(1)</script>" + "lal😊ala")).toBe(
|
||||
"<script>alert(1)</script>lal😊ala"
|
||||
);
|
||||
expect(
|
||||
escapeHTML("<script>alert(1)</script>" + "lal😊ala".repeat(10))
|
||||
).toBe("<script>alert(1)</script>" + "lal😊ala".repeat(10));
|
||||
|
||||
for (let i = 1; i < 10; i++)
|
||||
expect(escapeHTML("<script>alert(1)</script>" + "la😊".repeat(i))).toBe(
|
||||
"<script>alert(1)</script>" + "la😊".repeat(i)
|
||||
);
|
||||
|
||||
expect(escapeHTML("la😊" + "<script>alert(1)</script>")).toBe(
|
||||
"la😊" + "<script>alert(1)</script>"
|
||||
);
|
||||
expect(
|
||||
escapeHTML(("lalala" + "<script>alert(1)</script>😊").repeat(1))
|
||||
).toBe(("lalala" + "<script>alert(1)</script>😊").repeat(1));
|
||||
|
||||
expect(escapeHTML("😊".repeat(100))).toBe("😊".repeat(100));
|
||||
expect(escapeHTML("😊<".repeat(100))).toBe("😊<".repeat(100));
|
||||
expect(escapeHTML("<😊>".repeat(100))).toBe("<😊>".repeat(100));
|
||||
});
|
||||
});
|
||||
@@ -258,6 +258,9 @@ void* JSFunctionCall(void* globalObject, void* callFrame);
|
||||
bool my_callback_function(void* arg0);
|
||||
|
||||
bool my_callback_function(void* arg0) {
|
||||
#ifdef INJECT_BEFORE
|
||||
INJECT_BEFORE;
|
||||
#endif
|
||||
EncodedJSValue arguments[1] = {
|
||||
PTR_TO_JSVALUE(arg0)
|
||||
};
|
||||
|
||||
110
integration/bunjs-only-snippets/streams.test.js
Normal file
110
integration/bunjs-only-snippets/streams.test.js
Normal file
@@ -0,0 +1,110 @@
|
||||
import { file, gc } from "bun";
|
||||
import { expect, it } from "bun:test";
|
||||
import { writeFileSync } from "node:fs";
|
||||
|
||||
it("exists globally", () => {
|
||||
expect(typeof ReadableStream).toBe("function");
|
||||
expect(typeof ReadableStreamBYOBReader).toBe("function");
|
||||
expect(typeof ReadableStreamBYOBRequest).toBe("function");
|
||||
expect(typeof ReadableStreamDefaultController).toBe("function");
|
||||
expect(typeof ReadableStreamDefaultReader).toBe("function");
|
||||
expect(typeof TransformStream).toBe("function");
|
||||
expect(typeof TransformStreamDefaultController).toBe("function");
|
||||
expect(typeof WritableStream).toBe("function");
|
||||
expect(typeof WritableStreamDefaultController).toBe("function");
|
||||
expect(typeof WritableStreamDefaultWriter).toBe("function");
|
||||
expect(typeof ByteLengthQueuingStrategy).toBe("function");
|
||||
expect(typeof CountQueuingStrategy).toBe("function");
|
||||
});
|
||||
|
||||
it("ReadableStream", async () => {
|
||||
var stream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue(Buffer.from("abdefgh"));
|
||||
},
|
||||
pull(controller) {},
|
||||
cancel() {},
|
||||
type: "bytes",
|
||||
});
|
||||
const chunks = [];
|
||||
const chunk = await stream.getReader().read();
|
||||
chunks.push(chunk.value);
|
||||
expect(chunks[0].join("")).toBe(Buffer.from("abdefgh").join(""));
|
||||
});
|
||||
|
||||
it("ReadableStream for Blob", async () => {
|
||||
var blob = new Blob(["abdefgh", "ijklmnop"]);
|
||||
expect(await blob.text()).toBe("abdefghijklmnop");
|
||||
var stream = blob.stream();
|
||||
const chunks = [];
|
||||
var reader = stream.getReader();
|
||||
while (true) {
|
||||
const chunk = await reader.read();
|
||||
if (chunk.done) break;
|
||||
chunks.push(new TextDecoder().decode(chunk.value));
|
||||
}
|
||||
expect(chunks.join("")).toBe(
|
||||
new TextDecoder().decode(Buffer.from("abdefghijklmnop"))
|
||||
);
|
||||
});
|
||||
|
||||
it("ReadableStream for File", async () => {
|
||||
var blob = file(import.meta.dir + "/fetch.js.txt");
|
||||
var stream = blob.stream(24);
|
||||
const chunks = [];
|
||||
var reader = stream.getReader();
|
||||
stream = undefined;
|
||||
while (true) {
|
||||
const chunk = await reader.read();
|
||||
gc(true);
|
||||
if (chunk.done) break;
|
||||
chunks.push(chunk.value);
|
||||
expect(chunk.value.byteLength <= 24).toBe(true);
|
||||
gc(true);
|
||||
}
|
||||
reader = undefined;
|
||||
const output = new Uint8Array(await blob.arrayBuffer()).join("");
|
||||
const input = chunks.map((a) => a.join("")).join("");
|
||||
expect(output).toBe(input);
|
||||
gc(true);
|
||||
});
|
||||
|
||||
it("ReadableStream for File errors", async () => {
|
||||
try {
|
||||
var blob = file(import.meta.dir + "/fetch.js.txt.notfound");
|
||||
blob.stream().getReader();
|
||||
throw new Error("should not reach here");
|
||||
} catch (e) {
|
||||
expect(e.code).toBe("ENOENT");
|
||||
expect(e.syscall).toBe("open");
|
||||
}
|
||||
});
|
||||
|
||||
it("ReadableStream for empty blob closes immediately", async () => {
|
||||
var blob = new Blob([]);
|
||||
var stream = blob.stream();
|
||||
const chunks = [];
|
||||
var reader = stream.getReader();
|
||||
while (true) {
|
||||
const chunk = await reader.read();
|
||||
if (chunk.done) break;
|
||||
chunks.push(chunk.value);
|
||||
}
|
||||
|
||||
expect(chunks.length).toBe(0);
|
||||
});
|
||||
|
||||
it("ReadableStream for empty file closes immediately", async () => {
|
||||
writeFileSync("/tmp/bun-empty-file-123456", "");
|
||||
var blob = file("/tmp/bun-empty-file-123456");
|
||||
var stream = blob.stream();
|
||||
const chunks = [];
|
||||
var reader = stream.getReader();
|
||||
while (true) {
|
||||
const chunk = await reader.read();
|
||||
if (chunk.done) break;
|
||||
chunks.push(chunk.value);
|
||||
}
|
||||
|
||||
expect(chunks.length).toBe(0);
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"mitata": "^0.0.10",
|
||||
"mitata": "^0.1.3",
|
||||
"peechy": "0.4.32",
|
||||
"react": "^17.0.2"
|
||||
},
|
||||
@@ -9,6 +9,8 @@
|
||||
"build-fallback": "esbuild --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"he": "^1.2.0",
|
||||
"html-entities": "^2.3.3",
|
||||
"prettier": "^2.4.1",
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
|
||||
104
src/baby_list.zig
Normal file
104
src/baby_list.zig
Normal file
@@ -0,0 +1,104 @@
|
||||
const std = @import("std");
|
||||
const Environment = @import("./env.zig");
|
||||
|
||||
/// This is like ArrayList except it stores the length and capacity as u32
|
||||
/// In practice, it is very unusual to have lengths above 4 GB
|
||||
///
|
||||
/// This lets us have array lists which occupy the same amount of space as a slice
|
||||
pub fn BabyList(comptime Type: type) type {
|
||||
return struct {
|
||||
const ListType = @This();
|
||||
ptr: [*]Type = undefined,
|
||||
len: u32 = 0,
|
||||
cap: u32 = 0,
|
||||
|
||||
pub inline fn init(items: []const Type) ListType {
|
||||
@setRuntimeSafety(false);
|
||||
return ListType{
|
||||
// Remove the const qualifier from the items
|
||||
.ptr = @intToPtr([*]Type, @ptrToInt(items.ptr)),
|
||||
|
||||
.len = @truncate(u32, items.len),
|
||||
.cap = @truncate(u32, items.len),
|
||||
};
|
||||
}
|
||||
|
||||
pub inline fn fromList(list_: anytype) ListType {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
if (comptime Environment.allow_assert) {
|
||||
std.debug.assert(list_.items.len <= list_.capacity);
|
||||
}
|
||||
|
||||
return ListType{
|
||||
.ptr = list_.items.ptr,
|
||||
.len = @truncate(u32, list_.items.len),
|
||||
.cap = @truncate(u32, list_.capacity),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn update(this: *ListType, list_: anytype) void {
|
||||
@setRuntimeSafety(false);
|
||||
this.ptr = list_.items.ptr;
|
||||
this.len = @truncate(u32, list_.items.len);
|
||||
this.cap = @truncate(u32, list_.capacity);
|
||||
|
||||
if (comptime Environment.allow_assert) {
|
||||
std.debug.assert(this.len <= this.cap);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn list(this: ListType) std.ArrayListUnmanaged(Type) {
|
||||
return std.ArrayListUnmanaged(Type){
|
||||
.items = this.ptr[0..this.len],
|
||||
.capacity = this.cap,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn listManaged(this: ListType, allocator: std.mem.Allocator) std.ArrayList(Type) {
|
||||
return std.ArrayList(Type){
|
||||
.items = this.ptr[0..this.len],
|
||||
.capacity = this.cap,
|
||||
.allocator = allocator,
|
||||
};
|
||||
}
|
||||
|
||||
pub inline fn first(this: ListType) ?*Type {
|
||||
return if (this.len > 0) this.ptr[0] else @as(?*Type, null);
|
||||
}
|
||||
|
||||
pub inline fn last(this: ListType) ?*Type {
|
||||
return if (this.len > 0) &this.ptr[this.len - 1] else @as(?*Type, null);
|
||||
}
|
||||
|
||||
pub inline fn first_(this: ListType) Type {
|
||||
return this.ptr[0];
|
||||
}
|
||||
|
||||
pub fn one(allocator: std.mem.Allocator, value: Type) !ListType {
|
||||
var items = try allocator.alloc(Type, 1);
|
||||
items[0] = value;
|
||||
return ListType{
|
||||
.ptr = @ptrCast([*]Type, items.ptr),
|
||||
.len = 1,
|
||||
.cap = 1,
|
||||
};
|
||||
}
|
||||
|
||||
pub inline fn @"[0]"(this: ListType) Type {
|
||||
return this.ptr[0];
|
||||
}
|
||||
const OOM = error{OutOfMemory};
|
||||
|
||||
pub fn push(this: *ListType, allocator: std.mem.Allocator, value: Type) OOM!void {
|
||||
var list_ = this.list();
|
||||
try list_.append(allocator, value);
|
||||
this.update(list_);
|
||||
}
|
||||
|
||||
pub inline fn slice(this: ListType) []Type {
|
||||
@setRuntimeSafety(false);
|
||||
return this.ptr[0..this.len];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -120,8 +120,7 @@ pub const Run = struct {
|
||||
Global.exit(1);
|
||||
}
|
||||
|
||||
const result = promise.result(this.vm.global.vm());
|
||||
JSC.C.JSValueProtect(this.vm.global.ref(), result.asObjectRef());
|
||||
_ = promise.result(this.vm.global.vm());
|
||||
|
||||
if (this.vm.log.msgs.items.len > 0) {
|
||||
if (Output.enable_ansi_colors) {
|
||||
@@ -133,6 +132,8 @@ pub const Run = struct {
|
||||
Output.flush();
|
||||
}
|
||||
|
||||
this.vm.global.vm().releaseWeakRefs();
|
||||
_ = this.vm.global.vm().runGC(false);
|
||||
this.vm.tick();
|
||||
|
||||
{
|
||||
|
||||
@@ -126,7 +126,6 @@ pub const Bunfig = struct {
|
||||
if (prop.value.?.data != .e_string) continue;
|
||||
valid_count += 1;
|
||||
}
|
||||
|
||||
var buffer = allocator.alloc([]const u8, valid_count * 2) catch unreachable;
|
||||
var keys = buffer[0..valid_count];
|
||||
var values = buffer[valid_count..];
|
||||
@@ -442,19 +441,19 @@ pub const Bunfig = struct {
|
||||
|
||||
if (json.get("jsxImportSource")) |expr| {
|
||||
if (expr.asString(allocator)) |value| {
|
||||
jsx_import_source = value;
|
||||
jsx_import_source = try allocator.dupe(u8, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (json.get("jsxFragment")) |expr| {
|
||||
if (expr.asString(allocator)) |value| {
|
||||
jsx_fragment = value;
|
||||
jsx_fragment = try allocator.dupe(u8, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (json.get("jsxFactory")) |expr| {
|
||||
if (expr.asString(allocator)) |value| {
|
||||
jsx_factory = value;
|
||||
jsx_factory = try allocator.dupe(u8, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
56
src/c.zig
56
src/c.zig
@@ -249,3 +249,59 @@ pub fn getSelfExeSharedLibPaths(allocator: std.mem.Allocator) error{OutOfMemory}
|
||||
else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"),
|
||||
}
|
||||
}
|
||||
|
||||
/// The madvise() system call allows a process that has knowledge of its mem-ory memory
|
||||
/// ory behavior to describe it to the system. The advice passed in may be
|
||||
/// used by the system to alter its virtual memory paging strategy. This
|
||||
/// advice may improve application and system performance. The behavior
|
||||
/// specified in advice can only be one of the following values:
|
||||
///
|
||||
/// MADV_NORMAL Indicates that the application has no advice to give on
|
||||
/// its behavior in the specified address range. This is
|
||||
/// the system default behavior. This is used with
|
||||
/// madvise() system call.
|
||||
///
|
||||
/// POSIX_MADV_NORMAL
|
||||
/// Same as MADV_NORMAL but used with posix_madvise() system
|
||||
/// call.
|
||||
///
|
||||
/// MADV_SEQUENTIAL Indicates that the application expects to access this
|
||||
/// address range in a sequential manner. This is used with
|
||||
/// madvise() system call.
|
||||
///
|
||||
/// POSIX_MADV_SEQUENTIAL
|
||||
/// Same as MADV_SEQUENTIAL but used with posix_madvise()
|
||||
/// system call.
|
||||
///
|
||||
/// MADV_RANDOM Indicates that the application expects to access this
|
||||
/// address range in a random manner. This is used with
|
||||
/// madvise() system call.
|
||||
///
|
||||
/// POSIX_MADV_RANDOM
|
||||
/// Same as MADV_RANDOM but used with posix_madvise() system
|
||||
/// call.
|
||||
///
|
||||
/// MADV_WILLNEED Indicates that the application expects to access this
|
||||
/// address range soon. This is used with madvise() system
|
||||
/// call.
|
||||
///
|
||||
/// POSIX_MADV_WILLNEED
|
||||
/// Same as MADV_WILLNEED but used with posix_madvise() sys-tem system
|
||||
/// tem call.
|
||||
///
|
||||
/// MADV_DONTNEED Indicates that the application is not expecting to
|
||||
/// access this address range soon. This is used with
|
||||
/// madvise() system call.
|
||||
///
|
||||
/// POSIX_MADV_DONTNEED
|
||||
/// Same as MADV_DONTNEED but used with posix_madvise() sys-tem system
|
||||
/// tem call.
|
||||
///
|
||||
/// MADV_FREE Indicates that the application will not need the infor-mation information
|
||||
/// mation contained in this address range, so the pages may
|
||||
/// be reused right away. The address range will remain
|
||||
/// valid. This is used with madvise() system call.
|
||||
///
|
||||
/// The posix_madvise() behaves same as madvise() except that it uses values
|
||||
/// with POSIX_ prefix for the advice system call argument.
|
||||
pub extern "c" fn posix_madvise(ptr: *anyopaque, len: usize, advice: i32) c_int;
|
||||
|
||||
Submodule src/deps/mimalloc updated: 9e41263d39...6d07c0b9ba
126
src/deps/uws.zig
126
src/deps/uws.zig
@@ -1,11 +1,13 @@
|
||||
const Api = @import("../api/schema.zig").Api;
|
||||
const std = @import("std");
|
||||
const Environment = @import("../env.zig");
|
||||
pub const u_int8_t = u8;
|
||||
pub const u_int16_t = c_ushort;
|
||||
pub const u_int32_t = c_uint;
|
||||
pub const u_int64_t = c_ulonglong;
|
||||
pub const LIBUS_LISTEN_DEFAULT: c_int = 0;
|
||||
pub const LIBUS_LISTEN_EXCLUSIVE_PORT: c_int = 1;
|
||||
pub const us_socket_t = opaque {};
|
||||
pub const Socket = opaque {};
|
||||
pub const us_timer_t = opaque {};
|
||||
pub const us_socket_context_t = opaque {};
|
||||
pub const Loop = opaque {
|
||||
@@ -17,10 +19,13 @@ pub const Loop = opaque {
|
||||
return us_wakeup_loop(this);
|
||||
}
|
||||
|
||||
pub fn tick(this: *Loop) void {
|
||||
us_loop_tick(this);
|
||||
}
|
||||
|
||||
pub fn nextTick(this: *Loop, comptime UserType: type, user_data: UserType, comptime deferCallback: fn (ctx: UserType) void) void {
|
||||
const Handler = struct {
|
||||
pub fn callback(data: *anyopaque) callconv(.C) void {
|
||||
const std = @import("std");
|
||||
deferCallback(@ptrCast(UserType, @alignCast(@alignOf(std.meta.Child(UserType)), data)));
|
||||
}
|
||||
};
|
||||
@@ -34,7 +39,6 @@ pub const Loop = opaque {
|
||||
return uws_loop_removePostHandler(handler.loop, callback);
|
||||
}
|
||||
pub fn callback(data: *anyopaque, _: *Loop) callconv(.C) void {
|
||||
const std = @import("std");
|
||||
callback(@ptrCast(UserType, @alignCast(@alignOf(std.meta.Child(UserType)), data)));
|
||||
}
|
||||
};
|
||||
@@ -56,6 +60,7 @@ pub const Loop = opaque {
|
||||
extern fn us_loop_free(loop: ?*Loop) void;
|
||||
extern fn us_loop_ext(loop: ?*Loop) ?*anyopaque;
|
||||
extern fn us_loop_run(loop: ?*Loop) void;
|
||||
extern fn us_loop_tick(loop: ?*Loop) void;
|
||||
extern fn us_wakeup_loop(loop: ?*Loop) void;
|
||||
extern fn us_loop_integrate(loop: ?*Loop) void;
|
||||
extern fn us_loop_iteration_number(loop: ?*Loop) c_longlong;
|
||||
@@ -85,26 +90,87 @@ extern fn us_socket_context_on_server_name(ssl: c_int, context: ?*us_socket_cont
|
||||
extern fn us_socket_context_get_native_handle(ssl: c_int, context: ?*us_socket_context_t) ?*anyopaque;
|
||||
extern fn us_create_socket_context(ssl: c_int, loop: ?*Loop, ext_size: c_int, options: us_socket_context_options_t) ?*us_socket_context_t;
|
||||
extern fn us_socket_context_free(ssl: c_int, context: ?*us_socket_context_t) void;
|
||||
extern fn us_socket_context_on_open(ssl: c_int, context: ?*us_socket_context_t, on_open: ?fn (?*us_socket_t, c_int, [*c]u8, c_int) callconv(.C) ?*us_socket_t) void;
|
||||
extern fn us_socket_context_on_close(ssl: c_int, context: ?*us_socket_context_t, on_close: ?fn (?*us_socket_t, c_int, ?*anyopaque) callconv(.C) ?*us_socket_t) void;
|
||||
extern fn us_socket_context_on_data(ssl: c_int, context: ?*us_socket_context_t, on_data: ?fn (?*us_socket_t, [*c]u8, c_int) callconv(.C) ?*us_socket_t) void;
|
||||
extern fn us_socket_context_on_writable(ssl: c_int, context: ?*us_socket_context_t, on_writable: ?fn (*us_socket_t) callconv(.C) ?*us_socket_t) void;
|
||||
extern fn us_socket_context_on_timeout(ssl: c_int, context: ?*us_socket_context_t, on_timeout: ?fn (?*us_socket_t) callconv(.C) ?*us_socket_t) void;
|
||||
extern fn us_socket_context_on_connect_error(ssl: c_int, context: ?*us_socket_context_t, on_connect_error: ?fn (?*us_socket_t, c_int) callconv(.C) ?*us_socket_t) void;
|
||||
extern fn us_socket_context_on_end(ssl: c_int, context: ?*us_socket_context_t, on_end: ?fn (?*us_socket_t) callconv(.C) ?*us_socket_t) void;
|
||||
extern fn us_socket_context_on_open(ssl: c_int, context: ?*us_socket_context_t, on_open: ?fn (?*Socket, c_int, [*c]u8, c_int) callconv(.C) ?*Socket) void;
|
||||
extern fn us_socket_context_on_close(ssl: c_int, context: ?*us_socket_context_t, on_close: ?fn (?*Socket, c_int, ?*anyopaque) callconv(.C) ?*Socket) void;
|
||||
extern fn us_socket_context_on_data(ssl: c_int, context: ?*us_socket_context_t, on_data: ?fn (?*Socket, [*c]u8, c_int) callconv(.C) ?*Socket) void;
|
||||
extern fn us_socket_context_on_writable(ssl: c_int, context: ?*us_socket_context_t, on_writable: ?fn (*Socket) callconv(.C) ?*Socket) void;
|
||||
extern fn us_socket_context_on_timeout(ssl: c_int, context: ?*us_socket_context_t, on_timeout: ?fn (?*Socket) callconv(.C) ?*Socket) void;
|
||||
extern fn us_socket_context_on_connect_error(ssl: c_int, context: ?*us_socket_context_t, on_connect_error: ?fn (?*Socket, c_int) callconv(.C) ?*Socket) void;
|
||||
extern fn us_socket_context_on_end(ssl: c_int, context: ?*us_socket_context_t, on_end: ?fn (?*Socket) callconv(.C) ?*Socket) void;
|
||||
extern fn us_socket_context_ext(ssl: c_int, context: ?*us_socket_context_t) ?*anyopaque;
|
||||
|
||||
extern fn us_socket_context_listen(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, options: c_int, socket_ext_size: c_int) ?*listen_socket_t;
|
||||
|
||||
extern fn us_socket_context_connect(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, source_host: [*c]const u8, options: c_int, socket_ext_size: c_int) ?*us_socket_t;
|
||||
extern fn us_socket_is_established(ssl: c_int, s: ?*us_socket_t) c_int;
|
||||
extern fn us_socket_close_connecting(ssl: c_int, s: ?*us_socket_t) ?*us_socket_t;
|
||||
extern fn us_socket_context_connect(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, source_host: [*c]const u8, options: c_int, socket_ext_size: c_int) ?*Socket;
|
||||
extern fn us_socket_is_established(ssl: c_int, s: ?*Socket) c_int;
|
||||
extern fn us_socket_close_connecting(ssl: c_int, s: ?*Socket) ?*Socket;
|
||||
extern fn us_socket_context_loop(ssl: c_int, context: ?*us_socket_context_t) ?*Loop;
|
||||
extern fn us_socket_context_adopt_socket(ssl: c_int, context: ?*us_socket_context_t, s: ?*us_socket_t, ext_size: c_int) ?*us_socket_t;
|
||||
extern fn us_socket_context_adopt_socket(ssl: c_int, context: ?*us_socket_context_t, s: ?*Socket, ext_size: c_int) ?*Socket;
|
||||
extern fn us_create_child_socket_context(ssl: c_int, context: ?*us_socket_context_t, context_ext_size: c_int) ?*us_socket_context_t;
|
||||
|
||||
pub const Poll = opaque {
|
||||
extern fn us_create_poll(loop: ?*Loop, fallthrough: c_int, ext_size: c_uint) *Poll;
|
||||
pub fn create(
|
||||
loop: *Loop,
|
||||
comptime Data: type,
|
||||
file: c_int,
|
||||
val: Data,
|
||||
fallthrough: bool,
|
||||
flags: Flags,
|
||||
callback: CallbackType,
|
||||
) ?*Poll {
|
||||
var poll = us_create_callback(loop, @as(c_int, @boolToInt(fallthrough)), file, @sizeOf(Data));
|
||||
if (comptime Data != void) {
|
||||
poll.data(Data).* = val;
|
||||
}
|
||||
var flags_int: c_int = 0;
|
||||
if (flags.read) {
|
||||
flags_int |= Flags.read_flag;
|
||||
}
|
||||
|
||||
if (flags.write) {
|
||||
flags_int |= Flags.write_flag;
|
||||
}
|
||||
|
||||
us_callback_set(poll, flags_int, callback);
|
||||
return poll;
|
||||
}
|
||||
|
||||
pub fn stop(self: *Poll, loop: *Loop) void {
|
||||
us_poll_stop(self, loop);
|
||||
}
|
||||
|
||||
pub fn data(self: *Poll, comptime Data: type) *Data {
|
||||
return us_poll_ext(self).?;
|
||||
}
|
||||
|
||||
pub fn fd(self: *Poll) @import("std").os.fd_t {
|
||||
return @intCast(@import("std").os.fd_t, us_poll_fd(self));
|
||||
}
|
||||
|
||||
pub fn start(self: *Poll, poll_type: Flags) void {
|
||||
// us_poll_start(self, loop: ?*Loop, events: c_int)
|
||||
_ = self;
|
||||
_ = poll_type;
|
||||
}
|
||||
|
||||
pub const Flags = struct {
|
||||
read: bool = false,
|
||||
write: bool = false,
|
||||
|
||||
//#define LIBUS_SOCKET_READABLE
|
||||
pub const read_flag = if (Environment.isLinux) std.os.linux.EPOLL.IN else 1;
|
||||
// #define LIBUS_SOCKET_WRITABLE
|
||||
pub const write_flag = if (Environment.isLinux) std.os.linux.EPOLL.OUT else 2;
|
||||
};
|
||||
|
||||
pub fn deinit(self: *Poll) void {
|
||||
us_poll_free(self);
|
||||
}
|
||||
|
||||
// (void* userData, int fd, int events, int error, struct us_poll_t *poll)
|
||||
pub const CallbackType = fn (?*anyopaque, c_int, c_int, c_int, *Poll) void;
|
||||
extern fn us_create_callback(loop: ?*Loop, fallthrough: c_int, fd: c_int, ext_size: c_uint) *Poll;
|
||||
extern fn us_callback_set(poll: *Poll, events: c_int, callback: CallbackType) *Poll;
|
||||
extern fn us_poll_free(p: ?*Poll, loop: ?*Loop) void;
|
||||
extern fn us_poll_init(p: ?*Poll, fd: c_int, poll_type: c_int) void;
|
||||
extern fn us_poll_start(p: ?*Poll, loop: ?*Loop, events: c_int) void;
|
||||
@@ -116,19 +182,19 @@ pub const Poll = opaque {
|
||||
extern fn us_poll_resize(p: ?*Poll, loop: ?*Loop, ext_size: c_uint) ?*Poll;
|
||||
};
|
||||
|
||||
extern fn us_socket_get_native_handle(ssl: c_int, s: ?*us_socket_t) ?*anyopaque;
|
||||
extern fn us_socket_write(ssl: c_int, s: ?*us_socket_t, data: [*c]const u8, length: c_int, msg_more: c_int) c_int;
|
||||
extern fn us_socket_timeout(ssl: c_int, s: ?*us_socket_t, seconds: c_uint) void;
|
||||
extern fn us_socket_ext(ssl: c_int, s: ?*us_socket_t) ?*anyopaque;
|
||||
extern fn us_socket_context(ssl: c_int, s: ?*us_socket_t) ?*us_socket_context_t;
|
||||
extern fn us_socket_flush(ssl: c_int, s: ?*us_socket_t) void;
|
||||
extern fn us_socket_shutdown(ssl: c_int, s: ?*us_socket_t) void;
|
||||
extern fn us_socket_shutdown_read(ssl: c_int, s: ?*us_socket_t) void;
|
||||
extern fn us_socket_is_shut_down(ssl: c_int, s: ?*us_socket_t) c_int;
|
||||
extern fn us_socket_is_closed(ssl: c_int, s: ?*us_socket_t) c_int;
|
||||
extern fn us_socket_close(ssl: c_int, s: ?*us_socket_t, code: c_int, reason: ?*anyopaque) ?*us_socket_t;
|
||||
extern fn us_socket_local_port(ssl: c_int, s: ?*us_socket_t) c_int;
|
||||
extern fn us_socket_remote_address(ssl: c_int, s: ?*us_socket_t, buf: [*c]u8, length: [*c]c_int) void;
|
||||
extern fn us_socket_get_native_handle(ssl: c_int, s: ?*Socket) ?*anyopaque;
|
||||
extern fn us_socket_write(ssl: c_int, s: ?*Socket, data: [*c]const u8, length: c_int, msg_more: c_int) c_int;
|
||||
extern fn Socketimeout(ssl: c_int, s: ?*Socket, seconds: c_uint) void;
|
||||
extern fn us_socket_ext(ssl: c_int, s: ?*Socket) ?*anyopaque;
|
||||
extern fn us_socket_context(ssl: c_int, s: ?*Socket) ?*us_socket_context_t;
|
||||
extern fn us_socket_flush(ssl: c_int, s: ?*Socket) void;
|
||||
extern fn us_socket_shutdown(ssl: c_int, s: ?*Socket) void;
|
||||
extern fn us_socket_shutdown_read(ssl: c_int, s: ?*Socket) void;
|
||||
extern fn us_socket_is_shut_down(ssl: c_int, s: ?*Socket) c_int;
|
||||
extern fn us_socket_is_closed(ssl: c_int, s: ?*Socket) c_int;
|
||||
extern fn us_socket_close(ssl: c_int, s: ?*Socket, code: c_int, reason: ?*anyopaque) ?*Socket;
|
||||
extern fn us_socket_local_port(ssl: c_int, s: ?*Socket) c_int;
|
||||
extern fn us_socket_remote_address(ssl: c_int, s: ?*Socket, buf: [*c]u8, length: [*c]c_int) void;
|
||||
pub const uws_app_s = opaque {};
|
||||
pub const uws_req_s = opaque {};
|
||||
pub const uws_websocket_s = opaque {};
|
||||
@@ -607,7 +673,7 @@ pub fn NewApp(comptime ssl: bool) type {
|
||||
// };
|
||||
|
||||
// const OnWritable = struct {
|
||||
// pub fn handle(socket: *us_socket_t) callconv(.C) ?*us_socket_t {
|
||||
// pub fn handle(socket: *Socket) callconv(.C) ?*Socket {
|
||||
// if (comptime UserDataType == void) {
|
||||
// @call(.{ .modifier = .always_inline }, handler, .{
|
||||
// void{},
|
||||
@@ -644,7 +710,7 @@ pub fn NewApp(comptime ssl: bool) type {
|
||||
};
|
||||
}
|
||||
extern fn uws_res_prepare_for_sendfile(ssl: c_int, res: *uws_res) void;
|
||||
extern fn uws_res_get_native_handle(ssl: c_int, res: *uws_res) *us_socket_t;
|
||||
extern fn uws_res_get_native_handle(ssl: c_int, res: *uws_res) *Socket;
|
||||
extern fn uws_create_app(ssl: c_int, options: us_socket_context_options_t) *uws_app_t;
|
||||
extern fn uws_app_destroy(ssl: c_int, app: *uws_app_t) void;
|
||||
extern fn uws_app_get(ssl: c_int, app: *uws_app_t, pattern: [*c]const u8, handler: uws_method_handler, user_data: ?*anyopaque) void;
|
||||
|
||||
@@ -91,3 +91,6 @@ pub const atomic_file_watcher = env.isLinux;
|
||||
|
||||
pub const node_streams = env.isDebug or env.isTest;
|
||||
pub const simd = true;
|
||||
|
||||
// This change didn't seem to make a meaningful difference in microbenchmarks
|
||||
pub const latin1_is_now_ascii = false;
|
||||
|
||||
@@ -8,6 +8,18 @@ pub const default_allocator: std.mem.Allocator = if (!use_mimalloc)
|
||||
else
|
||||
@import("./memory_allocator.zig").c_allocator;
|
||||
|
||||
pub const huge_allocator: std.mem.Allocator = if (!use_mimalloc)
|
||||
std.heap.c_allocator
|
||||
else
|
||||
@import("./memory_allocator.zig").huge_allocator;
|
||||
|
||||
pub const auto_allocator: std.mem.Allocator = if (!use_mimalloc)
|
||||
std.heap.c_allocator
|
||||
else
|
||||
@import("./memory_allocator.zig").auto_allocator;
|
||||
|
||||
pub const huge_allocator_threshold: comptime_int = @import("./memory_allocator.zig").huge_threshold;
|
||||
|
||||
pub const C = @import("c.zig");
|
||||
|
||||
pub const FeatureFlags = @import("feature_flags.zig");
|
||||
@@ -159,3 +171,33 @@ pub fn span(ptr: anytype) std.mem.Span(@TypeOf(ptr)) {
|
||||
|
||||
pub const IdentityContext = @import("./identity_context.zig").IdentityContext;
|
||||
pub const ArrayIdentityContext = @import("./identity_context.zig").ArrayIdentityContext;
|
||||
pub const BabyList = @import("./baby_list.zig").BabyList;
|
||||
pub const ByteList = BabyList(u8);
|
||||
|
||||
pub fn DebugOnly(comptime Type: type) type {
|
||||
if (comptime Environment.isDebug) {
|
||||
return Type;
|
||||
}
|
||||
|
||||
return void;
|
||||
}
|
||||
|
||||
pub fn DebugOnlyDefault(comptime val: anytype) if (Environment.isDebug) @TypeOf(val) else void {
|
||||
if (comptime Environment.isDebug) {
|
||||
return val;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
pub inline fn range(comptime min: anytype, comptime max: anytype) [max - min]usize {
|
||||
return comptime brk: {
|
||||
var slice: [max - min]usize = undefined;
|
||||
var i: usize = min;
|
||||
while (i < max) {
|
||||
slice[i - min] = i;
|
||||
i += 1;
|
||||
}
|
||||
break :brk slice;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -270,8 +270,9 @@ pub const darwin = struct {
|
||||
pub extern "c" fn @"accept$NOCANCEL"(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
|
||||
pub extern "c" fn @"accept4$NOCANCEL"(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
|
||||
pub extern "c" fn @"open$NOCANCEL"(path: [*:0]const u8, oflag: c_uint, ...) c_int;
|
||||
pub extern "c" fn @"read$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize;
|
||||
pub extern "c" fn @"pread$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize;
|
||||
};
|
||||
|
||||
pub const OpenError = error{
|
||||
/// In WASI, this error may occur when the file descriptor does
|
||||
/// not hold the required rights to open a new resource relative to it.
|
||||
@@ -539,9 +540,11 @@ pub fn run_for_ns(self: *IO, nanoseconds: u63) !void {
|
||||
}
|
||||
}
|
||||
|
||||
const default_timespec = std.mem.zeroInit(os.timespec, .{});
|
||||
|
||||
fn flush(self: *IO, wait_for_completions: bool) !void {
|
||||
var io_pending = self.io_pending.peek();
|
||||
var events: [256]os.Kevent = undefined;
|
||||
var events: [512]os.Kevent = undefined;
|
||||
|
||||
// Check timeouts and fill events with completions in io_pending
|
||||
// (they will be submitted through kevent).
|
||||
@@ -552,7 +555,7 @@ fn flush(self: *IO, wait_for_completions: bool) !void {
|
||||
// Only call kevent() if we need to submit io events or if we need to wait for completions.
|
||||
if (change_events > 0 or self.completed.peek() == null) {
|
||||
// Zero timeouts for kevent() implies a non-blocking poll
|
||||
var ts = std.mem.zeroes(os.timespec);
|
||||
var ts = default_timespec;
|
||||
|
||||
// We need to wait (not poll) on kevent if there's nothing to submit or complete.
|
||||
// We should never wait indefinitely (timeout_ptr = null for kevent) given:
|
||||
@@ -602,7 +605,6 @@ fn flush_io(_: *IO, events: []os.Kevent, io_pending_top: *?*Completion) usize {
|
||||
for (events) |*kevent, flushed| {
|
||||
const completion = io_pending_top.* orelse return flushed;
|
||||
io_pending_top.* = completion.next;
|
||||
|
||||
const event_info = switch (completion.operation) {
|
||||
.accept => |op| [3]c_int{
|
||||
op.socket,
|
||||
@@ -711,6 +713,7 @@ const Operation = union(enum) {
|
||||
buf: [*]u8,
|
||||
len: u32,
|
||||
offset: u64,
|
||||
positional: bool = true,
|
||||
},
|
||||
recv: struct {
|
||||
socket: os.socket_t,
|
||||
@@ -774,9 +777,13 @@ fn submitWithIncrementPending(
|
||||
self.pending_count += 1;
|
||||
const Context = @TypeOf(context);
|
||||
const onCompleteFn = struct {
|
||||
fn onComplete(io: *IO, _completion: *Completion) void {
|
||||
fn onComplete(
|
||||
io: *IO,
|
||||
_completion: *Completion,
|
||||
) void {
|
||||
// Perform the actual operaton
|
||||
const op_data = &@field(_completion.operation, @tagName(operation_tag));
|
||||
|
||||
const result = OperationImpl.doOperation(op_data);
|
||||
|
||||
// Requeue onto io_pending if error.WouldBlock
|
||||
@@ -1161,8 +1168,9 @@ pub fn read(
|
||||
completion: *Completion,
|
||||
fd: os.fd_t,
|
||||
buffer: []u8,
|
||||
offset: u64,
|
||||
offset: ?u64,
|
||||
) void {
|
||||
const offset_ = offset orelse @as(u64, 0);
|
||||
self.submit(
|
||||
context,
|
||||
callback,
|
||||
@@ -1172,16 +1180,21 @@ pub fn read(
|
||||
.fd = fd,
|
||||
.buf = buffer.ptr,
|
||||
.len = @intCast(u32, buffer_limit(buffer.len)),
|
||||
.offset = offset,
|
||||
.offset = offset_,
|
||||
.positional = offset != null,
|
||||
},
|
||||
struct {
|
||||
fn doOperation(op: anytype) ReadError!usize {
|
||||
while (true) {
|
||||
const rc = os.system.pread(
|
||||
const rc = if (op.positional) os.system.pread(
|
||||
op.fd,
|
||||
op.buf,
|
||||
op.len,
|
||||
@bitCast(isize, op.offset),
|
||||
) else os.system.read(
|
||||
op.fd,
|
||||
op.buf,
|
||||
op.len,
|
||||
);
|
||||
return switch (@enumToInt(os.errno(rc))) {
|
||||
0 => @intCast(usize, rc),
|
||||
|
||||
@@ -1231,7 +1231,7 @@ pub fn read(
|
||||
completion: *Completion,
|
||||
fd: os.fd_t,
|
||||
buffer: []u8,
|
||||
offset: u64,
|
||||
offset: ?u64,
|
||||
) void {
|
||||
completion.* = .{
|
||||
.io = self,
|
||||
@@ -1250,7 +1250,8 @@ pub fn read(
|
||||
.read = .{
|
||||
.fd = fd,
|
||||
.buffer = buffer,
|
||||
.offset = offset,
|
||||
// pread is irrelevant here
|
||||
.offset = offset orelse 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Submodule src/javascript/jsc/WebKit updated: 06d0294f9c...ff1f8e24b7
@@ -623,7 +623,7 @@ pub fn openInEditor(
|
||||
) js.JSValueRef {
|
||||
var edit = &VirtualMachine.vm.rareData().editor_context;
|
||||
|
||||
var arguments = JSC.Node.ArgumentsSlice.from(args);
|
||||
var arguments = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), args);
|
||||
defer arguments.deinit();
|
||||
var path: string = "";
|
||||
var editor_choice: ?Editor = null;
|
||||
@@ -822,7 +822,7 @@ fn doResolve(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) ?JSC.JSValue {
|
||||
var args = JSC.Node.ArgumentsSlice.from(arguments);
|
||||
var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
|
||||
defer args.deinit();
|
||||
const specifier = args.protectEatNext() orelse {
|
||||
JSC.throwInvalidArguments("Expected a specifier and a from path", .{}, ctx, exception);
|
||||
@@ -1543,7 +1543,7 @@ pub fn serve(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) js.JSValueRef {
|
||||
var args = JSC.Node.ArgumentsSlice.from(arguments);
|
||||
var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
|
||||
var config = JSC.API.ServerConfig.fromJS(ctx.ptr(), &args, exception);
|
||||
if (exception.* != null) {
|
||||
return null;
|
||||
@@ -1612,6 +1612,100 @@ pub fn serve(
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub export fn Bun__escapeHTML(
|
||||
globalObject: *JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
const arguments = callframe.arguments();
|
||||
if (arguments.len < 1) {
|
||||
return ZigString.Empty.toValue(globalObject);
|
||||
}
|
||||
|
||||
const input_value = arguments[0];
|
||||
const zig_str = input_value.getZigString(globalObject);
|
||||
if (zig_str.len == 0)
|
||||
return ZigString.Empty.toValue(globalObject);
|
||||
|
||||
if (zig_str.is16Bit()) {
|
||||
var input_slice = zig_str.utf16SliceAligned();
|
||||
var escaped_html = strings.escapeHTMLForUTF16Input(globalObject.bunVM().allocator, input_slice) catch {
|
||||
globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toValue(globalObject));
|
||||
return JSC.JSValue.jsUndefined();
|
||||
};
|
||||
|
||||
if (escaped_html.ptr == input_slice.ptr and escaped_html.len == input_slice.len) {
|
||||
return input_value;
|
||||
}
|
||||
|
||||
if (input_slice.len == 1) {
|
||||
// single character escaped strings are statically allocated
|
||||
return ZigString.init(std.mem.sliceAsBytes(escaped_html)).to16BitValue(globalObject);
|
||||
}
|
||||
|
||||
if (comptime Environment.allow_assert) {
|
||||
// assert that re-encoding the string produces the same result
|
||||
std.debug.assert(
|
||||
std.mem.eql(
|
||||
u16,
|
||||
(strings.toUTF16Alloc(bun.default_allocator, strings.toUTF8Alloc(bun.default_allocator, escaped_html) catch unreachable, false) catch unreachable).?,
|
||||
escaped_html,
|
||||
),
|
||||
);
|
||||
|
||||
// assert we do not allocate a new string unnecessarily
|
||||
std.debug.assert(
|
||||
!std.mem.eql(
|
||||
u16,
|
||||
input_slice,
|
||||
escaped_html,
|
||||
),
|
||||
);
|
||||
|
||||
// the output should always be longer than the input
|
||||
std.debug.assert(escaped_html.len > input_slice.len);
|
||||
}
|
||||
|
||||
return ZigString.from16(escaped_html.ptr, escaped_html.len).toExternalValue(globalObject);
|
||||
} else {
|
||||
var input_slice = zig_str.slice();
|
||||
var escaped_html = strings.escapeHTMLForLatin1Input(globalObject.bunVM().allocator, input_slice) catch {
|
||||
globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toValue(globalObject));
|
||||
return JSC.JSValue.jsUndefined();
|
||||
};
|
||||
|
||||
if (escaped_html.ptr == input_slice.ptr and escaped_html.len == input_slice.len) {
|
||||
return input_value;
|
||||
}
|
||||
|
||||
if (input_slice.len == 1) {
|
||||
// single character escaped strings are statically allocated
|
||||
return ZigString.init(escaped_html).toValue(globalObject);
|
||||
}
|
||||
|
||||
if (comptime Environment.allow_assert) {
|
||||
// the output should always be longer than the input
|
||||
std.debug.assert(escaped_html.len > input_slice.len);
|
||||
|
||||
// assert we do not allocate a new string unnecessarily
|
||||
std.debug.assert(
|
||||
!std.mem.eql(
|
||||
u8,
|
||||
input_slice,
|
||||
escaped_html,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ZigString.init(escaped_html).toExternalValue(globalObject);
|
||||
}
|
||||
}
|
||||
|
||||
comptime {
|
||||
if (!JSC.is_bindgen) {
|
||||
_ = Bun__escapeHTML;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn allocUnsafe(
|
||||
_: void,
|
||||
ctx: js.JSContextRef,
|
||||
@@ -1620,7 +1714,7 @@ pub fn allocUnsafe(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) js.JSValueRef {
|
||||
var args = JSC.Node.ArgumentsSlice.from(arguments);
|
||||
var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
|
||||
|
||||
const length = @intCast(
|
||||
usize,
|
||||
@@ -1649,7 +1743,7 @@ pub fn mmapFile(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) js.JSValueRef {
|
||||
var args = JSC.Node.ArgumentsSlice.from(arguments);
|
||||
var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
|
||||
|
||||
var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
|
||||
const path = getFilePath(ctx, arguments[0..@minimum(1, arguments.len)], &buf, exception) orelse return null;
|
||||
@@ -1795,7 +1889,7 @@ pub const Hash = struct {
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) js.JSValueRef {
|
||||
var args = JSC.Node.ArgumentsSlice.from(arguments);
|
||||
var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
|
||||
var input: []const u8 = "";
|
||||
var input_slice = ZigString.Slice.empty;
|
||||
defer input_slice.deinit();
|
||||
@@ -2375,7 +2469,7 @@ pub const FFI = struct {
|
||||
return JSC.toInvalidArguments("ptr to invalid memory, that would segfault Bun :(", .{}, globalThis.ref());
|
||||
}
|
||||
|
||||
return JSC.JSValue.jsNumber(@bitCast(f64, @as(usize, addr)));
|
||||
return JSC.JSValue.fromPtrAddress(addr);
|
||||
}
|
||||
|
||||
const ValueOrError = union(enum) {
|
||||
|
||||
@@ -351,7 +351,7 @@ pub const FFI = struct {
|
||||
return ZigString.init("Failed to compile (nothing happend!)").toErrorInstance(global);
|
||||
},
|
||||
.compiled => |compiled| {
|
||||
var cb = Bun__CreateFFIFunction(
|
||||
var cb = JSC.NewFunctionPtr(
|
||||
global,
|
||||
&ZigString.init(std.mem.span(function_name)),
|
||||
@intCast(u32, function.arg_types.items.len),
|
||||
@@ -443,7 +443,7 @@ pub const FFI = struct {
|
||||
return ZigString.init("Failed to compile (nothing happend!)").toErrorInstance(global);
|
||||
},
|
||||
.compiled => |compiled| {
|
||||
var cb = Bun__CreateFFIFunction(
|
||||
var cb = JSC.NewFunctionPtr(
|
||||
global,
|
||||
&ZigString.init(std.mem.span(function_name)),
|
||||
@intCast(u32, function.arg_types.items.len),
|
||||
@@ -1434,10 +1434,3 @@ pub const FFI = struct {
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
extern fn Bun__CreateFFIFunction(
|
||||
globalObject: *JSGlobalObject,
|
||||
symbolName: *const ZigString,
|
||||
argCount: u32,
|
||||
functionPointer: *anyopaque,
|
||||
) *anyopaque;
|
||||
|
||||
@@ -408,6 +408,124 @@ pub const HTMLRewriter = struct {
|
||||
this.context.deinit(bun.default_allocator);
|
||||
}
|
||||
};
|
||||
|
||||
// pub const StreamOutputSink = struct {
|
||||
// global: *JSGlobalObject,
|
||||
// rewriter: *LOLHTML.HTMLRewriter,
|
||||
// context: LOLHTMLContext,
|
||||
// response: *Response,
|
||||
// input: JSC.WebCore.Blob = undefined,
|
||||
// pub fn init(context: LOLHTMLContext, global: *JSGlobalObject, original: *Response, builder: *LOLHTML.HTMLRewriter.Builder) JSValue {
|
||||
// var result = bun.default_allocator.create(Response) catch unreachable;
|
||||
// var sink = bun.default_allocator.create(StreamOutputSink) catch unreachable;
|
||||
// sink.* = StreamOutputSink{
|
||||
// .global = global,
|
||||
// .rewriter = undefined,
|
||||
// .context = context,
|
||||
// .response = result,
|
||||
// };
|
||||
|
||||
// for (sink.context.document_handlers.items) |doc| {
|
||||
// doc.ctx = sink;
|
||||
// }
|
||||
// for (sink.context.element_handlers.items) |doc| {
|
||||
// doc.ctx = sink;
|
||||
// }
|
||||
|
||||
// sink.rewriter = builder.build(
|
||||
// .UTF8,
|
||||
// .{
|
||||
// .preallocated_parsing_buffer_size = @maximum(original.body.len(), 1024),
|
||||
// .max_allowed_memory_usage = std.math.maxInt(u32),
|
||||
// },
|
||||
// false,
|
||||
// StreamOutputSink,
|
||||
// sink,
|
||||
// StreamOutputSink.write,
|
||||
// StreamOutputSink.done,
|
||||
// ) catch {
|
||||
// sink.deinit();
|
||||
// bun.default_allocator.destroy(result);
|
||||
|
||||
// return throwLOLHTMLError(global);
|
||||
// };
|
||||
|
||||
// result.* = Response{
|
||||
// .allocator = bun.default_allocator,
|
||||
// .body = .{
|
||||
// .init = .{
|
||||
// .status_code = 200,
|
||||
// },
|
||||
// .value = .{
|
||||
// .Locked = .{
|
||||
// .global = global,
|
||||
// .task = sink,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// };
|
||||
|
||||
// result.body.init.headers = original.body.init.headers;
|
||||
// result.body.init.method = original.body.init.method;
|
||||
// result.body.init.status_code = original.body.init.status_code;
|
||||
|
||||
// result.url = bun.default_allocator.dupe(u8, original.url) catch unreachable;
|
||||
// result.status_text = bun.default_allocator.dupe(u8, original.status_text) catch unreachable;
|
||||
|
||||
// var input: JSC.WebCore.Blob = original.body.value.use();
|
||||
|
||||
// const is_pending = input.needsToReadFile();
|
||||
// defer if (!is_pending) input.detach();
|
||||
|
||||
// if (is_pending) {
|
||||
// input.doReadFileInternal(*StreamOutputSink, sink, onFinishedLoading, global);
|
||||
// } else if (sink.runOutputSink(input.sharedView(), false, false)) |error_value| {
|
||||
// return error_value;
|
||||
// }
|
||||
|
||||
// // Hold off on cloning until we're actually done.
|
||||
|
||||
// return JSC.JSValue.fromRef(
|
||||
// Response.makeMaybePooled(sink.global.ref(), sink.response),
|
||||
// );
|
||||
// }
|
||||
|
||||
// pub fn runOutputSink(
|
||||
// sink: *StreamOutputSink,
|
||||
// bytes: []const u8,
|
||||
// is_async: bool,
|
||||
// free_bytes_on_end: bool,
|
||||
// ) ?JSValue {
|
||||
// defer if (free_bytes_on_end)
|
||||
// bun.default_allocator.free(bun.constStrToU8(bytes));
|
||||
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// pub const Sync = enum { suspended, pending, done };
|
||||
|
||||
// pub fn done(this: *StreamOutputSink) void {
|
||||
// var prev_value = this.response.body.value;
|
||||
// var bytes = this.bytes.toOwnedSliceLeaky();
|
||||
// this.response.body.value = .{
|
||||
// .Blob = JSC.WebCore.Blob.init(bytes, this.bytes.allocator, this.global),
|
||||
// };
|
||||
// prev_value.resolve(
|
||||
// &this.response.body.value,
|
||||
// this.global,
|
||||
// );
|
||||
// }
|
||||
|
||||
// pub fn write(this: *StreamOutputSink, bytes: []const u8) void {
|
||||
// this.bytes.append(bytes) catch unreachable;
|
||||
// }
|
||||
|
||||
// pub fn deinit(this: *StreamOutputSink) void {
|
||||
// this.bytes.deinit();
|
||||
|
||||
// this.context.deinit(bun.default_allocator);
|
||||
// }
|
||||
// };
|
||||
};
|
||||
|
||||
const DocumentHandler = struct {
|
||||
|
||||
@@ -238,7 +238,7 @@ pub const ServerConfig = struct {
|
||||
};
|
||||
|
||||
pub fn fromJS(global: *JSC.JSGlobalObject, arguments: *JSC.Node.ArgumentsSlice, exception: JSC.C.ExceptionRef) ServerConfig {
|
||||
var env = VirtualMachine.vm.bundler.env;
|
||||
var env = arguments.vm.bundler.env;
|
||||
|
||||
var args = ServerConfig{
|
||||
.port = 3000,
|
||||
@@ -250,7 +250,7 @@ pub const ServerConfig = struct {
|
||||
args.development = false;
|
||||
}
|
||||
|
||||
if (VirtualMachine.vm.bundler.options.production) {
|
||||
if (arguments.vm.bundler.options.production) {
|
||||
args.development = false;
|
||||
}
|
||||
|
||||
@@ -264,11 +264,11 @@ pub const ServerConfig = struct {
|
||||
}
|
||||
}
|
||||
|
||||
if (VirtualMachine.vm.bundler.options.transform_options.port) |port| {
|
||||
if (arguments.vm.bundler.options.transform_options.port) |port| {
|
||||
args.port = port;
|
||||
}
|
||||
|
||||
if (VirtualMachine.vm.bundler.options.transform_options.origin) |origin| {
|
||||
if (arguments.vm.bundler.options.transform_options.origin) |origin| {
|
||||
args.base_uri = origin;
|
||||
}
|
||||
|
||||
@@ -515,6 +515,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
url: string,
|
||||
method: HTTP.Method,
|
||||
aborted: bool = false,
|
||||
finalized: bun.DebugOnly(bool) = bun.DebugOnlyDefault(false),
|
||||
|
||||
/// We can only safely free once the request body promise is finalized
|
||||
/// and the response is rejected
|
||||
pending_promises_for_abort: u8 = 0,
|
||||
|
||||
has_marked_complete: bool = false,
|
||||
response_jsvalue: JSC.JSValue = JSC.JSValue.zero,
|
||||
@@ -549,7 +554,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
arguments: []const JSC.JSValue,
|
||||
) void {
|
||||
if (ctx.aborted) {
|
||||
ctx.finalize();
|
||||
ctx.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -579,16 +584,20 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
ctx.render(response);
|
||||
}
|
||||
|
||||
pub fn finalizeForAbort(this: *RequestContext) void {
|
||||
this.pending_promises_for_abort -|= 1;
|
||||
if (this.pending_promises_for_abort == 0) this.finalize();
|
||||
}
|
||||
|
||||
pub fn onReject(
|
||||
ctx: *RequestContext,
|
||||
_: *JSC.JSGlobalObject,
|
||||
arguments: []const JSC.JSValue,
|
||||
) void {
|
||||
if (ctx.aborted) {
|
||||
ctx.finalize();
|
||||
ctx.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
|
||||
handleReject(ctx, if (arguments.len > 0) arguments[0] else JSC.JSValue.jsUndefined());
|
||||
}
|
||||
|
||||
@@ -598,10 +607,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
);
|
||||
|
||||
if (ctx.aborted) {
|
||||
ctx.finalize();
|
||||
ctx.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ctx.resp.hasResponded()) {
|
||||
ctx.renderMissing();
|
||||
}
|
||||
@@ -674,8 +682,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
}
|
||||
|
||||
pub fn onWritableResponseBuffer(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool {
|
||||
std.debug.assert(this.resp == resp);
|
||||
if (this.aborted) {
|
||||
this.finalize();
|
||||
this.finalizeForAbort();
|
||||
return false;
|
||||
}
|
||||
return this.sendWritableBytes(this.response_buf_owned.items, write_offset, resp);
|
||||
@@ -694,10 +703,69 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
};
|
||||
}
|
||||
|
||||
pub fn onAbort(this: *RequestContext, _: *App.Response) void {
|
||||
pub fn isDeadRequest(this: *RequestContext) bool {
|
||||
if (this.pending_promises_for_abort > 0) return false;
|
||||
|
||||
if (this.promise != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.request_js_object) |obj| {
|
||||
if (obj.value().as(Request)) |req| {
|
||||
if (req.body == .Locked) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn onAbort(this: *RequestContext, resp: *App.Response) void {
|
||||
std.debug.assert(this.resp == resp);
|
||||
std.debug.assert(!this.aborted);
|
||||
this.aborted = true;
|
||||
this.finalizeWithoutDeinit();
|
||||
this.markComplete();
|
||||
|
||||
// if we can, free the request now.
|
||||
if (this.isDeadRequest()) {
|
||||
this.finalizeWithoutDeinit();
|
||||
this.markComplete();
|
||||
this.deinit();
|
||||
} else {
|
||||
this.pending_promises_for_abort = 0;
|
||||
|
||||
// if we cannot, we have to reject pending promises
|
||||
// first, we reject the request body promise
|
||||
if (this.request_js_object != null) {
|
||||
var request_js = this.request_js_object.?.value();
|
||||
request_js.ensureStillAlive();
|
||||
|
||||
this.request_js_object = null;
|
||||
defer request_js.ensureStillAlive();
|
||||
defer JSC.C.JSValueUnprotect(this.server.globalThis.ref(), request_js.asObjectRef());
|
||||
// User called .blob(), .json(), text(), or .arrayBuffer() on the Request object
|
||||
// but we received nothing or the connection was aborted
|
||||
if (request_js.as(Request)) |req| {
|
||||
// the promise is pending
|
||||
if (req.body == .Locked and (req.body.Locked.action != .none or req.body.Locked.promise != null)) {
|
||||
this.pending_promises_for_abort += 1;
|
||||
req.body.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis);
|
||||
}
|
||||
req.uws_request = null;
|
||||
}
|
||||
}
|
||||
|
||||
// then, we reject the response promise
|
||||
if (this.promise) |promise| {
|
||||
this.pending_promises_for_abort += 1;
|
||||
this.promise = null;
|
||||
promise.asPromise().?.reject(this.server.globalThis, JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis));
|
||||
}
|
||||
|
||||
if (this.pending_promises_for_abort > 0) {
|
||||
this.server.vm.tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn markComplete(this: *RequestContext) void {
|
||||
@@ -709,7 +777,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
// so it's important that we can safely do that
|
||||
pub fn finalizeWithoutDeinit(this: *RequestContext) void {
|
||||
this.blob.detach();
|
||||
this.request_body_buf.clearAndFree(this.allocator);
|
||||
|
||||
if (comptime Environment.allow_assert) {
|
||||
std.debug.assert(!this.finalized);
|
||||
this.finalized = true;
|
||||
}
|
||||
|
||||
if (!this.response_jsvalue.isEmpty()) {
|
||||
this.server.response_objects_pool.push(this.server.globalThis, this.response_jsvalue);
|
||||
@@ -717,38 +789,56 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
}
|
||||
|
||||
if (this.request_js_object != null) {
|
||||
var request_js = this.request_js_object.?.value();
|
||||
request_js.ensureStillAlive();
|
||||
|
||||
this.request_js_object = null;
|
||||
defer request_js.ensureStillAlive();
|
||||
defer JSC.C.JSValueUnprotect(this.server.globalThis.ref(), request_js.asObjectRef());
|
||||
// User called .blob(), .json(), text(), or .arrayBuffer() on the Request object
|
||||
// but we received nothing
|
||||
if (JSC.JSValue.fromRef(this.request_js_object).as(Request)) |req| {
|
||||
// but we received nothing or the connection was aborted
|
||||
if (request_js.as(Request)) |req| {
|
||||
// the promise is pending
|
||||
if (req.body == .Locked and req.body.Locked.action != .none and req.body.Locked.promise != null) {
|
||||
var old_body = req.body;
|
||||
req.body = JSC.WebCore.Body.Value.empty;
|
||||
old_body.Locked.callback = null;
|
||||
old_body.resolve(&req.body, this.server.globalThis);
|
||||
VirtualMachine.vm.tick();
|
||||
req.body.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis);
|
||||
}
|
||||
req.uws_request = null;
|
||||
JSC.C.JSValueUnprotect(this.server.globalThis.ref(), this.request_js_object);
|
||||
this.request_js_object = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.promise != null) {
|
||||
JSC.C.JSValueUnprotect(this.server.globalThis.ref(), this.promise.?.asObjectRef());
|
||||
if (this.promise) |promise| {
|
||||
this.promise = null;
|
||||
|
||||
if (promise.asInternalPromise()) |prom| {
|
||||
prom.rejectAsHandled(this.server.globalThis, (JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis)));
|
||||
} else if (promise.asPromise()) |prom| {
|
||||
prom.rejectAsHandled(this.server.globalThis, (JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis)));
|
||||
}
|
||||
JSC.C.JSValueUnprotect(this.server.globalThis.ref(), promise.asObjectRef());
|
||||
}
|
||||
|
||||
if (this.response_headers != null) {
|
||||
this.response_headers.?.deref();
|
||||
this.response_headers = null;
|
||||
}
|
||||
|
||||
this.response_buf_owned.clearAndFree(this.allocator);
|
||||
}
|
||||
pub fn finalize(this: *RequestContext) void {
|
||||
var server = this.server;
|
||||
this.finalizeWithoutDeinit();
|
||||
this.markComplete();
|
||||
this.deinit();
|
||||
}
|
||||
|
||||
pub fn deinit(this: *RequestContext) void {
|
||||
if (comptime Environment.allow_assert)
|
||||
std.debug.assert(this.finalized);
|
||||
|
||||
if (comptime Environment.allow_assert)
|
||||
std.debug.assert(this.has_marked_complete);
|
||||
|
||||
var server = this.server;
|
||||
this.request_body_buf.clearAndFree(this.allocator);
|
||||
this.response_buf_owned.clearAndFree(this.allocator);
|
||||
|
||||
server.request_pool_allocator.destroy(this);
|
||||
}
|
||||
|
||||
@@ -855,8 +945,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
}
|
||||
|
||||
pub fn onWritableBytes(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool {
|
||||
std.debug.assert(this.resp == resp);
|
||||
if (this.aborted) {
|
||||
this.finalize();
|
||||
this.finalizeForAbort();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -865,6 +956,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
}
|
||||
|
||||
pub fn sendWritableBytes(this: *RequestContext, bytes_: []const u8, write_offset: c_ulong, resp: *App.Response) bool {
|
||||
std.debug.assert(this.resp == resp);
|
||||
|
||||
var bytes = bytes_[@minimum(bytes_.len, @truncate(usize, write_offset))..];
|
||||
if (resp.tryEnd(bytes, bytes_.len)) {
|
||||
this.finalize();
|
||||
@@ -976,7 +1069,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
|
||||
pub fn doSendfile(this: *RequestContext, blob: Blob) void {
|
||||
if (this.aborted) {
|
||||
this.finalize();
|
||||
this.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -994,7 +1087,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
|
||||
pub fn onReadFile(this: *RequestContext, result: Blob.Store.ReadFile.ResultType) void {
|
||||
if (this.aborted) {
|
||||
this.finalize();
|
||||
this.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1024,7 +1117,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
const err = value.Error;
|
||||
_ = value.use();
|
||||
if (this.aborted) {
|
||||
this.finalize();
|
||||
this.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
this.runErrorHandler(err);
|
||||
@@ -1034,7 +1127,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
this.blob = value.use();
|
||||
|
||||
if (this.aborted) {
|
||||
this.finalize();
|
||||
this.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1068,7 +1161,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
|
||||
pub fn doRender(this: *RequestContext) void {
|
||||
if (this.aborted) {
|
||||
this.finalize();
|
||||
this.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
var response = this.response_ptr.?;
|
||||
@@ -1232,7 +1325,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
|
||||
pub fn resolveRequestBody(this: *RequestContext) void {
|
||||
if (this.aborted) {
|
||||
this.finalize();
|
||||
this.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1251,7 +1344,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
}
|
||||
}
|
||||
|
||||
pub fn onBodyChunk(this: *RequestContext, _: *App.Response, chunk: []const u8, last: bool) void {
|
||||
pub fn onBodyChunk(this: *RequestContext, resp: *App.Response, chunk: []const u8, last: bool) void {
|
||||
std.debug.assert(this.resp == resp);
|
||||
|
||||
if (this.aborted) return;
|
||||
this.request_body_buf.appendSlice(this.allocator, chunk) catch @panic("Out of memory while allocating request body");
|
||||
if (last) {
|
||||
@@ -1264,7 +1359,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
}
|
||||
}
|
||||
|
||||
pub fn onRequestData(this: *RequestContext) void {
|
||||
pub fn onPull(this: *RequestContext) void {
|
||||
if (this.req.header("content-length")) |content_length| {
|
||||
const len = std.fmt.parseInt(usize, content_length, 10) catch 0;
|
||||
if (len == 0) {
|
||||
@@ -1301,8 +1396,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
|
||||
this.resp.onData(*RequestContext, onBodyChunk, this);
|
||||
}
|
||||
|
||||
pub fn onRequestDataCallback(this: *anyopaque) void {
|
||||
onRequestData(bun.cast(*RequestContext, this));
|
||||
pub fn onPullCallback(this: *anyopaque) void {
|
||||
onPull(bun.cast(*RequestContext, this));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1522,7 +1617,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
|
||||
this.listen_callback = JSC.AnyTask.New(ThisServer, run).init(this);
|
||||
this.vm.eventLoop().enqueueTask(JSC.Task.init(&this.listen_callback));
|
||||
if (needs_post_handler) {
|
||||
_ = this.vm.uws_event_loop.?.addPostHandler(*JSC.VirtualMachine.EventLoop, this.vm.eventLoop(), JSC.VirtualMachine.EventLoop.tick);
|
||||
_ = this.vm.uws_event_loop.?.addPostHandler(*JSC.EventLoop, this.vm.eventLoop(), JSC.EventLoop.tick);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1605,7 +1700,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
|
||||
.Locked = .{
|
||||
.task = ctx,
|
||||
.global = this.globalThis,
|
||||
.onRequestData = RequestContext.onRequestDataCallback,
|
||||
.onPull = RequestContext.onPullCallback,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1617,10 +1712,9 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
|
||||
const response_value = JSC.C.JSObjectCallAsFunctionReturnValue(this.globalThis.ref(), this.config.onRequest.asObjectRef(), this.thisObject.asObjectRef(), 1, &args);
|
||||
|
||||
if (ctx.aborted) {
|
||||
ctx.finalize();
|
||||
ctx.finalizeForAbort();
|
||||
return;
|
||||
}
|
||||
|
||||
if (response_value.isEmptyOrUndefinedOrNull() and !ctx.resp.hasResponded()) {
|
||||
ctx.renderMissing();
|
||||
return;
|
||||
|
||||
@@ -737,7 +737,7 @@ pub fn constructor(
|
||||
exception: js.ExceptionRef,
|
||||
) js.JSObjectRef {
|
||||
var temp = std.heap.ArenaAllocator.init(getAllocator(ctx));
|
||||
var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
defer temp.deinit();
|
||||
const transpiler_options: TranspilerOptions = if (arguments.len > 0)
|
||||
transformOptionsFromJSC(ctx, temp.allocator(), &args, exception) catch {
|
||||
@@ -874,7 +874,7 @@ pub fn scan(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) JSC.C.JSObjectRef {
|
||||
var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
defer args.arena.deinit();
|
||||
const code_arg = args.next() orelse {
|
||||
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
|
||||
@@ -965,7 +965,7 @@ pub fn transform(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) JSC.C.JSObjectRef {
|
||||
var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
defer args.arena.deinit();
|
||||
const code_arg = args.next() orelse {
|
||||
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
|
||||
@@ -1006,7 +1006,7 @@ pub fn transformSync(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) JSC.C.JSObjectRef {
|
||||
var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
defer args.arena.deinit();
|
||||
const code_arg = args.next() orelse {
|
||||
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
|
||||
@@ -1193,7 +1193,7 @@ pub fn scanImports(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) JSC.C.JSObjectRef {
|
||||
var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
|
||||
const code_arg = args.next() orelse {
|
||||
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
|
||||
return null;
|
||||
|
||||
@@ -2553,6 +2553,7 @@ pub export fn MarkedArrayBuffer_deallocator(bytes_: *anyopaque, _: *anyopaque) v
|
||||
// but we don't
|
||||
mimalloc.mi_free(bytes_);
|
||||
}
|
||||
|
||||
pub export fn BlobArrayBuffer_deallocator(_: *anyopaque, blob: *anyopaque) void {
|
||||
// zig's memory allocator interface won't work here
|
||||
// mimalloc knows the size of things
|
||||
@@ -2646,7 +2647,6 @@ pub const JSPrivateDataPtr = TaggedPointerUnion(.{
|
||||
Stats,
|
||||
TextChunk,
|
||||
TextDecoder,
|
||||
TextEncoder,
|
||||
TimeoutTask,
|
||||
Transpiler,
|
||||
FFI,
|
||||
@@ -2793,7 +2793,7 @@ pub fn wrapWithHasContainer(
|
||||
arguments: []const js.JSValueRef,
|
||||
exception: js.ExceptionRef,
|
||||
) js.JSObjectRef {
|
||||
var iter = JSC.Node.ArgumentsSlice.from(arguments);
|
||||
var iter = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
|
||||
var args: Args = undefined;
|
||||
|
||||
comptime var i: usize = 0;
|
||||
@@ -2934,14 +2934,15 @@ pub fn wrapWithHasContainer(
|
||||
}
|
||||
|
||||
if (comptime maybe_async) {
|
||||
JavaScript.VirtualMachine.vm.tick();
|
||||
var vm = ctx.ptr().bunVM();
|
||||
vm.tick();
|
||||
|
||||
var promise = JSC.JSInternalPromise.resolvedPromise(ctx.ptr(), result);
|
||||
|
||||
switch (promise.status(ctx.ptr().vm())) {
|
||||
JSC.JSPromise.Status.Pending => {
|
||||
while (promise.status(ctx.ptr().vm()) == .Pending) {
|
||||
JavaScript.VirtualMachine.vm.tick();
|
||||
vm.tick();
|
||||
}
|
||||
result = promise.result(ctx.ptr().vm());
|
||||
},
|
||||
|
||||
@@ -23,49 +23,127 @@ using namespace JSC;
|
||||
|
||||
|
||||
#define BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
|
||||
macro(AbortSignal) \
|
||||
macro(ReadableByteStreamController) \
|
||||
macro(ReadableStream) \
|
||||
macro(ReadableStreamBYOBReader) \
|
||||
macro(ReadableStreamBYOBRequest) \
|
||||
macro(ReadableStreamDefaultController) \
|
||||
macro(ReadableStreamDefaultReader) \
|
||||
macro(TransformStream) \
|
||||
macro(TransformStreamDefaultController) \
|
||||
macro(WritableStream) \
|
||||
macro(WritableStreamDefaultController) \
|
||||
macro(WritableStreamDefaultWriter) \
|
||||
macro(abortAlgorithm) \
|
||||
macro(abortSteps) \
|
||||
macro(addEventListener) \
|
||||
macro(appendFromJS) \
|
||||
macro(argv) \
|
||||
macro(associatedReadableByteStreamController) \
|
||||
macro(autoAllocateChunkSize) \
|
||||
macro(backingMap) \
|
||||
macro(backingSet) \
|
||||
macro(backpressure) \
|
||||
macro(backpressureChangePromise) \
|
||||
macro(basename) \
|
||||
macro(body) \
|
||||
macro(bunNativePtr) \
|
||||
macro(bunNativeType) \
|
||||
macro(byobRequest) \
|
||||
macro(cancel) \
|
||||
macro(cancelAlgorithm) \
|
||||
macro(chdir) \
|
||||
macro(cloneArrayBuffer) \
|
||||
macro(close) \
|
||||
macro(closeAlgorithm) \
|
||||
macro(closeRequest) \
|
||||
macro(closeRequested) \
|
||||
macro(closed) \
|
||||
macro(closedPromise) \
|
||||
macro(closedPromiseCapability) \
|
||||
macro(code) \
|
||||
macro(connect) \
|
||||
macro(controlledReadableStream) \
|
||||
macro(controller) \
|
||||
macro(cork) \
|
||||
macro(createFIFO) \
|
||||
macro(createNativeReadableStream) \
|
||||
macro(createEmptyReadableStream) \
|
||||
macro(createReadableStream) \
|
||||
macro(createUninitializedArrayBuffer) \
|
||||
macro(createWritableStreamFromInternal) \
|
||||
macro(cwd) \
|
||||
macro(dataView) \
|
||||
macro(decode) \
|
||||
macro(delimiter) \
|
||||
macro(whenSignalAborted) \
|
||||
macro(destroy) \
|
||||
macro(dir) \
|
||||
macro(dirname) \
|
||||
macro(disturbed) \
|
||||
macro(document) \
|
||||
macro(encode) \
|
||||
macro(encoding) \
|
||||
macro(end) \
|
||||
macro(errno) \
|
||||
macro(errorSteps) \
|
||||
macro(execArgv) \
|
||||
macro(extname) \
|
||||
macro(failureKind) \
|
||||
macro(fatal) \
|
||||
macro(fetch) \
|
||||
macro(fetchRequest) \
|
||||
macro(file) \
|
||||
macro(filePath) \
|
||||
macro(fillFromJS) \
|
||||
macro(finishConsumingStream) \
|
||||
macro(flush) \
|
||||
macro(flushAlgorithm) \
|
||||
macro(format) \
|
||||
macro(get) \
|
||||
macro(getInternalWritableStream) \
|
||||
macro(handleEvent) \
|
||||
macro(hash) \
|
||||
macro(header) \
|
||||
macro(highWaterMark) \
|
||||
macro(host) \
|
||||
macro(hostname) \
|
||||
macro(href) \
|
||||
macro(ignoreBOM) \
|
||||
macro(inFlightCloseRequest) \
|
||||
macro(inFlightWriteRequest) \
|
||||
macro(initializeWith) \
|
||||
macro(internalStream) \
|
||||
macro(internalWritable) \
|
||||
macro(isAbortSignal) \
|
||||
macro(isAbsolute) \
|
||||
macro(isDisturbed) \
|
||||
macro(isPaused) \
|
||||
macro(isSecureContext) \
|
||||
macro(isWindows) \
|
||||
macro(join) \
|
||||
macro(kind) \
|
||||
macro(localStreams) \
|
||||
macro(makeDOMException) \
|
||||
macro(makeGetterTypeError) \
|
||||
macro(makeThisTypeError) \
|
||||
macro(map) \
|
||||
macro(nativeReadableStreamPrototype) \
|
||||
macro(nextTick) \
|
||||
macro(normalize) \
|
||||
macro(on) \
|
||||
macro(once) \
|
||||
macro(options) \
|
||||
macro(origin) \
|
||||
macro(ownerReadableStream) \
|
||||
macro(parse) \
|
||||
macro(password) \
|
||||
macro(patch) \
|
||||
macro(path) \
|
||||
macro(pathname) \
|
||||
macro(pause) \
|
||||
macro(pendingAbortRequest) \
|
||||
macro(pendingPullIntos) \
|
||||
macro(pid) \
|
||||
macro(pipe) \
|
||||
macro(port) \
|
||||
@@ -74,30 +152,77 @@ using namespace JSC;
|
||||
macro(prependEventListener) \
|
||||
macro(process) \
|
||||
macro(protocol) \
|
||||
macro(pull) \
|
||||
macro(pullAgain) \
|
||||
macro(pullAlgorithm) \
|
||||
macro(pulling) \
|
||||
macro(put) \
|
||||
macro(queue) \
|
||||
macro(read) \
|
||||
macro(readIntoRequests) \
|
||||
macro(readRequests) \
|
||||
macro(readable) \
|
||||
macro(readableStreamController) \
|
||||
macro(reader) \
|
||||
macro(readyPromise) \
|
||||
macro(readyPromiseCapability) \
|
||||
macro(relative) \
|
||||
macro(require) \
|
||||
macro(resolveSync) \
|
||||
macro(releaseLock) \
|
||||
macro(removeEventListener) \
|
||||
macro(require) \
|
||||
macro(resolve) \
|
||||
macro(resolveSync) \
|
||||
macro(resume) \
|
||||
macro(search) \
|
||||
macro(searchParams) \
|
||||
macro(self) \
|
||||
macro(sep) \
|
||||
macro(setBody) \
|
||||
macro(setStatus) \
|
||||
macro(size) \
|
||||
macro(start) \
|
||||
macro(startConsumingStream) \
|
||||
macro(started) \
|
||||
macro(startedPromise) \
|
||||
macro(state) \
|
||||
macro(storedError) \
|
||||
macro(strategy) \
|
||||
macro(strategyHWM) \
|
||||
macro(strategySizeAlgorithm) \
|
||||
macro(stream) \
|
||||
macro(streamClosed) \
|
||||
macro(streamClosing) \
|
||||
macro(streamErrored) \
|
||||
macro(streamReadable) \
|
||||
macro(streamWaiting) \
|
||||
macro(streamWritable) \
|
||||
macro(structuredCloneForStream) \
|
||||
macro(syscall) \
|
||||
macro(title) \
|
||||
macro(textDecoderStreamDecoder) \
|
||||
macro(textDecoderStreamTransform) \
|
||||
macro(textEncoderStreamEncoder) \
|
||||
macro(textEncoderStreamTransform) \
|
||||
macro(toNamespacedPath) \
|
||||
macro(trace) \
|
||||
macro(transformAlgorithm) \
|
||||
macro(uncork) \
|
||||
macro(underlyingByteSource) \
|
||||
macro(underlyingSink) \
|
||||
macro(underlyingSource) \
|
||||
macro(unpipe) \
|
||||
macro(unshift) \
|
||||
macro(url) \
|
||||
macro(username) \
|
||||
macro(version) \
|
||||
macro(versions) \
|
||||
macro(view) \
|
||||
macro(whenSignalAborted) \
|
||||
macro(writable) \
|
||||
macro(write) \
|
||||
macro(dataView) \
|
||||
macro(writeAlgorithm) \
|
||||
macro(writeRequests) \
|
||||
macro(writer) \
|
||||
macro(writing) \
|
||||
BUN_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) \
|
||||
|
||||
class BunBuiltinNames {
|
||||
@@ -123,5 +248,7 @@ private:
|
||||
BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_NAMES)
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
|
||||
|
||||
@@ -14,21 +14,23 @@
|
||||
#include "wtf/MainThread.h"
|
||||
|
||||
#include "JSDOMConstructorBase.h"
|
||||
#include "JSDOMBuiltinConstructorBase.h"
|
||||
|
||||
#include "BunGCOutputConstraint.h"
|
||||
#include "WebCoreTypedArrayController.h"
|
||||
#include "JavaScriptCore/AbstractSlotVisitorInlines.h"
|
||||
#include "JavaScriptCore/JSCellInlines.h"
|
||||
#include "JavaScriptCore/WeakInlines.h"
|
||||
#include "JavaScriptCore/JSCInlines.h"
|
||||
|
||||
#include "JSDOMWrapper.h"
|
||||
|
||||
namespace WebCore {
|
||||
using namespace JSC;
|
||||
|
||||
JSHeapData::JSHeapData(Heap& heap)
|
||||
// : m_domNamespaceObjectSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMObject)
|
||||
// ,
|
||||
: m_subspaces(makeUnique<ExtendedDOMIsoSubspaces>())
|
||||
: m_heapCellTypeForJSWorkerGlobalScope(JSC::IsoHeapCellType::Args<Zig::GlobalObject>())
|
||||
, m_domBuiltinConstructorSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMBuiltinConstructorBase)
|
||||
, m_domConstructorSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMConstructorBase)
|
||||
, m_domNamespaceObjectSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMObject)
|
||||
, m_subspaces(makeUnique<ExtendedDOMIsoSubspaces>())
|
||||
|
||||
{
|
||||
}
|
||||
@@ -36,11 +38,14 @@ JSHeapData::JSHeapData(Heap& heap)
|
||||
#define CLIENT_ISO_SUBSPACE_INIT(subspace) subspace(m_heapData->subspace)
|
||||
|
||||
JSVMClientData::JSVMClientData(VM& vm)
|
||||
: m_builtinNames(vm)
|
||||
: m_builtinFunctions(vm)
|
||||
, m_builtinNames(vm)
|
||||
, m_heapData(JSHeapData::ensureHeapData(vm.heap))
|
||||
, CLIENT_ISO_SUBSPACE_INIT(m_domBuiltinConstructorSpace)
|
||||
, CLIENT_ISO_SUBSPACE_INIT(m_domConstructorSpace)
|
||||
, CLIENT_ISO_SUBSPACE_INIT(m_domNamespaceObjectSpace)
|
||||
, m_clientSubspaces(makeUnique<ExtendedDOMClientIsoSubspaces>())
|
||||
, m_builtinFunctions(vm)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@@ -59,8 +64,11 @@ JSHeapData* JSHeapData::ensureHeapData(Heap& heap)
|
||||
return singleton;
|
||||
}
|
||||
|
||||
JSVMClientData::~JSVMClientData() {}
|
||||
|
||||
JSVMClientData::~JSVMClientData()
|
||||
{
|
||||
ASSERT(m_normalWorld->hasOneRef());
|
||||
m_normalWorld = nullptr;
|
||||
}
|
||||
void JSVMClientData::create(VM* vm)
|
||||
{
|
||||
JSVMClientData* clientData = new JSVMClientData(*vm);
|
||||
@@ -68,7 +76,6 @@ void JSVMClientData::create(VM* vm)
|
||||
clientData->m_normalWorld = DOMWrapperWorld::create(*vm, DOMWrapperWorld::Type::Normal);
|
||||
|
||||
vm->heap.addMarkingConstraint(makeUnique<WebCore::DOMGCOutputConstraint>(*vm, clientData->heapData()));
|
||||
|
||||
vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController(true));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
func(*space);
|
||||
}
|
||||
|
||||
// JSC::IsoSubspace m_domNamespaceObjectSpace;
|
||||
JSC::IsoHeapCellType m_heapCellTypeForJSWorkerGlobalScope;
|
||||
|
||||
private:
|
||||
Lock m_lock;
|
||||
@@ -62,6 +62,8 @@ private:
|
||||
private:
|
||||
std::unique_ptr<ExtendedDOMIsoSubspaces> m_subspaces;
|
||||
JSC::IsoSubspace m_domConstructorSpace;
|
||||
JSC::IsoSubspace m_domBuiltinConstructorSpace;
|
||||
JSC::IsoSubspace m_domNamespaceObjectSpace;
|
||||
|
||||
Vector<JSC::IsoSubspace*> m_outputConstraintSpaces;
|
||||
};
|
||||
@@ -89,6 +91,8 @@ public:
|
||||
|
||||
Vector<JSC::IsoSubspace*>& outputConstraintSpaces() { return m_outputConstraintSpaces; }
|
||||
|
||||
JSC::GCClient::IsoSubspace& domBuiltinConstructorSpace() { return m_domBuiltinConstructorSpace; }
|
||||
|
||||
template<typename Func> void forEachOutputConstraintSpace(const Func& func)
|
||||
{
|
||||
for (auto* space : m_outputConstraintSpaces)
|
||||
@@ -103,8 +107,8 @@ private:
|
||||
|
||||
RefPtr<WebCore::DOMWrapperWorld> m_normalWorld;
|
||||
JSC::GCClient::IsoSubspace m_domConstructorSpace;
|
||||
|
||||
// JSC::IsoSubspace m_domNamespaceObjectSpace;
|
||||
JSC::GCClient::IsoSubspace m_domBuiltinConstructorSpace;
|
||||
JSC::GCClient::IsoSubspace m_domNamespaceObjectSpace;
|
||||
|
||||
std::unique_ptr<ExtendedDOMClientIsoSubspaces> m_clientSubspaces;
|
||||
Vector<JSC::IsoSubspace*> m_outputConstraintSpaces;
|
||||
@@ -168,9 +172,15 @@ static JSVMClientData* clientData(JSC::VM& vm)
|
||||
return static_cast<WebCore::JSVMClientData*>(vm.clientData);
|
||||
}
|
||||
|
||||
static inline BunBuiltinNames& builtinNames(JSC::VM& vm)
|
||||
{
|
||||
return clientData(vm)->builtinNames();
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
|
||||
namespace WebCore {
|
||||
using JSVMClientData = WebCore::JSVMClientData;
|
||||
using JSHeapData = WebCore::JSHeapData;
|
||||
|
||||
}
|
||||
@@ -31,105 +31,105 @@
|
||||
#include "JavaScriptCore/VM.h"
|
||||
#include "JavaScriptCore/MarkingConstraint.h"
|
||||
|
||||
namespace JSC {
|
||||
// namespace JSC {
|
||||
|
||||
class VisitCounter {
|
||||
public:
|
||||
VisitCounter() {}
|
||||
// class VisitCounter {
|
||||
// public:
|
||||
// VisitCounter() {}
|
||||
|
||||
VisitCounter(AbstractSlotVisitor& visitor)
|
||||
: m_visitor(&visitor)
|
||||
, m_initialVisitCount(visitor.visitCount())
|
||||
{
|
||||
}
|
||||
// VisitCounter(AbstractSlotVisitor& visitor)
|
||||
// : m_visitor(&visitor)
|
||||
// , m_initialVisitCount(visitor.visitCount())
|
||||
// {
|
||||
// }
|
||||
|
||||
AbstractSlotVisitor& visitor() const { return *m_visitor; }
|
||||
// AbstractSlotVisitor& visitor() const { return *m_visitor; }
|
||||
|
||||
size_t visitCount() const
|
||||
{
|
||||
return m_visitor->visitCount() - m_initialVisitCount;
|
||||
}
|
||||
// size_t visitCount() const
|
||||
// {
|
||||
// return m_visitor->visitCount() - m_initialVisitCount;
|
||||
// }
|
||||
|
||||
private:
|
||||
AbstractSlotVisitor* m_visitor { nullptr };
|
||||
size_t m_initialVisitCount { 0 };
|
||||
};
|
||||
// private:
|
||||
// AbstractSlotVisitor* m_visitor { nullptr };
|
||||
// size_t m_initialVisitCount { 0 };
|
||||
// };
|
||||
|
||||
static constexpr bool verboseMarkingConstraint = false;
|
||||
// static constexpr bool verboseMarkingConstraint = false;
|
||||
|
||||
MarkingConstraint::MarkingConstraint(CString abbreviatedName, CString name, ConstraintVolatility volatility, ConstraintConcurrency concurrency, ConstraintParallelism parallelism)
|
||||
: m_abbreviatedName(abbreviatedName)
|
||||
, m_name(WTFMove(name))
|
||||
, m_volatility(volatility)
|
||||
, m_concurrency(concurrency)
|
||||
, m_parallelism(parallelism)
|
||||
{
|
||||
}
|
||||
// MarkingConstraint::MarkingConstraint(CString abbreviatedName, CString name, ConstraintVolatility volatility, ConstraintConcurrency concurrency, ConstraintParallelism parallelism)
|
||||
// : m_abbreviatedName(abbreviatedName)
|
||||
// , m_name(WTFMove(name))
|
||||
// , m_volatility(volatility)
|
||||
// , m_concurrency(concurrency)
|
||||
// , m_parallelism(parallelism)
|
||||
// {
|
||||
// }
|
||||
|
||||
MarkingConstraint::~MarkingConstraint()
|
||||
{
|
||||
}
|
||||
// MarkingConstraint::~MarkingConstraint()
|
||||
// {
|
||||
// }
|
||||
|
||||
void MarkingConstraint::resetStats()
|
||||
{
|
||||
m_lastVisitCount = 0;
|
||||
}
|
||||
// void MarkingConstraint::resetStats()
|
||||
// {
|
||||
// m_lastVisitCount = 0;
|
||||
// }
|
||||
|
||||
void MarkingConstraint::execute(SlotVisitor& visitor)
|
||||
{
|
||||
ASSERT(!visitor.heap()->isMarkingForGCVerifier());
|
||||
VisitCounter visitCounter(visitor);
|
||||
executeImpl(visitor);
|
||||
m_lastVisitCount += visitCounter.visitCount();
|
||||
if (verboseMarkingConstraint && visitCounter.visitCount())
|
||||
dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in execute)");
|
||||
}
|
||||
// void MarkingConstraint::execute(SlotVisitor& visitor)
|
||||
// {
|
||||
// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
|
||||
// VisitCounter visitCounter(visitor);
|
||||
// executeImpl(visitor);
|
||||
// m_lastVisitCount += visitCounter.visitCount();
|
||||
// if (verboseMarkingConstraint && visitCounter.visitCount())
|
||||
// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in execute)");
|
||||
// }
|
||||
|
||||
void MarkingConstraint::executeSynchronously(AbstractSlotVisitor& visitor)
|
||||
{
|
||||
prepareToExecuteImpl(NoLockingNecessary, visitor);
|
||||
executeImpl(visitor);
|
||||
}
|
||||
// void MarkingConstraint::executeSynchronously(AbstractSlotVisitor& visitor)
|
||||
// {
|
||||
// prepareToExecuteImpl(NoLockingNecessary, visitor);
|
||||
// executeImpl(visitor);
|
||||
// }
|
||||
|
||||
double MarkingConstraint::quickWorkEstimate(SlotVisitor&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// double MarkingConstraint::quickWorkEstimate(SlotVisitor&)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
double MarkingConstraint::workEstimate(SlotVisitor& visitor)
|
||||
{
|
||||
return lastVisitCount() + quickWorkEstimate(visitor);
|
||||
}
|
||||
// double MarkingConstraint::workEstimate(SlotVisitor& visitor)
|
||||
// {
|
||||
// return lastVisitCount() + quickWorkEstimate(visitor);
|
||||
// }
|
||||
|
||||
void MarkingConstraint::prepareToExecute(const AbstractLocker& constraintSolvingLocker, SlotVisitor& visitor)
|
||||
{
|
||||
ASSERT(!visitor.heap()->isMarkingForGCVerifier());
|
||||
dataLogIf(Options::logGC(), abbreviatedName());
|
||||
VisitCounter visitCounter(visitor);
|
||||
prepareToExecuteImpl(constraintSolvingLocker, visitor);
|
||||
m_lastVisitCount = visitCounter.visitCount();
|
||||
if (verboseMarkingConstraint && visitCounter.visitCount())
|
||||
dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in prepareToExecute)");
|
||||
}
|
||||
// void MarkingConstraint::prepareToExecute(const AbstractLocker& constraintSolvingLocker, SlotVisitor& visitor)
|
||||
// {
|
||||
// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
|
||||
// dataLogIf(Options::logGC(), abbreviatedName());
|
||||
// VisitCounter visitCounter(visitor);
|
||||
// prepareToExecuteImpl(constraintSolvingLocker, visitor);
|
||||
// m_lastVisitCount = visitCounter.visitCount();
|
||||
// if (verboseMarkingConstraint && visitCounter.visitCount())
|
||||
// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in prepareToExecute)");
|
||||
// }
|
||||
|
||||
void MarkingConstraint::doParallelWork(SlotVisitor& visitor, SharedTask<void(SlotVisitor&)>& task)
|
||||
{
|
||||
ASSERT(!visitor.heap()->isMarkingForGCVerifier());
|
||||
VisitCounter visitCounter(visitor);
|
||||
task.run(visitor);
|
||||
if (verboseMarkingConstraint && visitCounter.visitCount())
|
||||
dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in doParallelWork)");
|
||||
{
|
||||
Locker locker { m_lock };
|
||||
m_lastVisitCount += visitCounter.visitCount();
|
||||
}
|
||||
}
|
||||
// void MarkingConstraint::doParallelWork(SlotVisitor& visitor, SharedTask<void(SlotVisitor&)>& task)
|
||||
// {
|
||||
// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
|
||||
// VisitCounter visitCounter(visitor);
|
||||
// task.run(visitor);
|
||||
// if (verboseMarkingConstraint && visitCounter.visitCount())
|
||||
// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in doParallelWork)");
|
||||
// {
|
||||
// Locker locker { m_lock };
|
||||
// m_lastVisitCount += visitCounter.visitCount();
|
||||
// }
|
||||
// }
|
||||
|
||||
void MarkingConstraint::prepareToExecuteImpl(const AbstractLocker&, AbstractSlotVisitor&)
|
||||
{
|
||||
}
|
||||
// void MarkingConstraint::prepareToExecuteImpl(const AbstractLocker&, AbstractSlotVisitor&)
|
||||
// {
|
||||
// }
|
||||
|
||||
} // namespace JSC
|
||||
// } // namespace JSC
|
||||
|
||||
#include "BunGCOutputConstraint.h"
|
||||
|
||||
|
||||
293
src/javascript/jsc/bindings/BunJSCModule.cpp
Normal file
293
src/javascript/jsc/bindings/BunJSCModule.cpp
Normal file
@@ -0,0 +1,293 @@
|
||||
#include "root.h"
|
||||
#include "JavaScriptCore/JSCInlines.h"
|
||||
|
||||
#include "JavaScriptCore/JavaScript.h"
|
||||
#include "wtf/MemoryFootprint.h"
|
||||
#include "JavaScriptCore/CodeBlock.h"
|
||||
#include "JavaScriptCore/JSCInlines.h"
|
||||
#include "JavaScriptCore/TestRunnerUtils.h"
|
||||
#include "JavaScriptCore/JIT.h"
|
||||
#include "JavaScriptCore/APICast.h"
|
||||
#include "JavaScriptCore/JSBasePrivate.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
|
||||
#include "mimalloc.h"
|
||||
|
||||
using namespace JSC;
|
||||
using namespace WTF;
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionDescribe);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionDescribe, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
if (callFrame->argumentCount() < 1)
|
||||
return JSValue::encode(jsUndefined());
|
||||
return JSValue::encode(jsString(vm, toString(callFrame->argument(0))));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionDescribeArray);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionDescribeArray, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
if (callFrame->argumentCount() < 1)
|
||||
return JSValue::encode(jsUndefined());
|
||||
VM& vm = globalObject->vm();
|
||||
JSObject* object = jsDynamicCast<JSObject*>(callFrame->argument(0));
|
||||
if (!object)
|
||||
return JSValue::encode(jsNontrivialString(vm, "<not object>"_s));
|
||||
return JSValue::encode(jsNontrivialString(vm, toString("<Butterfly: ", RawPointer(object->butterfly()), "; public length: ", object->getArrayLength(), "; vector length: ", object->getVectorLength(), ">")));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionGCAndSweep);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionGCAndSweep, (JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
JSLockHolder lock(vm);
|
||||
vm.heap.collectNow(Sync, CollectionScope::Full);
|
||||
return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection()));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionFullGC);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionFullGC, (JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
JSLockHolder lock(vm);
|
||||
vm.heap.collectSync(CollectionScope::Full);
|
||||
return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection()));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionEdenGC);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionEdenGC, (JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
JSLockHolder lock(vm);
|
||||
vm.heap.collectSync(CollectionScope::Eden);
|
||||
return JSValue::encode(jsNumber(vm.heap.sizeAfterLastEdenCollection()));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionHeapSize);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionHeapSize, (JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
JSLockHolder lock(vm);
|
||||
return JSValue::encode(jsNumber(vm.heap.size()));
|
||||
}
|
||||
|
||||
class JSCMemoryFootprint : public JSDestructibleObject {
|
||||
using Base = JSDestructibleObject;
|
||||
|
||||
public:
|
||||
template<typename CellType, SubspaceAccess>
|
||||
static CompleteSubspace* subspaceFor(VM& vm)
|
||||
{
|
||||
return &vm.destructibleObjectSpace();
|
||||
}
|
||||
|
||||
JSCMemoryFootprint(VM& vm, Structure* structure)
|
||||
: Base(vm, structure)
|
||||
{
|
||||
}
|
||||
|
||||
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
|
||||
{
|
||||
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
|
||||
}
|
||||
|
||||
static JSCMemoryFootprint* create(VM& vm, JSGlobalObject* globalObject)
|
||||
{
|
||||
Structure* structure = createStructure(vm, globalObject, jsNull());
|
||||
JSCMemoryFootprint* footprint = new (NotNull, allocateCell<JSCMemoryFootprint>(vm)) JSCMemoryFootprint(vm, structure);
|
||||
footprint->finishCreation(vm);
|
||||
return footprint;
|
||||
}
|
||||
|
||||
void finishCreation(VM& vm)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
|
||||
auto addProperty = [&](VM& vm, ASCIILiteral name, JSValue value) {
|
||||
JSCMemoryFootprint::addProperty(vm, name, value);
|
||||
};
|
||||
|
||||
size_t elapsed_msecs = 0;
|
||||
size_t user_msecs = 0;
|
||||
size_t system_msecs = 0;
|
||||
size_t current_rss = 0;
|
||||
size_t peak_rss = 0;
|
||||
size_t current_commit = 0;
|
||||
size_t peak_commit = 0;
|
||||
size_t page_faults = 0;
|
||||
|
||||
mi_process_info(&elapsed_msecs, &user_msecs, &system_msecs,
|
||||
¤t_rss, &peak_rss,
|
||||
¤t_commit, &peak_commit, &page_faults);
|
||||
|
||||
addProperty(vm, "current"_s, jsNumber(current_rss));
|
||||
addProperty(vm, "peak"_s, jsNumber(peak_rss));
|
||||
addProperty(vm, "currentCommit"_s, jsNumber(current_commit));
|
||||
addProperty(vm, "peakCommit"_s, jsNumber(peak_commit));
|
||||
addProperty(vm, "pageFaults"_s, jsNumber(page_faults));
|
||||
}
|
||||
|
||||
DECLARE_INFO;
|
||||
|
||||
private:
|
||||
void addProperty(VM& vm, ASCIILiteral name, JSValue value)
|
||||
{
|
||||
Identifier identifier = Identifier::fromString(vm, name);
|
||||
putDirect(vm, identifier, value);
|
||||
}
|
||||
};
|
||||
|
||||
const ClassInfo JSCMemoryFootprint::s_info = { "MemoryFootprint"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCMemoryFootprint) };
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionMemoryUsageStatistics);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionMemoryUsageStatistics, (JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
auto contextRef = toRef(globalObject);
|
||||
return JSValue::encode(toJS(JSGetMemoryUsageStatistics(contextRef)));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionCreateMemoryFootprint);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionCreateMemoryFootprint, (JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
JSLockHolder lock(vm);
|
||||
return JSValue::encode(JSCMemoryFootprint::create(vm, globalObject));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionGetRandomSeed);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionGetRandomSeed, (JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
return JSValue::encode(jsNumber(globalObject->weakRandom().seed()));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionSetRandomSeed);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionSetRandomSeed, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
unsigned seed = callFrame->argument(0).toUInt32(globalObject);
|
||||
RETURN_IF_EXCEPTION(scope, encodedJSValue());
|
||||
globalObject->weakRandom().setSeed(seed);
|
||||
return JSValue::encode(jsUndefined());
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionIsRope);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionIsRope, (JSGlobalObject*, CallFrame* callFrame))
|
||||
{
|
||||
JSValue argument = callFrame->argument(0);
|
||||
if (!argument.isString())
|
||||
return JSValue::encode(jsBoolean(false));
|
||||
const StringImpl* impl = asString(argument)->tryGetValueImpl();
|
||||
return JSValue::encode(jsBoolean(!impl));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionCallerSourceOrigin);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionCallerSourceOrigin, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
|
||||
if (sourceOrigin.url().isNull())
|
||||
return JSValue::encode(jsNull());
|
||||
return JSValue::encode(jsString(vm, sourceOrigin.string()));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionNoFTL);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionNoFTL, (JSGlobalObject*, CallFrame* callFrame))
|
||||
{
|
||||
if (callFrame->argumentCount()) {
|
||||
FunctionExecutable* executable = getExecutableForFunction(callFrame->argument(0));
|
||||
if (executable)
|
||||
executable->setNeverFTLOptimize(true);
|
||||
}
|
||||
return JSValue::encode(jsUndefined());
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionNoOSRExitFuzzing);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionNoOSRExitFuzzing, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
return JSValue::encode(setCannotUseOSRExitFuzzing(globalObject, callFrame));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionOptimizeNextInvocation);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionOptimizeNextInvocation, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
return JSValue::encode(optimizeNextInvocation(globalObject, callFrame));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionNumberOfDFGCompiles);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionNumberOfDFGCompiles, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
return JSValue::encode(numberOfDFGCompiles(globalObject, callFrame));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionReleaseWeakRefs);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionReleaseWeakRefs, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
globalObject->vm().finalizeSynchronousJSExecution();
|
||||
return JSValue::encode(jsUndefined());
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionTotalCompileTime);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionTotalCompileTime, (JSGlobalObject*, CallFrame*))
|
||||
{
|
||||
return JSValue::encode(jsNumber(JIT::totalCompileTime().milliseconds()));
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionReoptimizationRetryCount);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionReoptimizationRetryCount, (JSGlobalObject*, CallFrame* callFrame))
|
||||
{
|
||||
if (callFrame->argumentCount() < 1)
|
||||
return JSValue::encode(jsUndefined());
|
||||
|
||||
CodeBlock* block = getSomeBaselineCodeBlockForFunction(callFrame->argument(0));
|
||||
if (!block)
|
||||
return JSValue::encode(jsNumber(0));
|
||||
|
||||
return JSValue::encode(jsNumber(block->reoptimizationRetryCounter()));
|
||||
}
|
||||
|
||||
extern "C" void Bun__drainMicrotasks();
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionDrainMicrotasks);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionDrainMicrotasks, (JSGlobalObject * globalObject, CallFrame*))
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
vm.drainMicrotasks();
|
||||
Bun__drainMicrotasks();
|
||||
return JSValue::encode(jsUndefined());
|
||||
}
|
||||
|
||||
JSC::JSObject* createJSCModule(JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
VM& vm = globalObject->vm();
|
||||
JSC::JSObject* object = nullptr;
|
||||
|
||||
{
|
||||
JSC::ObjectInitializationScope initializationScope(vm);
|
||||
object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 20);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "describe"_s), 1, functionDescribe, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "describeArray"_s), 1, functionDescribeArray, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "gcAndSweep"_s), 1, functionGCAndSweep, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "fullGC"_s), 1, functionFullGC, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "edenGC"_s), 1, functionEdenGC, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "heapSize"_s), 1, functionHeapSize, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "heapStats"_s), 1, functionMemoryUsageStatistics, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "memoryUsage"_s), 1, functionCreateMemoryFootprint, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getRandomSeed"_s), 1, functionGetRandomSeed, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "setRandomSeed"_s), 1, functionSetRandomSeed, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "isRope"_s), 1, functionIsRope, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "callerSourceOrigin"_s), 1, functionCallerSourceOrigin, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "noFTL"_s), 1, functionNoFTL, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "noOSRExitFuzzing"_s), 1, functionNoOSRExitFuzzing, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "optimizeNextInvocation"_s), 1, functionOptimizeNextInvocation, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "numberOfDFGCompiles"_s), 1, functionNumberOfDFGCompiles, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "releaseWeakRefs"_s), 1, functionReleaseWeakRefs, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "totalCompileTime"_s), 1, functionTotalCompileTime, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "reoptimizationRetryCount"_s), 1, functionReoptimizationRetryCount, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "drainMicrotasks"_s), 1, functionDrainMicrotasks, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
4
src/javascript/jsc/bindings/BunJSCModule.h
Normal file
4
src/javascript/jsc/bindings/BunJSCModule.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "root.h"
|
||||
#include "JavaScriptCore/JSObject.h"
|
||||
|
||||
JSC::JSObject* createJSCModule(JSC::JSGlobalObject* globalObject);
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "ByteLengthQueuingStrategyBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_byteLengthQueuingStrategyHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_byteLengthQueuingStrategyHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_byteLengthQueuingStrategyHighWaterMarkCodeLength = 286;
|
||||
static const JSC::Intrinsic s_byteLengthQueuingStrategyHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_byteLengthQueuingStrategyHighWaterMarkCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const highWaterMark = @getByIdDirectPrivate(this, \"highWaterMark\");\n" \
|
||||
" if (highWaterMark === @undefined)\n" \
|
||||
" @throwTypeError(\"ByteLengthQueuingStrategy.highWaterMark getter called on incompatible |this| value.\");\n" \
|
||||
"\n" \
|
||||
" return highWaterMark;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_byteLengthQueuingStrategySizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_byteLengthQueuingStrategySizeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_byteLengthQueuingStrategySizeCodeLength = 71;
|
||||
static const JSC::Intrinsic s_byteLengthQueuingStrategySizeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_byteLengthQueuingStrategySizeCode =
|
||||
"(function (chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" return chunk.byteLength;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength = 155;
|
||||
static const JSC::Intrinsic s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode =
|
||||
"(function (parameters)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(this, \"highWaterMark\", @extractHighWaterMarkFromQueuingStrategyInit(parameters));\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().byteLengthQueuingStrategyBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().byteLengthQueuingStrategyBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
143
src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.h
Normal file
143
src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ByteLengthQueuingStrategy */
|
||||
extern const char* const s_byteLengthQueuingStrategyHighWaterMarkCode;
|
||||
extern const int s_byteLengthQueuingStrategyHighWaterMarkCodeLength;
|
||||
extern const JSC::ConstructAbility s_byteLengthQueuingStrategyHighWaterMarkCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_byteLengthQueuingStrategyHighWaterMarkCodeConstructorKind;
|
||||
extern const char* const s_byteLengthQueuingStrategySizeCode;
|
||||
extern const int s_byteLengthQueuingStrategySizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_byteLengthQueuingStrategySizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_byteLengthQueuingStrategySizeCodeConstructorKind;
|
||||
extern const char* const s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode;
|
||||
extern const int s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength;
|
||||
extern const JSC::ConstructAbility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_DATA(macro) \
|
||||
macro(highWaterMark, byteLengthQueuingStrategyHighWaterMark, 0) \
|
||||
macro(size, byteLengthQueuingStrategySize, 1) \
|
||||
macro(initializeByteLengthQueuingStrategy, byteLengthQueuingStrategyInitializeByteLengthQueuingStrategy, 1) \
|
||||
|
||||
#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_HIGHWATERMARK 1
|
||||
#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_SIZE 1
|
||||
#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_INITIALIZEBYTELENGTHQUEUINGSTRATEGY 1
|
||||
|
||||
#define WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(macro) \
|
||||
macro(byteLengthQueuingStrategyHighWaterMarkCode, highWaterMark, "get highWaterMark"_s, s_byteLengthQueuingStrategyHighWaterMarkCodeLength) \
|
||||
macro(byteLengthQueuingStrategySizeCode, size, ASCIILiteral(), s_byteLengthQueuingStrategySizeCodeLength) \
|
||||
macro(byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode, initializeByteLengthQueuingStrategy, ASCIILiteral(), s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(highWaterMark) \
|
||||
macro(initializeByteLengthQueuingStrategy) \
|
||||
macro(size) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ByteLengthQueuingStrategyBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ByteLengthQueuingStrategyBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ByteLengthQueuingStrategyBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ByteLengthQueuingStrategyBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
104
src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.cpp
Normal file
104
src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "CountQueuingStrategyBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_countQueuingStrategyHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_countQueuingStrategyHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_countQueuingStrategyHighWaterMarkCodeLength = 281;
|
||||
static const JSC::Intrinsic s_countQueuingStrategyHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_countQueuingStrategyHighWaterMarkCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const highWaterMark = @getByIdDirectPrivate(this, \"highWaterMark\");\n" \
|
||||
" if (highWaterMark === @undefined)\n" \
|
||||
" @throwTypeError(\"CountQueuingStrategy.highWaterMark getter called on incompatible |this| value.\");\n" \
|
||||
"\n" \
|
||||
" return highWaterMark;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_countQueuingStrategySizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_countQueuingStrategySizeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_countQueuingStrategySizeCodeLength = 51;
|
||||
static const JSC::Intrinsic s_countQueuingStrategySizeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_countQueuingStrategySizeCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" return 1;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength = 155;
|
||||
static const JSC::Intrinsic s_countQueuingStrategyInitializeCountQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_countQueuingStrategyInitializeCountQueuingStrategyCode =
|
||||
"(function (parameters)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(this, \"highWaterMark\", @extractHighWaterMarkFromQueuingStrategyInit(parameters));\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().countQueuingStrategyBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().countQueuingStrategyBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
143
src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.h
Normal file
143
src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* CountQueuingStrategy */
|
||||
extern const char* const s_countQueuingStrategyHighWaterMarkCode;
|
||||
extern const int s_countQueuingStrategyHighWaterMarkCodeLength;
|
||||
extern const JSC::ConstructAbility s_countQueuingStrategyHighWaterMarkCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_countQueuingStrategyHighWaterMarkCodeConstructorKind;
|
||||
extern const char* const s_countQueuingStrategySizeCode;
|
||||
extern const int s_countQueuingStrategySizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_countQueuingStrategySizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_countQueuingStrategySizeCodeConstructorKind;
|
||||
extern const char* const s_countQueuingStrategyInitializeCountQueuingStrategyCode;
|
||||
extern const int s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength;
|
||||
extern const JSC::ConstructAbility s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_DATA(macro) \
|
||||
macro(highWaterMark, countQueuingStrategyHighWaterMark, 0) \
|
||||
macro(size, countQueuingStrategySize, 0) \
|
||||
macro(initializeCountQueuingStrategy, countQueuingStrategyInitializeCountQueuingStrategy, 1) \
|
||||
|
||||
#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_HIGHWATERMARK 1
|
||||
#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_SIZE 1
|
||||
#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_INITIALIZECOUNTQUEUINGSTRATEGY 1
|
||||
|
||||
#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(macro) \
|
||||
macro(countQueuingStrategyHighWaterMarkCode, highWaterMark, "get highWaterMark"_s, s_countQueuingStrategyHighWaterMarkCodeLength) \
|
||||
macro(countQueuingStrategySizeCode, size, ASCIILiteral(), s_countQueuingStrategySizeCodeLength) \
|
||||
macro(countQueuingStrategyInitializeCountQueuingStrategyCode, initializeCountQueuingStrategy, ASCIILiteral(), s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(highWaterMark) \
|
||||
macro(initializeCountQueuingStrategy) \
|
||||
macro(size) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class CountQueuingStrategyBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit CountQueuingStrategyBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* CountQueuingStrategyBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void CountQueuingStrategyBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -1308,16 +1308,16 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_concat, (JSGlobalObject * l
|
||||
|
||||
/* Hash table for constructor */
|
||||
static const HashTableValue JSBufferConstructorTableValues[] = {
|
||||
{ "alloc", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_alloc), (intptr_t)(3) } },
|
||||
{ "allocUnsafe", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
|
||||
{ "allocUnsafeSlow", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
|
||||
{ "byteLength", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_byteLength), (intptr_t)(2) } },
|
||||
{ "compare", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_compare), (intptr_t)(2) } },
|
||||
{ "concat", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_concat), (intptr_t)(2) } },
|
||||
{ "from", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferConstructorFromCodeGenerator), (intptr_t)(1) } },
|
||||
{ "isBuffer", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isBuffer), (intptr_t)(1) } },
|
||||
{ "toBuffer", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_toBuffer), (intptr_t)(1) } },
|
||||
{ "isEncoding", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isEncoding), (intptr_t)(1) } },
|
||||
{ "alloc"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_alloc), (intptr_t)(3) } },
|
||||
{ "allocUnsafe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
|
||||
{ "allocUnsafeSlow"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
|
||||
{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_byteLength), (intptr_t)(2) } },
|
||||
{ "compare"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_compare), (intptr_t)(2) } },
|
||||
{ "concat"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_concat), (intptr_t)(2) } },
|
||||
{ "from"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferConstructorFromCodeGenerator), (intptr_t)(1) } },
|
||||
{ "isBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isBuffer), (intptr_t)(1) } },
|
||||
{ "toBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_toBuffer), (intptr_t)(1) } },
|
||||
{ "isEncoding"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isEncoding), (intptr_t)(1) } },
|
||||
};
|
||||
|
||||
template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBufferConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
|
||||
@@ -1431,96 +1431,96 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_write, (JSGlobalObject * lexi
|
||||
|
||||
static const HashTableValue JSBufferPrototypeTableValues[]
|
||||
= {
|
||||
{ "asciiSlice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeAsciiSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "asciiWrite", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeAsciiWriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "base64Slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64SliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "base64urlSlice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64urlSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "base64urlWrite", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64urlWriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "base64Write", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64WriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "compare", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_compare), (intptr_t)(5) } },
|
||||
{ "copy", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_copy), (intptr_t)(4) } },
|
||||
{ "equals", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_equals), (intptr_t)(1) } },
|
||||
{ "fill", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_fill), (intptr_t)(4) } },
|
||||
{ "hexSlice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeHexSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "hexWrite", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeHexWriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "includes", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_includes), (intptr_t)(3) } },
|
||||
{ "indexOf", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_indexOf), (intptr_t)(3) } },
|
||||
{ "lastIndexOf", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_lastIndexOf), (intptr_t)(3) } },
|
||||
{ "latin1Slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeLatin1SliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "latin1Write", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeLatin1WriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigInt64", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigUInt64", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readDouble", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleBECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readFloat", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatBECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt16", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt32", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt8CodeGenerator), (intptr_t)(2) } },
|
||||
{ "readUint16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUint16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUint32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUint32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUint8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "subarray", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "swap16", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap16), (intptr_t)(0) } },
|
||||
{ "swap32", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap32), (intptr_t)(0) } },
|
||||
{ "swap64", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap64), (intptr_t)(0) } },
|
||||
{ "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_toString), (intptr_t)(4) } },
|
||||
{ "ucs2Slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUcs2SliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "ucs2Write", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUcs2WriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "utf16leSlice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf16leSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "utf16leWrite", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf16leWriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "utf8Slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf8SliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "utf8Write", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf8WriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "write", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_write), (intptr_t)(4) } },
|
||||
{ "writeBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigUint64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigUint64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeDouble", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleBECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeFloat", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatBECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint16", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt16", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint32", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt32", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "asciiSlice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeAsciiSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "asciiWrite"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeAsciiWriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "base64Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64SliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "base64urlSlice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64urlSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "base64urlWrite"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64urlWriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "base64Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64WriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "compare"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_compare), (intptr_t)(5) } },
|
||||
{ "copy"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_copy), (intptr_t)(4) } },
|
||||
{ "equals"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_equals), (intptr_t)(1) } },
|
||||
{ "fill"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_fill), (intptr_t)(4) } },
|
||||
{ "hexSlice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeHexSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "hexWrite"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeHexWriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "includes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_includes), (intptr_t)(3) } },
|
||||
{ "indexOf"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_indexOf), (intptr_t)(3) } },
|
||||
{ "lastIndexOf"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_lastIndexOf), (intptr_t)(3) } },
|
||||
{ "latin1Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeLatin1SliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "latin1Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeLatin1WriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigInt64"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigUInt64"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigUInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readBigUInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readDouble"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readDoubleBE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleBECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readDoubleLE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readFloat"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readFloatBE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatBECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readFloatLE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt16"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt32"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readInt8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt8CodeGenerator), (intptr_t)(2) } },
|
||||
{ "readUint16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUint16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUint32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUint32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUint8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "readUInt8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "subarray"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "swap16"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap16), (intptr_t)(0) } },
|
||||
{ "swap32"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap32), (intptr_t)(0) } },
|
||||
{ "swap64"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap64), (intptr_t)(0) } },
|
||||
{ "toString"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_toString), (intptr_t)(4) } },
|
||||
{ "ucs2Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUcs2SliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "ucs2Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUcs2WriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "utf16leSlice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf16leSliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "utf16leWrite"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf16leWriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "utf8Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf8SliceCodeGenerator), (intptr_t)(2) } },
|
||||
{ "utf8Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf8WriteCodeGenerator), (intptr_t)(1) } },
|
||||
{ "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_write), (intptr_t)(4) } },
|
||||
{ "writeBigInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigUint64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigUInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigUint64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeBigUInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeDouble"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeDoubleBE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleBECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeDoubleLE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeFloat"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeFloatBE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatBECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeFloatLE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeInt8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint16"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt16"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint32"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt32"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUint8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } },
|
||||
{ "writeUInt8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } },
|
||||
};
|
||||
|
||||
void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis)
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
//clang-format off
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
//clang-format off
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "DOMException.h"
|
||||
#include "JSDOMException.h"
|
||||
#include "JSDOMExceptionHandling.h"
|
||||
#include "JSDOMPromiseDeferred.h"
|
||||
|
||||
#include "JavaScriptCore/ErrorHandlingScope.h"
|
||||
#include "JavaScriptCore/Exception.h"
|
||||
@@ -275,10 +276,10 @@ void throwNonFiniteTypeError(JSGlobalObject& lexicalGlobalObject, JSC::ThrowScop
|
||||
throwTypeError(&lexicalGlobalObject, scope, "The provided value is non-finite"_s);
|
||||
}
|
||||
|
||||
// JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const JSC::ClassInfo* classInfo, JSC::PropertyName attributeName)
|
||||
// {
|
||||
// return createRejectedPromiseWithTypeError(lexicalGlobalObject, JSC::makeDOMAttributeGetterTypeErrorMessage(classInfo->className, String(attributeName.uid())), RejectedPromiseWithTypeErrorCause::NativeGetter);
|
||||
// }
|
||||
JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const JSC::ClassInfo* classInfo, JSC::PropertyName attributeName)
|
||||
{
|
||||
return createRejectedPromiseWithTypeError(lexicalGlobalObject, JSC::makeDOMAttributeGetterTypeErrorMessage(classInfo->className, String(attributeName.uid())), RejectedPromiseWithTypeErrorCause::NativeGetter);
|
||||
}
|
||||
|
||||
String makeThisTypeErrorMessage(const char* interfaceName, const char* functionName)
|
||||
{
|
||||
@@ -295,16 +296,16 @@ EncodedJSValue throwThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, JSC:
|
||||
return throwTypeError(lexicalGlobalObject, scope, makeThisTypeErrorMessage(interfaceName, functionName));
|
||||
}
|
||||
|
||||
// JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise& promise, const char* interfaceName, const char* methodName)
|
||||
// {
|
||||
// promise.reject(TypeError, makeThisTypeErrorMessage(interfaceName, methodName));
|
||||
// return JSValue::encode(jsUndefined());
|
||||
// }
|
||||
JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise& promise, const char* interfaceName, const char* methodName)
|
||||
{
|
||||
promise.reject(TypeError, makeThisTypeErrorMessage(interfaceName, methodName));
|
||||
return JSValue::encode(jsUndefined());
|
||||
}
|
||||
|
||||
// JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const char* interfaceName, const char* methodName)
|
||||
// {
|
||||
// return createRejectedPromiseWithTypeError(lexicalGlobalObject, makeThisTypeErrorMessage(interfaceName, methodName), RejectedPromiseWithTypeErrorCause::InvalidThis);
|
||||
// }
|
||||
JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const char* interfaceName, const char* methodName)
|
||||
{
|
||||
return createRejectedPromiseWithTypeError(lexicalGlobalObject, makeThisTypeErrorMessage(interfaceName, methodName), RejectedPromiseWithTypeErrorCause::InvalidThis);
|
||||
}
|
||||
|
||||
void throwDOMSyntaxError(JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope, ASCIILiteral message)
|
||||
{
|
||||
|
||||
@@ -60,9 +60,9 @@ String makeUnsupportedIndexedSetterErrorMessage(const char* interfaceName);
|
||||
|
||||
WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::JSGlobalObject&, JSC::ThrowScope&, const char* interfaceName, const char* functionName);
|
||||
|
||||
// WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject&, const JSC::ClassInfo*, JSC::PropertyName attributeName);
|
||||
// WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName);
|
||||
// WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject&, const char* interfaceName, const char* operationName);
|
||||
WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject&, const JSC::ClassInfo*, JSC::PropertyName attributeName);
|
||||
WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName);
|
||||
WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject&, const char* interfaceName, const char* operationName);
|
||||
|
||||
String retrieveErrorMessageWithoutName(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
|
||||
String retrieveErrorMessage(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
|
||||
|
||||
@@ -56,6 +56,7 @@ JSC::JSValue cloneAcrossWorlds(JSC::JSGlobalObject& lexicalGlobalObject, const J
|
||||
// FIXME: Why is owner->globalObject() better than lexicalGlobalObject.lexicalGlobalObject() here?
|
||||
// Unlike this, isWorldCompatible uses lexicalGlobalObject.lexicalGlobalObject(); should the two match?
|
||||
// return serializedValue->deserialize(lexicalGlobalObject, owner.globalObject());
|
||||
return JSC::jsNull();
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
|
||||
@@ -23,18 +23,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "root.h"
|
||||
|
||||
#include "DOMWrapperWorld.h"
|
||||
#include "JSDOMGlobalObject.h"
|
||||
#include "JSDOMWrapper.h"
|
||||
#include "ScriptWrappable.h"
|
||||
#include "ScriptWrappableInlines.h"
|
||||
#include "WebCoreTypedArrayController.h"
|
||||
#include "JavaScriptCore/JSArrayBuffer.h"
|
||||
#include "JavaScriptCore/TypedArrayInlines.h"
|
||||
#include "JavaScriptCore/Weak.h"
|
||||
#include "JavaScriptCore/WeakInlines.h"
|
||||
#include <JavaScriptCore/JSArrayBuffer.h>
|
||||
#include <JavaScriptCore/TypedArrayInlines.h>
|
||||
#include <JavaScriptCore/Weak.h>
|
||||
#include <JavaScriptCore/WeakInlines.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
|
||||
@@ -33,10 +33,14 @@
|
||||
extern "C" Zig::JSFFIFunction* Bun__CreateFFIFunction(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer)
|
||||
{
|
||||
JSC::VM& vm = globalObject->vm();
|
||||
Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, globalObject, argCount, Zig::toStringCopy(*symbolName), functionPointer, JSC::NoIntrinsic);
|
||||
JSC::gcProtect(function);
|
||||
Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, globalObject, argCount, symbolName != nullptr ? Zig::toStringCopy(*symbolName) : String(), functionPointer, JSC::NoIntrinsic);
|
||||
return function;
|
||||
}
|
||||
extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer);
|
||||
extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer)
|
||||
{
|
||||
return JSC::JSValue::encode(JSC::JSValue(Bun__CreateFFIFunction(globalObject, symbolName, argCount, functionPointer)));
|
||||
}
|
||||
|
||||
namespace Zig {
|
||||
using namespace JSC;
|
||||
@@ -70,7 +74,7 @@ void JSFFIFunction::finishCreation(VM& vm, NativeExecutable* executable, unsigne
|
||||
JSFFIFunction* JSFFIFunction::create(VM& vm, Zig::GlobalObject* globalObject, unsigned length, const String& name, FFIFunction FFIFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
|
||||
{
|
||||
|
||||
NativeExecutable* executable = vm.getHostFunction(FFIFunction, intrinsic, nativeConstructor, nullptr, name);
|
||||
NativeExecutable* executable = vm.getHostFunction(FFIFunction, intrinsic, FFIFunction, nullptr, name);
|
||||
|
||||
Structure* structure = globalObject->FFIFunctionStructure();
|
||||
JSFFIFunction* function = new (NotNull, allocateCell<JSFFIFunction>(vm)) JSFFIFunction(vm, executable, globalObject, structure, WTFMove(FFIFunction));
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -205,7 +205,7 @@ void Process::finishCreation(JSC::VM& vm)
|
||||
JSC::CustomGetterSetter::create(vm, Process_getPPID, nullptr),
|
||||
static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
|
||||
|
||||
putDirectCustomAccessor(vm, clientData->builtinNames().titlePublicName(),
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "dlopen"_s),
|
||||
JSC::CustomGetterSetter::create(vm, Process_getTitle, Process_setTitle),
|
||||
static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
|
||||
|
||||
@@ -249,7 +249,7 @@ void Process::finishCreation(JSC::VM& vm)
|
||||
JSC::JSValue(JSC::jsNumber(0)));
|
||||
|
||||
this->putDirect(this->vm(), clientData->builtinNames().versionPublicName(),
|
||||
JSC::jsString(this->vm(), Bun__version));
|
||||
JSC::jsString(this->vm(), makeAtomString(Bun__version)));
|
||||
|
||||
// this gives some way of identifying at runtime whether the SSR is happening in node or not.
|
||||
// this should probably be renamed to what the name of the bundler is, instead of "notNodeJS"
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "ReadableByteStreamControllerBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength = 366;
|
||||
static const JSC::Intrinsic s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode =
|
||||
"(function (stream, underlyingByteSource, highWaterMark)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (arguments.length !== 4 && arguments[3] !== @isReadableStream)\n" \
|
||||
" @throwTypeError(\"ReadableByteStreamController constructor should not be called directly\");\n" \
|
||||
"\n" \
|
||||
" return @privateInitializeReadableByteStreamController.@call(this, stream, underlyingByteSource, highWaterMark);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamControllerEnqueueCodeLength = 665;
|
||||
static const JSC::Intrinsic s_readableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamControllerEnqueueCode =
|
||||
"(function (chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableByteStreamController(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableByteStreamController\", \"enqueue\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"closeRequested\"))\n" \
|
||||
" @throwTypeError(\"ReadableByteStreamController is requested to close\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n" \
|
||||
" @throwTypeError(\"ReadableStream is not readable\");\n" \
|
||||
"\n" \
|
||||
" if (!@isObject(chunk) || !@ArrayBuffer.@isView(chunk))\n" \
|
||||
" @throwTypeError(\"Provided chunk is not a TypedArray\");\n" \
|
||||
"\n" \
|
||||
" return @readableByteStreamControllerEnqueue(this, chunk);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamControllerErrorCodeLength = 396;
|
||||
static const JSC::Intrinsic s_readableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamControllerErrorCode =
|
||||
"(function (error)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableByteStreamController(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableByteStreamController\", \"error\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n" \
|
||||
" @throwTypeError(\"ReadableStream is not readable\");\n" \
|
||||
"\n" \
|
||||
" @readableByteStreamControllerError(this, error);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamControllerCloseCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamControllerCloseCodeLength = 501;
|
||||
static const JSC::Intrinsic s_readableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamControllerCloseCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableByteStreamController(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableByteStreamController\", \"close\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"closeRequested\"))\n" \
|
||||
" @throwTypeError(\"Close has already been requested\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n" \
|
||||
" @throwTypeError(\"ReadableStream is not readable\");\n" \
|
||||
"\n" \
|
||||
" @readableByteStreamControllerClose(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamControllerByobRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamControllerByobRequestCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamControllerByobRequestCodeLength = 817;
|
||||
static const JSC::Intrinsic s_readableByteStreamControllerByobRequestCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamControllerByobRequestCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableByteStreamController(this))\n" \
|
||||
" throw @makeGetterTypeError(\"ReadableByteStreamController\", \"byobRequest\");\n" \
|
||||
"\n" \
|
||||
" \n" \
|
||||
" var request = @getByIdDirectPrivate(this, \"byobRequest\");\n" \
|
||||
" if (request === @undefined) {\n" \
|
||||
" var pending = @getByIdDirectPrivate(this, \"pendingPullIntos\");\n" \
|
||||
" const firstDescriptor = pending.peek();\n" \
|
||||
" if (firstDescriptor) {\n" \
|
||||
" const view = new @Uint8Array(firstDescriptor.buffer,\n" \
|
||||
" firstDescriptor.byteOffset + firstDescriptor.bytesFilled,\n" \
|
||||
" firstDescriptor.byteLength - firstDescriptor.bytesFilled);\n" \
|
||||
" @putByIdDirectPrivate(this, \"byobRequest\", new @ReadableStreamBYOBRequest(this, view, @isReadableStream));\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(this, \"byobRequest\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamControllerDesiredSizeCodeLength = 231;
|
||||
static const JSC::Intrinsic s_readableByteStreamControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamControllerDesiredSizeCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableByteStreamController(this))\n" \
|
||||
" throw @makeGetterTypeError(\"ReadableByteStreamController\", \"desiredSize\");\n" \
|
||||
"\n" \
|
||||
" return @readableByteStreamControllerGetDesiredSize(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().readableByteStreamControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableByteStreamControllerBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ReadableByteStreamController */
|
||||
extern const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode;
|
||||
extern const int s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamControllerEnqueueCode;
|
||||
extern const int s_readableByteStreamControllerEnqueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamControllerEnqueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamControllerEnqueueCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamControllerErrorCode;
|
||||
extern const int s_readableByteStreamControllerErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamControllerErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamControllerErrorCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamControllerCloseCode;
|
||||
extern const int s_readableByteStreamControllerCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamControllerCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamControllerCloseCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamControllerByobRequestCode;
|
||||
extern const int s_readableByteStreamControllerByobRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamControllerByobRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamControllerByobRequestCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamControllerDesiredSizeCode;
|
||||
extern const int s_readableByteStreamControllerDesiredSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamControllerDesiredSizeCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_DATA(macro) \
|
||||
macro(initializeReadableByteStreamController, readableByteStreamControllerInitializeReadableByteStreamController, 3) \
|
||||
macro(enqueue, readableByteStreamControllerEnqueue, 1) \
|
||||
macro(error, readableByteStreamControllerError, 1) \
|
||||
macro(close, readableByteStreamControllerClose, 0) \
|
||||
macro(byobRequest, readableByteStreamControllerByobRequest, 0) \
|
||||
macro(desiredSize, readableByteStreamControllerDesiredSize, 0) \
|
||||
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_INITIALIZEREADABLEBYTESTREAMCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_ENQUEUE 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_ERROR 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_CLOSE 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_BYOBREQUEST 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_DESIREDSIZE 1
|
||||
|
||||
#define WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(macro) \
|
||||
macro(readableByteStreamControllerInitializeReadableByteStreamControllerCode, initializeReadableByteStreamController, ASCIILiteral(), s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength) \
|
||||
macro(readableByteStreamControllerEnqueueCode, enqueue, ASCIILiteral(), s_readableByteStreamControllerEnqueueCodeLength) \
|
||||
macro(readableByteStreamControllerErrorCode, error, ASCIILiteral(), s_readableByteStreamControllerErrorCodeLength) \
|
||||
macro(readableByteStreamControllerCloseCode, close, ASCIILiteral(), s_readableByteStreamControllerCloseCodeLength) \
|
||||
macro(readableByteStreamControllerByobRequestCode, byobRequest, "get byobRequest"_s, s_readableByteStreamControllerByobRequestCodeLength) \
|
||||
macro(readableByteStreamControllerDesiredSizeCode, desiredSize, "get desiredSize"_s, s_readableByteStreamControllerDesiredSizeCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(byobRequest) \
|
||||
macro(close) \
|
||||
macro(desiredSize) \
|
||||
macro(enqueue) \
|
||||
macro(error) \
|
||||
macro(initializeReadableByteStreamController) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ReadableByteStreamControllerBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ReadableByteStreamControllerBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ReadableByteStreamControllerBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ReadableByteStreamControllerBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,946 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "ReadableByteStreamInternalsBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength = 2344;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode =
|
||||
"(function (stream, underlyingByteSource, highWaterMark)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(stream))\n" \
|
||||
" @throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"readableStreamController\") !== null)\n" \
|
||||
" @throwTypeError(\"ReadableStream already has a controller\");\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(this, \"controlledReadableStream\", stream);\n" \
|
||||
" @putByIdDirectPrivate(this, \"underlyingByteSource\", underlyingByteSource);\n" \
|
||||
" @putByIdDirectPrivate(this, \"pullAgain\", false);\n" \
|
||||
" @putByIdDirectPrivate(this, \"pulling\", false);\n" \
|
||||
" @readableByteStreamControllerClearPendingPullIntos(this);\n" \
|
||||
" @putByIdDirectPrivate(this, \"queue\", @newQueue());\n" \
|
||||
" @putByIdDirectPrivate(this, \"started\", false);\n" \
|
||||
" @putByIdDirectPrivate(this, \"closeRequested\", false);\n" \
|
||||
"\n" \
|
||||
" let hwm = @toNumber(highWaterMark);\n" \
|
||||
" if (@isNaN(hwm) || hwm < 0)\n" \
|
||||
" @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \
|
||||
" @putByIdDirectPrivate(this, \"strategyHWM\", hwm);\n" \
|
||||
"\n" \
|
||||
" let autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;\n" \
|
||||
" if (autoAllocateChunkSize !== @undefined) {\n" \
|
||||
" autoAllocateChunkSize = @toNumber(autoAllocateChunkSize);\n" \
|
||||
" if (autoAllocateChunkSize <= 0 || autoAllocateChunkSize === @Infinity || autoAllocateChunkSize === -@Infinity)\n" \
|
||||
" @throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\");\n" \
|
||||
" }\n" \
|
||||
" @putByIdDirectPrivate(this, \"autoAllocateChunkSize\", autoAllocateChunkSize);\n" \
|
||||
" @putByIdDirectPrivate(this, \"pendingPullIntos\", @createFIFO());\n" \
|
||||
"\n" \
|
||||
" const controller = this;\n" \
|
||||
" const startResult = @promiseInvokeOrNoopNoCatch(underlyingByteSource, \"start\", [this]).@then(() => {\n" \
|
||||
" @putByIdDirectPrivate(controller, \"started\", true);\n" \
|
||||
" @assert(!@getByIdDirectPrivate(controller, \"pulling\"));\n" \
|
||||
" @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \
|
||||
" @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
|
||||
" }, (error) => {\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"state\") === @streamReadable)\n" \
|
||||
" @readableByteStreamControllerError(controller, error);\n" \
|
||||
" });\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(this, \"cancel\", @readableByteStreamControllerCancel);\n" \
|
||||
" @putByIdDirectPrivate(this, \"pull\", @readableByteStreamControllerPull);\n" \
|
||||
"\n" \
|
||||
" return this;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength = 187;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode =
|
||||
"(function (controller, view)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(this, \"associatedReadableByteStreamController\", controller);\n" \
|
||||
" @putByIdDirectPrivate(this, \"view\", view);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsIsReadableByteStreamControllerCodeLength = 158;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsIsReadableByteStreamControllerCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" return @isObject(controller) && !!@getByIdDirectPrivate(controller, \"underlyingByteSource\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeLength = 179;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsIsReadableStreamBYOBRequestCode =
|
||||
"(function (byobRequest)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" return @isObject(byobRequest) && !!@getByIdDirectPrivate(byobRequest, \"associatedReadableByteStreamController\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeLength = 149;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsIsReadableStreamBYOBReaderCode =
|
||||
"(function (reader)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" return @isObject(reader) && !!@getByIdDirectPrivate(reader, \"readIntoRequests\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 398;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode =
|
||||
"(function (controller, reason)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" var pendingPullIntos = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \
|
||||
" var first = pendingPullIntos.peek();\n" \
|
||||
" if (first)\n" \
|
||||
" first.bytesFilled = 0;\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \
|
||||
" return @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, \"underlyingByteSource\"), \"cancel\", [reason]);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength = 399;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode =
|
||||
"(function (controller, e)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \
|
||||
" @readableByteStreamControllerClearPendingPullIntos(controller);\n" \
|
||||
" @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \
|
||||
" @readableStreamError(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), e);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength = 809;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \
|
||||
" @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \
|
||||
" @putByIdDirectPrivate(controller, \"closeRequested\", true);\n" \
|
||||
" return;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" var first = @getByIdDirectPrivate(controller, \"pendingPullIntos\")?.peek();\n" \
|
||||
" if (first) {\n" \
|
||||
" if (first.bytesFilled > 0) {\n" \
|
||||
" const e = @makeTypeError(\"Close requested while there remain pending bytes\");\n" \
|
||||
" @readableByteStreamControllerError(controller, e);\n" \
|
||||
" throw e;\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeLength = 347;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
|
||||
" var existing = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \
|
||||
" if (existing !== @undefined) {\n" \
|
||||
" existing.clear();\n" \
|
||||
" } else {\n" \
|
||||
" @putByIdDirectPrivate(controller, \"pendingPullIntos\", @createFIFO());\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 406;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
|
||||
" const state = @getByIdDirectPrivate(stream, \"state\");\n" \
|
||||
"\n" \
|
||||
" if (state === @streamErrored)\n" \
|
||||
" return null;\n" \
|
||||
" if (state === @streamClosed)\n" \
|
||||
" return 0;\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(controller, \"strategyHWM\") - @getByIdDirectPrivate(controller, \"queue\").size;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 176;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \
|
||||
" return reader !== @undefined && @isReadableStreamBYOBReader(reader);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength = 179;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \
|
||||
" return reader !== @undefined && @isReadableStreamDefaultReader(reader);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeLength = 458;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCode =
|
||||
"(function (controller) {\n" \
|
||||
"\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \
|
||||
" if (!@getByIdDirectPrivate(controller, \"queue\").size && @getByIdDirectPrivate(controller, \"closeRequested\"))\n" \
|
||||
" @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
|
||||
" else\n" \
|
||||
" @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1706;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
|
||||
" @assert(@readableStreamHasDefaultReader(stream));\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \
|
||||
" @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\")?.isEmpty());\n" \
|
||||
" const entry = @getByIdDirectPrivate(controller, \"queue\").content.shift();\n" \
|
||||
" @getByIdDirectPrivate(controller, \"queue\").size -= entry.byteLength;\n" \
|
||||
" @readableByteStreamControllerHandleQueueDrain(controller);\n" \
|
||||
" let view;\n" \
|
||||
" try {\n" \
|
||||
" view = new @Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);\n" \
|
||||
" } catch (error) {\n" \
|
||||
" return @Promise.@reject(error);\n" \
|
||||
" }\n" \
|
||||
" return @createFulfilledPromise({ value: view, done: false });\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"autoAllocateChunkSize\") !== @undefined) {\n" \
|
||||
" let buffer;\n" \
|
||||
" try {\n" \
|
||||
" buffer = @createUninitializedArrayBuffer(@getByIdDirectPrivate(controller, \"autoAllocateChunkSize\"));\n" \
|
||||
" } catch (error) {\n" \
|
||||
" return @Promise.@reject(error);\n" \
|
||||
" }\n" \
|
||||
" const pullIntoDescriptor = {\n" \
|
||||
" buffer,\n" \
|
||||
" byteOffset: 0,\n" \
|
||||
" byteLength: @getByIdDirectPrivate(controller, \"autoAllocateChunkSize\"),\n" \
|
||||
" bytesFilled: 0,\n" \
|
||||
" elementSize: 1,\n" \
|
||||
" ctor: @Uint8Array,\n" \
|
||||
" readerType: 'default'\n" \
|
||||
" };\n" \
|
||||
" @getByIdDirectPrivate(controller, \"pendingPullIntos\").push(pullIntoDescriptor);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" const promise = @readableStreamAddReadRequest(stream);\n" \
|
||||
" @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
|
||||
" return promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 874;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"state\") !== @streamReadable)\n" \
|
||||
" return false;\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"closeRequested\"))\n" \
|
||||
" return false;\n" \
|
||||
" if (!@getByIdDirectPrivate(controller, \"started\"))\n" \
|
||||
" return false;\n" \
|
||||
" if (@readableStreamHasDefaultReader(stream) && (@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\")?.isNotEmpty() || !!@getByIdDirectPrivate(reader, \"bunNativePtr\")))\n" \
|
||||
" return true;\n" \
|
||||
" if (@readableStreamHasBYOBReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\")?.isNotEmpty())\n" \
|
||||
" return true;\n" \
|
||||
" if (@readableByteStreamControllerGetDesiredSize(controller) > 0)\n" \
|
||||
" return true;\n" \
|
||||
" return false;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength = 1002;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@readableByteStreamControllerShouldCallPull(controller))\n" \
|
||||
" return;\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"pulling\")) {\n" \
|
||||
" @putByIdDirectPrivate(controller, \"pullAgain\", true);\n" \
|
||||
" return;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \
|
||||
" @putByIdDirectPrivate(controller, \"pulling\", true);\n" \
|
||||
" @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, \"underlyingByteSource\"), \"pull\", [controller]).@then(() => {\n" \
|
||||
" @putByIdDirectPrivate(controller, \"pulling\", false);\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"pullAgain\")) {\n" \
|
||||
" @putByIdDirectPrivate(controller, \"pullAgain\", false);\n" \
|
||||
" @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
|
||||
" }\n" \
|
||||
" }, (error) => {\n" \
|
||||
" if (@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable)\n" \
|
||||
" @readableByteStreamControllerError(controller, error);\n" \
|
||||
" });\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeLength = 90;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsTransferBufferToCurrentRealmCode =
|
||||
"(function (buffer)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" return buffer;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableStreamReaderKindCodeLength = 266;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamReaderKindCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableStreamReaderKindCode =
|
||||
"(function (reader) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
"\n" \
|
||||
" if (!!@getByIdDirectPrivate(reader, \"readRequests\"))\n" \
|
||||
" return @getByIdDirectPrivate(reader, \"bunNativePtr\") ? 3 : 1;\n" \
|
||||
"\n" \
|
||||
" if (!!@getByIdDirectPrivate(reader, \"readIntoRequests\"))\n" \
|
||||
" return 2;\n" \
|
||||
"\n" \
|
||||
" return 0;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1649;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode =
|
||||
"(function (controller, chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
|
||||
" @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \
|
||||
" var reader = @getByIdDirectPrivate(stream, \"reader\");\n" \
|
||||
"\n" \
|
||||
"\n" \
|
||||
" switch (reader ? @readableStreamReaderKind(reader) : 0) {\n" \
|
||||
" \n" \
|
||||
" case 1: {\n" \
|
||||
" if (!@getByIdDirectPrivate(reader, \"readRequests\")?.isNotEmpty())\n" \
|
||||
" @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);\n" \
|
||||
" else {\n" \
|
||||
" @assert(!@getByIdDirectPrivate(controller, \"queue\").content.size());\n" \
|
||||
" const transferredView = chunk.constructor === @Uint8Array ? chunk : new @Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);\n" \
|
||||
" @readableStreamFulfillReadRequest(stream, transferredView, false);\n" \
|
||||
" }\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" \n" \
|
||||
" case 2: {\n" \
|
||||
" @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);\n" \
|
||||
" @readableByteStreamControllerProcessPullDescriptors(controller);\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" \n" \
|
||||
" case 3: {\n" \
|
||||
" //\n" \
|
||||
"\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" default: {\n" \
|
||||
" @assert(!@isReadableStreamLocked(stream));\n" \
|
||||
" @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);\n" \
|
||||
" break;\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 303;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode =
|
||||
"(function (controller, buffer, byteOffset, byteLength)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @getByIdDirectPrivate(controller, \"queue\").content.push({\n" \
|
||||
" buffer: buffer,\n" \
|
||||
" byteOffset: byteOffset,\n" \
|
||||
" byteLength: byteLength\n" \
|
||||
" });\n" \
|
||||
" @getByIdDirectPrivate(controller, \"queue\").size += byteLength;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 619;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode =
|
||||
"(function (controller, view)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").isNotEmpty());\n" \
|
||||
"\n" \
|
||||
" let firstDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek();\n" \
|
||||
" \n" \
|
||||
" if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset)\n" \
|
||||
" @throwRangeError(\"Invalid value for view.byteOffset\");\n" \
|
||||
"\n" \
|
||||
" if (firstDescriptor.byteLength !== view.byteLength)\n" \
|
||||
" @throwRangeError(\"Invalid value for view.byteLength\");\n" \
|
||||
"\n" \
|
||||
" firstDescriptor.buffer = view.buffer;\n" \
|
||||
" @readableByteStreamControllerRespondInternal(controller, view.byteLength);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength = 411;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode =
|
||||
"(function (controller, bytesWritten)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" bytesWritten = @toNumber(bytesWritten);\n" \
|
||||
"\n" \
|
||||
" if (@isNaN(bytesWritten) || bytesWritten === @Infinity || bytesWritten < 0 )\n" \
|
||||
" @throwRangeError(\"bytesWritten has an incorrect value\");\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").isNotEmpty());\n" \
|
||||
"\n" \
|
||||
" @readableByteStreamControllerRespondInternal(controller, bytesWritten);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength = 712;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode =
|
||||
"(function (controller, bytesWritten)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" let firstDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek();\n" \
|
||||
" let stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \
|
||||
" if (bytesWritten !== 0)\n" \
|
||||
" @throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");\n" \
|
||||
" @readableByteStreamControllerRespondInClosedState(controller, firstDescriptor);\n" \
|
||||
" } else {\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \
|
||||
" @readableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 1440;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode =
|
||||
"(function (controller, bytesWritten, pullIntoDescriptor)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength)\n" \
|
||||
" @throwRangeError(\"bytesWritten value is too great\");\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").isEmpty() || @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek() === pullIntoDescriptor);\n" \
|
||||
" @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
|
||||
" pullIntoDescriptor.bytesFilled += bytesWritten;\n" \
|
||||
"\n" \
|
||||
" if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize)\n" \
|
||||
" return;\n" \
|
||||
"\n" \
|
||||
" @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \
|
||||
" const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;\n" \
|
||||
"\n" \
|
||||
" if (remainderSize > 0) {\n" \
|
||||
" const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;\n" \
|
||||
" const remainder = @cloneArrayBuffer(pullIntoDescriptor.buffer, end - remainderSize, remainderSize);\n" \
|
||||
" @readableByteStreamControllerEnqueueChunk(controller, remainder, 0, remainder.byteLength);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \
|
||||
" pullIntoDescriptor.bytesFilled -= remainderSize;\n" \
|
||||
" @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \
|
||||
" @readableByteStreamControllerProcessPullDescriptors(controller);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength = 730;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode =
|
||||
"(function (controller, firstDescriptor)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" firstDescriptor.buffer = @transferBufferToCurrentRealm(firstDescriptor.buffer);\n" \
|
||||
" @assert(firstDescriptor.bytesFilled === 0);\n" \
|
||||
"\n" \
|
||||
" if (@readableStreamHasBYOBReader(@getByIdDirectPrivate(controller, \"controlledReadableStream\"))) {\n" \
|
||||
" while (@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"reader\"), \"readIntoRequests\")?.isNotEmpty()) {\n" \
|
||||
" let pullIntoDescriptor = @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \
|
||||
" @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength = 712;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \
|
||||
" while (@getByIdDirectPrivate(controller, \"pendingPullIntos\").isNotEmpty()) {\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"queue\").size === 0)\n" \
|
||||
" return;\n" \
|
||||
" let pullIntoDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek();\n" \
|
||||
" if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {\n" \
|
||||
" @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \
|
||||
" @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength = 2359;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode =
|
||||
"(function (controller, pullIntoDescriptor)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const currentAlignedBytes = pullIntoDescriptor.bytesFilled - (pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize);\n" \
|
||||
" const maxBytesToCopy = @getByIdDirectPrivate(controller, \"queue\").size < pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled ?\n" \
|
||||
" @getByIdDirectPrivate(controller, \"queue\").size : pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled;\n" \
|
||||
" const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;\n" \
|
||||
" const maxAlignedBytes = maxBytesFilled - (maxBytesFilled % pullIntoDescriptor.elementSize);\n" \
|
||||
" let totalBytesToCopyRemaining = maxBytesToCopy;\n" \
|
||||
" let ready = false;\n" \
|
||||
"\n" \
|
||||
" if (maxAlignedBytes > currentAlignedBytes) {\n" \
|
||||
" totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;\n" \
|
||||
" ready = true;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" while (totalBytesToCopyRemaining > 0) {\n" \
|
||||
" let headOfQueue = @getByIdDirectPrivate(controller, \"queue\").content.peek();\n" \
|
||||
" const bytesToCopy = totalBytesToCopyRemaining < headOfQueue.byteLength ? totalBytesToCopyRemaining : headOfQueue.byteLength;\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" const destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" new @Uint8Array(pullIntoDescriptor.buffer).set(new @Uint8Array(headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy), destStart);\n" \
|
||||
"\n" \
|
||||
" if (headOfQueue.byteLength === bytesToCopy)\n" \
|
||||
" @getByIdDirectPrivate(controller, \"queue\").content.shift();\n" \
|
||||
" else {\n" \
|
||||
" headOfQueue.byteOffset += bytesToCopy;\n" \
|
||||
" headOfQueue.byteLength -= bytesToCopy;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" @getByIdDirectPrivate(controller, \"queue\").size -= bytesToCopy;\n" \
|
||||
" @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").isEmpty() || @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek() === pullIntoDescriptor);\n" \
|
||||
" @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
|
||||
" pullIntoDescriptor.bytesFilled += bytesToCopy;\n" \
|
||||
" totalBytesToCopyRemaining -= bytesToCopy;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" if (!ready) {\n" \
|
||||
" @assert(@getByIdDirectPrivate(controller, \"queue\").size === 0);\n" \
|
||||
" @assert(pullIntoDescriptor.bytesFilled > 0);\n" \
|
||||
" @assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" return ready;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength = 222;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" let descriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\").shift();\n" \
|
||||
" @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
|
||||
" return descriptor;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeLength = 430;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"byobRequest\") === @undefined)\n" \
|
||||
" return;\n" \
|
||||
" const byobRequest = @getByIdDirectPrivate(controller, \"byobRequest\");\n" \
|
||||
" @putByIdDirectPrivate(byobRequest, \"associatedReadableByteStreamController\", @undefined);\n" \
|
||||
" @putByIdDirectPrivate(byobRequest, \"view\", @undefined);\n" \
|
||||
" @putByIdDirectPrivate(controller, \"byobRequest\", @undefined);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength = 662;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode =
|
||||
"(function (stream, pullIntoDescriptor)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"state\") !== @streamErrored);\n" \
|
||||
" let done = false;\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \
|
||||
" @assert(!pullIntoDescriptor.bytesFilled);\n" \
|
||||
" done = true;\n" \
|
||||
" }\n" \
|
||||
" let filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);\n" \
|
||||
" if (pullIntoDescriptor.readerType === \"default\")\n" \
|
||||
" @readableStreamFulfillReadRequest(stream, filledView, done);\n" \
|
||||
" else {\n" \
|
||||
" @assert(pullIntoDescriptor.readerType === \"byob\");\n" \
|
||||
" @readableStreamFulfillReadIntoRequest(stream, filledView, done);\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeLength = 381;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCode =
|
||||
"(function (pullIntoDescriptor)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(pullIntoDescriptor.bytesFilled <= pullIntoDescriptor.byteLength);\n" \
|
||||
" @assert(pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize === 0);\n" \
|
||||
"\n" \
|
||||
" return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, pullIntoDescriptor.bytesFilled / pullIntoDescriptor.elementSize);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength = 243;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode =
|
||||
"(function (stream, chunk, done)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
" const readIntoRequest = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\").shift();\n" \
|
||||
" @fulfillPromise(readIntoRequest, { value: chunk, done: done });\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength = 462;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode =
|
||||
"(function (reader, view)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(reader, \"ownerReadableStream\");\n" \
|
||||
" @assert(!!stream);\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(stream, \"disturbed\", true);\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"state\") === @streamErrored)\n" \
|
||||
" return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \
|
||||
"\n" \
|
||||
" return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(stream, \"readableStreamController\"), view);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength = 2190;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode =
|
||||
"(function (controller, view)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
|
||||
" let elementSize = 1;\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" if (view.BYTES_PER_ELEMENT !== @undefined)\n" \
|
||||
" elementSize = view.BYTES_PER_ELEMENT;\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" const ctor = view.constructor;\n" \
|
||||
"\n" \
|
||||
" const pullIntoDescriptor = {\n" \
|
||||
" buffer: view.buffer,\n" \
|
||||
" byteOffset: view.byteOffset,\n" \
|
||||
" byteLength: view.byteLength,\n" \
|
||||
" bytesFilled: 0,\n" \
|
||||
" elementSize,\n" \
|
||||
" ctor,\n" \
|
||||
" readerType: 'byob'\n" \
|
||||
" };\n" \
|
||||
"\n" \
|
||||
" var pending = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \
|
||||
" if (pending?.isNotEmpty()) {\n" \
|
||||
" pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \
|
||||
" pending.push(pullIntoDescriptor);\n" \
|
||||
" return @readableStreamAddReadIntoRequest(stream);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \
|
||||
" const emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);\n" \
|
||||
" return @createFulfilledPromise({ value: emptyView, done: true });\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \
|
||||
" if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {\n" \
|
||||
" const filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);\n" \
|
||||
" @readableByteStreamControllerHandleQueueDrain(controller);\n" \
|
||||
" return @createFulfilledPromise({ value: filledView, done: false });\n" \
|
||||
" }\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"closeRequested\")) {\n" \
|
||||
" const e = @makeTypeError(\"Closing stream has been requested\");\n" \
|
||||
" @readableByteStreamControllerError(controller, e);\n" \
|
||||
" return @Promise.@reject(e);\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \
|
||||
" @getByIdDirectPrivate(controller, \"pendingPullIntos\").push(pullIntoDescriptor);\n" \
|
||||
" const promise = @readableStreamAddReadIntoRequest(stream);\n" \
|
||||
" @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
|
||||
" return promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength = 430;
|
||||
static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@isReadableStreamBYOBReader(@getByIdDirectPrivate(stream, \"reader\")));\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable || @getByIdDirectPrivate(stream, \"state\") === @streamClosed);\n" \
|
||||
"\n" \
|
||||
" const readRequest = @newPromise();\n" \
|
||||
" @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\").push(readRequest);\n" \
|
||||
"\n" \
|
||||
" return readRequest;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().readableByteStreamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableByteStreamInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,436 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ReadableByteStreamInternals */
|
||||
extern const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode;
|
||||
extern const int s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode;
|
||||
extern const int s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsIsReadableByteStreamControllerCode;
|
||||
extern const int s_readableByteStreamInternalsIsReadableByteStreamControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsIsReadableStreamBYOBRequestCode;
|
||||
extern const int s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsIsReadableStreamBYOBReaderCode;
|
||||
extern const int s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode;
|
||||
extern const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode;
|
||||
extern const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsTransferBufferToCurrentRealmCode;
|
||||
extern const int s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableStreamReaderKindCode;
|
||||
extern const int s_readableByteStreamInternalsReadableStreamReaderKindCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode;
|
||||
extern const int s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode;
|
||||
extern const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode;
|
||||
extern const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructorKind;
|
||||
extern const char* const s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCode;
|
||||
extern const int s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_DATA(macro) \
|
||||
macro(privateInitializeReadableByteStreamController, readableByteStreamInternalsPrivateInitializeReadableByteStreamController, 3) \
|
||||
macro(privateInitializeReadableStreamBYOBRequest, readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequest, 2) \
|
||||
macro(isReadableByteStreamController, readableByteStreamInternalsIsReadableByteStreamController, 1) \
|
||||
macro(isReadableStreamBYOBRequest, readableByteStreamInternalsIsReadableStreamBYOBRequest, 1) \
|
||||
macro(isReadableStreamBYOBReader, readableByteStreamInternalsIsReadableStreamBYOBReader, 1) \
|
||||
macro(readableByteStreamControllerCancel, readableByteStreamInternalsReadableByteStreamControllerCancel, 2) \
|
||||
macro(readableByteStreamControllerError, readableByteStreamInternalsReadableByteStreamControllerError, 2) \
|
||||
macro(readableByteStreamControllerClose, readableByteStreamInternalsReadableByteStreamControllerClose, 1) \
|
||||
macro(readableByteStreamControllerClearPendingPullIntos, readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntos, 1) \
|
||||
macro(readableByteStreamControllerGetDesiredSize, readableByteStreamInternalsReadableByteStreamControllerGetDesiredSize, 1) \
|
||||
macro(readableStreamHasBYOBReader, readableByteStreamInternalsReadableStreamHasBYOBReader, 1) \
|
||||
macro(readableStreamHasDefaultReader, readableByteStreamInternalsReadableStreamHasDefaultReader, 1) \
|
||||
macro(readableByteStreamControllerHandleQueueDrain, readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrain, 1) \
|
||||
macro(readableByteStreamControllerPull, readableByteStreamInternalsReadableByteStreamControllerPull, 1) \
|
||||
macro(readableByteStreamControllerShouldCallPull, readableByteStreamInternalsReadableByteStreamControllerShouldCallPull, 1) \
|
||||
macro(readableByteStreamControllerCallPullIfNeeded, readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeeded, 1) \
|
||||
macro(transferBufferToCurrentRealm, readableByteStreamInternalsTransferBufferToCurrentRealm, 1) \
|
||||
macro(readableStreamReaderKind, readableByteStreamInternalsReadableStreamReaderKind, 1) \
|
||||
macro(readableByteStreamControllerEnqueue, readableByteStreamInternalsReadableByteStreamControllerEnqueue, 2) \
|
||||
macro(readableByteStreamControllerEnqueueChunk, readableByteStreamInternalsReadableByteStreamControllerEnqueueChunk, 4) \
|
||||
macro(readableByteStreamControllerRespondWithNewView, readableByteStreamInternalsReadableByteStreamControllerRespondWithNewView, 2) \
|
||||
macro(readableByteStreamControllerRespond, readableByteStreamInternalsReadableByteStreamControllerRespond, 2) \
|
||||
macro(readableByteStreamControllerRespondInternal, readableByteStreamInternalsReadableByteStreamControllerRespondInternal, 2) \
|
||||
macro(readableByteStreamControllerRespondInReadableState, readableByteStreamInternalsReadableByteStreamControllerRespondInReadableState, 3) \
|
||||
macro(readableByteStreamControllerRespondInClosedState, readableByteStreamInternalsReadableByteStreamControllerRespondInClosedState, 2) \
|
||||
macro(readableByteStreamControllerProcessPullDescriptors, readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptors, 1) \
|
||||
macro(readableByteStreamControllerFillDescriptorFromQueue, readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueue, 2) \
|
||||
macro(readableByteStreamControllerShiftPendingDescriptor, readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptor, 1) \
|
||||
macro(readableByteStreamControllerInvalidateBYOBRequest, readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequest, 1) \
|
||||
macro(readableByteStreamControllerCommitDescriptor, readableByteStreamInternalsReadableByteStreamControllerCommitDescriptor, 2) \
|
||||
macro(readableByteStreamControllerConvertDescriptor, readableByteStreamInternalsReadableByteStreamControllerConvertDescriptor, 1) \
|
||||
macro(readableStreamFulfillReadIntoRequest, readableByteStreamInternalsReadableStreamFulfillReadIntoRequest, 3) \
|
||||
macro(readableStreamBYOBReaderRead, readableByteStreamInternalsReadableStreamBYOBReaderRead, 2) \
|
||||
macro(readableByteStreamControllerPullInto, readableByteStreamInternalsReadableByteStreamControllerPullInto, 2) \
|
||||
macro(readableStreamAddReadIntoRequest, readableByteStreamInternalsReadableStreamAddReadIntoRequest, 1) \
|
||||
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_PRIVATEINITIALIZEREADABLEBYTESTREAMCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_PRIVATEINITIALIZEREADABLESTREAMBYOBREQUEST 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLEBYTESTREAMCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLESTREAMBYOBREQUEST 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLESTREAMBYOBREADER 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCANCEL 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERERROR 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCLOSE 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCLEARPENDINGPULLINTOS 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERGETDESIREDSIZE 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMHASBYOBREADER 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMHASDEFAULTREADER 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERHANDLEQUEUEDRAIN 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPULL 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERSHOULDCALLPULL 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCALLPULLIFNEEDED 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_TRANSFERBUFFERTOCURRENTREALM 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMREADERKIND 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERENQUEUE 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERENQUEUECHUNK 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDWITHNEWVIEW 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPOND 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINTERNAL 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINREADABLESTATE 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINCLOSEDSTATE 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPROCESSPULLDESCRIPTORS 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERFILLDESCRIPTORFROMQUEUE 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERSHIFTPENDINGDESCRIPTOR 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERINVALIDATEBYOBREQUEST 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCOMMITDESCRIPTOR 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCONVERTDESCRIPTOR 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMFULFILLREADINTOREQUEST 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMBYOBREADERREAD 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPULLINTO 1
|
||||
#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMADDREADINTOREQUEST 1
|
||||
|
||||
#define WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(macro) \
|
||||
macro(readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode, privateInitializeReadableByteStreamController, ASCIILiteral(), s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength) \
|
||||
macro(readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode, privateInitializeReadableStreamBYOBRequest, ASCIILiteral(), s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength) \
|
||||
macro(readableByteStreamInternalsIsReadableByteStreamControllerCode, isReadableByteStreamController, ASCIILiteral(), s_readableByteStreamInternalsIsReadableByteStreamControllerCodeLength) \
|
||||
macro(readableByteStreamInternalsIsReadableStreamBYOBRequestCode, isReadableStreamBYOBRequest, ASCIILiteral(), s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeLength) \
|
||||
macro(readableByteStreamInternalsIsReadableStreamBYOBReaderCode, isReadableStreamBYOBReader, ASCIILiteral(), s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerCancelCode, readableByteStreamControllerCancel, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerErrorCode, readableByteStreamControllerError, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerCloseCode, readableByteStreamControllerClose, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode, readableByteStreamControllerClearPendingPullIntos, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode, readableByteStreamControllerGetDesiredSize, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableStreamHasBYOBReaderCode, readableStreamHasBYOBReader, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableStreamHasDefaultReaderCode, readableStreamHasDefaultReader, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCode, readableByteStreamControllerHandleQueueDrain, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerPullCode, readableByteStreamControllerPull, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode, readableByteStreamControllerShouldCallPull, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode, readableByteStreamControllerCallPullIfNeeded, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength) \
|
||||
macro(readableByteStreamInternalsTransferBufferToCurrentRealmCode, transferBufferToCurrentRealm, ASCIILiteral(), s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableStreamReaderKindCode, readableStreamReaderKind, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamReaderKindCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerEnqueueCode, readableByteStreamControllerEnqueue, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode, readableByteStreamControllerEnqueueChunk, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode, readableByteStreamControllerRespondWithNewView, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerRespondCode, readableByteStreamControllerRespond, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode, readableByteStreamControllerRespondInternal, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode, readableByteStreamControllerRespondInReadableState, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode, readableByteStreamControllerRespondInClosedState, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode, readableByteStreamControllerProcessPullDescriptors, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode, readableByteStreamControllerFillDescriptorFromQueue, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode, readableByteStreamControllerShiftPendingDescriptor, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCode, readableByteStreamControllerInvalidateBYOBRequest, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode, readableByteStreamControllerCommitDescriptor, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCode, readableByteStreamControllerConvertDescriptor, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode, readableStreamFulfillReadIntoRequest, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableStreamBYOBReaderReadCode, readableStreamBYOBReaderRead, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableByteStreamControllerPullIntoCode, readableByteStreamControllerPullInto, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength) \
|
||||
macro(readableByteStreamInternalsReadableStreamAddReadIntoRequestCode, readableStreamAddReadIntoRequest, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(isReadableByteStreamController) \
|
||||
macro(isReadableStreamBYOBReader) \
|
||||
macro(isReadableStreamBYOBRequest) \
|
||||
macro(privateInitializeReadableByteStreamController) \
|
||||
macro(privateInitializeReadableStreamBYOBRequest) \
|
||||
macro(readableByteStreamControllerCallPullIfNeeded) \
|
||||
macro(readableByteStreamControllerCancel) \
|
||||
macro(readableByteStreamControllerClearPendingPullIntos) \
|
||||
macro(readableByteStreamControllerClose) \
|
||||
macro(readableByteStreamControllerCommitDescriptor) \
|
||||
macro(readableByteStreamControllerConvertDescriptor) \
|
||||
macro(readableByteStreamControllerEnqueue) \
|
||||
macro(readableByteStreamControllerEnqueueChunk) \
|
||||
macro(readableByteStreamControllerError) \
|
||||
macro(readableByteStreamControllerFillDescriptorFromQueue) \
|
||||
macro(readableByteStreamControllerGetDesiredSize) \
|
||||
macro(readableByteStreamControllerHandleQueueDrain) \
|
||||
macro(readableByteStreamControllerInvalidateBYOBRequest) \
|
||||
macro(readableByteStreamControllerProcessPullDescriptors) \
|
||||
macro(readableByteStreamControllerPull) \
|
||||
macro(readableByteStreamControllerPullInto) \
|
||||
macro(readableByteStreamControllerRespond) \
|
||||
macro(readableByteStreamControllerRespondInClosedState) \
|
||||
macro(readableByteStreamControllerRespondInReadableState) \
|
||||
macro(readableByteStreamControllerRespondInternal) \
|
||||
macro(readableByteStreamControllerRespondWithNewView) \
|
||||
macro(readableByteStreamControllerShiftPendingDescriptor) \
|
||||
macro(readableByteStreamControllerShouldCallPull) \
|
||||
macro(readableStreamAddReadIntoRequest) \
|
||||
macro(readableStreamBYOBReaderRead) \
|
||||
macro(readableStreamFulfillReadIntoRequest) \
|
||||
macro(readableStreamHasBYOBReader) \
|
||||
macro(readableStreamHasDefaultReader) \
|
||||
macro(readableStreamReaderKind) \
|
||||
macro(transferBufferToCurrentRealm) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ReadableByteStreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ReadableByteStreamInternalsBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ReadableByteStreamInternalsBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ReadableByteStreamInternalsBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
class ReadableByteStreamInternalsBuiltinFunctions {
|
||||
public:
|
||||
explicit ReadableByteStreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
|
||||
|
||||
void init(JSC::JSGlobalObject&);
|
||||
template<typename Visitor> void visit(Visitor&);
|
||||
|
||||
public:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
|
||||
JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
};
|
||||
|
||||
inline void ReadableByteStreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
|
||||
{
|
||||
#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
|
||||
m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
|
||||
#undef EXPORT_FUNCTION
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
inline void ReadableByteStreamInternalsBuiltinFunctions::visit(Visitor& visitor)
|
||||
{
|
||||
#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
|
||||
#undef VISIT_FUNCTION
|
||||
}
|
||||
|
||||
template void ReadableByteStreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
|
||||
template void ReadableByteStreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
|
||||
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
169
src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.cpp
Normal file
169
src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "ReadableStreamBYOBReaderBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeLength = 585;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(stream))\n" \
|
||||
" @throwTypeError(\"ReadableStreamBYOBReader needs a ReadableStream\");\n" \
|
||||
" if (!@isReadableByteStreamController(@getByIdDirectPrivate(stream, \"readableStreamController\")))\n" \
|
||||
" @throwTypeError(\"ReadableStreamBYOBReader needs a ReadableByteStreamController\");\n" \
|
||||
" if (@isReadableStreamLocked(stream))\n" \
|
||||
" @throwTypeError(\"ReadableStream is locked\");\n" \
|
||||
"\n" \
|
||||
" @readableStreamReaderGenericInitialize(this, stream);\n" \
|
||||
" @putByIdDirectPrivate(this, \"readIntoRequests\", @createFIFO());\n" \
|
||||
"\n" \
|
||||
" return this;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBReaderCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBReaderCancelCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBReaderCancelCodeLength = 410;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBReaderCancelCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBReaderCancelCode =
|
||||
"(function (reason)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamBYOBReader(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"ReadableStreamBYOBReader\", \"cancel\"));\n" \
|
||||
"\n" \
|
||||
" if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"cancel() called on a reader owned by no readable stream\"));\n" \
|
||||
"\n" \
|
||||
" return @readableStreamReaderGenericCancel(this, reason);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBReaderReadCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBReaderReadCodeLength = 762;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBReaderReadCode =
|
||||
"(function (view)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamBYOBReader(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"ReadableStreamBYOBReader\", \"read\"));\n" \
|
||||
"\n" \
|
||||
" if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"read() called on a reader owned by no readable stream\"));\n" \
|
||||
"\n" \
|
||||
" if (!@isObject(view))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"Provided view is not an object\"));\n" \
|
||||
"\n" \
|
||||
" if (!@ArrayBuffer.@isView(view))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"Provided view is not an ArrayBufferView\"));\n" \
|
||||
"\n" \
|
||||
" if (view.byteLength === 0)\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"Provided view cannot have a 0 byteLength\"));\n" \
|
||||
"\n" \
|
||||
" return @readableStreamBYOBReaderRead(this, view);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBReaderReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBReaderReleaseLockCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBReaderReleaseLockCodeLength = 447;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBReaderReleaseLockCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBReaderReleaseLockCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamBYOBReader(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStreamBYOBReader\", \"releaseLock\");\n" \
|
||||
"\n" \
|
||||
" if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
|
||||
" return;\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"readIntoRequests\")?.isNotEmpty())\n" \
|
||||
" @throwTypeError(\"There are still pending read requests, cannot release the lock\");\n" \
|
||||
"\n" \
|
||||
" @readableStreamReaderGenericRelease(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBReaderClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBReaderClosedCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBReaderClosedCodeLength = 251;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBReaderClosedCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBReaderClosedCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamBYOBReader(this))\n" \
|
||||
" return @Promise.@reject(@makeGetterTypeError(\"ReadableStreamBYOBReader\", \"closed\"));\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(this, \"closedPromiseCapability\").@promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().readableStreamBYOBReaderBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamBYOBReaderBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
159
src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.h
Normal file
159
src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ReadableStreamBYOBReader */
|
||||
extern const char* const s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCode;
|
||||
extern const int s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructorKind;
|
||||
extern const char* const s_readableStreamBYOBReaderCancelCode;
|
||||
extern const int s_readableStreamBYOBReaderCancelCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBReaderCancelCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBReaderCancelCodeConstructorKind;
|
||||
extern const char* const s_readableStreamBYOBReaderReadCode;
|
||||
extern const int s_readableStreamBYOBReaderReadCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBReaderReadCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBReaderReadCodeConstructorKind;
|
||||
extern const char* const s_readableStreamBYOBReaderReleaseLockCode;
|
||||
extern const int s_readableStreamBYOBReaderReleaseLockCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBReaderReleaseLockCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBReaderReleaseLockCodeConstructorKind;
|
||||
extern const char* const s_readableStreamBYOBReaderClosedCode;
|
||||
extern const int s_readableStreamBYOBReaderClosedCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBReaderClosedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBReaderClosedCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_DATA(macro) \
|
||||
macro(initializeReadableStreamBYOBReader, readableStreamBYOBReaderInitializeReadableStreamBYOBReader, 1) \
|
||||
macro(cancel, readableStreamBYOBReaderCancel, 1) \
|
||||
macro(read, readableStreamBYOBReaderRead, 1) \
|
||||
macro(releaseLock, readableStreamBYOBReaderReleaseLock, 0) \
|
||||
macro(closed, readableStreamBYOBReaderClosed, 0) \
|
||||
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_INITIALIZEREADABLESTREAMBYOBREADER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_CANCEL 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_READ 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_RELEASELOCK 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_CLOSED 1
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(macro) \
|
||||
macro(readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCode, initializeReadableStreamBYOBReader, ASCIILiteral(), s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeLength) \
|
||||
macro(readableStreamBYOBReaderCancelCode, cancel, ASCIILiteral(), s_readableStreamBYOBReaderCancelCodeLength) \
|
||||
macro(readableStreamBYOBReaderReadCode, read, ASCIILiteral(), s_readableStreamBYOBReaderReadCodeLength) \
|
||||
macro(readableStreamBYOBReaderReleaseLockCode, releaseLock, ASCIILiteral(), s_readableStreamBYOBReaderReleaseLockCodeLength) \
|
||||
macro(readableStreamBYOBReaderClosedCode, closed, "get closed"_s, s_readableStreamBYOBReaderClosedCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(cancel) \
|
||||
macro(closed) \
|
||||
macro(initializeReadableStreamBYOBReader) \
|
||||
macro(read) \
|
||||
macro(releaseLock) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ReadableStreamBYOBReaderBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ReadableStreamBYOBReaderBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ReadableStreamBYOBReaderBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ReadableStreamBYOBReaderBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "ReadableStreamBYOBRequestBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength = 306;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode =
|
||||
"(function (controller, view)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (arguments.length !== 3 && arguments[2] !== @isReadableStream)\n" \
|
||||
" @throwTypeError(\"ReadableStreamBYOBRequest constructor should not be called directly\");\n" \
|
||||
"\n" \
|
||||
" return @privateInitializeReadableStreamBYOBRequest.@call(this, controller, view);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBRequestRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBRequestRespondCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBRequestRespondCodeLength = 504;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBRequestRespondCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBRequestRespondCode =
|
||||
"(function (bytesWritten)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamBYOBRequest(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStreamBYOBRequest\", \"respond\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"associatedReadableByteStreamController\") === @undefined)\n" \
|
||||
" @throwTypeError(\"ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined\");\n" \
|
||||
"\n" \
|
||||
" return @readableByteStreamControllerRespond(@getByIdDirectPrivate(this, \"associatedReadableByteStreamController\"), bytesWritten);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBRequestRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBRequestRespondWithNewViewCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBRequestRespondWithNewViewCodeLength = 691;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBRequestRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBRequestRespondWithNewViewCode =
|
||||
"(function (view)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamBYOBRequest(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStreamBYOBRequest\", \"respond\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"associatedReadableByteStreamController\") === @undefined)\n" \
|
||||
" @throwTypeError(\"ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined\");\n" \
|
||||
"\n" \
|
||||
" if (!@isObject(view))\n" \
|
||||
" @throwTypeError(\"Provided view is not an object\");\n" \
|
||||
"\n" \
|
||||
" if (!@ArrayBuffer.@isView(view))\n" \
|
||||
" @throwTypeError(\"Provided view is not an ArrayBufferView\");\n" \
|
||||
"\n" \
|
||||
" return @readableByteStreamControllerRespondWithNewView(@getByIdDirectPrivate(this, \"associatedReadableByteStreamController\"), view);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamBYOBRequestViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamBYOBRequestViewCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamBYOBRequestViewCodeLength = 204;
|
||||
static const JSC::Intrinsic s_readableStreamBYOBRequestViewCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamBYOBRequestViewCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamBYOBRequest(this))\n" \
|
||||
" throw @makeGetterTypeError(\"ReadableStreamBYOBRequest\", \"view\");\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(this, \"view\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().readableStreamBYOBRequestBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamBYOBRequestBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
151
src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.h
Normal file
151
src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ReadableStreamBYOBRequest */
|
||||
extern const char* const s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode;
|
||||
extern const int s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructorKind;
|
||||
extern const char* const s_readableStreamBYOBRequestRespondCode;
|
||||
extern const int s_readableStreamBYOBRequestRespondCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBRequestRespondCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBRequestRespondCodeConstructorKind;
|
||||
extern const char* const s_readableStreamBYOBRequestRespondWithNewViewCode;
|
||||
extern const int s_readableStreamBYOBRequestRespondWithNewViewCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBRequestRespondWithNewViewCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBRequestRespondWithNewViewCodeConstructorKind;
|
||||
extern const char* const s_readableStreamBYOBRequestViewCode;
|
||||
extern const int s_readableStreamBYOBRequestViewCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamBYOBRequestViewCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamBYOBRequestViewCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_DATA(macro) \
|
||||
macro(initializeReadableStreamBYOBRequest, readableStreamBYOBRequestInitializeReadableStreamBYOBRequest, 2) \
|
||||
macro(respond, readableStreamBYOBRequestRespond, 1) \
|
||||
macro(respondWithNewView, readableStreamBYOBRequestRespondWithNewView, 1) \
|
||||
macro(view, readableStreamBYOBRequestView, 0) \
|
||||
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_INITIALIZEREADABLESTREAMBYOBREQUEST 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_RESPOND 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_RESPONDWITHNEWVIEW 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_VIEW 1
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(macro) \
|
||||
macro(readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode, initializeReadableStreamBYOBRequest, ASCIILiteral(), s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength) \
|
||||
macro(readableStreamBYOBRequestRespondCode, respond, ASCIILiteral(), s_readableStreamBYOBRequestRespondCodeLength) \
|
||||
macro(readableStreamBYOBRequestRespondWithNewViewCode, respondWithNewView, ASCIILiteral(), s_readableStreamBYOBRequestRespondWithNewViewCodeLength) \
|
||||
macro(readableStreamBYOBRequestViewCode, view, "get view"_s, s_readableStreamBYOBRequestViewCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(initializeReadableStreamBYOBRequest) \
|
||||
macro(respond) \
|
||||
macro(respondWithNewView) \
|
||||
macro(view) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ReadableStreamBYOBRequestBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ReadableStreamBYOBRequestBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ReadableStreamBYOBRequestBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ReadableStreamBYOBRequestBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
425
src/javascript/jsc/bindings/ReadableStreamBuiltins.cpp
Normal file
425
src/javascript/jsc/bindings/ReadableStreamBuiltins.cpp
Normal file
@@ -0,0 +1,425 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "ReadableStreamBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamInitializeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamInitializeReadableStreamCodeLength = 2408;
|
||||
static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamInitializeReadableStreamCode =
|
||||
"(function (underlyingSource, strategy)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (underlyingSource === @undefined)\n" \
|
||||
" underlyingSource = { };\n" \
|
||||
" if (strategy === @undefined)\n" \
|
||||
" strategy = { };\n" \
|
||||
"\n" \
|
||||
" if (!@isObject(underlyingSource))\n" \
|
||||
" @throwTypeError(\"ReadableStream constructor takes an object as first argument\");\n" \
|
||||
"\n" \
|
||||
" if (strategy !== @undefined && !@isObject(strategy))\n" \
|
||||
" @throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(this, \"state\", @streamReadable);\n" \
|
||||
" \n" \
|
||||
" @putByIdDirectPrivate(this, \"reader\", @undefined);\n" \
|
||||
" \n" \
|
||||
" @putByIdDirectPrivate(this, \"storedError\", @undefined);\n" \
|
||||
" \n" \
|
||||
" @putByIdDirectPrivate(this, \"disturbed\", false);\n" \
|
||||
" \n" \
|
||||
" //\n" \
|
||||
" @putByIdDirectPrivate(this, \"readableStreamController\", null);\n" \
|
||||
" \n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" if (@getByIdDirectPrivate(underlyingSource, \"pull\") !== @undefined) {\n" \
|
||||
" \n" \
|
||||
" const size = @getByIdDirectPrivate(strategy, \"size\");\n" \
|
||||
" const highWaterMark = @getByIdDirectPrivate(strategy, \"highWaterMark\");\n" \
|
||||
" @setupReadableStreamDefaultController(this, underlyingSource, size, highWaterMark !== @undefined ? highWaterMark : 1, @getByIdDirectPrivate(underlyingSource, \"start\"), @getByIdDirectPrivate(underlyingSource, \"pull\"), @getByIdDirectPrivate(underlyingSource, \"cancel\"));\n" \
|
||||
" \n" \
|
||||
" return this;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" const type = underlyingSource.type;\n" \
|
||||
" const typeString = @toString(type);\n" \
|
||||
"\n" \
|
||||
" if (typeString === \"bytes\") {\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
"\n" \
|
||||
" if (strategy.highWaterMark === @undefined)\n" \
|
||||
" strategy.highWaterMark = 0;\n" \
|
||||
" if (strategy.size !== @undefined)\n" \
|
||||
" @throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");\n" \
|
||||
"\n" \
|
||||
" let readableByteStreamControllerConstructor = @ReadableByteStreamController;\n" \
|
||||
" \n" \
|
||||
" @putByIdDirectPrivate(this, \"readableStreamController\", new @ReadableByteStreamController(this, underlyingSource, strategy.highWaterMark, @isReadableStream));\n" \
|
||||
" } else if (type === @undefined) {\n" \
|
||||
" if (strategy.highWaterMark === @undefined)\n" \
|
||||
" strategy.highWaterMark = 1;\n" \
|
||||
" \n" \
|
||||
" @setupReadableStreamDefaultController(this, underlyingSource, strategy.size, strategy.highWaterMark, underlyingSource.start, underlyingSource.pull, underlyingSource.cancel);\n" \
|
||||
" } else\n" \
|
||||
" @throwRangeError(\"Invalid type for underlying source\");\n" \
|
||||
"\n" \
|
||||
" return this;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamCreateEmptyReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamCreateEmptyReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamCreateEmptyReadableStreamCodeLength = 178;
|
||||
static const JSC::Intrinsic s_readableStreamCreateEmptyReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamCreateEmptyReadableStreamCode =
|
||||
"(function () {\n" \
|
||||
" var stream = new @ReadableStream({\n" \
|
||||
" pull() {},\n" \
|
||||
" start() {},\n" \
|
||||
" cancel() {},\n" \
|
||||
" });\n" \
|
||||
" @readableStreamClose(stream);\n" \
|
||||
" return stream;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamCreateNativeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamCreateNativeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamCreateNativeReadableStreamCodeLength = 2956;
|
||||
static const JSC::Intrinsic s_readableStreamCreateNativeReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamCreateNativeReadableStreamCode =
|
||||
"(function (nativePtr, nativeType, autoAllocateChunkSize) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" var cached = globalThis[Symbol.for(\"Bun.nativeReadableStreamPrototype\")] ||= new @Map;\n" \
|
||||
" var Prototype = cached.@get(nativeType);\n" \
|
||||
" if (Prototype === @undefined) {\n" \
|
||||
" var [pull, start, cancel, setClose, deinit] = globalThis[Symbol.for(\"Bun.lazy\")](nativeType);\n" \
|
||||
" var closer = [false];\n" \
|
||||
"var handleResult;\n" \
|
||||
" function handleNativeReadableStreamPromiseResult(val) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" var {c, v} = this;\n" \
|
||||
" this.c = @undefined;\n" \
|
||||
" this.v = @undefined;\n" \
|
||||
" handleResult(val, c, v);\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" \n" \
|
||||
" handleResult = function handleResult(result, controller, view) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (result && @isPromise(result)) {\n" \
|
||||
" return result.then(handleNativeReadableStreamPromiseResult.bind({c: controller, v: view}), (err) => controller.error(err));\n" \
|
||||
" } else if (result !== false) {\n" \
|
||||
" if (view && view.byteLength === result) {\n" \
|
||||
" controller.byobRequest.respondWithNewView(view);\n" \
|
||||
" } else {\n" \
|
||||
" controller.byobRequest.respond(result);\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" if (closer[0] || result === false) {\n" \
|
||||
" @enqueueJob(() => controller.close());\n" \
|
||||
" closer[0] = false;\n" \
|
||||
" }\n" \
|
||||
" };\n" \
|
||||
"\n" \
|
||||
" Prototype = class NativeReadableStreamSource {\n" \
|
||||
" constructor(tag, autoAllocateChunkSize) {\n" \
|
||||
" this.pull = this.pull_.bind(tag);\n" \
|
||||
" this.cancel = this.cancel_.bind(tag);\n" \
|
||||
" this.autoAllocateChunkSize = autoAllocateChunkSize;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" pull;\n" \
|
||||
" cancel;\n" \
|
||||
"\n" \
|
||||
" type = \"bytes\";\n" \
|
||||
" autoAllocateChunkSize = 0;\n" \
|
||||
"\n" \
|
||||
" static startSync = start;\n" \
|
||||
" \n" \
|
||||
" pull_(controller) {\n" \
|
||||
" closer[0] = false;\n" \
|
||||
" var result;\n" \
|
||||
"\n" \
|
||||
" const view = controller.byobRequest.view;\n" \
|
||||
" try {\n" \
|
||||
" result = pull(this, view, closer);\n" \
|
||||
" } catch(err) {\n" \
|
||||
" return controller.error(err);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" return handleResult(result, controller, view);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" cancel_(reason) {\n" \
|
||||
" cancel(this, reason);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" static registry = new FinalizationRegistry(deinit);\n" \
|
||||
" }\n" \
|
||||
" cached.@set(nativeType, Prototype);\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" const chunkSize = Prototype.startSync(nativePtr, autoAllocateChunkSize);\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" if (chunkSize === 0) {\n" \
|
||||
" return @createEmptyReadableStream();\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" var instance = new Prototype(nativePtr, chunkSize);\n" \
|
||||
" Prototype.registry.register(instance, nativePtr);\n" \
|
||||
" var stream = new @ReadableStream(instance);\n" \
|
||||
" @putByIdDirectPrivate(stream, \"bunNativeType\", nativeType);\n" \
|
||||
" @putByIdDirectPrivate(stream, \"bunNativePtr\", nativePtr);\n" \
|
||||
" return stream;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamCancelCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamCancelCodeLength = 324;
|
||||
static const JSC::Intrinsic s_readableStreamCancelCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamCancelCode =
|
||||
"(function (reason)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"ReadableStream\", \"cancel\"));\n" \
|
||||
"\n" \
|
||||
" if (@isReadableStreamLocked(this))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"ReadableStream is locked\"));\n" \
|
||||
"\n" \
|
||||
" return @readableStreamCancel(this, reason);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamGetReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamGetReaderCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamGetReaderCodeLength = 481;
|
||||
static const JSC::Intrinsic s_readableStreamGetReaderCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamGetReaderCode =
|
||||
"(function (options)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStream\", \"getReader\");\n" \
|
||||
"\n" \
|
||||
" const mode = @toDictionary(options, { }, \"ReadableStream.getReader takes an object as first argument\").mode;\n" \
|
||||
" if (mode === @undefined)\n" \
|
||||
" return new @ReadableStreamDefaultReader(this);\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" if (mode == 'byob')\n" \
|
||||
" return new @ReadableStreamBYOBReader(this);\n" \
|
||||
"\n" \
|
||||
" \n" \
|
||||
" @throwTypeError(\"Invalid mode is specified\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamPipeThroughCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamPipeThroughCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamPipeThroughCodeLength = 1485;
|
||||
static const JSC::Intrinsic s_readableStreamPipeThroughCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamPipeThroughCode =
|
||||
"(function (streams, options)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const transforms = streams;\n" \
|
||||
"\n" \
|
||||
" const readable = transforms[\"readable\"];\n" \
|
||||
" if (!@isReadableStream(readable))\n" \
|
||||
" throw @makeTypeError(\"readable should be ReadableStream\");\n" \
|
||||
"\n" \
|
||||
" const writable = transforms[\"writable\"];\n" \
|
||||
" const internalWritable = @getInternalWritableStream(writable);\n" \
|
||||
" if (!@isWritableStream(internalWritable))\n" \
|
||||
" throw @makeTypeError(\"writable should be WritableStream\");\n" \
|
||||
"\n" \
|
||||
" let preventClose = false;\n" \
|
||||
" let preventAbort = false;\n" \
|
||||
" let preventCancel = false;\n" \
|
||||
" let signal;\n" \
|
||||
" if (!@isUndefinedOrNull(options)) {\n" \
|
||||
" if (!@isObject(options))\n" \
|
||||
" throw @makeTypeError(\"options must be an object\");\n" \
|
||||
"\n" \
|
||||
" preventAbort = !!options[\"preventAbort\"];\n" \
|
||||
" preventCancel = !!options[\"preventCancel\"];\n" \
|
||||
" preventClose = !!options[\"preventClose\"];\n" \
|
||||
"\n" \
|
||||
" signal = options[\"signal\"];\n" \
|
||||
" if (signal !== @undefined && !@isAbortSignal(signal))\n" \
|
||||
" throw @makeTypeError(\"options.signal must be AbortSignal\");\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStream\", \"pipeThrough\");\n" \
|
||||
"\n" \
|
||||
" if (@isReadableStreamLocked(this))\n" \
|
||||
" throw @makeTypeError(\"ReadableStream is locked\");\n" \
|
||||
"\n" \
|
||||
" if (@isWritableStreamLocked(internalWritable))\n" \
|
||||
" throw @makeTypeError(\"WritableStream is locked\");\n" \
|
||||
"\n" \
|
||||
" @readableStreamPipeToWritableStream(this, internalWritable, preventClose, preventAbort, preventCancel, signal);\n" \
|
||||
"\n" \
|
||||
" return readable;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamPipeToCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamPipeToCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamPipeToCodeLength = 1523;
|
||||
static const JSC::Intrinsic s_readableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamPipeToCode =
|
||||
"(function (destination)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" let options = arguments[1];\n" \
|
||||
"\n" \
|
||||
" let preventClose = false;\n" \
|
||||
" let preventAbort = false;\n" \
|
||||
" let preventCancel = false;\n" \
|
||||
" let signal;\n" \
|
||||
" if (!@isUndefinedOrNull(options)) {\n" \
|
||||
" if (!@isObject(options))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"options must be an object\"));\n" \
|
||||
"\n" \
|
||||
" try {\n" \
|
||||
" preventAbort = !!options[\"preventAbort\"];\n" \
|
||||
" preventCancel = !!options[\"preventCancel\"];\n" \
|
||||
" preventClose = !!options[\"preventClose\"];\n" \
|
||||
"\n" \
|
||||
" signal = options[\"signal\"];\n" \
|
||||
" } catch(e) {\n" \
|
||||
" return @Promise.@reject(e);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" if (signal !== @undefined && !@isAbortSignal(signal))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"options.signal must be AbortSignal\"));\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" const internalDestination = @getInternalWritableStream(destination);\n" \
|
||||
" if (!@isWritableStream(internalDestination))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"ReadableStream pipeTo requires a WritableStream\"));\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"ReadableStream\", \"pipeTo\"));\n" \
|
||||
"\n" \
|
||||
" if (@isReadableStreamLocked(this))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"ReadableStream is locked\"));\n" \
|
||||
"\n" \
|
||||
" if (@isWritableStreamLocked(internalDestination))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"WritableStream is locked\"));\n" \
|
||||
"\n" \
|
||||
" return @readableStreamPipeToWritableStream(this, internalDestination, preventClose, preventAbort, preventCancel, signal);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamTeeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamTeeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamTeeCodeLength = 175;
|
||||
static const JSC::Intrinsic s_readableStreamTeeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamTeeCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStream\", \"tee\");\n" \
|
||||
"\n" \
|
||||
" return @readableStreamTee(this, false);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamLockedCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamLockedCodeLength = 178;
|
||||
static const JSC::Intrinsic s_readableStreamLockedCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamLockedCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(this))\n" \
|
||||
" throw @makeGetterTypeError(\"ReadableStream\", \"locked\");\n" \
|
||||
"\n" \
|
||||
" return @isReadableStreamLocked(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().readableStreamBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
191
src/javascript/jsc/bindings/ReadableStreamBuiltins.h
Normal file
191
src/javascript/jsc/bindings/ReadableStreamBuiltins.h
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ReadableStream */
|
||||
extern const char* const s_readableStreamInitializeReadableStreamCode;
|
||||
extern const int s_readableStreamInitializeReadableStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInitializeReadableStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstructorKind;
|
||||
extern const char* const s_readableStreamCreateEmptyReadableStreamCode;
|
||||
extern const int s_readableStreamCreateEmptyReadableStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamCreateEmptyReadableStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamCreateEmptyReadableStreamCodeConstructorKind;
|
||||
extern const char* const s_readableStreamCreateNativeReadableStreamCode;
|
||||
extern const int s_readableStreamCreateNativeReadableStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamCreateNativeReadableStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamCreateNativeReadableStreamCodeConstructorKind;
|
||||
extern const char* const s_readableStreamCancelCode;
|
||||
extern const int s_readableStreamCancelCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamCancelCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamCancelCodeConstructorKind;
|
||||
extern const char* const s_readableStreamGetReaderCode;
|
||||
extern const int s_readableStreamGetReaderCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamGetReaderCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamGetReaderCodeConstructorKind;
|
||||
extern const char* const s_readableStreamPipeThroughCode;
|
||||
extern const int s_readableStreamPipeThroughCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamPipeThroughCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamPipeThroughCodeConstructorKind;
|
||||
extern const char* const s_readableStreamPipeToCode;
|
||||
extern const int s_readableStreamPipeToCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamPipeToCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamPipeToCodeConstructorKind;
|
||||
extern const char* const s_readableStreamTeeCode;
|
||||
extern const int s_readableStreamTeeCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamTeeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamTeeCodeConstructorKind;
|
||||
extern const char* const s_readableStreamLockedCode;
|
||||
extern const int s_readableStreamLockedCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamLockedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamLockedCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_DATA(macro) \
|
||||
macro(initializeReadableStream, readableStreamInitializeReadableStream, 2) \
|
||||
macro(createEmptyReadableStream, readableStreamCreateEmptyReadableStream, 0) \
|
||||
macro(createNativeReadableStream, readableStreamCreateNativeReadableStream, 3) \
|
||||
macro(cancel, readableStreamCancel, 1) \
|
||||
macro(getReader, readableStreamGetReader, 1) \
|
||||
macro(pipeThrough, readableStreamPipeThrough, 2) \
|
||||
macro(pipeTo, readableStreamPipeTo, 1) \
|
||||
macro(tee, readableStreamTee, 0) \
|
||||
macro(locked, readableStreamLocked, 0) \
|
||||
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_INITIALIZEREADABLESTREAM 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_CREATEEMPTYREADABLESTREAM 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_CREATENATIVEREADABLESTREAM 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_CANCEL 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_GETREADER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_PIPETHROUGH 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_PIPETO 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_TEE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAM_LOCKED 1
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(macro) \
|
||||
macro(readableStreamInitializeReadableStreamCode, initializeReadableStream, ASCIILiteral(), s_readableStreamInitializeReadableStreamCodeLength) \
|
||||
macro(readableStreamCreateEmptyReadableStreamCode, createEmptyReadableStream, ASCIILiteral(), s_readableStreamCreateEmptyReadableStreamCodeLength) \
|
||||
macro(readableStreamCreateNativeReadableStreamCode, createNativeReadableStream, ASCIILiteral(), s_readableStreamCreateNativeReadableStreamCodeLength) \
|
||||
macro(readableStreamCancelCode, cancel, ASCIILiteral(), s_readableStreamCancelCodeLength) \
|
||||
macro(readableStreamGetReaderCode, getReader, ASCIILiteral(), s_readableStreamGetReaderCodeLength) \
|
||||
macro(readableStreamPipeThroughCode, pipeThrough, ASCIILiteral(), s_readableStreamPipeThroughCodeLength) \
|
||||
macro(readableStreamPipeToCode, pipeTo, ASCIILiteral(), s_readableStreamPipeToCodeLength) \
|
||||
macro(readableStreamTeeCode, tee, ASCIILiteral(), s_readableStreamTeeCodeLength) \
|
||||
macro(readableStreamLockedCode, locked, "get locked"_s, s_readableStreamLockedCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(cancel) \
|
||||
macro(createEmptyReadableStream) \
|
||||
macro(createNativeReadableStream) \
|
||||
macro(getReader) \
|
||||
macro(initializeReadableStream) \
|
||||
macro(locked) \
|
||||
macro(pipeThrough) \
|
||||
macro(pipeTo) \
|
||||
macro(tee) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ReadableStreamBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ReadableStreamBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ReadableStreamBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ReadableStreamBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "ReadableStreamDefaultControllerBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeLength = 376;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCode =
|
||||
"(function (stream, underlyingSource, size, highWaterMark)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (arguments.length !== 5 && arguments[4] !== @isReadableStream)\n" \
|
||||
" @throwTypeError(\"ReadableStreamDefaultController constructor should not be called directly\");\n" \
|
||||
"\n" \
|
||||
" return @privateInitializeReadableStreamDefaultController.@call(this, stream, underlyingSource, size, highWaterMark);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultControllerEnqueueCodeLength = 412;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultControllerEnqueueCode =
|
||||
"(function (chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultController(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStreamDefaultController\", \"enqueue\");\n" \
|
||||
"\n" \
|
||||
" if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))\n" \
|
||||
" @throwTypeError(\"ReadableStreamDefaultController is not in a state where chunk can be enqueued\");\n" \
|
||||
"\n" \
|
||||
" return @readableStreamDefaultControllerEnqueue(this, chunk);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultControllerErrorCodeLength = 228;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultControllerErrorCode =
|
||||
"(function (error)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultController(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStreamDefaultController\", \"error\");\n" \
|
||||
"\n" \
|
||||
" @readableStreamDefaultControllerError(this, error);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultControllerCloseCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultControllerCloseCodeLength = 384;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultControllerCloseCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultController(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStreamDefaultController\", \"close\");\n" \
|
||||
"\n" \
|
||||
" if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))\n" \
|
||||
" @throwTypeError(\"ReadableStreamDefaultController is not in a state where it can be closed\");\n" \
|
||||
"\n" \
|
||||
" @readableStreamDefaultControllerClose(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultControllerDesiredSizeCodeLength = 240;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultControllerDesiredSizeCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultController(this))\n" \
|
||||
" throw @makeGetterTypeError(\"ReadableStreamDefaultController\", \"desiredSize\");\n" \
|
||||
"\n" \
|
||||
" return @readableStreamDefaultControllerGetDesiredSize(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().readableStreamDefaultControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamDefaultControllerBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ReadableStreamDefaultController */
|
||||
extern const char* const s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCode;
|
||||
extern const int s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultControllerEnqueueCode;
|
||||
extern const int s_readableStreamDefaultControllerEnqueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultControllerEnqueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultControllerEnqueueCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultControllerErrorCode;
|
||||
extern const int s_readableStreamDefaultControllerErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultControllerErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultControllerErrorCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultControllerCloseCode;
|
||||
extern const int s_readableStreamDefaultControllerCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultControllerCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultControllerCloseCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultControllerDesiredSizeCode;
|
||||
extern const int s_readableStreamDefaultControllerDesiredSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultControllerDesiredSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultControllerDesiredSizeCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_DATA(macro) \
|
||||
macro(initializeReadableStreamDefaultController, readableStreamDefaultControllerInitializeReadableStreamDefaultController, 4) \
|
||||
macro(enqueue, readableStreamDefaultControllerEnqueue, 1) \
|
||||
macro(error, readableStreamDefaultControllerError, 1) \
|
||||
macro(close, readableStreamDefaultControllerClose, 0) \
|
||||
macro(desiredSize, readableStreamDefaultControllerDesiredSize, 0) \
|
||||
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_INITIALIZEREADABLESTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_ENQUEUE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_ERROR 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_CLOSE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_DESIREDSIZE 1
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(macro) \
|
||||
macro(readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCode, initializeReadableStreamDefaultController, ASCIILiteral(), s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeLength) \
|
||||
macro(readableStreamDefaultControllerEnqueueCode, enqueue, ASCIILiteral(), s_readableStreamDefaultControllerEnqueueCodeLength) \
|
||||
macro(readableStreamDefaultControllerErrorCode, error, ASCIILiteral(), s_readableStreamDefaultControllerErrorCodeLength) \
|
||||
macro(readableStreamDefaultControllerCloseCode, close, ASCIILiteral(), s_readableStreamDefaultControllerCloseCodeLength) \
|
||||
macro(readableStreamDefaultControllerDesiredSizeCode, desiredSize, "get desiredSize"_s, s_readableStreamDefaultControllerDesiredSizeCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(close) \
|
||||
macro(desiredSize) \
|
||||
macro(enqueue) \
|
||||
macro(error) \
|
||||
macro(initializeReadableStreamDefaultController) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ReadableStreamDefaultControllerBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ReadableStreamDefaultControllerBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ReadableStreamDefaultControllerBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ReadableStreamDefaultControllerBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "ReadableStreamDefaultReaderBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeLength = 393;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStream(stream))\n" \
|
||||
" @throwTypeError(\"ReadableStreamDefaultReader needs a ReadableStream\");\n" \
|
||||
" if (@isReadableStreamLocked(stream))\n" \
|
||||
" @throwTypeError(\"ReadableStream is locked\");\n" \
|
||||
"\n" \
|
||||
" @readableStreamReaderGenericInitialize(this, stream);\n" \
|
||||
" @putByIdDirectPrivate(this, \"readRequests\", @createFIFO());\n" \
|
||||
"\n" \
|
||||
" return this;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultReaderCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultReaderCancelCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultReaderCancelCodeLength = 416;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultReaderCancelCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultReaderCancelCode =
|
||||
"(function (reason)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultReader(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"ReadableStreamDefaultReader\", \"cancel\"));\n" \
|
||||
"\n" \
|
||||
" if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"cancel() called on a reader owned by no readable stream\"));\n" \
|
||||
"\n" \
|
||||
" return @readableStreamReaderGenericCancel(this, reason);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultReaderReadManyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultReaderReadManyCodeLength = 2136;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultReaderReadManyCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultReaderReadManyCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultReader(this))\n" \
|
||||
" @throwTypeError(\"ReadableStreamDefaultReader.readMany() should not be called directly\");\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(this, \"ownerReadableStream\");\n" \
|
||||
" if (!stream)\n" \
|
||||
" @throwTypeError(\"readMany() called on a reader owned by no readable stream\");\n" \
|
||||
"\n" \
|
||||
" const state = @getByIdDirectPrivate(stream, \"state\");\n" \
|
||||
" @putByIdDirectPrivate(stream, \"disturbed\", true);\n" \
|
||||
" if (state === @streamClosed)\n" \
|
||||
" return {value: [], size: 0, done: true};\n" \
|
||||
" else if (state === @streamErrored) {\n" \
|
||||
" throw @getByIdDirectPrivate(stream, \"storedError\");\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" var controller = @getByIdDirectPrivate(stream, \"readableStreamController\");\n" \
|
||||
" \n" \
|
||||
" const content = @getByIdDirectPrivate(controller, \"queue\").content;\n" \
|
||||
" var size = @getByIdDirectPrivate(controller, \"queue\").size;\n" \
|
||||
" var values = content.toArray(false);\n" \
|
||||
" var length = values.length;\n" \
|
||||
"\n" \
|
||||
" if (length > 0) {\n" \
|
||||
" @resetQueue(@getByIdDirectPrivate(controller, \"queue\"));\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"closeRequested\"))\n" \
|
||||
" @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
|
||||
" else\n" \
|
||||
" @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
|
||||
" } else {\n" \
|
||||
" return controller.@pull(controller).@then(({value, done}) => {\n" \
|
||||
" if (done) {\n" \
|
||||
" return {value: [], size: 0, done: true};\n" \
|
||||
" }\n" \
|
||||
" var queue = @getByIdDirectPrivate(controller, \"queue\");\n" \
|
||||
" const content = [value].concat(queue.content.toArray(false));\n" \
|
||||
" var size = queue.size;\n" \
|
||||
" @resetQueue(queue);\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(controller, \"closeRequested\"))\n" \
|
||||
" @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
|
||||
" else\n" \
|
||||
" @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
|
||||
" controller = @undefined;\n" \
|
||||
"\n" \
|
||||
" return {value: values, size: size, done: false};\n" \
|
||||
" });\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" controller = @undefined;\n" \
|
||||
"\n" \
|
||||
" return {value: values, size, done: false};\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultReaderReadCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultReaderReadCodeLength = 395;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultReaderReadCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultReader(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"ReadableStreamDefaultReader\", \"read\"));\n" \
|
||||
" if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"read() called on a reader owned by no readable stream\"));\n" \
|
||||
"\n" \
|
||||
" return @readableStreamDefaultReaderRead(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultReaderReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultReaderReleaseLockCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultReaderReleaseLockCodeLength = 449;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultReaderReleaseLockCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultReaderReleaseLockCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultReader(this))\n" \
|
||||
" throw @makeThisTypeError(\"ReadableStreamDefaultReader\", \"releaseLock\");\n" \
|
||||
"\n" \
|
||||
" if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
|
||||
" return;\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"readRequests\")?.isNotEmpty())\n" \
|
||||
" @throwTypeError(\"There are still pending read requests, cannot release the lock\");\n" \
|
||||
"\n" \
|
||||
" @readableStreamReaderGenericRelease(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_readableStreamDefaultReaderClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_readableStreamDefaultReaderClosedCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_readableStreamDefaultReaderClosedCodeLength = 257;
|
||||
static const JSC::Intrinsic s_readableStreamDefaultReaderClosedCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_readableStreamDefaultReaderClosedCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isReadableStreamDefaultReader(this))\n" \
|
||||
" return @Promise.@reject(@makeGetterTypeError(\"ReadableStreamDefaultReader\", \"closed\"));\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(this, \"closedPromiseCapability\").@promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().readableStreamDefaultReaderBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamDefaultReaderBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ReadableStreamDefaultReader */
|
||||
extern const char* const s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCode;
|
||||
extern const int s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultReaderCancelCode;
|
||||
extern const int s_readableStreamDefaultReaderCancelCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultReaderCancelCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultReaderCancelCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultReaderReadManyCode;
|
||||
extern const int s_readableStreamDefaultReaderReadManyCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultReaderReadManyCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultReaderReadCode;
|
||||
extern const int s_readableStreamDefaultReaderReadCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultReaderReadCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultReaderReadCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultReaderReleaseLockCode;
|
||||
extern const int s_readableStreamDefaultReaderReleaseLockCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultReaderReleaseLockCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultReaderReleaseLockCodeConstructorKind;
|
||||
extern const char* const s_readableStreamDefaultReaderClosedCode;
|
||||
extern const int s_readableStreamDefaultReaderClosedCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamDefaultReaderClosedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamDefaultReaderClosedCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_DATA(macro) \
|
||||
macro(initializeReadableStreamDefaultReader, readableStreamDefaultReaderInitializeReadableStreamDefaultReader, 1) \
|
||||
macro(cancel, readableStreamDefaultReaderCancel, 1) \
|
||||
macro(readMany, readableStreamDefaultReaderReadMany, 0) \
|
||||
macro(read, readableStreamDefaultReaderRead, 0) \
|
||||
macro(releaseLock, readableStreamDefaultReaderReleaseLock, 0) \
|
||||
macro(closed, readableStreamDefaultReaderClosed, 0) \
|
||||
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_INITIALIZEREADABLESTREAMDEFAULTREADER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_CANCEL 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_READMANY 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_READ 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_RELEASELOCK 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_CLOSED 1
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(macro) \
|
||||
macro(readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCode, initializeReadableStreamDefaultReader, ASCIILiteral(), s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeLength) \
|
||||
macro(readableStreamDefaultReaderCancelCode, cancel, ASCIILiteral(), s_readableStreamDefaultReaderCancelCodeLength) \
|
||||
macro(readableStreamDefaultReaderReadManyCode, readMany, ASCIILiteral(), s_readableStreamDefaultReaderReadManyCodeLength) \
|
||||
macro(readableStreamDefaultReaderReadCode, read, ASCIILiteral(), s_readableStreamDefaultReaderReadCodeLength) \
|
||||
macro(readableStreamDefaultReaderReleaseLockCode, releaseLock, ASCIILiteral(), s_readableStreamDefaultReaderReleaseLockCodeLength) \
|
||||
macro(readableStreamDefaultReaderClosedCode, closed, "get closed"_s, s_readableStreamDefaultReaderClosedCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(cancel) \
|
||||
macro(closed) \
|
||||
macro(initializeReadableStreamDefaultReader) \
|
||||
macro(read) \
|
||||
macro(readMany) \
|
||||
macro(releaseLock) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ReadableStreamDefaultReaderBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ReadableStreamDefaultReaderBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ReadableStreamDefaultReaderBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ReadableStreamDefaultReaderBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
1092
src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.cpp
Normal file
1092
src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.cpp
Normal file
File diff suppressed because it is too large
Load Diff
484
src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.h
Normal file
484
src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.h
Normal file
@@ -0,0 +1,484 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* ReadableStreamInternals */
|
||||
extern const char* const s_readableStreamInternalsReadableStreamReaderGenericInitializeCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode;
|
||||
extern const int s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode;
|
||||
extern const int s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerErrorCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamPipeToCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamPipeToCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsAcquireReadableStreamDefaultReaderCode;
|
||||
extern const int s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToLoopCode;
|
||||
extern const int s_readableStreamInternalsPipeToLoopCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToLoopCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToDoReadWriteCode;
|
||||
extern const int s_readableStreamInternalsPipeToDoReadWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToDoReadWriteCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode;
|
||||
extern const int s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode;
|
||||
extern const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCode;
|
||||
extern const int s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode;
|
||||
extern const int s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToShutdownWithActionCode;
|
||||
extern const int s_readableStreamInternalsPipeToShutdownWithActionCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownWithActionCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownWithActionCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToShutdownCode;
|
||||
extern const int s_readableStreamInternalsPipeToShutdownCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsPipeToFinalizeCode;
|
||||
extern const int s_readableStreamInternalsPipeToFinalizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsPipeToFinalizeCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamTeeCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamTeeCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsIsReadableStreamCode;
|
||||
extern const int s_readableStreamInternalsIsReadableStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsIsReadableStreamDefaultReaderCode;
|
||||
extern const int s_readableStreamInternalsIsReadableStreamDefaultReaderCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsIsReadableStreamDefaultControllerCode;
|
||||
extern const int s_readableStreamInternalsIsReadableStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamErrorCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsIsReadableStreamLockedCode;
|
||||
extern const int s_readableStreamInternalsIsReadableStreamLockedCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamLockedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamLockedCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamCancelCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamCancelCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCloseCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamCloseCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamAddReadRequestCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamAddReadRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsIsReadableStreamDisturbedCode;
|
||||
extern const int s_readableStreamInternalsIsReadableStreamDisturbedCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamReaderGenericReleaseCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeConstructorKind;
|
||||
extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode;
|
||||
extern const int s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_DATA(macro) \
|
||||
macro(readableStreamReaderGenericInitialize, readableStreamInternalsReadableStreamReaderGenericInitialize, 2) \
|
||||
macro(privateInitializeReadableStreamDefaultController, readableStreamInternalsPrivateInitializeReadableStreamDefaultController, 4) \
|
||||
macro(setupReadableStreamDefaultController, readableStreamInternalsSetupReadableStreamDefaultController, 7) \
|
||||
macro(readableStreamDefaultControllerError, readableStreamInternalsReadableStreamDefaultControllerError, 2) \
|
||||
macro(readableStreamPipeTo, readableStreamInternalsReadableStreamPipeTo, 2) \
|
||||
macro(acquireReadableStreamDefaultReader, readableStreamInternalsAcquireReadableStreamDefaultReader, 1) \
|
||||
macro(readableStreamPipeToWritableStream, readableStreamInternalsReadableStreamPipeToWritableStream, 6) \
|
||||
macro(pipeToLoop, readableStreamInternalsPipeToLoop, 1) \
|
||||
macro(pipeToDoReadWrite, readableStreamInternalsPipeToDoReadWrite, 1) \
|
||||
macro(pipeToErrorsMustBePropagatedForward, readableStreamInternalsPipeToErrorsMustBePropagatedForward, 1) \
|
||||
macro(pipeToErrorsMustBePropagatedBackward, readableStreamInternalsPipeToErrorsMustBePropagatedBackward, 1) \
|
||||
macro(pipeToClosingMustBePropagatedForward, readableStreamInternalsPipeToClosingMustBePropagatedForward, 1) \
|
||||
macro(pipeToClosingMustBePropagatedBackward, readableStreamInternalsPipeToClosingMustBePropagatedBackward, 1) \
|
||||
macro(pipeToShutdownWithAction, readableStreamInternalsPipeToShutdownWithAction, 2) \
|
||||
macro(pipeToShutdown, readableStreamInternalsPipeToShutdown, 1) \
|
||||
macro(pipeToFinalize, readableStreamInternalsPipeToFinalize, 1) \
|
||||
macro(readableStreamTee, readableStreamInternalsReadableStreamTee, 2) \
|
||||
macro(readableStreamTeePullFunction, readableStreamInternalsReadableStreamTeePullFunction, 3) \
|
||||
macro(readableStreamTeeBranch1CancelFunction, readableStreamInternalsReadableStreamTeeBranch1CancelFunction, 2) \
|
||||
macro(readableStreamTeeBranch2CancelFunction, readableStreamInternalsReadableStreamTeeBranch2CancelFunction, 2) \
|
||||
macro(isReadableStream, readableStreamInternalsIsReadableStream, 1) \
|
||||
macro(isReadableStreamDefaultReader, readableStreamInternalsIsReadableStreamDefaultReader, 1) \
|
||||
macro(isReadableStreamDefaultController, readableStreamInternalsIsReadableStreamDefaultController, 1) \
|
||||
macro(readableStreamError, readableStreamInternalsReadableStreamError, 2) \
|
||||
macro(readableStreamDefaultControllerShouldCallPull, readableStreamInternalsReadableStreamDefaultControllerShouldCallPull, 1) \
|
||||
macro(readableStreamDefaultControllerCallPullIfNeeded, readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeeded, 1) \
|
||||
macro(isReadableStreamLocked, readableStreamInternalsIsReadableStreamLocked, 1) \
|
||||
macro(readableStreamDefaultControllerGetDesiredSize, readableStreamInternalsReadableStreamDefaultControllerGetDesiredSize, 1) \
|
||||
macro(readableStreamReaderGenericCancel, readableStreamInternalsReadableStreamReaderGenericCancel, 2) \
|
||||
macro(readableStreamCancel, readableStreamInternalsReadableStreamCancel, 2) \
|
||||
macro(readableStreamDefaultControllerCancel, readableStreamInternalsReadableStreamDefaultControllerCancel, 2) \
|
||||
macro(readableStreamDefaultControllerPull, readableStreamInternalsReadableStreamDefaultControllerPull, 1) \
|
||||
macro(readableStreamDefaultControllerClose, readableStreamInternalsReadableStreamDefaultControllerClose, 1) \
|
||||
macro(readableStreamClose, readableStreamInternalsReadableStreamClose, 1) \
|
||||
macro(readableStreamFulfillReadRequest, readableStreamInternalsReadableStreamFulfillReadRequest, 3) \
|
||||
macro(readableStreamDefaultControllerEnqueue, readableStreamInternalsReadableStreamDefaultControllerEnqueue, 2) \
|
||||
macro(readableStreamDefaultReaderRead, readableStreamInternalsReadableStreamDefaultReaderRead, 1) \
|
||||
macro(readableStreamAddReadRequest, readableStreamInternalsReadableStreamAddReadRequest, 1) \
|
||||
macro(isReadableStreamDisturbed, readableStreamInternalsIsReadableStreamDisturbed, 1) \
|
||||
macro(readableStreamReaderGenericRelease, readableStreamInternalsReadableStreamReaderGenericRelease, 1) \
|
||||
macro(readableStreamDefaultControllerCanCloseOrEnqueue, readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueue, 1) \
|
||||
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICINITIALIZE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PRIVATEINITIALIZEREADABLESTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_SETUPREADABLESTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERERROR 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMPIPETO 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ACQUIREREADABLESTREAMDEFAULTREADER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMPIPETOWRITABLESTREAM 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOLOOP 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETODOREADWRITE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOERRORSMUSTBEPROPAGATEDFORWARD 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOERRORSMUSTBEPROPAGATEDBACKWARD 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOCLOSINGMUSTBEPROPAGATEDFORWARD 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOCLOSINGMUSTBEPROPAGATEDBACKWARD 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOSHUTDOWNWITHACTION 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOSHUTDOWN 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOFINALIZE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEPULLFUNCTION 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEBRANCH1CANCELFUNCTION 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEBRANCH2CANCELFUNCTION 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAM 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDEFAULTREADER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMERROR 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERSHOULDCALLPULL 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCALLPULLIFNEEDED 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMLOCKED 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERGETDESIREDSIZE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICCANCEL 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMCANCEL 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCANCEL 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERPULL 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCLOSE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMCLOSE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMFULFILLREADREQUEST 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERENQUEUE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTREADERREAD 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMADDREADREQUEST 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDISTURBED 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICRELEASE 1
|
||||
#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCANCLOSEORENQUEUE 1
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(macro) \
|
||||
macro(readableStreamInternalsReadableStreamReaderGenericInitializeCode, readableStreamReaderGenericInitialize, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength) \
|
||||
macro(readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode, privateInitializeReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength) \
|
||||
macro(readableStreamInternalsSetupReadableStreamDefaultControllerCode, setupReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerErrorCode, readableStreamDefaultControllerError, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamPipeToCode, readableStreamPipeTo, ASCIILiteral(), s_readableStreamInternalsReadableStreamPipeToCodeLength) \
|
||||
macro(readableStreamInternalsAcquireReadableStreamDefaultReaderCode, acquireReadableStreamDefaultReader, ASCIILiteral(), s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamPipeToWritableStreamCode, readableStreamPipeToWritableStream, ASCIILiteral(), s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength) \
|
||||
macro(readableStreamInternalsPipeToLoopCode, pipeToLoop, ASCIILiteral(), s_readableStreamInternalsPipeToLoopCodeLength) \
|
||||
macro(readableStreamInternalsPipeToDoReadWriteCode, pipeToDoReadWrite, ASCIILiteral(), s_readableStreamInternalsPipeToDoReadWriteCodeLength) \
|
||||
macro(readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode, pipeToErrorsMustBePropagatedForward, ASCIILiteral(), s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength) \
|
||||
macro(readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode, pipeToErrorsMustBePropagatedBackward, ASCIILiteral(), s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength) \
|
||||
macro(readableStreamInternalsPipeToClosingMustBePropagatedForwardCode, pipeToClosingMustBePropagatedForward, ASCIILiteral(), s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeLength) \
|
||||
macro(readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode, pipeToClosingMustBePropagatedBackward, ASCIILiteral(), s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength) \
|
||||
macro(readableStreamInternalsPipeToShutdownWithActionCode, pipeToShutdownWithAction, ASCIILiteral(), s_readableStreamInternalsPipeToShutdownWithActionCodeLength) \
|
||||
macro(readableStreamInternalsPipeToShutdownCode, pipeToShutdown, ASCIILiteral(), s_readableStreamInternalsPipeToShutdownCodeLength) \
|
||||
macro(readableStreamInternalsPipeToFinalizeCode, pipeToFinalize, ASCIILiteral(), s_readableStreamInternalsPipeToFinalizeCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamTeeCode, readableStreamTee, ASCIILiteral(), s_readableStreamInternalsReadableStreamTeeCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamTeePullFunctionCode, readableStreamTeePullFunction, ASCIILiteral(), s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode, readableStreamTeeBranch1CancelFunction, ASCIILiteral(), s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode, readableStreamTeeBranch2CancelFunction, ASCIILiteral(), s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength) \
|
||||
macro(readableStreamInternalsIsReadableStreamCode, isReadableStream, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamCodeLength) \
|
||||
macro(readableStreamInternalsIsReadableStreamDefaultReaderCode, isReadableStreamDefaultReader, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamDefaultReaderCodeLength) \
|
||||
macro(readableStreamInternalsIsReadableStreamDefaultControllerCode, isReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamDefaultControllerCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamErrorCode, readableStreamError, ASCIILiteral(), s_readableStreamInternalsReadableStreamErrorCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode, readableStreamDefaultControllerShouldCallPull, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCode, readableStreamDefaultControllerCallPullIfNeeded, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeLength) \
|
||||
macro(readableStreamInternalsIsReadableStreamLockedCode, isReadableStreamLocked, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamLockedCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode, readableStreamDefaultControllerGetDesiredSize, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamReaderGenericCancelCode, readableStreamReaderGenericCancel, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamCancelCode, readableStreamCancel, ASCIILiteral(), s_readableStreamInternalsReadableStreamCancelCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerCancelCode, readableStreamDefaultControllerCancel, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerPullCode, readableStreamDefaultControllerPull, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerCloseCode, readableStreamDefaultControllerClose, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamCloseCode, readableStreamClose, ASCIILiteral(), s_readableStreamInternalsReadableStreamCloseCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamFulfillReadRequestCode, readableStreamFulfillReadRequest, ASCIILiteral(), s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerEnqueueCode, readableStreamDefaultControllerEnqueue, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultReaderReadCode, readableStreamDefaultReaderRead, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamAddReadRequestCode, readableStreamAddReadRequest, ASCIILiteral(), s_readableStreamInternalsReadableStreamAddReadRequestCodeLength) \
|
||||
macro(readableStreamInternalsIsReadableStreamDisturbedCode, isReadableStreamDisturbed, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamDisturbedCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamReaderGenericReleaseCode, readableStreamReaderGenericRelease, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeLength) \
|
||||
macro(readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode, readableStreamDefaultControllerCanCloseOrEnqueue, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(acquireReadableStreamDefaultReader) \
|
||||
macro(isReadableStream) \
|
||||
macro(isReadableStreamDefaultController) \
|
||||
macro(isReadableStreamDefaultReader) \
|
||||
macro(isReadableStreamDisturbed) \
|
||||
macro(isReadableStreamLocked) \
|
||||
macro(pipeToClosingMustBePropagatedBackward) \
|
||||
macro(pipeToClosingMustBePropagatedForward) \
|
||||
macro(pipeToDoReadWrite) \
|
||||
macro(pipeToErrorsMustBePropagatedBackward) \
|
||||
macro(pipeToErrorsMustBePropagatedForward) \
|
||||
macro(pipeToFinalize) \
|
||||
macro(pipeToLoop) \
|
||||
macro(pipeToShutdown) \
|
||||
macro(pipeToShutdownWithAction) \
|
||||
macro(privateInitializeReadableStreamDefaultController) \
|
||||
macro(readableStreamAddReadRequest) \
|
||||
macro(readableStreamCancel) \
|
||||
macro(readableStreamClose) \
|
||||
macro(readableStreamDefaultControllerCallPullIfNeeded) \
|
||||
macro(readableStreamDefaultControllerCanCloseOrEnqueue) \
|
||||
macro(readableStreamDefaultControllerCancel) \
|
||||
macro(readableStreamDefaultControllerClose) \
|
||||
macro(readableStreamDefaultControllerEnqueue) \
|
||||
macro(readableStreamDefaultControllerError) \
|
||||
macro(readableStreamDefaultControllerGetDesiredSize) \
|
||||
macro(readableStreamDefaultControllerPull) \
|
||||
macro(readableStreamDefaultControllerShouldCallPull) \
|
||||
macro(readableStreamDefaultReaderRead) \
|
||||
macro(readableStreamError) \
|
||||
macro(readableStreamFulfillReadRequest) \
|
||||
macro(readableStreamPipeTo) \
|
||||
macro(readableStreamPipeToWritableStream) \
|
||||
macro(readableStreamReaderGenericCancel) \
|
||||
macro(readableStreamReaderGenericInitialize) \
|
||||
macro(readableStreamReaderGenericRelease) \
|
||||
macro(readableStreamTee) \
|
||||
macro(readableStreamTeeBranch1CancelFunction) \
|
||||
macro(readableStreamTeeBranch2CancelFunction) \
|
||||
macro(readableStreamTeePullFunction) \
|
||||
macro(setupReadableStreamDefaultController) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class ReadableStreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit ReadableStreamInternalsBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* ReadableStreamInternalsBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void ReadableStreamInternalsBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
class ReadableStreamInternalsBuiltinFunctions {
|
||||
public:
|
||||
explicit ReadableStreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
|
||||
|
||||
void init(JSC::JSGlobalObject&);
|
||||
template<typename Visitor> void visit(Visitor&);
|
||||
|
||||
public:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
|
||||
JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
};
|
||||
|
||||
inline void ReadableStreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
|
||||
{
|
||||
#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
|
||||
m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
|
||||
#undef EXPORT_FUNCTION
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
inline void ReadableStreamInternalsBuiltinFunctions::visit(Visitor& visitor)
|
||||
{
|
||||
#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
|
||||
#undef VISIT_FUNCTION
|
||||
}
|
||||
|
||||
template void ReadableStreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
|
||||
template void ReadableStreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
|
||||
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
0
src/javascript/jsc/bindings/StreamGlobals.h
Normal file
0
src/javascript/jsc/bindings/StreamGlobals.h
Normal file
464
src/javascript/jsc/bindings/StreamInternalsBuiltins.cpp
Normal file
464
src/javascript/jsc/bindings/StreamInternalsBuiltins.cpp
Normal file
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "StreamInternalsBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsMarkPromiseAsHandledCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsMarkPromiseAsHandledCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsMarkPromiseAsHandledCodeLength = 217;
|
||||
static const JSC::Intrinsic s_streamInternalsMarkPromiseAsHandledCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsMarkPromiseAsHandledCode =
|
||||
"(function (promise)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@isPromise(promise));\n" \
|
||||
" @putPromiseInternalField(promise, @promiseFieldFlags, @getPromiseInternalField(promise, @promiseFieldFlags) | @promiseFlagsIsHandled);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsShieldingPromiseResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsShieldingPromiseResolveCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsShieldingPromiseResolveCodeLength = 198;
|
||||
static const JSC::Intrinsic s_streamInternalsShieldingPromiseResolveCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsShieldingPromiseResolveCode =
|
||||
"(function (result)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const promise = @Promise.@resolve(result);\n" \
|
||||
" if (promise.@then === @undefined)\n" \
|
||||
" promise.@then = @Promise.prototype.@then;\n" \
|
||||
" return promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeLength = 190;
|
||||
static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCode =
|
||||
"(function (object, method, args)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (method === @undefined)\n" \
|
||||
" return @Promise.@resolve();\n" \
|
||||
" return @shieldingPromiseResolve(method.@apply(object, args));\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength = 127;
|
||||
static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopNoCatchCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsPromiseInvokeOrNoopNoCatchCode =
|
||||
"(function (object, key, args)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" return @promiseInvokeOrNoopMethodNoCatch(object, object[key], args);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsPromiseInvokeOrNoopMethodCodeLength = 210;
|
||||
static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopMethodCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsPromiseInvokeOrNoopMethodCode =
|
||||
"(function (object, method, args)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" try {\n" \
|
||||
" return @promiseInvokeOrNoopMethodNoCatch(object, method, args);\n" \
|
||||
" }\n" \
|
||||
" catch(error) {\n" \
|
||||
" return @Promise.@reject(error);\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsPromiseInvokeOrNoopCodeLength = 198;
|
||||
static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsPromiseInvokeOrNoopCode =
|
||||
"(function (object, key, args)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" try {\n" \
|
||||
" return @promiseInvokeOrNoopNoCatch(object, key, args);\n" \
|
||||
" }\n" \
|
||||
" catch(error) {\n" \
|
||||
" return @Promise.@reject(error);\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength = 362;
|
||||
static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsPromiseInvokeOrFallbackOrNoopCode =
|
||||
"(function (object, key1, args1, key2, args2)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" try {\n" \
|
||||
" const method = object[key1];\n" \
|
||||
" if (method === @undefined)\n" \
|
||||
" return @promiseInvokeOrNoopNoCatch(object, key2, args2);\n" \
|
||||
" return @shieldingPromiseResolve(method.@apply(object, args1));\n" \
|
||||
" }\n" \
|
||||
" catch(error) {\n" \
|
||||
" return @Promise.@reject(error);\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength = 430;
|
||||
static const JSC::Intrinsic s_streamInternalsValidateAndNormalizeQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsValidateAndNormalizeQueuingStrategyCode =
|
||||
"(function (size, highWaterMark)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (size !== @undefined && typeof size !== \"function\")\n" \
|
||||
" @throwTypeError(\"size parameter must be a function\");\n" \
|
||||
"\n" \
|
||||
" const newHighWaterMark = @toNumber(highWaterMark);\n" \
|
||||
"\n" \
|
||||
" if (@isNaN(newHighWaterMark) || newHighWaterMark < 0)\n" \
|
||||
" @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \
|
||||
"\n" \
|
||||
" return { size: size, highWaterMark: newHighWaterMark };\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsCreateFIFOCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsCreateFIFOCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsCreateFIFOCodeLength = 2764;
|
||||
static const JSC::Intrinsic s_streamInternalsCreateFIFOCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsCreateFIFOCode =
|
||||
"(function () {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" class Denqueue {\n" \
|
||||
" constructor() {\n" \
|
||||
" this._head = 0;\n" \
|
||||
" this._tail = 0;\n" \
|
||||
" //\n" \
|
||||
" this._capacityMask = 0x3;\n" \
|
||||
" this._list = @newArrayWithSize(4);\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" size() {\n" \
|
||||
" if (this._head === this._tail) return 0;\n" \
|
||||
" if (this._head < this._tail) return this._tail - this._head;\n" \
|
||||
" else return this._capacityMask + 1 - (this._head - this._tail);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" isEmpty() {\n" \
|
||||
" return this.size() == 0;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" isNotEmpty() {\n" \
|
||||
" return this.size() > 0;\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" shift() {\n" \
|
||||
" var head = this._head;\n" \
|
||||
" if (head === this._tail) return @undefined;\n" \
|
||||
" var item = this._list[head];\n" \
|
||||
" @putByValDirect(this._list, head, @undefined);\n" \
|
||||
" this._head = (head + 1) & this._capacityMask;\n" \
|
||||
" if (head < 2 && this._tail > 10000 && this._tail <= this._list.length >>> 2) this._shrinkArray();\n" \
|
||||
" return item;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" peek() {\n" \
|
||||
" if (this._head === this._tail) return @undefined;\n" \
|
||||
" return this._list[this._head];\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" push(item) {\n" \
|
||||
" var tail = this._tail;\n" \
|
||||
" @putByValDirect(this._list, tail, item);\n" \
|
||||
" this._tail = (tail + 1) & this._capacityMask;\n" \
|
||||
" if (this._tail === this._head) {\n" \
|
||||
" this._growArray();\n" \
|
||||
" }\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" toArray(fullCopy) {\n" \
|
||||
" var list = this._list;\n" \
|
||||
" var len = @toLength(list.length);\n" \
|
||||
" \n" \
|
||||
" if (fullCopy || this._head > this._tail) {\n" \
|
||||
" var _head = @toLength(this._head);\n" \
|
||||
" var _tail = @toLength(this._tail);\n" \
|
||||
" var total = @toLength((len - _head) + _tail);\n" \
|
||||
" var array = @newArrayWithSize(total);\n" \
|
||||
" var j = 0;\n" \
|
||||
" for (var i = _head; i < len; i++) @putByValDirect(array, j++, list[i]);\n" \
|
||||
" for (var i = 0; i < _tail; i++) @putByValDirect(array, j++, list[i]);\n" \
|
||||
" return array;\n" \
|
||||
" } else {\n" \
|
||||
" return @Array.prototype.slice.@call(list, this._head, this._tail);\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" clear() {\n" \
|
||||
" this._head = 0;\n" \
|
||||
" this._tail = 0;\n" \
|
||||
" this._list.fill(undefined);\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" _growArray() {\n" \
|
||||
" if (this._head) {\n" \
|
||||
" //\n" \
|
||||
" this._list = this.toArray(true);\n" \
|
||||
" this._head = 0;\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" //\n" \
|
||||
" this._tail = @toLength(this._list.length);\n" \
|
||||
" \n" \
|
||||
" this._list.length <<= 1;\n" \
|
||||
" this._capacityMask = (this._capacityMask << 1) | 1;\n" \
|
||||
" }\n" \
|
||||
" \n" \
|
||||
" shrinkArray() {\n" \
|
||||
" this._list.length >>>= 1;\n" \
|
||||
" this._capacityMask >>>= 1;\n" \
|
||||
" }\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" \n" \
|
||||
" return new Denqueue();\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsNewQueueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsNewQueueCodeLength = 85;
|
||||
static const JSC::Intrinsic s_streamInternalsNewQueueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsNewQueueCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" return { content: @createFIFO(), size: 0 };\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsDequeueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsDequeueValueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsDequeueValueCodeLength = 195;
|
||||
static const JSC::Intrinsic s_streamInternalsDequeueValueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsDequeueValueCode =
|
||||
"(function (queue)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const record = queue.content.shift();\n" \
|
||||
" queue.size -= record.size;\n" \
|
||||
" //\n" \
|
||||
" if (queue.size < 0)\n" \
|
||||
" queue.size = 0;\n" \
|
||||
" return record.value;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsEnqueueValueWithSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsEnqueueValueWithSizeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsEnqueueValueWithSizeCodeLength = 248;
|
||||
static const JSC::Intrinsic s_streamInternalsEnqueueValueWithSizeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsEnqueueValueWithSizeCode =
|
||||
"(function (queue, value, size)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" size = @toNumber(size);\n" \
|
||||
" if (!@isFinite(size) || size < 0)\n" \
|
||||
" @throwRangeError(\"size has an incorrect value\");\n" \
|
||||
" \n" \
|
||||
" queue.content.push({ value, size });\n" \
|
||||
" queue.size += size;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsPeekQueueValueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsPeekQueueValueCodeLength = 115;
|
||||
static const JSC::Intrinsic s_streamInternalsPeekQueueValueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsPeekQueueValueCode =
|
||||
"(function (queue)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(queue.content.isNotEmpty());\n" \
|
||||
"\n" \
|
||||
" return queue.peek().value;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsResetQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsResetQueueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsResetQueueCodeLength = 152;
|
||||
static const JSC::Intrinsic s_streamInternalsResetQueueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsResetQueueCode =
|
||||
"(function (queue)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(\"content\" in queue);\n" \
|
||||
" @assert(\"size\" in queue);\n" \
|
||||
" queue.content.clear();\n" \
|
||||
" queue.size = 0;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsExtractSizeAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsExtractSizeAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsExtractSizeAlgorithmCodeLength = 288;
|
||||
static const JSC::Intrinsic s_streamInternalsExtractSizeAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsExtractSizeAlgorithmCode =
|
||||
"(function (strategy)\n" \
|
||||
"{\n" \
|
||||
" if (!(\"size\" in strategy))\n" \
|
||||
" return () => 1;\n" \
|
||||
" const sizeAlgorithm = strategy[\"size\"];\n" \
|
||||
" if (typeof sizeAlgorithm !== \"function\")\n" \
|
||||
" @throwTypeError(\"strategy.size must be a function\");\n" \
|
||||
"\n" \
|
||||
" return (chunk) => { return sizeAlgorithm(chunk); };\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsExtractHighWaterMarkCodeLength = 325;
|
||||
static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsExtractHighWaterMarkCode =
|
||||
"(function (strategy, defaultHWM)\n" \
|
||||
"{\n" \
|
||||
" if (!(\"highWaterMark\" in strategy))\n" \
|
||||
" return defaultHWM;\n" \
|
||||
" const highWaterMark = strategy[\"highWaterMark\"];\n" \
|
||||
" if (@isNaN(highWaterMark) || highWaterMark < 0)\n" \
|
||||
" @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \
|
||||
"\n" \
|
||||
" return @toNumber(highWaterMark);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeLength = 335;
|
||||
static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCode =
|
||||
"(function (init)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isObject(init))\n" \
|
||||
" @throwTypeError(\"QueuingStrategyInit argument must be an object.\");\n" \
|
||||
" const {highWaterMark} = init;\n" \
|
||||
" if (highWaterMark === @undefined)\n" \
|
||||
" @throwTypeError(\"QueuingStrategyInit.highWaterMark member is required.\");\n" \
|
||||
"\n" \
|
||||
" return @toNumber(highWaterMark);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsCreateFulfilledPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsCreateFulfilledPromiseCodeLength = 115;
|
||||
static const JSC::Intrinsic s_streamInternalsCreateFulfilledPromiseCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsCreateFulfilledPromiseCode =
|
||||
"(function (value)\n" \
|
||||
"{\n" \
|
||||
" const promise = @newPromise();\n" \
|
||||
" @fulfillPromise(promise, value);\n" \
|
||||
" return promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_streamInternalsToDictionaryCodeLength = 212;
|
||||
static const JSC::Intrinsic s_streamInternalsToDictionaryCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_streamInternalsToDictionaryCode =
|
||||
"(function (value, defaultValue, errorMessage)\n" \
|
||||
"{\n" \
|
||||
" if (value === @undefined || value === null)\n" \
|
||||
" return defaultValue;\n" \
|
||||
" if (!@isObject(value))\n" \
|
||||
" @throwTypeError(errorMessage);\n" \
|
||||
" return value;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().streamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().streamInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
308
src/javascript/jsc/bindings/StreamInternalsBuiltins.h
Normal file
308
src/javascript/jsc/bindings/StreamInternalsBuiltins.h
Normal file
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* StreamInternals */
|
||||
extern const char* const s_streamInternalsMarkPromiseAsHandledCode;
|
||||
extern const int s_streamInternalsMarkPromiseAsHandledCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsMarkPromiseAsHandledCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsMarkPromiseAsHandledCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsShieldingPromiseResolveCode;
|
||||
extern const int s_streamInternalsShieldingPromiseResolveCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsShieldingPromiseResolveCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsShieldingPromiseResolveCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCode;
|
||||
extern const int s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsPromiseInvokeOrNoopNoCatchCode;
|
||||
extern const int s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsPromiseInvokeOrNoopMethodCode;
|
||||
extern const int s_streamInternalsPromiseInvokeOrNoopMethodCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsPromiseInvokeOrNoopCode;
|
||||
extern const int s_streamInternalsPromiseInvokeOrNoopCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsPromiseInvokeOrFallbackOrNoopCode;
|
||||
extern const int s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsValidateAndNormalizeQueuingStrategyCode;
|
||||
extern const int s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsCreateFIFOCode;
|
||||
extern const int s_streamInternalsCreateFIFOCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsCreateFIFOCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsCreateFIFOCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsNewQueueCode;
|
||||
extern const int s_streamInternalsNewQueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsNewQueueCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsDequeueValueCode;
|
||||
extern const int s_streamInternalsDequeueValueCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsDequeueValueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsDequeueValueCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsEnqueueValueWithSizeCode;
|
||||
extern const int s_streamInternalsEnqueueValueWithSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsEnqueueValueWithSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsEnqueueValueWithSizeCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsPeekQueueValueCode;
|
||||
extern const int s_streamInternalsPeekQueueValueCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsPeekQueueValueCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsResetQueueCode;
|
||||
extern const int s_streamInternalsResetQueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsResetQueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsResetQueueCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsExtractSizeAlgorithmCode;
|
||||
extern const int s_streamInternalsExtractSizeAlgorithmCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsExtractSizeAlgorithmCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsExtractSizeAlgorithmCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsExtractHighWaterMarkCode;
|
||||
extern const int s_streamInternalsExtractHighWaterMarkCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCode;
|
||||
extern const int s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsCreateFulfilledPromiseCode;
|
||||
extern const int s_streamInternalsCreateFulfilledPromiseCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsCreateFulfilledPromiseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructorKind;
|
||||
extern const char* const s_streamInternalsToDictionaryCode;
|
||||
extern const int s_streamInternalsToDictionaryCodeLength;
|
||||
extern const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_DATA(macro) \
|
||||
macro(markPromiseAsHandled, streamInternalsMarkPromiseAsHandled, 1) \
|
||||
macro(shieldingPromiseResolve, streamInternalsShieldingPromiseResolve, 1) \
|
||||
macro(promiseInvokeOrNoopMethodNoCatch, streamInternalsPromiseInvokeOrNoopMethodNoCatch, 3) \
|
||||
macro(promiseInvokeOrNoopNoCatch, streamInternalsPromiseInvokeOrNoopNoCatch, 3) \
|
||||
macro(promiseInvokeOrNoopMethod, streamInternalsPromiseInvokeOrNoopMethod, 3) \
|
||||
macro(promiseInvokeOrNoop, streamInternalsPromiseInvokeOrNoop, 3) \
|
||||
macro(promiseInvokeOrFallbackOrNoop, streamInternalsPromiseInvokeOrFallbackOrNoop, 5) \
|
||||
macro(validateAndNormalizeQueuingStrategy, streamInternalsValidateAndNormalizeQueuingStrategy, 2) \
|
||||
macro(createFIFO, streamInternalsCreateFIFO, 0) \
|
||||
macro(newQueue, streamInternalsNewQueue, 0) \
|
||||
macro(dequeueValue, streamInternalsDequeueValue, 1) \
|
||||
macro(enqueueValueWithSize, streamInternalsEnqueueValueWithSize, 3) \
|
||||
macro(peekQueueValue, streamInternalsPeekQueueValue, 1) \
|
||||
macro(resetQueue, streamInternalsResetQueue, 1) \
|
||||
macro(extractSizeAlgorithm, streamInternalsExtractSizeAlgorithm, 1) \
|
||||
macro(extractHighWaterMark, streamInternalsExtractHighWaterMark, 2) \
|
||||
macro(extractHighWaterMarkFromQueuingStrategyInit, streamInternalsExtractHighWaterMarkFromQueuingStrategyInit, 1) \
|
||||
macro(createFulfilledPromise, streamInternalsCreateFulfilledPromise, 1) \
|
||||
macro(toDictionary, streamInternalsToDictionary, 3) \
|
||||
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_MARKPROMISEASHANDLED 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_SHIELDINGPROMISERESOLVE 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPMETHODNOCATCH 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPNOCATCH 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPMETHOD 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOP 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORFALLBACKORNOOP 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_VALIDATEANDNORMALIZEQUEUINGSTRATEGY 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_CREATEFIFO 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_NEWQUEUE 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_DEQUEUEVALUE 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_ENQUEUEVALUEWITHSIZE 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_PEEKQUEUEVALUE 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_RESETQUEUE 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTSIZEALGORITHM 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTHIGHWATERMARK 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTHIGHWATERMARKFROMQUEUINGSTRATEGYINIT 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_CREATEFULFILLEDPROMISE 1
|
||||
#define WEBCORE_BUILTIN_STREAMINTERNALS_TODICTIONARY 1
|
||||
|
||||
#define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(macro) \
|
||||
macro(streamInternalsMarkPromiseAsHandledCode, markPromiseAsHandled, ASCIILiteral(), s_streamInternalsMarkPromiseAsHandledCodeLength) \
|
||||
macro(streamInternalsShieldingPromiseResolveCode, shieldingPromiseResolve, ASCIILiteral(), s_streamInternalsShieldingPromiseResolveCodeLength) \
|
||||
macro(streamInternalsPromiseInvokeOrNoopMethodNoCatchCode, promiseInvokeOrNoopMethodNoCatch, ASCIILiteral(), s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeLength) \
|
||||
macro(streamInternalsPromiseInvokeOrNoopNoCatchCode, promiseInvokeOrNoopNoCatch, ASCIILiteral(), s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength) \
|
||||
macro(streamInternalsPromiseInvokeOrNoopMethodCode, promiseInvokeOrNoopMethod, ASCIILiteral(), s_streamInternalsPromiseInvokeOrNoopMethodCodeLength) \
|
||||
macro(streamInternalsPromiseInvokeOrNoopCode, promiseInvokeOrNoop, ASCIILiteral(), s_streamInternalsPromiseInvokeOrNoopCodeLength) \
|
||||
macro(streamInternalsPromiseInvokeOrFallbackOrNoopCode, promiseInvokeOrFallbackOrNoop, ASCIILiteral(), s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength) \
|
||||
macro(streamInternalsValidateAndNormalizeQueuingStrategyCode, validateAndNormalizeQueuingStrategy, ASCIILiteral(), s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength) \
|
||||
macro(streamInternalsCreateFIFOCode, createFIFO, ASCIILiteral(), s_streamInternalsCreateFIFOCodeLength) \
|
||||
macro(streamInternalsNewQueueCode, newQueue, ASCIILiteral(), s_streamInternalsNewQueueCodeLength) \
|
||||
macro(streamInternalsDequeueValueCode, dequeueValue, ASCIILiteral(), s_streamInternalsDequeueValueCodeLength) \
|
||||
macro(streamInternalsEnqueueValueWithSizeCode, enqueueValueWithSize, ASCIILiteral(), s_streamInternalsEnqueueValueWithSizeCodeLength) \
|
||||
macro(streamInternalsPeekQueueValueCode, peekQueueValue, ASCIILiteral(), s_streamInternalsPeekQueueValueCodeLength) \
|
||||
macro(streamInternalsResetQueueCode, resetQueue, ASCIILiteral(), s_streamInternalsResetQueueCodeLength) \
|
||||
macro(streamInternalsExtractSizeAlgorithmCode, extractSizeAlgorithm, ASCIILiteral(), s_streamInternalsExtractSizeAlgorithmCodeLength) \
|
||||
macro(streamInternalsExtractHighWaterMarkCode, extractHighWaterMark, ASCIILiteral(), s_streamInternalsExtractHighWaterMarkCodeLength) \
|
||||
macro(streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCode, extractHighWaterMarkFromQueuingStrategyInit, ASCIILiteral(), s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeLength) \
|
||||
macro(streamInternalsCreateFulfilledPromiseCode, createFulfilledPromise, ASCIILiteral(), s_streamInternalsCreateFulfilledPromiseCodeLength) \
|
||||
macro(streamInternalsToDictionaryCode, toDictionary, ASCIILiteral(), s_streamInternalsToDictionaryCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(createFIFO) \
|
||||
macro(createFulfilledPromise) \
|
||||
macro(dequeueValue) \
|
||||
macro(enqueueValueWithSize) \
|
||||
macro(extractHighWaterMark) \
|
||||
macro(extractHighWaterMarkFromQueuingStrategyInit) \
|
||||
macro(extractSizeAlgorithm) \
|
||||
macro(markPromiseAsHandled) \
|
||||
macro(newQueue) \
|
||||
macro(peekQueueValue) \
|
||||
macro(promiseInvokeOrFallbackOrNoop) \
|
||||
macro(promiseInvokeOrNoop) \
|
||||
macro(promiseInvokeOrNoopMethod) \
|
||||
macro(promiseInvokeOrNoopMethodNoCatch) \
|
||||
macro(promiseInvokeOrNoopNoCatch) \
|
||||
macro(resetQueue) \
|
||||
macro(shieldingPromiseResolve) \
|
||||
macro(toDictionary) \
|
||||
macro(validateAndNormalizeQueuingStrategy) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class StreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit StreamInternalsBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* StreamInternalsBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void StreamInternalsBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
class StreamInternalsBuiltinFunctions {
|
||||
public:
|
||||
explicit StreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
|
||||
|
||||
void init(JSC::JSGlobalObject&);
|
||||
template<typename Visitor> void visit(Visitor&);
|
||||
|
||||
public:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
|
||||
JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
};
|
||||
|
||||
inline void StreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
|
||||
{
|
||||
#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
|
||||
m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
|
||||
#undef EXPORT_FUNCTION
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
inline void StreamInternalsBuiltinFunctions::visit(Visitor& visitor)
|
||||
{
|
||||
#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
|
||||
#undef VISIT_FUNCTION
|
||||
}
|
||||
|
||||
template void StreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
|
||||
template void StreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
|
||||
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
170
src/javascript/jsc/bindings/TransformStreamBuiltins.cpp
Normal file
170
src/javascript/jsc/bindings/TransformStreamBuiltins.cpp
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "TransformStreamBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInitializeTransformStreamCodeLength = 2727;
|
||||
static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInitializeTransformStreamCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" let transformer = arguments[0];\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" if (@isObject(transformer) && @getByIdDirectPrivate(transformer, \"TransformStream\"))\n" \
|
||||
" return this;\n" \
|
||||
"\n" \
|
||||
" let writableStrategy = arguments[1];\n" \
|
||||
" let readableStrategy = arguments[2];\n" \
|
||||
"\n" \
|
||||
" if (transformer === @undefined)\n" \
|
||||
" transformer = null;\n" \
|
||||
"\n" \
|
||||
" if (readableStrategy === @undefined)\n" \
|
||||
" readableStrategy = { };\n" \
|
||||
"\n" \
|
||||
" if (writableStrategy === @undefined)\n" \
|
||||
" writableStrategy = { };\n" \
|
||||
"\n" \
|
||||
" let transformerDict = { };\n" \
|
||||
" if (transformer !== null) {\n" \
|
||||
" if (\"start\" in transformer) {\n" \
|
||||
" transformerDict[\"start\"] = transformer[\"start\"];\n" \
|
||||
" if (typeof transformerDict[\"start\"] !== \"function\")\n" \
|
||||
" @throwTypeError(\"transformer.start should be a function\");\n" \
|
||||
" }\n" \
|
||||
" if (\"transform\" in transformer) {\n" \
|
||||
" transformerDict[\"transform\"] = transformer[\"transform\"];\n" \
|
||||
" if (typeof transformerDict[\"transform\"] !== \"function\")\n" \
|
||||
" @throwTypeError(\"transformer.transform should be a function\");\n" \
|
||||
" }\n" \
|
||||
" if (\"flush\" in transformer) {\n" \
|
||||
" transformerDict[\"flush\"] = transformer[\"flush\"];\n" \
|
||||
" if (typeof transformerDict[\"flush\"] !== \"function\")\n" \
|
||||
" @throwTypeError(\"transformer.flush should be a function\");\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" if (\"readableType\" in transformer)\n" \
|
||||
" @throwRangeError(\"TransformStream transformer has a readableType\");\n" \
|
||||
" if (\"writableType\" in transformer)\n" \
|
||||
" @throwRangeError(\"TransformStream transformer has a writableType\");\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" const readableHighWaterMark = @extractHighWaterMark(readableStrategy, 0);\n" \
|
||||
" const readableSizeAlgorithm = @extractSizeAlgorithm(readableStrategy);\n" \
|
||||
"\n" \
|
||||
" const writableHighWaterMark = @extractHighWaterMark(writableStrategy, 1);\n" \
|
||||
" const writableSizeAlgorithm = @extractSizeAlgorithm(writableStrategy);\n" \
|
||||
"\n" \
|
||||
" const startPromiseCapability = @newPromiseCapability(@Promise);\n" \
|
||||
" @initializeTransformStream(this, startPromiseCapability.@promise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);\n" \
|
||||
" @setUpTransformStreamDefaultControllerFromTransformer(this, transformer, transformerDict);\n" \
|
||||
"\n" \
|
||||
" if (\"start\" in transformerDict) {\n" \
|
||||
" const controller = @getByIdDirectPrivate(this, \"controller\");\n" \
|
||||
" const startAlgorithm = () => @promiseInvokeOrNoopMethodNoCatch(transformer, transformerDict[\"start\"], [controller]);\n" \
|
||||
" startAlgorithm().@then(() => {\n" \
|
||||
" //\n" \
|
||||
" startPromiseCapability.@resolve.@call();\n" \
|
||||
" }, (error) => {\n" \
|
||||
" startPromiseCapability.@reject.@call(@undefined, error);\n" \
|
||||
" });\n" \
|
||||
" } else\n" \
|
||||
" startPromiseCapability.@resolve.@call();\n" \
|
||||
"\n" \
|
||||
" return this;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamReadableCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamReadableCodeLength = 190;
|
||||
static const JSC::Intrinsic s_transformStreamReadableCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamReadableCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isTransformStream(this))\n" \
|
||||
" throw @makeThisTypeError(\"TransformStream\", \"readable\");\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(this, \"readable\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamWritableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamWritableCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamWritableCodeLength = 190;
|
||||
static const JSC::Intrinsic s_transformStreamWritableCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamWritableCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isTransformStream(this))\n" \
|
||||
" throw @makeThisTypeError(\"TransformStream\", \"writable\");\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(this, \"writable\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().transformStreamBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().transformStreamBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
143
src/javascript/jsc/bindings/TransformStreamBuiltins.h
Normal file
143
src/javascript/jsc/bindings/TransformStreamBuiltins.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* TransformStream */
|
||||
extern const char* const s_transformStreamInitializeTransformStreamCode;
|
||||
extern const int s_transformStreamInitializeTransformStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInitializeTransformStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstructorKind;
|
||||
extern const char* const s_transformStreamReadableCode;
|
||||
extern const int s_transformStreamReadableCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamReadableCodeConstructorKind;
|
||||
extern const char* const s_transformStreamWritableCode;
|
||||
extern const int s_transformStreamWritableCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamWritableCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamWritableCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_DATA(macro) \
|
||||
macro(initializeTransformStream, transformStreamInitializeTransformStream, 0) \
|
||||
macro(readable, transformStreamReadable, 0) \
|
||||
macro(writable, transformStreamWritable, 0) \
|
||||
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAM_INITIALIZETRANSFORMSTREAM 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAM_READABLE 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAM_WRITABLE 1
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(macro) \
|
||||
macro(transformStreamInitializeTransformStreamCode, initializeTransformStream, ASCIILiteral(), s_transformStreamInitializeTransformStreamCodeLength) \
|
||||
macro(transformStreamReadableCode, readable, "get readable"_s, s_transformStreamReadableCodeLength) \
|
||||
macro(transformStreamWritableCode, writable, ASCIILiteral(), s_transformStreamWritableCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(initializeTransformStream) \
|
||||
macro(readable) \
|
||||
macro(writable) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class TransformStreamBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit TransformStreamBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* TransformStreamBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void TransformStreamBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "TransformStreamDefaultControllerBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeLength = 54;
|
||||
static const JSC::Intrinsic s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" return this;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamDefaultControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 465;
|
||||
static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamDefaultControllerDesiredSizeCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isTransformStreamDefaultController(this))\n" \
|
||||
" throw @makeThisTypeError(\"TransformStreamDefaultController\", \"enqueue\");\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(this, \"stream\");\n" \
|
||||
" const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
|
||||
" const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
|
||||
"\n" \
|
||||
" return @readableStreamDefaultControllerGetDesiredSize(readableController);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamDefaultControllerEnqueueCodeLength = 235;
|
||||
static const JSC::Intrinsic s_transformStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamDefaultControllerEnqueueCode =
|
||||
"(function (chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isTransformStreamDefaultController(this))\n" \
|
||||
" throw @makeThisTypeError(\"TransformStreamDefaultController\", \"enqueue\");\n" \
|
||||
"\n" \
|
||||
" @transformStreamDefaultControllerEnqueue(this, chunk);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamDefaultControllerErrorCodeLength = 223;
|
||||
static const JSC::Intrinsic s_transformStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamDefaultControllerErrorCode =
|
||||
"(function (e)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isTransformStreamDefaultController(this))\n" \
|
||||
" throw @makeThisTypeError(\"TransformStreamDefaultController\", \"error\");\n" \
|
||||
"\n" \
|
||||
" @transformStreamDefaultControllerError(this, e);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamDefaultControllerTerminateCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamDefaultControllerTerminateCodeLength = 227;
|
||||
static const JSC::Intrinsic s_transformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamDefaultControllerTerminateCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isTransformStreamDefaultController(this))\n" \
|
||||
" throw @makeThisTypeError(\"TransformStreamDefaultController\", \"terminate\");\n" \
|
||||
"\n" \
|
||||
" @transformStreamDefaultControllerTerminate(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().transformStreamDefaultControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().transformStreamDefaultControllerBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* TransformStreamDefaultController */
|
||||
extern const char* const s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCode;
|
||||
extern const int s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_transformStreamDefaultControllerDesiredSizeCode;
|
||||
extern const int s_transformStreamDefaultControllerDesiredSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamDefaultControllerDesiredSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeConstructorKind;
|
||||
extern const char* const s_transformStreamDefaultControllerEnqueueCode;
|
||||
extern const int s_transformStreamDefaultControllerEnqueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamDefaultControllerEnqueueCodeConstructorKind;
|
||||
extern const char* const s_transformStreamDefaultControllerErrorCode;
|
||||
extern const int s_transformStreamDefaultControllerErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamDefaultControllerErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamDefaultControllerErrorCodeConstructorKind;
|
||||
extern const char* const s_transformStreamDefaultControllerTerminateCode;
|
||||
extern const int s_transformStreamDefaultControllerTerminateCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamDefaultControllerTerminateCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamDefaultControllerTerminateCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_DATA(macro) \
|
||||
macro(initializeTransformStreamDefaultController, transformStreamDefaultControllerInitializeTransformStreamDefaultController, 0) \
|
||||
macro(desiredSize, transformStreamDefaultControllerDesiredSize, 0) \
|
||||
macro(enqueue, transformStreamDefaultControllerEnqueue, 1) \
|
||||
macro(error, transformStreamDefaultControllerError, 1) \
|
||||
macro(terminate, transformStreamDefaultControllerTerminate, 0) \
|
||||
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_INITIALIZETRANSFORMSTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_DESIREDSIZE 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_ENQUEUE 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_ERROR 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_TERMINATE 1
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(macro) \
|
||||
macro(transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCode, initializeTransformStreamDefaultController, ASCIILiteral(), s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeLength) \
|
||||
macro(transformStreamDefaultControllerDesiredSizeCode, desiredSize, "get desiredSize"_s, s_transformStreamDefaultControllerDesiredSizeCodeLength) \
|
||||
macro(transformStreamDefaultControllerEnqueueCode, enqueue, ASCIILiteral(), s_transformStreamDefaultControllerEnqueueCodeLength) \
|
||||
macro(transformStreamDefaultControllerErrorCode, error, ASCIILiteral(), s_transformStreamDefaultControllerErrorCodeLength) \
|
||||
macro(transformStreamDefaultControllerTerminateCode, terminate, ASCIILiteral(), s_transformStreamDefaultControllerTerminateCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(desiredSize) \
|
||||
macro(enqueue) \
|
||||
macro(error) \
|
||||
macro(initializeTransformStreamDefaultController) \
|
||||
macro(terminate) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class TransformStreamDefaultControllerBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit TransformStreamDefaultControllerBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* TransformStreamDefaultControllerBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void TransformStreamDefaultControllerBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
492
src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.cpp
Normal file
492
src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.cpp
Normal file
@@ -0,0 +1,492 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "TransformStreamInternalsBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsIsTransformStreamCodeLength = 120;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsIsTransformStreamCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsIsTransformStreamCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" return @isObject(stream) && !!@getByIdDirectPrivate(stream, \"readable\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsIsTransformStreamDefaultControllerCodeLength = 142;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsIsTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsIsTransformStreamDefaultControllerCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" return @isObject(controller) && !!@getByIdDirectPrivate(controller, \"transformAlgorithm\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsCreateTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsCreateTransformStreamCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsCreateTransformStreamCodeLength = 1317;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsCreateTransformStreamCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsCreateTransformStreamCode =
|
||||
"(function (startAlgorithm, transformAlgorithm, flushAlgorithm, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm)\n" \
|
||||
"{\n" \
|
||||
" if (writableHighWaterMark === @undefined)\n" \
|
||||
" writableHighWaterMark = 1;\n" \
|
||||
" if (writableSizeAlgorithm === @undefined)\n" \
|
||||
" writableSizeAlgorithm = () => 1;\n" \
|
||||
" if (readableHighWaterMark === @undefined)\n" \
|
||||
" readableHighWaterMark = 0;\n" \
|
||||
" if (readableSizeAlgorithm === @undefined)\n" \
|
||||
" readableSizeAlgorithm = () => 1;\n" \
|
||||
" @assert(writableHighWaterMark >= 0);\n" \
|
||||
" @assert(readableHighWaterMark >= 0);\n" \
|
||||
"\n" \
|
||||
" const transform = {};\n" \
|
||||
" @putByIdDirectPrivate(transform, \"TransformStream\", true);\n" \
|
||||
"\n" \
|
||||
" const stream = new @TransformStream(transform);\n" \
|
||||
" const startPromiseCapability = @newPromiseCapability(@Promise);\n" \
|
||||
" @initializeTransformStream(stream, startPromiseCapability.@promise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);\n" \
|
||||
"\n" \
|
||||
" const controller = new @TransformStreamDefaultController();\n" \
|
||||
" @setUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);\n" \
|
||||
"\n" \
|
||||
" startAlgorithm().@then(() => {\n" \
|
||||
" startPromiseCapability.@resolve.@call();\n" \
|
||||
" }, (error) => {\n" \
|
||||
" startPromiseCapability.@reject.@call(@undefined, error);\n" \
|
||||
" });\n" \
|
||||
"\n" \
|
||||
" return stream;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsInitializeTransformStreamCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsInitializeTransformStreamCodeLength = 1881;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsInitializeTransformStreamCode =
|
||||
"(function (stream, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const startAlgorithm = () => { return startPromise; };\n" \
|
||||
" const writeAlgorithm = (chunk) => { return @transformStreamDefaultSinkWriteAlgorithm(stream, chunk); }\n" \
|
||||
" const abortAlgorithm = (reason) => { return @transformStreamDefaultSinkAbortAlgorithm(stream, reason); }\n" \
|
||||
" const closeAlgorithm = () => { return @transformStreamDefaultSinkCloseAlgorithm(stream); }\n" \
|
||||
" const writable = @createWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, writableHighWaterMark, writableSizeAlgorithm);\n" \
|
||||
"\n" \
|
||||
" const pullAlgorithm = () => { return @transformStreamDefaultSourcePullAlgorithm(stream); };\n" \
|
||||
" const cancelAlgorithm = (reason) => {\n" \
|
||||
" @transformStreamErrorWritableAndUnblockWrite(stream, reason);\n" \
|
||||
" return @Promise.@resolve();\n" \
|
||||
" };\n" \
|
||||
" const underlyingSource = { };\n" \
|
||||
" @putByIdDirectPrivate(underlyingSource, \"start\", startAlgorithm);\n" \
|
||||
" @putByIdDirectPrivate(underlyingSource, \"pull\", pullAlgorithm);\n" \
|
||||
" @putByIdDirectPrivate(underlyingSource, \"cancel\", cancelAlgorithm);\n" \
|
||||
" const options = { };\n" \
|
||||
" @putByIdDirectPrivate(options, \"size\", readableSizeAlgorithm);\n" \
|
||||
" @putByIdDirectPrivate(options, \"highWaterMark\", readableHighWaterMark);\n" \
|
||||
" const readable = new @ReadableStream(underlyingSource, options);\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" @putByIdDirectPrivate(stream, \"writable\", writable);\n" \
|
||||
" //\n" \
|
||||
" @putByIdDirectPrivate(stream, \"internalWritable\", @getInternalWritableStream(writable));\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(stream, \"readable\", readable);\n" \
|
||||
" @putByIdDirectPrivate(stream, \"backpressure\", @undefined);\n" \
|
||||
" @putByIdDirectPrivate(stream, \"backpressureChangePromise\", @undefined);\n" \
|
||||
"\n" \
|
||||
" @transformStreamSetBackpressure(stream, true);\n" \
|
||||
" @putByIdDirectPrivate(stream, \"controller\", @undefined);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamErrorCodeLength = 330;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamErrorCode =
|
||||
"(function (stream, e)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
|
||||
" const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
|
||||
" @readableStreamDefaultControllerError(readableController, e);\n" \
|
||||
"\n" \
|
||||
" @transformStreamErrorWritableAndUnblockWrite(stream, e);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength = 431;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode =
|
||||
"(function (stream, e)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(stream, \"controller\"));\n" \
|
||||
"\n" \
|
||||
" const writable = @getByIdDirectPrivate(stream, \"internalWritable\");\n" \
|
||||
" @writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(writable, \"controller\"), e);\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"backpressure\"))\n" \
|
||||
" @transformStreamSetBackpressure(stream, false);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamSetBackpressureCodeLength = 498;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamSetBackpressureCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamSetBackpressureCode =
|
||||
"(function (stream, backpressure)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"backpressure\") !== backpressure);\n" \
|
||||
"\n" \
|
||||
" const backpressureChangePromise = @getByIdDirectPrivate(stream, \"backpressureChangePromise\");\n" \
|
||||
" if (backpressureChangePromise !== @undefined)\n" \
|
||||
" backpressureChangePromise.@resolve.@call();\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(stream, \"backpressureChangePromise\", @newPromiseCapability(@Promise));\n" \
|
||||
" @putByIdDirectPrivate(stream, \"backpressure\", backpressure);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeLength = 478;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode =
|
||||
"(function (stream, controller, transformAlgorithm, flushAlgorithm)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@isTransformStream(stream));\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"controller\") === @undefined);\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(controller, \"stream\", stream);\n" \
|
||||
" @putByIdDirectPrivate(stream, \"controller\", controller);\n" \
|
||||
" @putByIdDirectPrivate(controller, \"transformAlgorithm\", transformAlgorithm);\n" \
|
||||
" @putByIdDirectPrivate(controller, \"flushAlgorithm\", flushAlgorithm);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 940;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode =
|
||||
"(function (stream, transformer, transformerDict)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const controller = new @TransformStreamDefaultController();\n" \
|
||||
" let transformAlgorithm = (chunk) => {\n" \
|
||||
" try {\n" \
|
||||
" @transformStreamDefaultControllerEnqueue(controller, chunk);\n" \
|
||||
" } catch (e) {\n" \
|
||||
" return @Promise.@reject(e);\n" \
|
||||
" }\n" \
|
||||
" return @Promise.@resolve();\n" \
|
||||
" };\n" \
|
||||
" let flushAlgorithm = () => { return @Promise.@resolve(); };\n" \
|
||||
"\n" \
|
||||
" if (\"transform\" in transformerDict)\n" \
|
||||
" transformAlgorithm = (chunk) => {\n" \
|
||||
" return @promiseInvokeOrNoopMethod(transformer, transformerDict[\"transform\"], [chunk, controller]);\n" \
|
||||
" };\n" \
|
||||
"\n" \
|
||||
" if (\"flush\" in transformerDict) {\n" \
|
||||
" flushAlgorithm = () => {\n" \
|
||||
" return @promiseInvokeOrNoopMethod(transformer, transformerDict[\"flush\"], [controller]);\n" \
|
||||
" };\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" @setUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeLength = 190;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" @putByIdDirectPrivate(controller, \"transformAlgorithm\", true);\n" \
|
||||
" @putByIdDirectPrivate(controller, \"flushAlgorithm\", @undefined);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength = 979;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode =
|
||||
"(function (controller, chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
|
||||
" const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
|
||||
" const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
|
||||
"\n" \
|
||||
" @assert(readableController !== @undefined);\n" \
|
||||
" if (!@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))\n" \
|
||||
" @throwTypeError(\"TransformStream.readable cannot close or enqueue\");\n" \
|
||||
"\n" \
|
||||
" try {\n" \
|
||||
" @readableStreamDefaultControllerEnqueue(readableController, chunk);\n" \
|
||||
" } catch (e) {\n" \
|
||||
" @transformStreamErrorWritableAndUnblockWrite(stream, e);\n" \
|
||||
" throw @getByIdDirectPrivate(readable, \"storedError\");\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" const backpressure = !@readableStreamDefaultControllerShouldCallPull(readableController);\n" \
|
||||
" if (backpressure !== @getByIdDirectPrivate(stream, \"backpressure\")) {\n" \
|
||||
" @assert(backpressure);\n" \
|
||||
" @transformStreamSetBackpressure(stream, true);\n" \
|
||||
" }\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeLength = 125;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultControllerErrorCode =
|
||||
"(function (controller, e)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @transformStreamError(@getByIdDirectPrivate(controller, \"stream\"), e);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 500;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode =
|
||||
"(function (controller, chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const promiseCapability = @newPromiseCapability(@Promise);\n" \
|
||||
"\n" \
|
||||
" const transformPromise = @getByIdDirectPrivate(controller, \"transformAlgorithm\").@call(@undefined, chunk);\n" \
|
||||
" transformPromise.@then(() => {\n" \
|
||||
" promiseCapability.@resolve();\n" \
|
||||
" }, (r) => {\n" \
|
||||
" @transformStreamError(@getByIdDirectPrivate(controller, \"stream\"), r);\n" \
|
||||
" promiseCapability.@reject.@call(@undefined, r);\n" \
|
||||
" });\n" \
|
||||
" return promiseCapability.@promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 554;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode =
|
||||
"(function (controller)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
|
||||
" const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
|
||||
" const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" if (@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))\n" \
|
||||
" @readableStreamDefaultControllerClose(readableController);\n" \
|
||||
" const error = @makeTypeError(\"the stream has been terminated\");\n" \
|
||||
" @transformStreamErrorWritableAndUnblockWrite(stream, error);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength = 1373;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode =
|
||||
"(function (stream, chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" const writable = @getByIdDirectPrivate(stream, \"internalWritable\");\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(writable, \"state\") === \"writable\");\n" \
|
||||
"\n" \
|
||||
" const controller = @getByIdDirectPrivate(stream, \"controller\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"backpressure\")) {\n" \
|
||||
" const promiseCapability = @newPromiseCapability(@Promise);\n" \
|
||||
"\n" \
|
||||
" const backpressureChangePromise = @getByIdDirectPrivate(stream, \"backpressureChangePromise\");\n" \
|
||||
" @assert(backpressureChangePromise !== @undefined);\n" \
|
||||
" backpressureChangePromise.@promise.@then(() => {\n" \
|
||||
" const state = @getByIdDirectPrivate(writable, \"state\");\n" \
|
||||
" if (state === \"erroring\") {\n" \
|
||||
" promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(writable, \"storedError\"));\n" \
|
||||
" return;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" @assert(state === \"writable\");\n" \
|
||||
" @transformStreamDefaultControllerPerformTransform(controller, chunk).@then(() => {\n" \
|
||||
" promiseCapability.@resolve();\n" \
|
||||
" }, (e) => {\n" \
|
||||
" promiseCapability.@reject.@call(@undefined, e);\n" \
|
||||
" });\n" \
|
||||
" }, (e) => {\n" \
|
||||
" promiseCapability.@reject.@call(@undefined, e);\n" \
|
||||
" });\n" \
|
||||
"\n" \
|
||||
" return promiseCapability.@promise;\n" \
|
||||
" }\n" \
|
||||
" return @transformStreamDefaultControllerPerformTransform(controller, chunk);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength = 126;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode =
|
||||
"(function (stream, reason)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @transformStreamError(stream, reason);\n" \
|
||||
" return @Promise.@resolve();\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength = 1295;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
" const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
|
||||
" const controller = @getByIdDirectPrivate(stream, \"controller\");\n" \
|
||||
" const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
|
||||
"\n" \
|
||||
" const flushAlgorithm = @getByIdDirectPrivate(controller, \"flushAlgorithm\");\n" \
|
||||
" @assert(flushAlgorithm !== @undefined);\n" \
|
||||
" const flushPromise = @getByIdDirectPrivate(controller, \"flushAlgorithm\").@call();\n" \
|
||||
" @transformStreamDefaultControllerClearAlgorithms(controller);\n" \
|
||||
"\n" \
|
||||
" const promiseCapability = @newPromiseCapability(@Promise);\n" \
|
||||
" flushPromise.@then(() => {\n" \
|
||||
" if (@getByIdDirectPrivate(readable, \"state\") === @streamErrored) {\n" \
|
||||
" promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(readable, \"storedError\"));\n" \
|
||||
" return;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" if (@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))\n" \
|
||||
" @readableStreamDefaultControllerClose(readableController);\n" \
|
||||
" promiseCapability.@resolve();\n" \
|
||||
" }, (r) => {\n" \
|
||||
" @transformStreamError(@getByIdDirectPrivate(controller, \"stream\"), r);\n" \
|
||||
" promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(readable, \"storedError\"));\n" \
|
||||
" });\n" \
|
||||
" return promiseCapability.@promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength = 325;
|
||||
static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"backpressure\"));\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"backpressureChangePromise\") !== @undefined);\n" \
|
||||
"\n" \
|
||||
" @transformStreamSetBackpressure(stream, false);\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(stream, \"backpressureChangePromise\").@promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().transformStreamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().transformStreamInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
300
src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.h
Normal file
300
src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* TransformStreamInternals */
|
||||
extern const char* const s_transformStreamInternalsIsTransformStreamCode;
|
||||
extern const int s_transformStreamInternalsIsTransformStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsIsTransformStreamDefaultControllerCode;
|
||||
extern const int s_transformStreamInternalsIsTransformStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsCreateTransformStreamCode;
|
||||
extern const int s_transformStreamInternalsCreateTransformStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsCreateTransformStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsCreateTransformStreamCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsInitializeTransformStreamCode;
|
||||
extern const int s_transformStreamInternalsInitializeTransformStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsInitializeTransformStreamCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamErrorCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamSetBackpressureCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamSetBackpressureCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode;
|
||||
extern const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode;
|
||||
extern const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerErrorCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructorKind;
|
||||
extern const char* const s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode;
|
||||
extern const int s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength;
|
||||
extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_DATA(macro) \
|
||||
macro(isTransformStream, transformStreamInternalsIsTransformStream, 1) \
|
||||
macro(isTransformStreamDefaultController, transformStreamInternalsIsTransformStreamDefaultController, 1) \
|
||||
macro(createTransformStream, transformStreamInternalsCreateTransformStream, 7) \
|
||||
macro(initializeTransformStream, transformStreamInternalsInitializeTransformStream, 6) \
|
||||
macro(transformStreamError, transformStreamInternalsTransformStreamError, 2) \
|
||||
macro(transformStreamErrorWritableAndUnblockWrite, transformStreamInternalsTransformStreamErrorWritableAndUnblockWrite, 2) \
|
||||
macro(transformStreamSetBackpressure, transformStreamInternalsTransformStreamSetBackpressure, 2) \
|
||||
macro(setUpTransformStreamDefaultController, transformStreamInternalsSetUpTransformStreamDefaultController, 4) \
|
||||
macro(setUpTransformStreamDefaultControllerFromTransformer, transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformer, 3) \
|
||||
macro(transformStreamDefaultControllerClearAlgorithms, transformStreamInternalsTransformStreamDefaultControllerClearAlgorithms, 1) \
|
||||
macro(transformStreamDefaultControllerEnqueue, transformStreamInternalsTransformStreamDefaultControllerEnqueue, 2) \
|
||||
macro(transformStreamDefaultControllerError, transformStreamInternalsTransformStreamDefaultControllerError, 2) \
|
||||
macro(transformStreamDefaultControllerPerformTransform, transformStreamInternalsTransformStreamDefaultControllerPerformTransform, 2) \
|
||||
macro(transformStreamDefaultControllerTerminate, transformStreamInternalsTransformStreamDefaultControllerTerminate, 1) \
|
||||
macro(transformStreamDefaultSinkWriteAlgorithm, transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithm, 2) \
|
||||
macro(transformStreamDefaultSinkAbortAlgorithm, transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithm, 2) \
|
||||
macro(transformStreamDefaultSinkCloseAlgorithm, transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithm, 1) \
|
||||
macro(transformStreamDefaultSourcePullAlgorithm, transformStreamInternalsTransformStreamDefaultSourcePullAlgorithm, 1) \
|
||||
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_ISTRANSFORMSTREAM 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_ISTRANSFORMSTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_CREATETRANSFORMSTREAM 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_INITIALIZETRANSFORMSTREAM 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMERROR 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMERRORWRITABLEANDUNBLOCKWRITE 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMSETBACKPRESSURE 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_SETUPTRANSFORMSTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_SETUPTRANSFORMSTREAMDEFAULTCONTROLLERFROMTRANSFORMER 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERCLEARALGORITHMS 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERENQUEUE 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERERROR 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERPERFORMTRANSFORM 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERTERMINATE 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKWRITEALGORITHM 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKABORTALGORITHM 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKCLOSEALGORITHM 1
|
||||
#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSOURCEPULLALGORITHM 1
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(macro) \
|
||||
macro(transformStreamInternalsIsTransformStreamCode, isTransformStream, ASCIILiteral(), s_transformStreamInternalsIsTransformStreamCodeLength) \
|
||||
macro(transformStreamInternalsIsTransformStreamDefaultControllerCode, isTransformStreamDefaultController, ASCIILiteral(), s_transformStreamInternalsIsTransformStreamDefaultControllerCodeLength) \
|
||||
macro(transformStreamInternalsCreateTransformStreamCode, createTransformStream, ASCIILiteral(), s_transformStreamInternalsCreateTransformStreamCodeLength) \
|
||||
macro(transformStreamInternalsInitializeTransformStreamCode, initializeTransformStream, ASCIILiteral(), s_transformStreamInternalsInitializeTransformStreamCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamErrorCode, transformStreamError, ASCIILiteral(), s_transformStreamInternalsTransformStreamErrorCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode, transformStreamErrorWritableAndUnblockWrite, ASCIILiteral(), s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamSetBackpressureCode, transformStreamSetBackpressure, ASCIILiteral(), s_transformStreamInternalsTransformStreamSetBackpressureCodeLength) \
|
||||
macro(transformStreamInternalsSetUpTransformStreamDefaultControllerCode, setUpTransformStreamDefaultController, ASCIILiteral(), s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeLength) \
|
||||
macro(transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode, setUpTransformStreamDefaultControllerFromTransformer, ASCIILiteral(), s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCode, transformStreamDefaultControllerClearAlgorithms, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultControllerEnqueueCode, transformStreamDefaultControllerEnqueue, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultControllerErrorCode, transformStreamDefaultControllerError, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode, transformStreamDefaultControllerPerformTransform, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultControllerTerminateCode, transformStreamDefaultControllerTerminate, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode, transformStreamDefaultSinkWriteAlgorithm, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode, transformStreamDefaultSinkAbortAlgorithm, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode, transformStreamDefaultSinkCloseAlgorithm, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength) \
|
||||
macro(transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode, transformStreamDefaultSourcePullAlgorithm, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(createTransformStream) \
|
||||
macro(initializeTransformStream) \
|
||||
macro(isTransformStream) \
|
||||
macro(isTransformStreamDefaultController) \
|
||||
macro(setUpTransformStreamDefaultController) \
|
||||
macro(setUpTransformStreamDefaultControllerFromTransformer) \
|
||||
macro(transformStreamDefaultControllerClearAlgorithms) \
|
||||
macro(transformStreamDefaultControllerEnqueue) \
|
||||
macro(transformStreamDefaultControllerError) \
|
||||
macro(transformStreamDefaultControllerPerformTransform) \
|
||||
macro(transformStreamDefaultControllerTerminate) \
|
||||
macro(transformStreamDefaultSinkAbortAlgorithm) \
|
||||
macro(transformStreamDefaultSinkCloseAlgorithm) \
|
||||
macro(transformStreamDefaultSinkWriteAlgorithm) \
|
||||
macro(transformStreamDefaultSourcePullAlgorithm) \
|
||||
macro(transformStreamError) \
|
||||
macro(transformStreamErrorWritableAndUnblockWrite) \
|
||||
macro(transformStreamSetBackpressure) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class TransformStreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit TransformStreamInternalsBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* TransformStreamInternalsBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void TransformStreamInternalsBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
class TransformStreamInternalsBuiltinFunctions {
|
||||
public:
|
||||
explicit TransformStreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
|
||||
|
||||
void init(JSC::JSGlobalObject&);
|
||||
template<typename Visitor> void visit(Visitor&);
|
||||
|
||||
public:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
|
||||
JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
};
|
||||
|
||||
inline void TransformStreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
|
||||
{
|
||||
#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
|
||||
m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
|
||||
#undef EXPORT_FUNCTION
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
inline void TransformStreamInternalsBuiltinFunctions::visit(Visitor& visitor)
|
||||
{
|
||||
#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
|
||||
#undef VISIT_FUNCTION
|
||||
}
|
||||
|
||||
template void TransformStreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
|
||||
template void TransformStreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
|
||||
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -57,7 +57,7 @@ String URLDecomposition::username() const
|
||||
void URLDecomposition::setUsername(StringView user)
|
||||
{
|
||||
auto fullURL = this->fullURL();
|
||||
if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"))
|
||||
if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"_s))
|
||||
return;
|
||||
fullURL.setUser(user);
|
||||
setFullURL(fullURL);
|
||||
@@ -71,7 +71,7 @@ String URLDecomposition::password() const
|
||||
void URLDecomposition::setPassword(StringView password)
|
||||
{
|
||||
auto fullURL = this->fullURL();
|
||||
if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"))
|
||||
if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"_s))
|
||||
return;
|
||||
fullURL.setPassword(password);
|
||||
setFullURL(fullURL);
|
||||
@@ -95,7 +95,7 @@ static unsigned countASCIIDigits(StringView string)
|
||||
void URLDecomposition::setHost(StringView value)
|
||||
{
|
||||
auto fullURL = this->fullURL();
|
||||
if (value.isEmpty() && !fullURL.protocolIs("file") && fullURL.hasSpecialScheme())
|
||||
if (value.isEmpty() && !fullURL.protocolIs("file"_s) && fullURL.hasSpecialScheme())
|
||||
return;
|
||||
|
||||
size_t separator = value.reverseFind(':');
|
||||
@@ -148,7 +148,7 @@ void URLDecomposition::setHostname(StringView value)
|
||||
{
|
||||
auto fullURL = this->fullURL();
|
||||
auto host = removeAllLeadingSolidusCharacters(value);
|
||||
if (host.isEmpty() && !fullURL.protocolIs("file") && fullURL.hasSpecialScheme())
|
||||
if (host.isEmpty() && !fullURL.protocolIs("file"_s) && fullURL.hasSpecialScheme())
|
||||
return;
|
||||
if (fullURL.cannotBeABaseURL() || !fullURL.canSetHostOrPort())
|
||||
return;
|
||||
@@ -195,7 +195,7 @@ static std::optional<std::optional<uint16_t>> parsePort(StringView string, Strin
|
||||
void URLDecomposition::setPort(StringView value)
|
||||
{
|
||||
auto fullURL = this->fullURL();
|
||||
if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file") || !fullURL.canSetHostOrPort())
|
||||
if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"_s) || !fullURL.canSetHostOrPort())
|
||||
return;
|
||||
auto port = parsePort(value, fullURL.protocol());
|
||||
if (!port)
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -42,6 +47,11 @@ namespace WebCore {
|
||||
|
||||
JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
, m_readableByteStreamInternals(m_vm)
|
||||
, m_readableStreamInternals(m_vm)
|
||||
, m_streamInternals(m_vm)
|
||||
, m_transformStreamInternals(m_vm)
|
||||
, m_writableStreamInternals(m_vm)
|
||||
{
|
||||
UNUSED_PARAM(vm);
|
||||
}
|
||||
@@ -49,6 +59,11 @@ JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm)
|
||||
template<typename Visitor>
|
||||
void JSBuiltinInternalFunctions::visit(Visitor& visitor)
|
||||
{
|
||||
m_readableByteStreamInternals.visit(visitor);
|
||||
m_readableStreamInternals.visit(visitor);
|
||||
m_streamInternals.visit(visitor);
|
||||
m_transformStreamInternals.visit(visitor);
|
||||
m_writableStreamInternals.visit(visitor);
|
||||
UNUSED_PARAM(visitor);
|
||||
}
|
||||
|
||||
@@ -58,11 +73,41 @@ template void JSBuiltinInternalFunctions::visit(SlotVisitor&);
|
||||
SUPPRESS_ASAN void JSBuiltinInternalFunctions::initialize(JSDOMGlobalObject& globalObject)
|
||||
{
|
||||
UNUSED_PARAM(globalObject);
|
||||
m_readableByteStreamInternals.init(globalObject);
|
||||
m_readableStreamInternals.init(globalObject);
|
||||
m_streamInternals.init(globalObject);
|
||||
m_transformStreamInternals.init(globalObject);
|
||||
m_writableStreamInternals.init(globalObject);
|
||||
|
||||
JSVMClientData& clientData = *static_cast<JSVMClientData*>(m_vm.clientData);
|
||||
JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = {
|
||||
#define DECLARE_GLOBAL_STATIC(name) \
|
||||
JSDOMGlobalObject::GlobalPropertyInfo( \
|
||||
clientData.builtinFunctions().readableByteStreamInternalsBuiltins().name##PrivateName(), readableByteStreamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
|
||||
WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
|
||||
#undef DECLARE_GLOBAL_STATIC
|
||||
#define DECLARE_GLOBAL_STATIC(name) \
|
||||
JSDOMGlobalObject::GlobalPropertyInfo( \
|
||||
clientData.builtinFunctions().readableStreamInternalsBuiltins().name##PrivateName(), readableStreamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
|
||||
WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
|
||||
#undef DECLARE_GLOBAL_STATIC
|
||||
#define DECLARE_GLOBAL_STATIC(name) \
|
||||
JSDOMGlobalObject::GlobalPropertyInfo( \
|
||||
clientData.builtinFunctions().streamInternalsBuiltins().name##PrivateName(), streamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
|
||||
WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
|
||||
#undef DECLARE_GLOBAL_STATIC
|
||||
#define DECLARE_GLOBAL_STATIC(name) \
|
||||
JSDOMGlobalObject::GlobalPropertyInfo( \
|
||||
clientData.builtinFunctions().transformStreamInternalsBuiltins().name##PrivateName(), transformStreamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
|
||||
WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
|
||||
#undef DECLARE_GLOBAL_STATIC
|
||||
#define DECLARE_GLOBAL_STATIC(name) \
|
||||
JSDOMGlobalObject::GlobalPropertyInfo( \
|
||||
clientData.builtinFunctions().writableStreamInternalsBuiltins().name##PrivateName(), writableStreamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
|
||||
#undef DECLARE_GLOBAL_STATIC
|
||||
};
|
||||
//globalObject.addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
|
||||
globalObject.addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
|
||||
UNUSED_PARAM(clientData);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//clang-format off
|
||||
namespace Zig { class GlobalObject; }
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -32,6 +37,11 @@ namespace Zig { class GlobalObject; }
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ReadableByteStreamInternalsBuiltins.h"
|
||||
#include "ReadableStreamInternalsBuiltins.h"
|
||||
#include "StreamInternalsBuiltins.h"
|
||||
#include "TransformStreamInternalsBuiltins.h"
|
||||
#include "WritableStreamInternalsBuiltins.h"
|
||||
#include <JavaScriptCore/VM.h>
|
||||
#include <JavaScriptCore/WeakInlines.h>
|
||||
|
||||
@@ -46,9 +56,19 @@ public:
|
||||
template<typename Visitor> void visit(Visitor&);
|
||||
void initialize(JSDOMGlobalObject&);
|
||||
|
||||
ReadableByteStreamInternalsBuiltinFunctions& readableByteStreamInternals() { return m_readableByteStreamInternals; }
|
||||
ReadableStreamInternalsBuiltinFunctions& readableStreamInternals() { return m_readableStreamInternals; }
|
||||
StreamInternalsBuiltinFunctions& streamInternals() { return m_streamInternals; }
|
||||
TransformStreamInternalsBuiltinFunctions& transformStreamInternals() { return m_transformStreamInternals; }
|
||||
WritableStreamInternalsBuiltinFunctions& writableStreamInternals() { return m_writableStreamInternals; }
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
ReadableByteStreamInternalsBuiltinFunctions m_readableByteStreamInternals;
|
||||
ReadableStreamInternalsBuiltinFunctions m_readableStreamInternals;
|
||||
StreamInternalsBuiltinFunctions m_streamInternals;
|
||||
TransformStreamInternalsBuiltinFunctions m_transformStreamInternals;
|
||||
WritableStreamInternalsBuiltinFunctions m_writableStreamInternals;
|
||||
};
|
||||
|
||||
} // namespace WebCore
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,9 +35,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ByteLengthQueuingStrategyBuiltins.h"
|
||||
#include "CountQueuingStrategyBuiltins.h"
|
||||
#include "JSBufferConstructorBuiltins.h"
|
||||
#include "JSBufferPrototypeBuiltins.h"
|
||||
#include "JSZigGlobalObjectBuiltins.h"
|
||||
#include "ReadableByteStreamControllerBuiltins.h"
|
||||
#include "ReadableByteStreamInternalsBuiltins.h"
|
||||
#include "ReadableStreamBYOBReaderBuiltins.h"
|
||||
#include "ReadableStreamBYOBRequestBuiltins.h"
|
||||
#include "ReadableStreamBuiltins.h"
|
||||
#include "ReadableStreamDefaultControllerBuiltins.h"
|
||||
#include "ReadableStreamDefaultReaderBuiltins.h"
|
||||
#include "ReadableStreamInternalsBuiltins.h"
|
||||
#include "StreamInternalsBuiltins.h"
|
||||
#include "TransformStreamBuiltins.h"
|
||||
#include "TransformStreamDefaultControllerBuiltins.h"
|
||||
#include "TransformStreamInternalsBuiltins.h"
|
||||
#include "WritableStreamDefaultControllerBuiltins.h"
|
||||
#include "WritableStreamDefaultWriterBuiltins.h"
|
||||
#include "WritableStreamInternalsBuiltins.h"
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
@@ -41,21 +63,77 @@ class JSBuiltinFunctions {
|
||||
public:
|
||||
explicit JSBuiltinFunctions(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
, m_byteLengthQueuingStrategyBuiltins(m_vm)
|
||||
, m_countQueuingStrategyBuiltins(m_vm)
|
||||
, m_jsBufferConstructorBuiltins(m_vm)
|
||||
, m_jsBufferPrototypeBuiltins(m_vm)
|
||||
, m_jsZigGlobalObjectBuiltins(m_vm)
|
||||
, m_readableByteStreamControllerBuiltins(m_vm)
|
||||
, m_readableByteStreamInternalsBuiltins(m_vm)
|
||||
, m_readableStreamBuiltins(m_vm)
|
||||
, m_readableStreamBYOBReaderBuiltins(m_vm)
|
||||
, m_readableStreamBYOBRequestBuiltins(m_vm)
|
||||
, m_readableStreamDefaultControllerBuiltins(m_vm)
|
||||
, m_readableStreamDefaultReaderBuiltins(m_vm)
|
||||
, m_readableStreamInternalsBuiltins(m_vm)
|
||||
, m_streamInternalsBuiltins(m_vm)
|
||||
, m_transformStreamBuiltins(m_vm)
|
||||
, m_transformStreamDefaultControllerBuiltins(m_vm)
|
||||
, m_transformStreamInternalsBuiltins(m_vm)
|
||||
, m_writableStreamDefaultControllerBuiltins(m_vm)
|
||||
, m_writableStreamDefaultWriterBuiltins(m_vm)
|
||||
, m_writableStreamInternalsBuiltins(m_vm)
|
||||
{
|
||||
m_readableByteStreamInternalsBuiltins.exportNames();
|
||||
m_readableStreamInternalsBuiltins.exportNames();
|
||||
m_streamInternalsBuiltins.exportNames();
|
||||
m_transformStreamInternalsBuiltins.exportNames();
|
||||
m_writableStreamInternalsBuiltins.exportNames();
|
||||
}
|
||||
|
||||
ByteLengthQueuingStrategyBuiltinsWrapper& byteLengthQueuingStrategyBuiltins() { return m_byteLengthQueuingStrategyBuiltins; }
|
||||
CountQueuingStrategyBuiltinsWrapper& countQueuingStrategyBuiltins() { return m_countQueuingStrategyBuiltins; }
|
||||
JSBufferConstructorBuiltinsWrapper& jsBufferConstructorBuiltins() { return m_jsBufferConstructorBuiltins; }
|
||||
JSBufferPrototypeBuiltinsWrapper& jsBufferPrototypeBuiltins() { return m_jsBufferPrototypeBuiltins; }
|
||||
JSZigGlobalObjectBuiltinsWrapper& jsZigGlobalObjectBuiltins() { return m_jsZigGlobalObjectBuiltins; }
|
||||
ReadableByteStreamControllerBuiltinsWrapper& readableByteStreamControllerBuiltins() { return m_readableByteStreamControllerBuiltins; }
|
||||
ReadableByteStreamInternalsBuiltinsWrapper& readableByteStreamInternalsBuiltins() { return m_readableByteStreamInternalsBuiltins; }
|
||||
ReadableStreamBuiltinsWrapper& readableStreamBuiltins() { return m_readableStreamBuiltins; }
|
||||
ReadableStreamBYOBReaderBuiltinsWrapper& readableStreamBYOBReaderBuiltins() { return m_readableStreamBYOBReaderBuiltins; }
|
||||
ReadableStreamBYOBRequestBuiltinsWrapper& readableStreamBYOBRequestBuiltins() { return m_readableStreamBYOBRequestBuiltins; }
|
||||
ReadableStreamDefaultControllerBuiltinsWrapper& readableStreamDefaultControllerBuiltins() { return m_readableStreamDefaultControllerBuiltins; }
|
||||
ReadableStreamDefaultReaderBuiltinsWrapper& readableStreamDefaultReaderBuiltins() { return m_readableStreamDefaultReaderBuiltins; }
|
||||
ReadableStreamInternalsBuiltinsWrapper& readableStreamInternalsBuiltins() { return m_readableStreamInternalsBuiltins; }
|
||||
StreamInternalsBuiltinsWrapper& streamInternalsBuiltins() { return m_streamInternalsBuiltins; }
|
||||
TransformStreamBuiltinsWrapper& transformStreamBuiltins() { return m_transformStreamBuiltins; }
|
||||
TransformStreamDefaultControllerBuiltinsWrapper& transformStreamDefaultControllerBuiltins() { return m_transformStreamDefaultControllerBuiltins; }
|
||||
TransformStreamInternalsBuiltinsWrapper& transformStreamInternalsBuiltins() { return m_transformStreamInternalsBuiltins; }
|
||||
WritableStreamDefaultControllerBuiltinsWrapper& writableStreamDefaultControllerBuiltins() { return m_writableStreamDefaultControllerBuiltins; }
|
||||
WritableStreamDefaultWriterBuiltinsWrapper& writableStreamDefaultWriterBuiltins() { return m_writableStreamDefaultWriterBuiltins; }
|
||||
WritableStreamInternalsBuiltinsWrapper& writableStreamInternalsBuiltins() { return m_writableStreamInternalsBuiltins; }
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
ByteLengthQueuingStrategyBuiltinsWrapper m_byteLengthQueuingStrategyBuiltins;
|
||||
CountQueuingStrategyBuiltinsWrapper m_countQueuingStrategyBuiltins;
|
||||
JSBufferConstructorBuiltinsWrapper m_jsBufferConstructorBuiltins;
|
||||
JSBufferPrototypeBuiltinsWrapper m_jsBufferPrototypeBuiltins;
|
||||
JSZigGlobalObjectBuiltinsWrapper m_jsZigGlobalObjectBuiltins;
|
||||
ReadableByteStreamControllerBuiltinsWrapper m_readableByteStreamControllerBuiltins;
|
||||
ReadableByteStreamInternalsBuiltinsWrapper m_readableByteStreamInternalsBuiltins;
|
||||
ReadableStreamBuiltinsWrapper m_readableStreamBuiltins;
|
||||
ReadableStreamBYOBReaderBuiltinsWrapper m_readableStreamBYOBReaderBuiltins;
|
||||
ReadableStreamBYOBRequestBuiltinsWrapper m_readableStreamBYOBRequestBuiltins;
|
||||
ReadableStreamDefaultControllerBuiltinsWrapper m_readableStreamDefaultControllerBuiltins;
|
||||
ReadableStreamDefaultReaderBuiltinsWrapper m_readableStreamDefaultReaderBuiltins;
|
||||
ReadableStreamInternalsBuiltinsWrapper m_readableStreamInternalsBuiltins;
|
||||
StreamInternalsBuiltinsWrapper m_streamInternalsBuiltins;
|
||||
TransformStreamBuiltinsWrapper m_transformStreamBuiltins;
|
||||
TransformStreamDefaultControllerBuiltinsWrapper m_transformStreamDefaultControllerBuiltins;
|
||||
TransformStreamInternalsBuiltinsWrapper m_transformStreamInternalsBuiltins;
|
||||
WritableStreamDefaultControllerBuiltinsWrapper m_writableStreamDefaultControllerBuiltins;
|
||||
WritableStreamDefaultWriterBuiltinsWrapper m_writableStreamDefaultWriterBuiltins;
|
||||
WritableStreamInternalsBuiltinsWrapper m_writableStreamInternalsBuiltins;
|
||||
};
|
||||
|
||||
} // namespace WebCore
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "WritableStreamDefaultControllerBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeLength = 482;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(this, \"queue\", @newQueue());\n" \
|
||||
" @putByIdDirectPrivate(this, \"abortSteps\", (reason) => {\n" \
|
||||
" const result = @getByIdDirectPrivate(this, \"abortAlgorithm\").@call(@undefined, reason);\n" \
|
||||
" @writableStreamDefaultControllerClearAlgorithms(this);\n" \
|
||||
" return result;\n" \
|
||||
" });\n" \
|
||||
"\n" \
|
||||
" @putByIdDirectPrivate(this, \"errorSteps\", () => {\n" \
|
||||
" @resetQueue(@getByIdDirectPrivate(this, \"queue\"));\n" \
|
||||
" });\n" \
|
||||
"\n" \
|
||||
" return this;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultControllerErrorCodeLength = 372;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultControllerErrorCode =
|
||||
"(function (e)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"abortSteps\") === @undefined)\n" \
|
||||
" throw @makeThisTypeError(\"WritableStreamDefaultController\", \"error\");\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(this, \"stream\");\n" \
|
||||
" if (@getByIdDirectPrivate(stream, \"state\") !== \"writable\")\n" \
|
||||
" return;\n" \
|
||||
" @writableStreamDefaultControllerError(this, e);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().writableStreamDefaultControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().writableStreamDefaultControllerBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* WritableStreamDefaultController */
|
||||
extern const char* const s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCode;
|
||||
extern const int s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_writableStreamDefaultControllerErrorCode;
|
||||
extern const int s_writableStreamDefaultControllerErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultControllerErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_DATA(macro) \
|
||||
macro(initializeWritableStreamDefaultController, writableStreamDefaultControllerInitializeWritableStreamDefaultController, 0) \
|
||||
macro(error, writableStreamDefaultControllerError, 1) \
|
||||
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTCONTROLLER_INITIALIZEWRITABLESTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTCONTROLLER_ERROR 1
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(macro) \
|
||||
macro(writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCode, initializeWritableStreamDefaultController, ASCIILiteral(), s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeLength) \
|
||||
macro(writableStreamDefaultControllerErrorCode, error, ASCIILiteral(), s_writableStreamDefaultControllerErrorCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(error) \
|
||||
macro(initializeWritableStreamDefaultController) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class WritableStreamDefaultControllerBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit WritableStreamDefaultControllerBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* WritableStreamDefaultControllerBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void WritableStreamDefaultControllerBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "WritableStreamDefaultWriterBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeLength = 376;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCode =
|
||||
"(function (stream)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" //\n" \
|
||||
" //\n" \
|
||||
" const internalStream = @getInternalWritableStream(stream);\n" \
|
||||
" if (internalStream)\n" \
|
||||
" stream = internalStream;\n" \
|
||||
"\n" \
|
||||
" if (!@isWritableStream(stream))\n" \
|
||||
" @throwTypeError(\"WritableStreamDefaultWriter constructor takes a WritableStream\");\n" \
|
||||
"\n" \
|
||||
" @setUpWritableStreamDefaultWriter(this, stream);\n" \
|
||||
" return this;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultWriterClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultWriterClosedCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultWriterClosedCodeLength = 247;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultWriterClosedCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultWriterClosedCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isWritableStreamDefaultWriter(this))\n" \
|
||||
" return @Promise.@reject(@makeGetterTypeError(\"WritableStreamDefaultWriter\", \"closed\"));\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(this, \"closedPromise\").@promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultWriterDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultWriterDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultWriterDesiredSizeCodeLength = 359;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultWriterDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultWriterDesiredSizeCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isWritableStreamDefaultWriter(this))\n" \
|
||||
" throw @makeThisTypeError(\"WritableStreamDefaultWriter\", \"desiredSize\");\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"stream\") === @undefined)\n" \
|
||||
" @throwTypeError(\"WritableStreamDefaultWriter has no stream\");\n" \
|
||||
"\n" \
|
||||
" return @writableStreamDefaultWriterGetDesiredSize(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultWriterReadyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultWriterReadyCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultWriterReadyCodeLength = 243;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultWriterReadyCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultWriterReadyCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isWritableStreamDefaultWriter(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\", \"ready\"));\n" \
|
||||
"\n" \
|
||||
" return @getByIdDirectPrivate(this, \"readyPromise\").@promise;\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultWriterAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultWriterAbortCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultWriterAbortCodeLength = 401;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultWriterAbortCode =
|
||||
"(function (reason)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isWritableStreamDefaultWriter(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\", \"abort\"));\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"stream\") === @undefined)\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter has no stream\"));\n" \
|
||||
"\n" \
|
||||
" return @writableStreamDefaultWriterAbort(this, reason);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultWriterCloseCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultWriterCloseCodeLength = 569;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultWriterCloseCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isWritableStreamDefaultWriter(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\", \"close\"));\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(this, \"stream\");\n" \
|
||||
" if (stream === @undefined)\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter has no stream\"));\n" \
|
||||
"\n" \
|
||||
" if (@writableStreamCloseQueuedOrInFlight(stream))\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter is being closed\"));\n" \
|
||||
" \n" \
|
||||
" return @writableStreamDefaultWriterClose(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultWriterReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultWriterReleaseLockCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultWriterReleaseLockCodeLength = 387;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultWriterReleaseLockCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultWriterReleaseLockCode =
|
||||
"(function ()\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isWritableStreamDefaultWriter(this))\n" \
|
||||
" throw @makeThisTypeError(\"WritableStreamDefaultWriter\", \"releaseLock\");\n" \
|
||||
"\n" \
|
||||
" const stream = @getByIdDirectPrivate(this, \"stream\");\n" \
|
||||
" if (stream === @undefined)\n" \
|
||||
" return;\n" \
|
||||
"\n" \
|
||||
" @assert(@getByIdDirectPrivate(stream, \"writer\") !== @undefined);\n" \
|
||||
" @writableStreamDefaultWriterRelease(this);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_writableStreamDefaultWriterWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_writableStreamDefaultWriterWriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_writableStreamDefaultWriterWriteCodeLength = 399;
|
||||
static const JSC::Intrinsic s_writableStreamDefaultWriterWriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_writableStreamDefaultWriterWriteCode =
|
||||
"(function (chunk)\n" \
|
||||
"{\n" \
|
||||
" \"use strict\";\n" \
|
||||
"\n" \
|
||||
" if (!@isWritableStreamDefaultWriter(this))\n" \
|
||||
" return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\", \"write\"));\n" \
|
||||
"\n" \
|
||||
" if (@getByIdDirectPrivate(this, \"stream\") === @undefined)\n" \
|
||||
" return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter has no stream\"));\n" \
|
||||
"\n" \
|
||||
" return @writableStreamDefaultWriterWrite(this, chunk);\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
|
||||
#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
|
||||
{\
|
||||
JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
|
||||
return clientData->builtinFunctions().writableStreamDefaultWriterBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().writableStreamDefaultWriterBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
|
||||
}
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
|
||||
#undef DEFINE_BUILTIN_GENERATOR
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* WritableStreamDefaultWriter */
|
||||
extern const char* const s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCode;
|
||||
extern const int s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructorKind;
|
||||
extern const char* const s_writableStreamDefaultWriterClosedCode;
|
||||
extern const int s_writableStreamDefaultWriterClosedCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultWriterClosedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultWriterClosedCodeConstructorKind;
|
||||
extern const char* const s_writableStreamDefaultWriterDesiredSizeCode;
|
||||
extern const int s_writableStreamDefaultWriterDesiredSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultWriterDesiredSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultWriterDesiredSizeCodeConstructorKind;
|
||||
extern const char* const s_writableStreamDefaultWriterReadyCode;
|
||||
extern const int s_writableStreamDefaultWriterReadyCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultWriterReadyCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultWriterReadyCodeConstructorKind;
|
||||
extern const char* const s_writableStreamDefaultWriterAbortCode;
|
||||
extern const int s_writableStreamDefaultWriterAbortCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultWriterAbortCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultWriterAbortCodeConstructorKind;
|
||||
extern const char* const s_writableStreamDefaultWriterCloseCode;
|
||||
extern const int s_writableStreamDefaultWriterCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultWriterCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultWriterCloseCodeConstructorKind;
|
||||
extern const char* const s_writableStreamDefaultWriterReleaseLockCode;
|
||||
extern const int s_writableStreamDefaultWriterReleaseLockCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultWriterReleaseLockCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultWriterReleaseLockCodeConstructorKind;
|
||||
extern const char* const s_writableStreamDefaultWriterWriteCode;
|
||||
extern const int s_writableStreamDefaultWriterWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamDefaultWriterWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamDefaultWriterWriteCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_DATA(macro) \
|
||||
macro(initializeWritableStreamDefaultWriter, writableStreamDefaultWriterInitializeWritableStreamDefaultWriter, 1) \
|
||||
macro(closed, writableStreamDefaultWriterClosed, 0) \
|
||||
macro(desiredSize, writableStreamDefaultWriterDesiredSize, 0) \
|
||||
macro(ready, writableStreamDefaultWriterReady, 0) \
|
||||
macro(abort, writableStreamDefaultWriterAbort, 1) \
|
||||
macro(close, writableStreamDefaultWriterClose, 0) \
|
||||
macro(releaseLock, writableStreamDefaultWriterReleaseLock, 0) \
|
||||
macro(write, writableStreamDefaultWriterWrite, 1) \
|
||||
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_INITIALIZEWRITABLESTREAMDEFAULTWRITER 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_CLOSED 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_DESIREDSIZE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_READY 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_ABORT 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_CLOSE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_RELEASELOCK 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_WRITE 1
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(macro) \
|
||||
macro(writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCode, initializeWritableStreamDefaultWriter, ASCIILiteral(), s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeLength) \
|
||||
macro(writableStreamDefaultWriterClosedCode, closed, "get closed"_s, s_writableStreamDefaultWriterClosedCodeLength) \
|
||||
macro(writableStreamDefaultWriterDesiredSizeCode, desiredSize, "get desiredSize"_s, s_writableStreamDefaultWriterDesiredSizeCodeLength) \
|
||||
macro(writableStreamDefaultWriterReadyCode, ready, "get ready"_s, s_writableStreamDefaultWriterReadyCodeLength) \
|
||||
macro(writableStreamDefaultWriterAbortCode, abort, ASCIILiteral(), s_writableStreamDefaultWriterAbortCodeLength) \
|
||||
macro(writableStreamDefaultWriterCloseCode, close, ASCIILiteral(), s_writableStreamDefaultWriterCloseCodeLength) \
|
||||
macro(writableStreamDefaultWriterReleaseLockCode, releaseLock, ASCIILiteral(), s_writableStreamDefaultWriterReleaseLockCodeLength) \
|
||||
macro(writableStreamDefaultWriterWriteCode, write, ASCIILiteral(), s_writableStreamDefaultWriterWriteCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(abort) \
|
||||
macro(close) \
|
||||
macro(closed) \
|
||||
macro(desiredSize) \
|
||||
macro(initializeWritableStreamDefaultWriter) \
|
||||
macro(ready) \
|
||||
macro(releaseLock) \
|
||||
macro(write) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class WritableStreamDefaultWriterBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit WritableStreamDefaultWriterBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* WritableStreamDefaultWriterBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void WritableStreamDefaultWriterBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
1103
src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.cpp
Normal file
1103
src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.cpp
Normal file
File diff suppressed because it is too large
Load Diff
540
src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.h
Normal file
540
src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.h
Normal file
@@ -0,0 +1,540 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Igalia
|
||||
* Copyright (c) 2015 Igalia S.L.
|
||||
* Copyright (c) 2015 Igalia.
|
||||
* Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 2017 Canon Inc.
|
||||
* Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* WritableStreamInternals */
|
||||
extern const char* const s_writableStreamInternalsIsWritableStreamCode;
|
||||
extern const int s_writableStreamInternalsIsWritableStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsIsWritableStreamDefaultWriterCode;
|
||||
extern const int s_writableStreamInternalsIsWritableStreamDefaultWriterCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamDefaultWriterCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamDefaultWriterCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsAcquireWritableStreamDefaultWriterCode;
|
||||
extern const int s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsCreateWritableStreamCode;
|
||||
extern const int s_writableStreamInternalsCreateWritableStreamCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsCreateWritableStreamCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode;
|
||||
extern const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsInitializeWritableStreamSlotsCode;
|
||||
extern const int s_writableStreamInternalsInitializeWritableStreamSlotsCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamCloseForBindingsCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamCloseForBindingsCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseForBindingsCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseForBindingsCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamAbortForBindingsCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamAbortForBindingsCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortForBindingsCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortForBindingsCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsIsWritableStreamLockedCode;
|
||||
extern const int s_writableStreamInternalsIsWritableStreamLockedCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamLockedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamLockedCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode;
|
||||
extern const int s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamAbortCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamAbortCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamCloseCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDealWithRejectionCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithRejectionCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamFinishErroringCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamFinishErroringCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishErroringCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamStartErroringCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamStartErroringCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamStartErroringCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode;
|
||||
extern const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode;
|
||||
extern const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsIsCloseSentinelCode;
|
||||
extern const int s_writableStreamInternalsIsCloseSentinelCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsIsCloseSentinelCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsIsCloseSentinelCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerCloseCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructorKind;
|
||||
extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode;
|
||||
extern const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructorKind;
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_DATA(macro) \
|
||||
macro(isWritableStream, writableStreamInternalsIsWritableStream, 1) \
|
||||
macro(isWritableStreamDefaultWriter, writableStreamInternalsIsWritableStreamDefaultWriter, 1) \
|
||||
macro(acquireWritableStreamDefaultWriter, writableStreamInternalsAcquireWritableStreamDefaultWriter, 1) \
|
||||
macro(createWritableStream, writableStreamInternalsCreateWritableStream, 6) \
|
||||
macro(createInternalWritableStreamFromUnderlyingSink, writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSink, 2) \
|
||||
macro(initializeWritableStreamSlots, writableStreamInternalsInitializeWritableStreamSlots, 2) \
|
||||
macro(writableStreamCloseForBindings, writableStreamInternalsWritableStreamCloseForBindings, 1) \
|
||||
macro(writableStreamAbortForBindings, writableStreamInternalsWritableStreamAbortForBindings, 2) \
|
||||
macro(isWritableStreamLocked, writableStreamInternalsIsWritableStreamLocked, 1) \
|
||||
macro(setUpWritableStreamDefaultWriter, writableStreamInternalsSetUpWritableStreamDefaultWriter, 2) \
|
||||
macro(writableStreamAbort, writableStreamInternalsWritableStreamAbort, 2) \
|
||||
macro(writableStreamClose, writableStreamInternalsWritableStreamClose, 1) \
|
||||
macro(writableStreamAddWriteRequest, writableStreamInternalsWritableStreamAddWriteRequest, 1) \
|
||||
macro(writableStreamCloseQueuedOrInFlight, writableStreamInternalsWritableStreamCloseQueuedOrInFlight, 1) \
|
||||
macro(writableStreamDealWithRejection, writableStreamInternalsWritableStreamDealWithRejection, 2) \
|
||||
macro(writableStreamFinishErroring, writableStreamInternalsWritableStreamFinishErroring, 1) \
|
||||
macro(writableStreamFinishInFlightClose, writableStreamInternalsWritableStreamFinishInFlightClose, 1) \
|
||||
macro(writableStreamFinishInFlightCloseWithError, writableStreamInternalsWritableStreamFinishInFlightCloseWithError, 2) \
|
||||
macro(writableStreamFinishInFlightWrite, writableStreamInternalsWritableStreamFinishInFlightWrite, 1) \
|
||||
macro(writableStreamFinishInFlightWriteWithError, writableStreamInternalsWritableStreamFinishInFlightWriteWithError, 2) \
|
||||
macro(writableStreamHasOperationMarkedInFlight, writableStreamInternalsWritableStreamHasOperationMarkedInFlight, 1) \
|
||||
macro(writableStreamMarkCloseRequestInFlight, writableStreamInternalsWritableStreamMarkCloseRequestInFlight, 1) \
|
||||
macro(writableStreamMarkFirstWriteRequestInFlight, writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlight, 1) \
|
||||
macro(writableStreamRejectCloseAndClosedPromiseIfNeeded, writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeeded, 1) \
|
||||
macro(writableStreamStartErroring, writableStreamInternalsWritableStreamStartErroring, 2) \
|
||||
macro(writableStreamUpdateBackpressure, writableStreamInternalsWritableStreamUpdateBackpressure, 2) \
|
||||
macro(writableStreamDefaultWriterAbort, writableStreamInternalsWritableStreamDefaultWriterAbort, 2) \
|
||||
macro(writableStreamDefaultWriterClose, writableStreamInternalsWritableStreamDefaultWriterClose, 1) \
|
||||
macro(writableStreamDefaultWriterCloseWithErrorPropagation, writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagation, 1) \
|
||||
macro(writableStreamDefaultWriterEnsureClosedPromiseRejected, writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejected, 2) \
|
||||
macro(writableStreamDefaultWriterEnsureReadyPromiseRejected, writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejected, 2) \
|
||||
macro(writableStreamDefaultWriterGetDesiredSize, writableStreamInternalsWritableStreamDefaultWriterGetDesiredSize, 1) \
|
||||
macro(writableStreamDefaultWriterRelease, writableStreamInternalsWritableStreamDefaultWriterRelease, 1) \
|
||||
macro(writableStreamDefaultWriterWrite, writableStreamInternalsWritableStreamDefaultWriterWrite, 2) \
|
||||
macro(setUpWritableStreamDefaultController, writableStreamInternalsSetUpWritableStreamDefaultController, 8) \
|
||||
macro(setUpWritableStreamDefaultControllerFromUnderlyingSink, writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSink, 5) \
|
||||
macro(writableStreamDefaultControllerAdvanceQueueIfNeeded, writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeeded, 1) \
|
||||
macro(isCloseSentinel, writableStreamInternalsIsCloseSentinel, 0) \
|
||||
macro(writableStreamDefaultControllerClearAlgorithms, writableStreamInternalsWritableStreamDefaultControllerClearAlgorithms, 1) \
|
||||
macro(writableStreamDefaultControllerClose, writableStreamInternalsWritableStreamDefaultControllerClose, 1) \
|
||||
macro(writableStreamDefaultControllerError, writableStreamInternalsWritableStreamDefaultControllerError, 2) \
|
||||
macro(writableStreamDefaultControllerErrorIfNeeded, writableStreamInternalsWritableStreamDefaultControllerErrorIfNeeded, 2) \
|
||||
macro(writableStreamDefaultControllerGetBackpressure, writableStreamInternalsWritableStreamDefaultControllerGetBackpressure, 1) \
|
||||
macro(writableStreamDefaultControllerGetChunkSize, writableStreamInternalsWritableStreamDefaultControllerGetChunkSize, 2) \
|
||||
macro(writableStreamDefaultControllerGetDesiredSize, writableStreamInternalsWritableStreamDefaultControllerGetDesiredSize, 1) \
|
||||
macro(writableStreamDefaultControllerProcessClose, writableStreamInternalsWritableStreamDefaultControllerProcessClose, 1) \
|
||||
macro(writableStreamDefaultControllerProcessWrite, writableStreamInternalsWritableStreamDefaultControllerProcessWrite, 2) \
|
||||
macro(writableStreamDefaultControllerWrite, writableStreamInternalsWritableStreamDefaultControllerWrite, 3) \
|
||||
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAM 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAMDEFAULTWRITER 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ACQUIREWRITABLESTREAMDEFAULTWRITER 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_CREATEWRITABLESTREAM 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_CREATEINTERNALWRITABLESTREAMFROMUNDERLYINGSINK 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_INITIALIZEWRITABLESTREAMSLOTS 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSEFORBINDINGS 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMABORTFORBINDINGS 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAMLOCKED 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTWRITER 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMABORT 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMADDWRITEREQUEST 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSEQUEUEDORINFLIGHT 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEALWITHREJECTION 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHERRORING 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTCLOSE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTCLOSEWITHERROR 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTWRITE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTWRITEWITHERROR 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMHASOPERATIONMARKEDINFLIGHT 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMMARKCLOSEREQUESTINFLIGHT 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMMARKFIRSTWRITEREQUESTINFLIGHT 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMREJECTCLOSEANDCLOSEDPROMISEIFNEEDED 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMSTARTERRORING 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMUPDATEBACKPRESSURE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERABORT 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERCLOSE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERCLOSEWITHERRORPROPAGATION 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERENSURECLOSEDPROMISEREJECTED 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERENSUREREADYPROMISEREJECTED 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERGETDESIREDSIZE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERRELEASE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERWRITE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTCONTROLLER 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTCONTROLLERFROMUNDERLYINGSINK 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERADVANCEQUEUEIFNEEDED 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISCLOSESENTINEL 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERCLEARALGORITHMS 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERCLOSE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERERROR 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERERRORIFNEEDED 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETBACKPRESSURE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETCHUNKSIZE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETDESIREDSIZE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERPROCESSCLOSE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERPROCESSWRITE 1
|
||||
#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERWRITE 1
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(macro) \
|
||||
macro(writableStreamInternalsIsWritableStreamCode, isWritableStream, ASCIILiteral(), s_writableStreamInternalsIsWritableStreamCodeLength) \
|
||||
macro(writableStreamInternalsIsWritableStreamDefaultWriterCode, isWritableStreamDefaultWriter, ASCIILiteral(), s_writableStreamInternalsIsWritableStreamDefaultWriterCodeLength) \
|
||||
macro(writableStreamInternalsAcquireWritableStreamDefaultWriterCode, acquireWritableStreamDefaultWriter, ASCIILiteral(), s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeLength) \
|
||||
macro(writableStreamInternalsCreateWritableStreamCode, createWritableStream, ASCIILiteral(), s_writableStreamInternalsCreateWritableStreamCodeLength) \
|
||||
macro(writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode, createInternalWritableStreamFromUnderlyingSink, ASCIILiteral(), s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength) \
|
||||
macro(writableStreamInternalsInitializeWritableStreamSlotsCode, initializeWritableStreamSlots, ASCIILiteral(), s_writableStreamInternalsInitializeWritableStreamSlotsCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamCloseForBindingsCode, writableStreamCloseForBindings, ASCIILiteral(), s_writableStreamInternalsWritableStreamCloseForBindingsCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamAbortForBindingsCode, writableStreamAbortForBindings, ASCIILiteral(), s_writableStreamInternalsWritableStreamAbortForBindingsCodeLength) \
|
||||
macro(writableStreamInternalsIsWritableStreamLockedCode, isWritableStreamLocked, ASCIILiteral(), s_writableStreamInternalsIsWritableStreamLockedCodeLength) \
|
||||
macro(writableStreamInternalsSetUpWritableStreamDefaultWriterCode, setUpWritableStreamDefaultWriter, ASCIILiteral(), s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamAbortCode, writableStreamAbort, ASCIILiteral(), s_writableStreamInternalsWritableStreamAbortCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamCloseCode, writableStreamClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamCloseCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamAddWriteRequestCode, writableStreamAddWriteRequest, ASCIILiteral(), s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamCloseQueuedOrInFlightCode, writableStreamCloseQueuedOrInFlight, ASCIILiteral(), s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDealWithRejectionCode, writableStreamDealWithRejection, ASCIILiteral(), s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamFinishErroringCode, writableStreamFinishErroring, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishErroringCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamFinishInFlightCloseCode, writableStreamFinishInFlightClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode, writableStreamFinishInFlightCloseWithError, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamFinishInFlightWriteCode, writableStreamFinishInFlightWrite, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode, writableStreamFinishInFlightWriteWithError, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamHasOperationMarkedInFlightCode, writableStreamHasOperationMarkedInFlight, ASCIILiteral(), s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamMarkCloseRequestInFlightCode, writableStreamMarkCloseRequestInFlight, ASCIILiteral(), s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode, writableStreamMarkFirstWriteRequestInFlight, ASCIILiteral(), s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode, writableStreamRejectCloseAndClosedPromiseIfNeeded, ASCIILiteral(), s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamStartErroringCode, writableStreamStartErroring, ASCIILiteral(), s_writableStreamInternalsWritableStreamStartErroringCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamUpdateBackpressureCode, writableStreamUpdateBackpressure, ASCIILiteral(), s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultWriterAbortCode, writableStreamDefaultWriterAbort, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultWriterCloseCode, writableStreamDefaultWriterClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode, writableStreamDefaultWriterCloseWithErrorPropagation, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode, writableStreamDefaultWriterEnsureClosedPromiseRejected, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode, writableStreamDefaultWriterEnsureReadyPromiseRejected, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode, writableStreamDefaultWriterGetDesiredSize, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultWriterReleaseCode, writableStreamDefaultWriterRelease, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultWriterWriteCode, writableStreamDefaultWriterWrite, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength) \
|
||||
macro(writableStreamInternalsSetUpWritableStreamDefaultControllerCode, setUpWritableStreamDefaultController, ASCIILiteral(), s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength) \
|
||||
macro(writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode, setUpWritableStreamDefaultControllerFromUnderlyingSink, ASCIILiteral(), s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode, writableStreamDefaultControllerAdvanceQueueIfNeeded, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength) \
|
||||
macro(writableStreamInternalsIsCloseSentinelCode, isCloseSentinel, ASCIILiteral(), s_writableStreamInternalsIsCloseSentinelCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCode, writableStreamDefaultControllerClearAlgorithms, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerCloseCode, writableStreamDefaultControllerClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerErrorCode, writableStreamDefaultControllerError, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCode, writableStreamDefaultControllerErrorIfNeeded, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode, writableStreamDefaultControllerGetBackpressure, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode, writableStreamDefaultControllerGetChunkSize, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCode, writableStreamDefaultControllerGetDesiredSize, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode, writableStreamDefaultControllerProcessClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode, writableStreamDefaultControllerProcessWrite, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength) \
|
||||
macro(writableStreamInternalsWritableStreamDefaultControllerWriteCode, writableStreamDefaultControllerWrite, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength) \
|
||||
|
||||
#define WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
|
||||
macro(acquireWritableStreamDefaultWriter) \
|
||||
macro(createInternalWritableStreamFromUnderlyingSink) \
|
||||
macro(createWritableStream) \
|
||||
macro(initializeWritableStreamSlots) \
|
||||
macro(isCloseSentinel) \
|
||||
macro(isWritableStream) \
|
||||
macro(isWritableStreamDefaultWriter) \
|
||||
macro(isWritableStreamLocked) \
|
||||
macro(setUpWritableStreamDefaultController) \
|
||||
macro(setUpWritableStreamDefaultControllerFromUnderlyingSink) \
|
||||
macro(setUpWritableStreamDefaultWriter) \
|
||||
macro(writableStreamAbort) \
|
||||
macro(writableStreamAbortForBindings) \
|
||||
macro(writableStreamAddWriteRequest) \
|
||||
macro(writableStreamClose) \
|
||||
macro(writableStreamCloseForBindings) \
|
||||
macro(writableStreamCloseQueuedOrInFlight) \
|
||||
macro(writableStreamDealWithRejection) \
|
||||
macro(writableStreamDefaultControllerAdvanceQueueIfNeeded) \
|
||||
macro(writableStreamDefaultControllerClearAlgorithms) \
|
||||
macro(writableStreamDefaultControllerClose) \
|
||||
macro(writableStreamDefaultControllerError) \
|
||||
macro(writableStreamDefaultControllerErrorIfNeeded) \
|
||||
macro(writableStreamDefaultControllerGetBackpressure) \
|
||||
macro(writableStreamDefaultControllerGetChunkSize) \
|
||||
macro(writableStreamDefaultControllerGetDesiredSize) \
|
||||
macro(writableStreamDefaultControllerProcessClose) \
|
||||
macro(writableStreamDefaultControllerProcessWrite) \
|
||||
macro(writableStreamDefaultControllerWrite) \
|
||||
macro(writableStreamDefaultWriterAbort) \
|
||||
macro(writableStreamDefaultWriterClose) \
|
||||
macro(writableStreamDefaultWriterCloseWithErrorPropagation) \
|
||||
macro(writableStreamDefaultWriterEnsureClosedPromiseRejected) \
|
||||
macro(writableStreamDefaultWriterEnsureReadyPromiseRejected) \
|
||||
macro(writableStreamDefaultWriterGetDesiredSize) \
|
||||
macro(writableStreamDefaultWriterRelease) \
|
||||
macro(writableStreamDefaultWriterWrite) \
|
||||
macro(writableStreamFinishErroring) \
|
||||
macro(writableStreamFinishInFlightClose) \
|
||||
macro(writableStreamFinishInFlightCloseWithError) \
|
||||
macro(writableStreamFinishInFlightWrite) \
|
||||
macro(writableStreamFinishInFlightWriteWithError) \
|
||||
macro(writableStreamHasOperationMarkedInFlight) \
|
||||
macro(writableStreamMarkCloseRequestInFlight) \
|
||||
macro(writableStreamMarkFirstWriteRequestInFlight) \
|
||||
macro(writableStreamRejectCloseAndClosedPromiseIfNeeded) \
|
||||
macro(writableStreamStartErroring) \
|
||||
macro(writableStreamUpdateBackpressure) \
|
||||
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
|
||||
JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
|
||||
#undef DECLARE_BUILTIN_GENERATOR
|
||||
|
||||
class WritableStreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
|
||||
public:
|
||||
explicit WritableStreamInternalsBuiltinsWrapper(JSC::VM& vm)
|
||||
: m_vm(vm)
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
|
||||
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
|
||||
{
|
||||
}
|
||||
|
||||
#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
JSC::UnlinkedFunctionExecutable* name##Executable(); \
|
||||
const JSC::SourceCode& name##Source() const { return m_##name##Source; }
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
|
||||
#undef EXPOSE_BUILTIN_EXECUTABLES
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
|
||||
|
||||
void exportNames();
|
||||
|
||||
private:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
|
||||
JSC::SourceCode m_##name##Source;\
|
||||
JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
|
||||
};
|
||||
|
||||
#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
|
||||
inline JSC::UnlinkedFunctionExecutable* WritableStreamInternalsBuiltinsWrapper::name##Executable() \
|
||||
{\
|
||||
if (!m_##name##Executable) {\
|
||||
JSC::Identifier executableName = functionName##PublicName();\
|
||||
if (overriddenName)\
|
||||
executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
|
||||
m_##name##Executable = JSC::Weak<JSC::UnlinkedFunctionExecutable>(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
|
||||
}\
|
||||
return m_##name##Executable.get();\
|
||||
}
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
|
||||
#undef DEFINE_BUILTIN_EXECUTABLES
|
||||
|
||||
inline void WritableStreamInternalsBuiltinsWrapper::exportNames()
|
||||
{
|
||||
#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
|
||||
#undef EXPORT_FUNCTION_NAME
|
||||
}
|
||||
|
||||
class WritableStreamInternalsBuiltinFunctions {
|
||||
public:
|
||||
explicit WritableStreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
|
||||
|
||||
void init(JSC::JSGlobalObject&);
|
||||
template<typename Visitor> void visit(Visitor&);
|
||||
|
||||
public:
|
||||
JSC::VM& m_vm;
|
||||
|
||||
#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
|
||||
JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
|
||||
#undef DECLARE_BUILTIN_SOURCE_MEMBERS
|
||||
};
|
||||
|
||||
inline void WritableStreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
|
||||
{
|
||||
#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
|
||||
m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
|
||||
#undef EXPORT_FUNCTION
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
inline void WritableStreamInternalsBuiltinFunctions::visit(Visitor& visitor)
|
||||
{
|
||||
#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
|
||||
WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
|
||||
#undef VISIT_FUNCTION
|
||||
}
|
||||
|
||||
template void WritableStreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
|
||||
template void WritableStreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
|
||||
|
||||
|
||||
|
||||
} // namespace WebCore
|
||||
@@ -97,6 +97,8 @@
|
||||
#include "napi.h"
|
||||
#include "JSZigGlobalObjectBuiltins.h"
|
||||
#include "JSSQLStatement.h"
|
||||
#include "ReadableStreamBuiltins.h"
|
||||
#include "BunJSCModule.h"
|
||||
|
||||
using JSGlobalObject = JSC::JSGlobalObject;
|
||||
using Exception = JSC::Exception;
|
||||
@@ -112,6 +114,27 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers;
|
||||
using JSBuffer = WebCore::JSBuffer;
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "IDLTypes.h"
|
||||
|
||||
#include "JSAbortAlgorithm.h"
|
||||
#include "JSDOMAttribute.h"
|
||||
#include "JSByteLengthQueuingStrategy.h"
|
||||
#include "JSCountQueuingStrategy.h"
|
||||
#include "JSReadableByteStreamController.h"
|
||||
#include "JSReadableStream.h"
|
||||
#include "JSReadableStreamBYOBReader.h"
|
||||
#include "JSReadableStreamBYOBRequest.h"
|
||||
#include "JSReadableStreamDefaultController.h"
|
||||
#include "JSReadableStreamDefaultReader.h"
|
||||
#include "JSTransformStream.h"
|
||||
#include "JSTransformStreamDefaultController.h"
|
||||
#include "JSWritableStream.h"
|
||||
#include "JSWritableStreamDefaultController.h"
|
||||
#include "JSWritableStreamDefaultWriter.h"
|
||||
#include "JavaScriptCore/BuiltinNames.h"
|
||||
#include "JSTextEncoder.h"
|
||||
#include "StructuredClone.h"
|
||||
|
||||
// #include <iostream>
|
||||
|
||||
static bool has_loaded_jsc = false;
|
||||
@@ -143,6 +166,8 @@ extern "C" void JSCInitialize()
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void* Bun__getVM();
|
||||
|
||||
extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObjectClass, int count,
|
||||
void* console_client)
|
||||
{
|
||||
@@ -159,7 +184,7 @@ extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObje
|
||||
JSC::JSLockHolder locker(vm);
|
||||
Zig::GlobalObject* globalObject = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::JSGlobalObject::create(vm, JSC::JSGlobalObject::createStructure(vm, JSC::jsNull())), JSC::jsNull()));
|
||||
globalObject->setConsole(globalObject);
|
||||
|
||||
globalObject->isThreadLocalDefaultGlobalObject = true;
|
||||
if (count > 0) {
|
||||
globalObject->installAPIGlobals(globalObjectClass, count, vm);
|
||||
}
|
||||
@@ -303,10 +328,18 @@ GlobalObject::GlobalObject(JSC::VM& vm, JSC::Structure* structure)
|
||||
, m_builtinInternalFunctions(vm)
|
||||
|
||||
{
|
||||
m_bunVM = Bun__getVM();
|
||||
|
||||
m_scriptExecutionContext = new WebCore::ScriptExecutionContext(&vm, this);
|
||||
}
|
||||
|
||||
GlobalObject::~GlobalObject() = default;
|
||||
|
||||
void GlobalObject::destroy(JSCell* cell)
|
||||
{
|
||||
static_cast<GlobalObject*>(cell)->GlobalObject::~GlobalObject();
|
||||
}
|
||||
|
||||
WebCore::ScriptExecutionContext* GlobalObject::scriptExecutionContext()
|
||||
{
|
||||
return m_scriptExecutionContext;
|
||||
@@ -351,6 +384,17 @@ JSC_DEFINE_CUSTOM_GETTER(JSBuffer_getter,
|
||||
WebCore::JSBuffer::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject));
|
||||
}
|
||||
|
||||
JSC_DECLARE_CUSTOM_GETTER(JSTextEncoder_getter);
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(JSTextEncoder_getter,
|
||||
(JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue,
|
||||
JSC::PropertyName))
|
||||
{
|
||||
Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
|
||||
return JSC::JSValue::encode(
|
||||
WebCore::JSTextEncoder::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject));
|
||||
}
|
||||
|
||||
JSC_DECLARE_CUSTOM_GETTER(JSDOMURL_getter);
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(JSDOMURL_getter,
|
||||
@@ -674,7 +718,7 @@ static JSC_DEFINE_HOST_FUNCTION(functionATOB,
|
||||
const WTF::String& encodedString = callFrame->argument(0).toWTFString(globalObject);
|
||||
|
||||
if (encodedString.isNull()) {
|
||||
return JSC::JSValue::encode(JSC::jsString(vm, ""));
|
||||
return JSC::JSValue::encode(JSC::jsEmptyString(vm));
|
||||
}
|
||||
|
||||
auto decodedData = WTF::base64Decode(encodedString, {
|
||||
@@ -827,6 +871,39 @@ static JSC_DEFINE_HOST_FUNCTION(functionReportError,
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(functionCreateUninitializedArrayBuffer);
|
||||
JSC_DEFINE_HOST_FUNCTION(functionCreateUninitializedArrayBuffer,
|
||||
(JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
|
||||
{
|
||||
size_t len = static_cast<size_t>(JSC__JSValue__toInt64(JSC::JSValue::encode(callFrame->argument(0))));
|
||||
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
|
||||
auto arrayBuffer = JSC::ArrayBuffer::tryCreateUninitialized(len, 1);
|
||||
|
||||
if (UNLIKELY(!arrayBuffer)) {
|
||||
JSC::throwOutOfMemoryError(globalObject, scope);
|
||||
return JSC::JSValue::encode(JSC::JSValue {});
|
||||
}
|
||||
|
||||
RELEASE_AND_RETURN(scope, JSValue::encode(JSC::JSArrayBuffer::create(globalObject->vm(), globalObject->arrayBufferStructure(JSC::ArrayBufferSharingMode::Default), WTFMove(arrayBuffer))));
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(functionNoop, (JSC::JSGlobalObject*, JSC::CallFrame*))
|
||||
{
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(noop_getter, (JSGlobalObject*, EncodedJSValue, PropertyName))
|
||||
{
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_SETTER(noop_setter,
|
||||
(JSC::JSGlobalObject*, JSC::EncodedJSValue,
|
||||
JSC::EncodedJSValue, JSC::PropertyName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// we're trying out a new way to do this lazy loading
|
||||
static JSC_DECLARE_HOST_FUNCTION(functionLazyLoad);
|
||||
static JSC_DEFINE_HOST_FUNCTION(functionLazyLoad,
|
||||
@@ -843,7 +920,33 @@ JSC:
|
||||
}
|
||||
default: {
|
||||
static NeverDestroyed<const String> sqliteString(MAKE_STATIC_STRING_IMPL("sqlite"));
|
||||
static NeverDestroyed<const String> bunJSCString(MAKE_STATIC_STRING_IMPL("bun:jsc"));
|
||||
static NeverDestroyed<const String> noopString(MAKE_STATIC_STRING_IMPL("noop"));
|
||||
JSC::JSValue moduleName = callFrame->argument(0);
|
||||
if (moduleName.isNumber()) {
|
||||
switch (moduleName.toInt32(globalObject)) {
|
||||
case 0: {
|
||||
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
|
||||
JSC::throwTypeError(globalObject, scope, "lazyLoad expects a string"_s);
|
||||
scope.release();
|
||||
return JSC::JSValue::encode(JSC::JSValue {});
|
||||
}
|
||||
|
||||
case 1: {
|
||||
return ByteBlob__JSReadableStreamSource__load(globalObject);
|
||||
}
|
||||
case 2: {
|
||||
return FileBlobLoader__JSReadableStreamSource__load(globalObject);
|
||||
}
|
||||
default: {
|
||||
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
|
||||
JSC::throwTypeError(globalObject, scope, "lazyLoad expects a string"_s);
|
||||
scope.release();
|
||||
return JSC::JSValue::encode(JSC::JSValue {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto string = moduleName.toWTFString(globalObject);
|
||||
if (string.isNull()) {
|
||||
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
|
||||
@@ -856,6 +959,18 @@ JSC:
|
||||
return JSC::JSValue::encode(JSSQLStatementConstructor::create(vm, globalObject, JSSQLStatementConstructor::createStructure(vm, globalObject, globalObject->m_functionPrototype.get())));
|
||||
}
|
||||
|
||||
if (string == bunJSCString) {
|
||||
return JSC::JSValue::encode(createJSCModule(globalObject));
|
||||
}
|
||||
|
||||
if (UNLIKELY(string == noopString)) {
|
||||
auto* obj = constructEmptyObject(globalObject);
|
||||
obj->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "getterSetter"_s)), JSC::CustomGetterSetter::create(vm, noop_getter, noop_setter), 0);
|
||||
Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, reinterpret_cast<Zig::GlobalObject*>(globalObject), 0, String(), functionNoop, JSC::NoIntrinsic);
|
||||
obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "function"_s)), function, JSC::PropertyAttribute::Function | 0);
|
||||
return JSC::JSValue::encode(obj);
|
||||
}
|
||||
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
|
||||
break;
|
||||
@@ -863,6 +978,577 @@ JSC:
|
||||
}
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSByteLengthQueuingStrategy::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_CountQueuingStrategyConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSCountQueuingStrategy::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_CountQueuingStrategyConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_CountQueuingStrategyConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSReadableByteStreamController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSReadableStream::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSReadableStreamBYOBReader::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSReadableStreamBYOBRequest::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSReadableStreamDefaultController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSReadableStreamDefaultReader::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_TransformStreamConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSTransformStream::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_TransformStreamConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_TransformStreamConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSTransformStreamDefaultController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_WritableStreamConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSWritableStream::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_WritableStreamConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_WritableStreamConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSWritableStreamDefaultController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
static inline JSValue jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
|
||||
{
|
||||
UNUSED_PARAM(lexicalGlobalObject);
|
||||
return JSWritableStreamDefaultWriter::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
|
||||
}
|
||||
|
||||
JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
|
||||
{
|
||||
return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
|
||||
}
|
||||
|
||||
JSC_DECLARE_HOST_FUNCTION(makeThisTypeErrorForBuiltins);
|
||||
JSC_DECLARE_HOST_FUNCTION(makeGetterTypeErrorForBuiltins);
|
||||
JSC_DECLARE_HOST_FUNCTION(makeDOMExceptionForBuiltins);
|
||||
JSC_DECLARE_HOST_FUNCTION(createWritableStreamFromInternal);
|
||||
JSC_DECLARE_HOST_FUNCTION(getInternalWritableStream);
|
||||
JSC_DECLARE_HOST_FUNCTION(whenSignalAborted);
|
||||
JSC_DECLARE_HOST_FUNCTION(isAbortSignal);
|
||||
JSC_DEFINE_HOST_FUNCTION(makeThisTypeErrorForBuiltins, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
ASSERT(callFrame);
|
||||
ASSERT(callFrame->argumentCount() == 2);
|
||||
VM& vm = globalObject->vm();
|
||||
DeferTermination deferScope(vm);
|
||||
auto scope = DECLARE_CATCH_SCOPE(vm);
|
||||
|
||||
auto interfaceName = callFrame->uncheckedArgument(0).getString(globalObject);
|
||||
scope.assertNoException();
|
||||
auto functionName = callFrame->uncheckedArgument(1).getString(globalObject);
|
||||
scope.assertNoException();
|
||||
return JSValue::encode(createTypeError(globalObject, makeThisTypeErrorMessage(interfaceName.utf8().data(), functionName.utf8().data())));
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(makeGetterTypeErrorForBuiltins, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
ASSERT(callFrame);
|
||||
ASSERT(callFrame->argumentCount() == 2);
|
||||
VM& vm = globalObject->vm();
|
||||
DeferTermination deferScope(vm);
|
||||
auto scope = DECLARE_CATCH_SCOPE(vm);
|
||||
|
||||
auto interfaceName = callFrame->uncheckedArgument(0).getString(globalObject);
|
||||
scope.assertNoException();
|
||||
auto attributeName = callFrame->uncheckedArgument(1).getString(globalObject);
|
||||
scope.assertNoException();
|
||||
|
||||
auto error = static_cast<ErrorInstance*>(createTypeError(globalObject, JSC::makeDOMAttributeGetterTypeErrorMessage(interfaceName.utf8().data(), attributeName)));
|
||||
error->setNativeGetterTypeError();
|
||||
return JSValue::encode(error);
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(makeDOMExceptionForBuiltins, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
ASSERT(callFrame);
|
||||
ASSERT(callFrame->argumentCount() == 2);
|
||||
|
||||
auto& vm = globalObject->vm();
|
||||
DeferTermination deferScope(vm);
|
||||
auto scope = DECLARE_CATCH_SCOPE(vm);
|
||||
|
||||
auto codeValue = callFrame->uncheckedArgument(0).getString(globalObject);
|
||||
scope.assertNoException();
|
||||
|
||||
auto message = callFrame->uncheckedArgument(1).getString(globalObject);
|
||||
scope.assertNoException();
|
||||
|
||||
ExceptionCode code { TypeError };
|
||||
if (codeValue == "AbortError")
|
||||
code = AbortError;
|
||||
auto value = createDOMException(globalObject, code, message);
|
||||
|
||||
EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
|
||||
|
||||
return JSValue::encode(value);
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(getInternalWritableStream, (JSGlobalObject*, CallFrame* callFrame))
|
||||
{
|
||||
ASSERT(callFrame);
|
||||
ASSERT(callFrame->argumentCount() == 1);
|
||||
|
||||
auto* writableStream = jsDynamicCast<JSWritableStream*>(callFrame->uncheckedArgument(0));
|
||||
if (UNLIKELY(!writableStream))
|
||||
return JSValue::encode(jsUndefined());
|
||||
return JSValue::encode(writableStream->wrapped().internalWritableStream());
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(createWritableStreamFromInternal, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
ASSERT(callFrame);
|
||||
ASSERT(callFrame->argumentCount() == 1);
|
||||
ASSERT(callFrame->uncheckedArgument(0).isObject());
|
||||
|
||||
auto* jsDOMGlobalObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
|
||||
auto internalWritableStream = InternalWritableStream::fromObject(*jsDOMGlobalObject, *callFrame->uncheckedArgument(0).toObject(globalObject));
|
||||
return JSValue::encode(toJSNewlyCreated(globalObject, jsDOMGlobalObject, WritableStream::create(WTFMove(internalWritableStream))));
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(whenSignalAborted, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
ASSERT(callFrame);
|
||||
ASSERT(callFrame->argumentCount() == 2);
|
||||
|
||||
auto& vm = globalObject->vm();
|
||||
auto* abortSignal = jsDynamicCast<JSAbortSignal*>(callFrame->uncheckedArgument(0));
|
||||
if (UNLIKELY(!abortSignal))
|
||||
return JSValue::encode(JSValue(JSC::JSValue::JSFalse));
|
||||
|
||||
Ref<AbortAlgorithm> abortAlgorithm = JSAbortAlgorithm::create(vm, callFrame->uncheckedArgument(1).getObject());
|
||||
|
||||
bool result = AbortSignal::whenSignalAborted(abortSignal->wrapped(), WTFMove(abortAlgorithm));
|
||||
return JSValue::encode(result ? JSValue(JSC::JSValue::JSTrue) : JSValue(JSC::JSValue::JSFalse));
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(isAbortSignal, (JSGlobalObject*, CallFrame* callFrame))
|
||||
{
|
||||
ASSERT(callFrame->argumentCount() == 1);
|
||||
return JSValue::encode(jsBoolean(callFrame->uncheckedArgument(0).inherits<JSAbortSignal>()));
|
||||
}
|
||||
|
||||
extern "C" JSC__JSValue ZigGlobalObject__createNativeReadableStream(Zig::GlobalObject* globalObject, JSC__JSValue nativeType, JSC__JSValue nativePtr);
|
||||
extern "C" JSC__JSValue ZigGlobalObject__createNativeReadableStream(Zig::GlobalObject* globalObject, JSC__JSValue nativeType, JSC__JSValue nativePtr)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
auto clientData = WebCore::clientData(vm);
|
||||
auto& builtinNames = WebCore::builtinNames(vm);
|
||||
|
||||
auto function = globalObject->getDirect(vm, builtinNames.createNativeReadableStreamPrivateName()).getObject();
|
||||
JSC::MarkedArgumentBuffer arguments = JSC::MarkedArgumentBuffer();
|
||||
arguments.append(JSValue::decode(nativeType));
|
||||
arguments.append(JSValue::decode(nativePtr));
|
||||
|
||||
auto callData = JSC::getCallData(function);
|
||||
return JSC::JSValue::encode(call(globalObject, function, callData, JSC::jsUndefined(), arguments));
|
||||
}
|
||||
|
||||
// static inline EncodedJSValue flattenArrayOfBuffersIntoArrayBuffer(JSGlobalObject* globalObject, JSValue arrayValue)
|
||||
// {
|
||||
// auto& vm = globalObject->vm();
|
||||
|
||||
// auto clientData = WebCore::clientData(vm);
|
||||
// if (arrayValue.isUndefinedOrNull() || !arrayValue) {
|
||||
// return JSC::JSValue::encode(JSC::JSArrayBuffer::create(vm, 0));
|
||||
// }
|
||||
|
||||
// auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
// auto array = JSC::jsDynamicCast<JSC::JSArray*>(arrayValue);
|
||||
// if (!array) {
|
||||
// throwTypeError(lexicalGlobalObject, throwScope, "Argument must be an array"_s);
|
||||
// return JSValue::encode(jsUndefined());
|
||||
// }
|
||||
|
||||
// size_t arrayLength = array->length();
|
||||
// if (arrayLength < 1) {
|
||||
// RELEASE_AND_RETURN(throwScope, JSC::JSArrayBuffer::create(lexicalGlobalObject, 0));
|
||||
// }
|
||||
|
||||
// size_t byteLength = 0;
|
||||
|
||||
// for (size_t i = 0; i < arrayLength; i++) {
|
||||
// auto element = array->getIndex(lexicalGlobalObject, i);
|
||||
// RETURN_IF_EXCEPTION(throwScope, {});
|
||||
|
||||
// auto* typedArray = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(element);
|
||||
// if (UNLIKELY(!typedArray)) {
|
||||
// throwTypeError(lexicalGlobalObject, throwScope, "Expected TypedArray"_s);
|
||||
// return JSValue::encode(jsUndefined());
|
||||
// }
|
||||
// byteLength += typedArray->byteLength();
|
||||
// }
|
||||
|
||||
// if (byteLength == 0) {
|
||||
// RELEASE_AND_RETURN(throwScope, JSC::JSArrayBuffer::create(lexicalGlobalObject, 0));
|
||||
// }
|
||||
|
||||
// auto& buffer = JSC::ArrayBuffer::tryCreateUninitialized(byteLength, 1);
|
||||
// if (UNLIKELY(!buffer)) {
|
||||
// throwTypeError(lexicalGlobalObject, throwScope, "Failed to allocate ArrayBuffer"_s);
|
||||
// return JSValue::encode(jsUndefined());
|
||||
// }
|
||||
|
||||
// size_t remain = byteLength;
|
||||
// auto* head = outBuffer->data();
|
||||
|
||||
// for (size_t i = 0; i < arrayLength && remain > 0; i++) {
|
||||
// auto element = array->getIndex(lexicalGlobalObject, i);
|
||||
// RETURN_IF_EXCEPTION(throwScope, {});
|
||||
// auto* typedArray = JSC::jsCast<JSC::JSArrayBufferView*>(element);
|
||||
// size_t length = std::min(remain, typedArray->byteLength());
|
||||
// memcpy(head, typedArray->vector(), length);
|
||||
// remain -= length;
|
||||
// head += length;
|
||||
// }
|
||||
|
||||
// return JSValue::encode(JSC::JSArrayBuffer::create(lexicalGlobalObject, WTFMove(buffer)));
|
||||
// }
|
||||
|
||||
// static EncodedJSValue ZigGlobalObject__readableStreamToArrayBuffer_resolve(JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
|
||||
// {
|
||||
// auto& vm = globalObject->vm();
|
||||
|
||||
// if (callFrame->argumentCount() < 1) {
|
||||
// auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
// throwTypeError(lexicalGlobalObject, throwScope, "Expected at least one argument"_s);
|
||||
// return JSValue::encode(jsUndefined());
|
||||
// }
|
||||
|
||||
// auto arrayValue = callFrame->uncheckedArgument(0);
|
||||
|
||||
// return flattenArrayOfBuffersIntoArrayBuffer(globalObject, arrayValue);
|
||||
// }
|
||||
|
||||
// extern "C" JSC__JSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue);
|
||||
// extern "C" JSC__JSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue)
|
||||
// {
|
||||
// auto& vm = globalObject->vm();
|
||||
|
||||
// auto clientData = WebCore::clientData(vm);
|
||||
// auto& builtinNames = WebCore::builtinNames(vm);
|
||||
|
||||
// auto function = globalObject->getDirect(vm, builtinNames.readableStreamToArrayPrivateName()).getObject();
|
||||
// JSC::MarkedArgumentBuffer arguments = JSC::MarkedArgumentBuffer();
|
||||
// arguments.append(JSValue::decode(readableStreamValue));
|
||||
|
||||
// auto callData = JSC::getCallData(function);
|
||||
// JSValue result = call(globalObject, function, callData, JSC::jsUndefined(), arguments);
|
||||
// if (UNLIKELY(result.isError()))
|
||||
// return JSValue::encode(result);
|
||||
// }
|
||||
|
||||
// extern "C" JSC__JSValue ZigGlobalObject__readableStreamToText(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue);
|
||||
// extern "C" JSC__JSValue ZigGlobalObject__readableStreamToText(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue)
|
||||
// {
|
||||
// auto& vm = globalObject->vm();
|
||||
// auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
// auto clientData = WebCore::clientData(vm);
|
||||
// auto& builtinNames = WebCore::builtinNames(vm);
|
||||
|
||||
// auto function = globalObject->getDirect(vm, builtinNames.createNativeReadableStreamPrivateName()).getObject();
|
||||
// JSC::MarkedArgumentBuffer arguments = JSC::MarkedArgumentBuffer();
|
||||
// arguments.append(JSValue::decode(nativeType));
|
||||
// arguments.append(JSValue::decode(nativePtr));
|
||||
|
||||
// auto callData = JSC::getCallData(function);
|
||||
// return JSC::JSValue::encode(call(globalObject, function, callData, JSC::jsUndefined(), arguments));
|
||||
// }
|
||||
|
||||
void GlobalObject::finishCreation(VM& vm)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
ASSERT(inherits(info()));
|
||||
|
||||
addBuiltinGlobals(vm);
|
||||
|
||||
RELEASE_ASSERT(classInfo());
|
||||
}
|
||||
|
||||
extern "C" EncodedJSValue Bun__escapeHTML(JSGlobalObject* globalObject, CallFrame* callFrame);
|
||||
|
||||
void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
|
||||
{
|
||||
m_builtinInternalFunctions.initialize(*this);
|
||||
|
||||
auto clientData = WebCore::clientData(vm);
|
||||
auto& builtinNames = WebCore::builtinNames(vm);
|
||||
|
||||
WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
|
||||
extraStaticGlobals.reserveCapacity(28);
|
||||
|
||||
JSC::Identifier queueMicrotaskIdentifier = JSC::Identifier::fromString(vm, "queueMicrotask"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { queueMicrotaskIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"queueMicrotask"_s, functionQueueMicrotask),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier setTimeoutIdentifier = JSC::Identifier::fromString(vm, "setTimeout"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { setTimeoutIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"setTimeout"_s, functionSetTimeout),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier clearTimeoutIdentifier = JSC::Identifier::fromString(vm, "clearTimeout"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { clearTimeoutIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"clearTimeout"_s, functionClearTimeout),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier setIntervalIdentifier = JSC::Identifier::fromString(vm, "setInterval"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { setIntervalIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"setInterval"_s, functionSetInterval),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier clearIntervalIdentifier = JSC::Identifier::fromString(vm, "clearInterval"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { clearIntervalIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"clearInterval"_s, functionClearInterval),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier escapeHTMLIdentifier = JSC::Identifier::fromString(vm, "escapeHTML"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { escapeHTMLIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"escapeHTML"_s, Bun__escapeHTML),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier atobIdentifier = JSC::Identifier::fromString(vm, "atob"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { atobIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"atob"_s, functionATOB),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier btoaIdentifier = JSC::Identifier::fromString(vm, "btoa"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { btoaIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"btoa"_s, functionBTOA),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
JSC::Identifier reportErrorIdentifier = JSC::Identifier::fromString(vm, "reportError"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { reportErrorIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"reportError"_s, functionReportError),
|
||||
JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
static NeverDestroyed<const String> BunLazyString(MAKE_STATIC_STRING_IMPL("Bun.lazy"));
|
||||
JSC::Identifier BunLazyIdentifier = JSC::Identifier::fromUid(vm.symbolRegistry().symbolForKey(BunLazyString));
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { BunLazyIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
BunLazyString, functionLazyLoad),
|
||||
JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::Function | 0 });
|
||||
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.makeThisTypeErrorPrivateName(), JSFunction::create(vm, this, 2, String(), makeThisTypeErrorForBuiltins), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.makeGetterTypeErrorPrivateName(), JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.makeDOMExceptionPrivateName(), JSFunction::create(vm, this, 2, String(), makeDOMExceptionForBuiltins), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.whenSignalAbortedPrivateName(), JSFunction::create(vm, this, 2, String(), whenSignalAborted), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.cloneArrayBufferPrivateName(), JSFunction::create(vm, this, 3, String(), cloneArrayBuffer), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.structuredCloneForStreamPrivateName(), JSFunction::create(vm, this, 1, String(), structuredCloneForStream), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(vm.propertyNames->builtinNames().ArrayBufferPrivateName(), arrayBufferConstructor(), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamClosedPrivateName(), jsNumber(1), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamClosingPrivateName(), jsNumber(2), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamErroredPrivateName(), jsNumber(3), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamReadablePrivateName(), jsNumber(4), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamWaitingPrivateName(), jsNumber(5), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamWritablePrivateName(), jsNumber(6), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.isAbortSignalPrivateName(), JSFunction::create(vm, this, 1, String(), isAbortSignal), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.getInternalWritableStreamPrivateName(), JSFunction::create(vm, this, 1, String(), getInternalWritableStream), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.createWritableStreamFromInternalPrivateName(), JSFunction::create(vm, this, 1, String(), createWritableStreamFromInternal), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
|
||||
|
||||
this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
|
||||
|
||||
extraStaticGlobals.releaseBuffer();
|
||||
|
||||
putDirectBuiltinFunction(vm, this, builtinNames.createFIFOPrivateName(), streamInternalsCreateFIFOCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
putDirectBuiltinFunction(vm, this, builtinNames.createNativeReadableStreamPrivateName(), readableStreamCreateNativeReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
putDirectBuiltinFunction(vm, this, builtinNames.createEmptyReadableStreamPrivateName(), readableStreamCreateEmptyReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
// putDirectBuiltinFunction(vm, this, builtinNames.readableStreamToArrayPrivateName(), readableStreamReadableStreamToArrayCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectNativeFunction(vm, this, builtinNames.createUninitializedArrayBufferPrivateName(), 1, functionCreateUninitializedArrayBuffer, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "process"_s), JSC::CustomGetterSetter::create(vm, property_lazyProcessGetter, property_lazyProcessSetter),
|
||||
JSC::PropertyAttribute::CustomAccessor | 0);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "URL"_s), JSC::CustomGetterSetter::create(vm, JSDOMURL_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "URLSearchParams"_s), JSC::CustomGetterSetter::create(vm, JSURLSearchParams_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "DOMException"_s), JSC::CustomGetterSetter::create(vm, JSDOMException_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Event"_s), JSC::CustomGetterSetter::create(vm, JSEvent_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "EventTarget"_s), JSC::CustomGetterSetter::create(vm, JSEventTarget_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "AbortController"_s), JSC::CustomGetterSetter::create(vm, JSDOMAbortController_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "AbortSignal"_s), JSC::CustomGetterSetter::create(vm, JSDOMAbortSignal_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CustomEvent"_s), JSC::CustomGetterSetter::create(vm, JSCustomEvent_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Headers"_s), JSC::CustomGetterSetter::create(vm, JSFetchHeaders_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ErrorEvent"_s), JSC::CustomGetterSetter::create(vm, JSErrorEvent_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Buffer"_s), JSC::CustomGetterSetter::create(vm, JSBuffer_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "TextEncoder"_s), JSC::CustomGetterSetter::create(vm, JSTextEncoder_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamConstructor, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamConstructor, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableByteStreamControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamBYOBReaderPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamBYOBRequestPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamDefaultReaderPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamDefaultWriterPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().AbortSignalPrivateName(), CustomGetterSetter::create(vm, JSDOMAbortSignal_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontEnum));
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableByteStreamControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamBYOBReaderPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamBYOBRequestPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamDefaultReaderPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamDefaultWriterPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ByteLengthQueuingStrategy"_s), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CountQueuingStrategy"_s), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_CountQueuingStrategyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
// putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().nativeReadableStreamPrototypePrivateName(), jsUndefined(), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum | 0);
|
||||
}
|
||||
|
||||
// This is not a publicly exposed API currently.
|
||||
// This is used by the bundler to make Response, Request, FetchEvent,
|
||||
// and any other objects available globally.
|
||||
@@ -872,7 +1558,7 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
|
||||
size_t constructor_count = 0;
|
||||
JSC__JSValue const* constructors = Zig__getAPIConstructors(&constructor_count, this);
|
||||
WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
|
||||
extraStaticGlobals.reserveCapacity((size_t)count + constructor_count + 3 + 11);
|
||||
extraStaticGlobals.reserveCapacity((size_t)count + constructor_count + 3 + 1);
|
||||
int i = 0;
|
||||
for (; i < constructor_count; i++) {
|
||||
auto* object = JSC::jsDynamicCast<JSC::JSCallbackConstructor*>(JSC::JSValue::decode(constructors[i]).asCell()->getObject());
|
||||
@@ -914,69 +1600,6 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
|
||||
// JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0);
|
||||
// }
|
||||
|
||||
JSC::Identifier queueMicrotaskIdentifier = JSC::Identifier::fromString(vm, "queueMicrotask"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { queueMicrotaskIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"queueMicrotask"_s, functionQueueMicrotask),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier setTimeoutIdentifier = JSC::Identifier::fromString(vm, "setTimeout"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { setTimeoutIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"setTimeout"_s, functionSetTimeout),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier clearTimeoutIdentifier = JSC::Identifier::fromString(vm, "clearTimeout"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { clearTimeoutIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"clearTimeout"_s, functionClearTimeout),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier setIntervalIdentifier = JSC::Identifier::fromString(vm, "setInterval"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { setIntervalIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"setInterval"_s, functionSetInterval),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier clearIntervalIdentifier = JSC::Identifier::fromString(vm, "clearInterval"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { clearIntervalIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"clearInterval"_s, functionClearInterval),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier atobIdentifier = JSC::Identifier::fromString(vm, "atob"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { atobIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"atob"_s, functionATOB),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
JSC::Identifier btoaIdentifier = JSC::Identifier::fromString(vm, "btoa"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { btoaIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"btoa"_s, functionBTOA),
|
||||
JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0 });
|
||||
JSC::Identifier reportErrorIdentifier = JSC::Identifier::fromString(vm, "reportError"_s);
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { reportErrorIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
"reportError"_s, functionReportError),
|
||||
JSC::PropertyAttribute::DontDelete | 0 });
|
||||
|
||||
static NeverDestroyed<const String> BunLazyString(MAKE_STATIC_STRING_IMPL("Bun.lazy"));
|
||||
JSC::Identifier BunLazyIdentifier = JSC::Identifier::fromUid(vm.symbolRegistry().symbolForKey(BunLazyString));
|
||||
extraStaticGlobals.uncheckedAppend(
|
||||
GlobalPropertyInfo { BunLazyIdentifier,
|
||||
JSC::JSFunction::create(vm, JSC::jsCast<JSC::JSGlobalObject*>(globalObject()), 0,
|
||||
BunLazyString, functionLazyLoad),
|
||||
JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::Function | 0 });
|
||||
|
||||
this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
|
||||
|
||||
m_NapiClassStructure.initLater(
|
||||
@@ -989,42 +1612,6 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
|
||||
init.setStructure(Zig::JSFFIFunction::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()));
|
||||
});
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "process"_s), JSC::CustomGetterSetter::create(vm, property_lazyProcessGetter, property_lazyProcessSetter),
|
||||
JSC::PropertyAttribute::CustomAccessor | 0);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "URL"_s), JSC::CustomGetterSetter::create(vm, JSDOMURL_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | 0);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "URLSearchParams"_s), JSC::CustomGetterSetter::create(vm, JSURLSearchParams_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "DOMException"_s), JSC::CustomGetterSetter::create(vm, JSDOMException_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Event"_s), JSC::CustomGetterSetter::create(vm, JSEvent_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "EventTarget"_s), JSC::CustomGetterSetter::create(vm, JSEventTarget_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "AbortController"_s), JSC::CustomGetterSetter::create(vm, JSDOMAbortController_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "AbortSignal"_s), JSC::CustomGetterSetter::create(vm, JSDOMAbortSignal_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CustomEvent"_s), JSC::CustomGetterSetter::create(vm, JSCustomEvent_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Headers"_s), JSC::CustomGetterSetter::create(vm, JSFetchHeaders_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ErrorEvent"_s), JSC::CustomGetterSetter::create(vm, JSErrorEvent_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Buffer"_s), JSC::CustomGetterSetter::create(vm, JSBuffer_getter, nullptr),
|
||||
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
// putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "SQL"_s), JSC::CustomGetterSetter::create(vm, JSSQLStatement_getter, nullptr),
|
||||
// JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
|
||||
|
||||
@@ -1050,14 +1637,14 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
for (auto& structure : thisObject->m_structures.values())
|
||||
visitor.append(structure);
|
||||
|
||||
// for (auto& guarded : thisObject->m_guardedObjects)
|
||||
// guarded->visitAggregate(visitor);
|
||||
for (auto& guarded : thisObject->m_guardedObjects)
|
||||
guarded->visitAggregate(visitor);
|
||||
}
|
||||
|
||||
for (auto& constructor : thisObject->constructors().array())
|
||||
visitor.append(constructor);
|
||||
|
||||
// thisObject->m_builtinInternalFunctions.visit(visitor);
|
||||
thisObject->m_builtinInternalFunctions.visit(visitor);
|
||||
thisObject->m_JSFFIFunctionStructure.visit(visitor);
|
||||
ScriptExecutionContext* context = thisObject->scriptExecutionContext();
|
||||
visitor.addOpaqueRoot(context);
|
||||
@@ -1161,7 +1748,7 @@ JSC::JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalOb
|
||||
|
||||
auto moduleKey = key.toWTFString(globalObject);
|
||||
RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
|
||||
if (moduleKey.endsWith(".node")) {
|
||||
if (moduleKey.endsWith(".node"_s)) {
|
||||
return rejectWithError(createTypeError(globalObject, "To load Node-API modules, use require() or process.dlopen instead of import."_s));
|
||||
}
|
||||
|
||||
@@ -1281,9 +1868,14 @@ JSC::JSValue GlobalObject::moduleLoaderEvaluate(JSGlobalObject* globalObject,
|
||||
void GlobalObject::queueMicrotaskToEventLoop(JSC::JSGlobalObject& global,
|
||||
Ref<JSC::Microtask>&& task)
|
||||
{
|
||||
|
||||
Zig__GlobalObject__queueMicrotaskToEventLoop(
|
||||
&global, &JSMicrotaskCallback::create(global, WTFMove(task)).leakRef());
|
||||
auto& globalObject = reinterpret_cast<GlobalObject&>(global);
|
||||
if (globalObject.isThreadLocalDefaultGlobalObject) {
|
||||
Zig__GlobalObject__queueMicrotaskToEventLoop(
|
||||
&global, reinterpret_cast<JSMicrotaskCallback*>(&JSMicrotaskCallbackDefaultGlobal::create(WTFMove(task)).leakRef()));
|
||||
} else {
|
||||
Zig__GlobalObject__queueMicrotaskToEventLoop(
|
||||
&global, &JSMicrotaskCallback::create(global, WTFMove(task)).leakRef());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Zig
|
||||
|
||||
@@ -12,6 +12,7 @@ class LazyClassStructure;
|
||||
|
||||
namespace WebCore {
|
||||
class ScriptExecutionContext;
|
||||
class DOMGuardedObject;
|
||||
}
|
||||
|
||||
#include "root.h"
|
||||
@@ -34,6 +35,7 @@ class ScriptExecutionContext;
|
||||
namespace Zig {
|
||||
|
||||
using JSDOMStructureMap = HashMap<const JSC::ClassInfo*, JSC::WriteBarrier<JSC::Structure>>;
|
||||
using DOMGuardedObjectSet = HashSet<WebCore::DOMGuardedObject*>;
|
||||
|
||||
class GlobalObject : public JSC::JSGlobalObject {
|
||||
using Base = JSC::JSGlobalObject;
|
||||
@@ -41,21 +43,22 @@ class GlobalObject : public JSC::JSGlobalObject {
|
||||
public:
|
||||
static const JSC::ClassInfo s_info;
|
||||
static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable;
|
||||
static constexpr bool needsDestruction = false;
|
||||
|
||||
template<typename, SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
||||
{
|
||||
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
||||
return nullptr;
|
||||
return WebCore::subspaceForImpl<GlobalObject, WebCore::UseCustomHeapCellType::No>(
|
||||
return WebCore::subspaceForImpl<GlobalObject, WebCore::UseCustomHeapCellType::Yes>(
|
||||
vm,
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForGlobalObject.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForGlobalObject = WTFMove(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForGlobalObject.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForGlobalObject = WTFMove(space); });
|
||||
[](auto& spaces) { return spaces.m_clientSubspaceForWorkerGlobalScope.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForWorkerGlobalScope = WTFMove(space); },
|
||||
[](auto& spaces) { return spaces.m_subspaceForWorkerGlobalScope.get(); },
|
||||
[](auto& spaces, auto&& space) { spaces.m_subspaceForWorkerGlobalScope = WTFMove(space); },
|
||||
[](auto& server) -> JSC::HeapCellType& { return server.m_heapCellTypeForJSWorkerGlobalScope; });
|
||||
}
|
||||
|
||||
~GlobalObject();
|
||||
static void destroy(JSC::JSCell*);
|
||||
|
||||
static constexpr const JSC::ClassInfo* info() { return &s_info; }
|
||||
|
||||
@@ -67,6 +70,19 @@ public:
|
||||
// Make binding code generation easier.
|
||||
GlobalObject* globalObject() { return this; }
|
||||
|
||||
DOMGuardedObjectSet& guardedObjects() WTF_REQUIRES_LOCK(m_gcLock) { return m_guardedObjects; }
|
||||
|
||||
const DOMGuardedObjectSet& guardedObjects() const WTF_IGNORES_THREAD_SAFETY_ANALYSIS
|
||||
{
|
||||
ASSERT(!Thread::mayBeGCThread());
|
||||
return m_guardedObjects;
|
||||
}
|
||||
DOMGuardedObjectSet& guardedObjects(NoLockingNecessaryTag) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
|
||||
{
|
||||
ASSERT(!vm().heap.mutatorShouldBeFenced());
|
||||
return m_guardedObjects;
|
||||
}
|
||||
|
||||
static GlobalObject* create(JSC::VM& vm, JSC::Structure* structure)
|
||||
{
|
||||
GlobalObject* ptr = new (NotNull, JSC::allocateCell<GlobalObject>(vm)) GlobalObject(vm, structure);
|
||||
@@ -106,6 +122,8 @@ public:
|
||||
|
||||
Lock& gcLock() WTF_RETURNS_LOCK(m_gcLock) { return m_gcLock; }
|
||||
|
||||
void clearDOMGuardedObjects();
|
||||
|
||||
static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, JSC::Exception*);
|
||||
static JSGlobalObject* deriveShadowRealmGlobalObject(JSGlobalObject* globalObject);
|
||||
static void queueMicrotaskToEventLoop(JSC::JSGlobalObject& global, Ref<JSC::Microtask>&& task);
|
||||
@@ -131,8 +149,12 @@ public:
|
||||
JSC::Structure* FFIFunctionStructure() { return m_JSFFIFunctionStructure.getInitializedOnMainThread(this); }
|
||||
JSC::Structure* NapiClassStructure() { return m_NapiClassStructure.getInitializedOnMainThread(this); }
|
||||
|
||||
void* bunVM() { return m_bunVM; }
|
||||
bool isThreadLocalDefaultGlobalObject = false;
|
||||
|
||||
private:
|
||||
void addBuiltinGlobals(JSC::VM&);
|
||||
void finishCreation(JSC::VM&);
|
||||
friend void WebCore::JSBuiltinInternalFunctions::initialize(Zig::GlobalObject&);
|
||||
WebCore::JSBuiltinInternalFunctions m_builtinInternalFunctions;
|
||||
GlobalObject(JSC::VM& vm, JSC::Structure* structure);
|
||||
@@ -144,9 +166,37 @@ private:
|
||||
Ref<WebCore::DOMWrapperWorld> m_world;
|
||||
LazyClassStructure m_JSFFIFunctionStructure;
|
||||
LazyClassStructure m_NapiClassStructure;
|
||||
DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock);
|
||||
void* m_bunVM;
|
||||
};
|
||||
|
||||
class JSMicrotaskCallback : public RefCounted<JSMicrotaskCallback> {
|
||||
class JSMicrotaskCallbackDefaultGlobal final : public RefCounted<JSMicrotaskCallbackDefaultGlobal> {
|
||||
public:
|
||||
static Ref<JSMicrotaskCallbackDefaultGlobal> create(Ref<JSC::Microtask>&& task)
|
||||
{
|
||||
return adoptRef(*new JSMicrotaskCallbackDefaultGlobal(WTFMove(task).leakRef()));
|
||||
}
|
||||
|
||||
void call(JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
|
||||
JSC::VM& vm = globalObject->vm();
|
||||
auto task = &m_task.leakRef();
|
||||
task->run(globalObject);
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
private:
|
||||
JSMicrotaskCallbackDefaultGlobal(Ref<JSC::Microtask>&& task)
|
||||
: m_task { WTFMove(task) }
|
||||
{
|
||||
}
|
||||
|
||||
Ref<JSC::Microtask> m_task;
|
||||
};
|
||||
|
||||
class JSMicrotaskCallback final : public RefCounted<JSMicrotaskCallback> {
|
||||
public:
|
||||
static Ref<JSMicrotaskCallback> create(JSC::JSGlobalObject& globalObject,
|
||||
Ref<JSC::Microtask>&& task)
|
||||
@@ -156,21 +206,27 @@ public:
|
||||
|
||||
void call()
|
||||
{
|
||||
auto* globalObject = m_globalObject.get();
|
||||
if (UNLIKELY(!globalObject)) {
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
||||
JSC::VM& vm = m_globalObject->vm();
|
||||
auto task = &m_task.leakRef();
|
||||
task->run(m_globalObject.get());
|
||||
task->run(globalObject);
|
||||
|
||||
task->~Microtask();
|
||||
delete this;
|
||||
}
|
||||
|
||||
private:
|
||||
JSMicrotaskCallback(JSC::JSGlobalObject& globalObject, Ref<JSC::Microtask>&& task)
|
||||
: m_globalObject { globalObject.vm(), &globalObject }
|
||||
: m_globalObject { &globalObject }
|
||||
, m_task { WTFMove(task) }
|
||||
{
|
||||
}
|
||||
|
||||
JSC::Strong<JSC::JSGlobalObject> m_globalObject;
|
||||
JSC::Weak<JSC::JSGlobalObject> m_globalObject;
|
||||
Ref<JSC::Microtask> m_task;
|
||||
};
|
||||
|
||||
|
||||
@@ -98,6 +98,50 @@ static void copyToUWS(WebCore::FetchHeaders* headers, UWSResponse* res)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename PromiseType, bool isInternal>
|
||||
static void handlePromise(PromiseType* promise, JSC__JSGlobalObject* globalObject, void* ctx, void (*ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3), void (*ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3))
|
||||
{
|
||||
JSC::Strong<PromiseType> strongValue = { globalObject->vm(), promise };
|
||||
JSC::JSNativeStdFunction* resolverFunction = JSC::JSNativeStdFunction::create(
|
||||
globalObject->vm(), globalObject, 1, String(), [&strongValue, ctx, ArgFn3](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> const JSC::EncodedJSValue {
|
||||
auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
|
||||
|
||||
WTF::Vector<JSC::EncodedJSValue, 16> arguments;
|
||||
arguments.reserveInitialCapacity(argCount);
|
||||
if (argCount) {
|
||||
for (uint16_t i = 0; i < argCount; ++i) {
|
||||
arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i)));
|
||||
}
|
||||
}
|
||||
|
||||
ArgFn3(globalObject, ctx, reinterpret_cast<void**>(arguments.data()), argCount);
|
||||
strongValue.clear();
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
});
|
||||
JSC::JSNativeStdFunction* rejecterFunction = JSC::JSNativeStdFunction::create(
|
||||
globalObject->vm(), globalObject, 1, String(),
|
||||
[&strongValue, ctx, ArgFn4](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> JSC::EncodedJSValue {
|
||||
auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
|
||||
WTF::Vector<JSC::EncodedJSValue, 16> arguments;
|
||||
arguments.reserveInitialCapacity(argCount);
|
||||
if (argCount) {
|
||||
for (uint16_t i = 0; i < argCount; ++i) {
|
||||
arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i)));
|
||||
}
|
||||
}
|
||||
|
||||
ArgFn4(globalObject, ctx, reinterpret_cast<void**>(arguments.data()), argCount);
|
||||
strongValue.clear();
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
});
|
||||
|
||||
if constexpr (!isInternal) {
|
||||
promise->performPromiseThen(globalObject, resolverFunction, rejecterFunction, JSC::jsUndefined());
|
||||
} else {
|
||||
promise->then(globalObject, resolverFunction, rejecterFunction);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
void WebCore__FetchHeaders__toUWSResponse(WebCore__FetchHeaders* arg0, bool is_ssl, void* arg2)
|
||||
@@ -306,10 +350,8 @@ JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0,
|
||||
|
||||
JSC::JSValue options = JSC::jsUndefined();
|
||||
|
||||
Structure* errorStructure = JSC_GET_DERIVED_STRUCTURE(vm, errorStructure, globalObject->errorPrototype(), globalObject->errorPrototype());
|
||||
|
||||
JSC::JSObject* result
|
||||
= JSC::ErrorInstance::create(globalObject, errorStructure, message, options);
|
||||
= JSC::ErrorInstance::create(globalObject, JSC::ErrorInstance::createStructure(vm, globalObject, globalObject->errorPrototype()), message, options);
|
||||
|
||||
auto clientData = WebCore::clientData(vm);
|
||||
|
||||
@@ -507,50 +549,15 @@ JSC__JSPromise* JSC__JSPromise__create(JSC__JSGlobalObject* arg0)
|
||||
}
|
||||
|
||||
// TODO: prevent this from allocating so much memory
|
||||
void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, void* ctx, void (*ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, JSC__JSValue arg2, size_t arg3), void (*ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, JSC__JSValue arg2, size_t arg3))
|
||||
void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, void* ctx, void (*ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3), void (*ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3))
|
||||
{
|
||||
|
||||
globalObject->vm().drainMicrotasks();
|
||||
auto* cell = JSC::JSValue::decode(JSValue0).asCell();
|
||||
JSC::Strong<JSC::Unknown> promiseValue = { globalObject->vm(), cell };
|
||||
|
||||
JSC::JSNativeStdFunction* resolverFunction = JSC::JSNativeStdFunction::create(
|
||||
globalObject->vm(), globalObject, 1, String(), [&promiseValue, ctx, ArgFn3](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> JSC::EncodedJSValue {
|
||||
auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
|
||||
|
||||
WTF::Vector<JSC::EncodedJSValue, 16> arguments;
|
||||
arguments.reserveInitialCapacity(argCount);
|
||||
if (argCount) {
|
||||
for (uint16_t i = 0; i < argCount; ++i) {
|
||||
arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i)));
|
||||
}
|
||||
}
|
||||
|
||||
ArgFn3(globalObject, ctx, reinterpret_cast<JSC__JSValue>(arguments.data()), argCount);
|
||||
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
});
|
||||
JSC::JSNativeStdFunction* rejecterFunction = JSC::JSNativeStdFunction::create(
|
||||
globalObject->vm(), globalObject, 1, String(),
|
||||
[&promiseValue, ctx, ArgFn4](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> JSC::EncodedJSValue {
|
||||
auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
|
||||
WTF::Vector<JSC::EncodedJSValue, 16> arguments;
|
||||
arguments.reserveInitialCapacity(argCount);
|
||||
if (argCount) {
|
||||
for (uint16_t i = 0; i < argCount; ++i) {
|
||||
arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i)));
|
||||
}
|
||||
}
|
||||
|
||||
ArgFn4(globalObject, ctx, reinterpret_cast<JSC__JSValue>(arguments.data()), argCount);
|
||||
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
});
|
||||
|
||||
if (JSC::JSPromise* promise = JSC::jsDynamicCast<JSC::JSPromise*>(cell)) {
|
||||
promise->performPromiseThen(globalObject, resolverFunction, rejecterFunction, JSC::jsUndefined());
|
||||
handlePromise<JSC::JSPromise, false>(promise, globalObject, ctx, ArgFn3, ArgFn4);
|
||||
} else if (JSC::JSInternalPromise* promise = JSC::jsDynamicCast<JSC::JSInternalPromise*>(cell)) {
|
||||
promise->then(globalObject, resolverFunction, rejecterFunction);
|
||||
handlePromise<JSC::JSInternalPromise, true>(promise, globalObject, ctx, ArgFn3, ArgFn4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,6 +815,11 @@ void Microtask__run(void* microtask, void* global)
|
||||
reinterpret_cast<Zig::JSMicrotaskCallback*>(microtask)->call();
|
||||
}
|
||||
|
||||
void Microtask__run_default(void* microtask, void* global)
|
||||
{
|
||||
reinterpret_cast<Zig::JSMicrotaskCallbackDefaultGlobal*>(microtask)->call(reinterpret_cast<Zig::GlobalObject*>(global));
|
||||
}
|
||||
|
||||
bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1,
|
||||
bool arg2)
|
||||
{
|
||||
@@ -877,6 +889,14 @@ static JSC::JSValue doLink(JSC__JSGlobalObject* globalObject, JSC::JSValue modul
|
||||
return JSC::linkAndEvaluateModule(globalObject, moduleKey, JSC::JSValue());
|
||||
}
|
||||
|
||||
JSC__JSValue ReadableStream__empty(Zig::GlobalObject* globalObject)
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
auto clientData = WebCore::clientData(vm);
|
||||
auto* function = globalObject->getDirect(vm, clientData->builtinNames().createEmptyReadableStreamPrivateName()).getObject();
|
||||
return JSValue::encode(JSC::call(globalObject, function, JSC::ArgList(), "ReadableStream.create"_s));
|
||||
}
|
||||
|
||||
JSC__JSValue JSC__JSValue__createRangeError(const ZigString* message, const ZigString* arg1,
|
||||
JSC__JSGlobalObject* globalObject)
|
||||
{
|
||||
@@ -967,15 +987,12 @@ bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* ar
|
||||
JSC::JSObject* object = value.getObject();
|
||||
|
||||
if (JSC::JSArrayBufferView* typedArray = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(object)) {
|
||||
if (JSC::ArrayBuffer* buffer = typedArray->possiblySharedBuffer()) {
|
||||
buffer->pinAndLock();
|
||||
arg2->ptr = reinterpret_cast<char*>(buffer->data());
|
||||
arg2->len = typedArray->length();
|
||||
arg2->byte_len = buffer->byteLength();
|
||||
arg2->offset = typedArray->byteOffset();
|
||||
arg2->cell_type = typedArray->type();
|
||||
return true;
|
||||
}
|
||||
arg2->ptr = reinterpret_cast<char*>(typedArray->vector());
|
||||
arg2->len = typedArray->length();
|
||||
arg2->byte_len = typedArray->byteLength();
|
||||
arg2->offset = typedArray->byteOffset();
|
||||
arg2->cell_type = typedArray->type();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (JSC::ArrayBuffer* buffer = JSC::toPossiblySharedArrayBuffer(vm, value)) {
|
||||
@@ -1084,23 +1101,31 @@ static void free_global_string(void* str, void* ptr, unsigned len)
|
||||
|
||||
JSC__JSValue ZigString__toExternalU16(const uint16_t* arg0, size_t len, JSC__JSGlobalObject* global)
|
||||
{
|
||||
return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString(
|
||||
global->vm(),
|
||||
ExternalStringImpl::create(reinterpret_cast<const UChar*>(arg0), len, nullptr, free_global_string))));
|
||||
auto ref = String(ExternalStringImpl::create(reinterpret_cast<const UChar*>(arg0), len, nullptr, free_global_string));
|
||||
|
||||
return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(
|
||||
global->vm(), WTFMove(ref))));
|
||||
}
|
||||
// This must be a globally allocated string
|
||||
JSC__JSValue ZigString__toExternalValue(const ZigString* arg0, JSC__JSGlobalObject* arg1)
|
||||
{
|
||||
ZigString str = *arg0;
|
||||
if (Zig::isTaggedUTF16Ptr(str.ptr)) {
|
||||
return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString(
|
||||
arg1->vm(),
|
||||
ExternalStringImpl::create(reinterpret_cast<const UChar*>(Zig::untag(str.ptr)), str.len, nullptr, free_global_string))));
|
||||
}
|
||||
auto ref = String(ExternalStringImpl::create(reinterpret_cast<const UChar*>(Zig::untag(str.ptr)), str.len, nullptr, free_global_string));
|
||||
|
||||
return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString(
|
||||
arg1->vm(),
|
||||
ExternalStringImpl::create(Zig::untag(str.ptr), str.len, nullptr, free_global_string))));
|
||||
return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(
|
||||
arg1->vm(), WTFMove(ref))));
|
||||
} else {
|
||||
auto ref = String(ExternalStringImpl::create(Zig::untag(str.ptr), str.len, nullptr, free_global_string));
|
||||
return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(
|
||||
arg1->vm(),
|
||||
WTFMove(ref))));
|
||||
}
|
||||
}
|
||||
|
||||
VirtualMachine* JSC__JSGlobalObject__bunVM(JSC__JSGlobalObject* arg0)
|
||||
{
|
||||
return reinterpret_cast<VirtualMachine*>(reinterpret_cast<Zig::GlobalObject*>(arg0)->bunVM());
|
||||
}
|
||||
|
||||
JSC__JSValue ZigString__toValueGC(const ZigString* arg0, JSC__JSGlobalObject* arg1)
|
||||
@@ -1432,116 +1457,6 @@ void JSC__SourceCode__fromString(JSC__SourceCode* arg0, const WTF__String* arg1,
|
||||
const JSC__SourceOrigin* arg2, WTF__String* arg3,
|
||||
unsigned char SourceType4) {}
|
||||
|
||||
#pragma mark - JSC::JSFunction
|
||||
|
||||
// JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
|
||||
// JSC__JSValue* arg2, size_t arg3,
|
||||
// JSC__Exception** arg4, const unsigned char* arg5)
|
||||
// {
|
||||
// auto args = makeArgs(arg2, arg3);
|
||||
// return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
|
||||
// JSC::JSValue::decode(JSValue0), args, (const char*)arg5));
|
||||
// }
|
||||
// JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSValue JSValue0, JSC__JSValue JSValue1,
|
||||
// JSC__JSGlobalObject* arg2,
|
||||
// JSC__JSValue* arg3, size_t arg4,
|
||||
// JSC__Exception** arg5,
|
||||
// const unsigned char* arg6)
|
||||
// {
|
||||
// auto args = makeArgs(arg3, arg4);
|
||||
// return JSC::JSValue::encode(JSC::call(arg2, JSC::JSValue::decode(JSValue0),
|
||||
// JSC::JSValue::decode(JSValue1), args, (const char*)arg6));
|
||||
// }
|
||||
// JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSValue JSValue0,
|
||||
// JSC__JSGlobalObject* arg1,
|
||||
// JSC__Exception** arg2,
|
||||
// const unsigned char* arg3)
|
||||
// {
|
||||
// return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
|
||||
// JSC::JSValue::decode(JSValue0), JSC::ArgList(),
|
||||
// (const char*)arg3));
|
||||
// }
|
||||
// JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
|
||||
// JSC__JSValue JSValue2, JSC__Exception** arg3,
|
||||
// const unsigned char* arg4)
|
||||
// {
|
||||
// return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
|
||||
// JSC::JSValue::decode(JSValue2), JSC::ArgList(),
|
||||
// (const char*)arg4));
|
||||
// }
|
||||
// JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0,
|
||||
// JSC__JSGlobalObject* arg1, JSC__JSValue* arg2,
|
||||
// size_t arg3, JSC__Exception** arg4,
|
||||
// const unsigned char* arg5)
|
||||
// {
|
||||
// auto args = makeArgs(arg2, arg3);
|
||||
// return JSC::JSValue::encode(
|
||||
// JSC::construct(arg1, JSC::JSValue::decode(JSValue0), args, (const char*)arg5));
|
||||
// }
|
||||
|
||||
// JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(
|
||||
// JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3,
|
||||
// size_t arg4, JSC__Exception** arg5, const unsigned char* arg6)
|
||||
// {
|
||||
// auto args = makeArgs(arg3, arg4);
|
||||
// return JSC::JSValue::encode(JSC::construct(arg2, JSC::JSValue::decode(JSValue0),
|
||||
// JSC::JSValue::decode(JSValue0), args,
|
||||
// (const char*)arg6));
|
||||
// }
|
||||
// JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0,
|
||||
// JSC__JSGlobalObject* arg1,
|
||||
// JSC__JSValue JSValue2, JSC__Exception** arg3,
|
||||
// const unsigned char* arg4)
|
||||
// {
|
||||
// return JSC::JSValue::encode(JSC::construct(arg1, JSC::JSValue::decode(JSValue0),
|
||||
// JSC::JSValue::decode(JSValue2), JSC::ArgList(),
|
||||
// (const char*)arg4));
|
||||
// }
|
||||
// JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0,
|
||||
// JSC__JSGlobalObject* arg1,
|
||||
// JSC__Exception** arg2,
|
||||
// const unsigned char* arg3)
|
||||
// {
|
||||
// return JSC::JSValue::encode(
|
||||
// JSC::construct(arg1, JSC::JSValue::decode(JSValue0), JSC::ArgList(), (const char*)arg3));
|
||||
// }
|
||||
|
||||
JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1,
|
||||
const WTF__String* arg2, void* ctx,
|
||||
NativeCallbackFunction callback)
|
||||
{
|
||||
return JSC::JSNativeStdFunction::create(
|
||||
reinterpret_cast<JSC::VM&>(arg0->vm()), arg0, arg1, arg2 != nullptr ? *arg2 : WTF::String(),
|
||||
[ctx, callback](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
|
||||
-> JSC::EncodedJSValue { return callback(ctx, globalObject, callFrame); });
|
||||
}
|
||||
// JSC__JSFunction* JSC__JSFunction__createFromSourceCode(
|
||||
// JSC__JSGlobalObject* arg0,
|
||||
// const unsigned char* arg1,
|
||||
// uint16_t arg2,
|
||||
// JSC__JSValue arg3,
|
||||
// uint16_t arg4,
|
||||
// const JSC__SourceCode* source,
|
||||
// JSC__SourceOrigin* origin,
|
||||
// JSC__JSObject** exception
|
||||
// ) {
|
||||
// JSC::VM& vm = reinterpret_cast<JSC::VM&>(arg0->vm());
|
||||
// JSC::Identifier functionName = JSC::Identifier::fromString(vm, arg2 &&
|
||||
// arg1 != nullptr ? WTF::StringImpl(static_cast<const LChar*>(arg1), arg2)
|
||||
// : vm->propertyNames->anonymous.impl());
|
||||
|
||||
// JSC::FunctionExecutable* function =
|
||||
// JSC::FunctionExecutable::fromGlobalCode(
|
||||
// functionName,
|
||||
// arg0,
|
||||
// source,
|
||||
// exception,
|
||||
// 0,
|
||||
// nullptr,
|
||||
// );
|
||||
|
||||
// }
|
||||
|
||||
bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1)
|
||||
{
|
||||
auto wrap = Wrap<WTF::String, bWTF__String>(arg0->displayName(reinterpret_cast<JSC::VM&>(arg1)));
|
||||
@@ -2426,7 +2341,12 @@ void exceptionFromString(ZigException* except, JSC::JSValue value, JSC::JSGlobal
|
||||
ref->ref();
|
||||
}
|
||||
|
||||
static WTF::StringView function_string_view = WTF::StringView("Function");
|
||||
void JSC__VM__releaseWeakRefs(JSC__VM* arg0)
|
||||
{
|
||||
arg0->finalizeSynchronousJSExecution();
|
||||
}
|
||||
|
||||
static auto function_string_view = MAKE_STATIC_STRING_IMPL("Function");
|
||||
void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2)
|
||||
{
|
||||
JSC::JSCell* cell = JSC::JSValue::decode(JSValue0).asCell();
|
||||
@@ -2436,10 +2356,10 @@ void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1
|
||||
}
|
||||
|
||||
const char* ptr = cell->className();
|
||||
auto view = WTF::StringView(ptr);
|
||||
auto view = WTF::StringView(ptr, strlen(ptr));
|
||||
|
||||
// Fallback to .name if className is empty
|
||||
if (view.length() == 0 || view == function_string_view) {
|
||||
if (view.length() == 0 || StringView(String(function_string_view)) == view) {
|
||||
JSC__JSValue__getNameProperty(JSValue0, arg1, arg2);
|
||||
return;
|
||||
} else {
|
||||
@@ -2544,12 +2464,16 @@ JSC__JSValue JSC__VM__runGC(JSC__VM* vm, bool sync)
|
||||
{
|
||||
JSC::JSLockHolder lock(vm);
|
||||
|
||||
vm->finalizeSynchronousJSExecution();
|
||||
|
||||
if (sync) {
|
||||
vm->heap.collectNow(JSC::Sync, JSC::CollectionScope::Full);
|
||||
} else {
|
||||
vm->heap.collectSync(JSC::CollectionScope::Full);
|
||||
}
|
||||
|
||||
vm->finalizeSynchronousJSExecution();
|
||||
|
||||
return JSC::JSValue::encode(JSC::jsNumber(vm->heap.sizeAfterLastFullCollection()));
|
||||
}
|
||||
|
||||
@@ -2587,6 +2511,11 @@ void JSC__VM__holdAPILock(JSC__VM* arg0, void* ctx, void (*callback)(void* arg0)
|
||||
callback(ctx);
|
||||
}
|
||||
|
||||
void JSC__JSString__iterator(JSC__JSString* arg0, JSC__JSGlobalObject* arg1, void* arg2)
|
||||
{
|
||||
jsstring_iterator* iter = (jsstring_iterator*)arg2;
|
||||
arg0->value(iter);
|
||||
}
|
||||
void JSC__VM__deferGC(JSC__VM* vm, void* ctx, void (*callback)(void* arg0))
|
||||
{
|
||||
JSC::GCDeferralContext deferralContext(reinterpret_cast<JSC__VM&>(vm));
|
||||
@@ -2623,13 +2552,14 @@ bool JSC__VM__isEntered(JSC__VM* arg0) { return (*arg0).isEntered(); }
|
||||
|
||||
void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1) { (*arg0).setExecutionForbidden(); }
|
||||
|
||||
bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2,
|
||||
const unsigned char* arg3, size_t arg4)
|
||||
void JSC__VM__throwError(JSC__VM* vm_, JSC__JSGlobalObject* arg1, JSC__JSValue value)
|
||||
{
|
||||
auto scope = arg2;
|
||||
auto global = arg1;
|
||||
const String& message = WTF::String(arg3, arg4);
|
||||
return JSC::throwException(global, (*scope), createError(global, message));
|
||||
JSC::VM& vm = *reinterpret_cast<JSC::VM*>(vm_);
|
||||
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
JSC::JSObject* error = JSC::JSValue::decode(value).getObject();
|
||||
JSC::Exception* exception = JSC::Exception::create(vm, error);
|
||||
scope.throwException(arg1, exception);
|
||||
}
|
||||
|
||||
#pragma mark - JSC::ThrowScope
|
||||
@@ -2662,27 +2592,6 @@ bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, unsigned char* arg1, un
|
||||
}
|
||||
JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0) { return arg0->exception(); }
|
||||
|
||||
#pragma mark - JSC::CallFrame
|
||||
|
||||
JSC__JSValue JSC__CallFrame__argument(const JSC__CallFrame* arg0, uint16_t arg1)
|
||||
{
|
||||
return JSC::JSValue::encode(arg0->argument(arg1));
|
||||
};
|
||||
size_t JSC__CallFrame__argumentsCount(const JSC__CallFrame* arg0) { return arg0->argumentCount(); }
|
||||
JSC__JSObject* JSC__CallFrame__jsCallee(const JSC__CallFrame* arg0) { return arg0->jsCallee(); }
|
||||
JSC__JSValue JSC__CallFrame__newTarget(const JSC__CallFrame* arg0)
|
||||
{
|
||||
return JSC::JSValue::encode(arg0->newTarget());
|
||||
};
|
||||
JSC__JSValue JSC__CallFrame__thisValue(const JSC__CallFrame* arg0)
|
||||
{
|
||||
return JSC::JSValue::encode(arg0->thisValue());
|
||||
}
|
||||
JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame* arg0, uint16_t arg1)
|
||||
{
|
||||
return JSC::JSValue::encode(arg0->uncheckedArgument(arg1));
|
||||
}
|
||||
|
||||
#pragma mark - JSC::Identifier
|
||||
|
||||
void JSC__Identifier__deinit(const JSC__Identifier* arg0)
|
||||
@@ -2997,4 +2906,10 @@ JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject* arg0,
|
||||
return JSC::JSValue::encode(
|
||||
JSC::JSPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1)));
|
||||
}
|
||||
}
|
||||
|
||||
JSC__JSValue JSC__JSValue__createUninitializedUint8Array(JSC__JSGlobalObject* arg0, size_t arg1)
|
||||
{
|
||||
JSC::JSValue value = JSC::JSUint8Array::createUninitialized(arg0, arg0->m_typedArrayUint8.get(arg0), arg1);
|
||||
return JSC::JSValue::encode(value);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
pub const Shimmer = @import("./shimmer.zig").Shimmer;
|
||||
const std = @import("std");
|
||||
const bun = @import("../../../global.zig");
|
||||
const string = bun.string;
|
||||
@@ -15,6 +14,7 @@ const ZigStackTrace = Exports.ZigStackTrace;
|
||||
const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false;
|
||||
const ArrayBuffer = @import("../base.zig").ArrayBuffer;
|
||||
const JSC = @import("../../../jsc.zig");
|
||||
const Shimmer = JSC.Shimmer;
|
||||
pub const JSObject = extern struct {
|
||||
pub const shim = Shimmer("JSC", "JSObject", @This());
|
||||
bytes: shim.Bytes,
|
||||
@@ -809,6 +809,10 @@ pub const JSString = extern struct {
|
||||
return shim.cppFn("value", .{ this, globalObject });
|
||||
}
|
||||
|
||||
pub fn iterator(this: *JSString, globalObject: *JSGlobalObject, iter: *anyopaque) void {
|
||||
return shim.cppFn("iterator", .{ this, globalObject, iter });
|
||||
}
|
||||
|
||||
pub fn length(this: *const JSString) usize {
|
||||
return shim.cppFn("length", .{
|
||||
this,
|
||||
@@ -833,7 +837,20 @@ pub const JSString = extern struct {
|
||||
});
|
||||
}
|
||||
|
||||
pub const Extern = [_][]const u8{ "toObject", "eql", "value", "length", "is8Bit", "createFromOwnedString", "createFromString" };
|
||||
pub const JStringIteratorAppend8Callback = fn (*Iterator, [*]const u8, u32) callconv(.C) void;
|
||||
pub const JStringIteratorAppend16Callback = fn (*Iterator, [*]const u16, u32) callconv(.C) void;
|
||||
pub const JStringIteratorWrite8Callback = fn (*Iterator, [*]const u8, u32, u32) callconv(.C) void;
|
||||
pub const JStringIteratorWrite16Callback = fn (*Iterator, [*]const u16, u32, u32) callconv(.C) void;
|
||||
pub const Iterator = extern struct {
|
||||
data: ?*anyopaque,
|
||||
stop: u8,
|
||||
append8: ?JStringIteratorAppend8Callback,
|
||||
append16: ?JStringIteratorAppend16Callback,
|
||||
write8: ?JStringIteratorWrite8Callback,
|
||||
write16: ?JStringIteratorWrite16Callback,
|
||||
};
|
||||
|
||||
pub const Extern = [_][]const u8{ "iterator", "toObject", "eql", "value", "length", "is8Bit", "createFromOwnedString", "createFromString" };
|
||||
};
|
||||
|
||||
pub const JSPromiseRejectionOperation = enum(u32) {
|
||||
@@ -1060,6 +1077,13 @@ pub const JSModuleRecord = extern struct {
|
||||
};
|
||||
};
|
||||
|
||||
pub fn Async(comptime ReturnType: type) type {
|
||||
return struct {
|
||||
promise: *?*JSPromise,
|
||||
continuation: anyframe->ReturnType,
|
||||
};
|
||||
}
|
||||
|
||||
pub const JSPromise = extern struct {
|
||||
pub const shim = Shimmer("JSC", "JSPromise", @This());
|
||||
bytes: shim.Bytes,
|
||||
@@ -1408,8 +1432,6 @@ pub const JSFunction = extern struct {
|
||||
pub const name = "JSC::JSFunction";
|
||||
pub const namespace = "JSC";
|
||||
|
||||
pub const NativeFunctionCallback = fn (ctx: ?*anyopaque, global: [*c]JSGlobalObject, call_frame: [*c]CallFrame) callconv(.C) JSValue;
|
||||
|
||||
// pub fn createFromSourceCode(
|
||||
// global: *JSGlobalObject,
|
||||
// function_name: ?[*]const u8,
|
||||
@@ -1431,15 +1453,7 @@ pub const JSFunction = extern struct {
|
||||
// exception,
|
||||
// });
|
||||
// }
|
||||
pub fn createFromNative(
|
||||
global: *JSGlobalObject,
|
||||
argument_count: u16,
|
||||
name_: ?*const String,
|
||||
ctx: ?*anyopaque,
|
||||
func: NativeFunctionCallback,
|
||||
) *JSFunction {
|
||||
return cppFn("createFromNative", .{ global, argument_count, name_, ctx, func });
|
||||
}
|
||||
|
||||
pub fn getName(this: *JSFunction, vm: *VM) String {
|
||||
return cppFn("getName", .{ this, vm });
|
||||
}
|
||||
@@ -1453,152 +1467,13 @@ pub const JSFunction = extern struct {
|
||||
// return cppFn("toString", .{ this, globalThis });
|
||||
// }
|
||||
|
||||
pub fn callWithArgumentsAndThis(
|
||||
function: JSValue,
|
||||
thisValue: JSValue,
|
||||
globalThis: *JSGlobalObject,
|
||||
arguments_ptr: [*]JSValue,
|
||||
arguments_len: usize,
|
||||
exception: ReturnableException,
|
||||
error_message: [*c]const u8,
|
||||
) JSValue {
|
||||
return cppFn("callWithArgumentsAndThis", .{
|
||||
function,
|
||||
thisValue,
|
||||
globalThis,
|
||||
arguments_ptr,
|
||||
arguments_len,
|
||||
exception,
|
||||
error_message,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn callWithArguments(
|
||||
function: JSValue,
|
||||
globalThis: *JSGlobalObject,
|
||||
arguments_ptr: [*]JSValue,
|
||||
arguments_len: usize,
|
||||
exception: ReturnableException,
|
||||
error_message: [*c]const u8,
|
||||
) JSValue {
|
||||
return cppFn("callWithArguments", .{
|
||||
function,
|
||||
globalThis,
|
||||
arguments_ptr,
|
||||
arguments_len,
|
||||
exception,
|
||||
error_message,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn callWithThis(
|
||||
function: JSValue,
|
||||
globalThis: *JSGlobalObject,
|
||||
thisValue: JSValue,
|
||||
exception: ReturnableException,
|
||||
error_message: [*c]const u8,
|
||||
) JSValue {
|
||||
return cppFn("callWithThis", .{
|
||||
function,
|
||||
globalThis,
|
||||
thisValue,
|
||||
exception,
|
||||
error_message,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn callWithoutAnyArgumentsOrThis(
|
||||
function: JSValue,
|
||||
globalThis: *JSGlobalObject,
|
||||
exception: ReturnableException,
|
||||
error_message: [*c]const u8,
|
||||
) JSValue {
|
||||
return cppFn("callWithoutAnyArgumentsOrThis", .{ function, globalThis, exception, error_message });
|
||||
}
|
||||
|
||||
pub fn constructWithArgumentsAndNewTarget(
|
||||
function: JSValue,
|
||||
newTarget: JSValue,
|
||||
globalThis: *JSGlobalObject,
|
||||
arguments_ptr: [*]JSValue,
|
||||
arguments_len: usize,
|
||||
exception: ReturnableException,
|
||||
error_message: [*c]const u8,
|
||||
) JSValue {
|
||||
return cppFn("constructWithArgumentsAndNewTarget", .{
|
||||
function,
|
||||
newTarget,
|
||||
globalThis,
|
||||
arguments_ptr,
|
||||
arguments_len,
|
||||
exception,
|
||||
error_message,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn constructWithArguments(
|
||||
function: JSValue,
|
||||
globalThis: *JSGlobalObject,
|
||||
arguments_ptr: [*]JSValue,
|
||||
arguments_len: usize,
|
||||
exception: ReturnableException,
|
||||
error_message: [*c]const u8,
|
||||
) JSValue {
|
||||
return cppFn("constructWithArguments", .{
|
||||
function,
|
||||
globalThis,
|
||||
arguments_ptr,
|
||||
arguments_len,
|
||||
exception,
|
||||
error_message,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn constructWithNewTarget(
|
||||
function: JSValue,
|
||||
globalThis: *JSGlobalObject,
|
||||
newTarget: JSValue,
|
||||
exception: ReturnableException,
|
||||
error_message: [*c]const u8,
|
||||
) JSValue {
|
||||
return cppFn("constructWithNewTarget", .{
|
||||
function,
|
||||
globalThis,
|
||||
newTarget,
|
||||
exception,
|
||||
error_message,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn constructWithoutAnyArgumentsOrNewTarget(
|
||||
function: JSValue,
|
||||
globalThis: *JSGlobalObject,
|
||||
exception: ReturnableException,
|
||||
error_message: [*c]const u8,
|
||||
) JSValue {
|
||||
return cppFn("constructWithoutAnyArgumentsOrNewTarget", .{
|
||||
function,
|
||||
globalThis,
|
||||
exception,
|
||||
error_message,
|
||||
});
|
||||
}
|
||||
|
||||
pub const Extern = [_][]const u8{
|
||||
"fromString",
|
||||
// "createFromSourceCode",
|
||||
"createFromNative",
|
||||
|
||||
"getName",
|
||||
"displayName",
|
||||
"calculatedDisplayName",
|
||||
"callWithArgumentsAndThis",
|
||||
"callWithArguments",
|
||||
"callWithThis",
|
||||
"callWithoutAnyArgumentsOrThis",
|
||||
"constructWithArgumentsAndNewTarget",
|
||||
"constructWithArguments",
|
||||
"constructWithNewTarget",
|
||||
"constructWithoutAnyArgumentsOrNewTarget",
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1631,6 +1506,10 @@ pub const JSGlobalObject = extern struct {
|
||||
}
|
||||
pub const ctx = ref;
|
||||
|
||||
pub inline fn ptr(this: *JSGlobalObject) *JSGlobalObject {
|
||||
return this;
|
||||
}
|
||||
|
||||
pub fn objectPrototype(this: *JSGlobalObject) *ObjectPrototype {
|
||||
return cppFn("objectPrototype", .{this});
|
||||
}
|
||||
@@ -1728,7 +1607,20 @@ pub const JSGlobalObject = extern struct {
|
||||
return cppFn("deleteModuleRegistryEntry", .{ this, name_ });
|
||||
}
|
||||
|
||||
pub fn bunVM_(this: *JSGlobalObject) *anyopaque {
|
||||
return cppFn("bunVM", .{this});
|
||||
}
|
||||
|
||||
pub fn bunVM(this: *JSGlobalObject) *JSC.VirtualMachine {
|
||||
if (comptime bun.Environment.allow_assert) {
|
||||
std.debug.assert(this.bunVM_() == @ptrCast(*anyopaque, JSC.VirtualMachine.vm));
|
||||
}
|
||||
|
||||
return @ptrCast(*JSC.VirtualMachine, @alignCast(std.meta.alignment(JSC.VirtualMachine), this.bunVM_()));
|
||||
}
|
||||
|
||||
pub const Extern = [_][]const u8{
|
||||
"bunVM",
|
||||
"putCachedObject",
|
||||
"getCachedObject",
|
||||
"createAggregateError",
|
||||
@@ -2012,19 +1904,27 @@ pub const String = extern struct {
|
||||
};
|
||||
};
|
||||
|
||||
pub const JSValue = enum(u64) {
|
||||
pub const JSValue = enum(i64) {
|
||||
@"undefined" = 0xa,
|
||||
_,
|
||||
|
||||
pub const shim = Shimmer("JSC", "JSValue", @This());
|
||||
pub const is_pointer = false;
|
||||
pub const Type = u64;
|
||||
pub const Type = i64;
|
||||
const cppFn = shim.cppFn;
|
||||
|
||||
pub const Encoded = extern union {
|
||||
asInt64: i64,
|
||||
ptr: *JSCell,
|
||||
asBits: extern struct { payload: i32, tag: i32 },
|
||||
asPtr: *anyopaque,
|
||||
asDouble: f64,
|
||||
};
|
||||
|
||||
pub const include = "JavaScriptCore/JSValue.h";
|
||||
pub const name = "JSC::JSValue";
|
||||
pub const namespace = "JSC";
|
||||
pub const zero = @intToEnum(JSValue, @as(u64, 0));
|
||||
pub const zero = @intToEnum(JSValue, @as(i64, 0));
|
||||
pub const JSType = enum(u8) {
|
||||
// The Cell value must come before any JS that is a JSCell.
|
||||
Cell,
|
||||
@@ -2289,6 +2189,20 @@ pub const JSValue = enum(u64) {
|
||||
return JSC.C.JSValueIsInstanceOfConstructor(global.ref(), this.asObjectRef(), constructor.asObjectRef(), null);
|
||||
}
|
||||
|
||||
pub fn call(this: JSValue, globalThis: *JSGlobalObject, args: []const JSC.JSValue) JSC.JSValue {
|
||||
return callWithThis(this, globalThis, JSC.JSValue.zero, args);
|
||||
}
|
||||
|
||||
pub fn callWithThis(this: JSValue, globalThis: *JSGlobalObject, thisValue: JSC.JSValue, args: []const JSC.JSValue) JSC.JSValue {
|
||||
return JSC.C.JSObjectCallAsFunctionReturnValue(
|
||||
globalThis.ref(),
|
||||
this.asObjectRef(),
|
||||
thisValue.asObjectRef(),
|
||||
args.len,
|
||||
@ptrCast([*]const JSC.C.JSValueRef, args.ptr),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn jsType(
|
||||
this: JSValue,
|
||||
) JSType {
|
||||
@@ -2345,6 +2259,16 @@ pub const JSValue = enum(u64) {
|
||||
return JSC.GetJSPrivateData(ZigType, value.asObjectRef());
|
||||
}
|
||||
|
||||
pub fn protect(this: JSValue) void {
|
||||
if (this.isEmptyOrUndefinedOrNull() or this.isNumber()) return;
|
||||
JSC.C.JSValueProtect(JSC.VirtualMachine.vm.global, this.asObjectRef());
|
||||
}
|
||||
|
||||
pub fn unprotect(this: JSValue) void {
|
||||
if (this.isEmptyOrUndefinedOrNull() or this.isNumber()) return;
|
||||
JSC.C.JSValueUnprotect(JSC.VirtualMachine.vm.global, this.asObjectRef());
|
||||
}
|
||||
|
||||
/// Create an object with exactly two properties
|
||||
pub fn createObject2(global: *JSGlobalObject, key1: *const ZigString, key2: *const ZigString, value1: JSValue, value2: JSValue) JSValue {
|
||||
return cppFn("createObject2", .{ global, key1, key2, value1, value2 });
|
||||
@@ -2369,6 +2293,11 @@ pub const JSValue = enum(u64) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn createUninitializedUint8Array(globalObject: *JSGlobalObject, len: usize) JSValue {
|
||||
if (comptime JSC.is_bindgen) unreachable;
|
||||
return shim.cppFn("createUninitializedUint8Array", .{ globalObject, len });
|
||||
}
|
||||
|
||||
pub fn createBufferWithCtx(globalObject: *JSGlobalObject, slice: []u8, ptr: ?*anyopaque, func: JSC.C.JSTypedArrayBytesDeallocator) JSValue {
|
||||
if (comptime JSC.is_bindgen) unreachable;
|
||||
@setRuntimeSafety(false);
|
||||
@@ -2527,15 +2456,23 @@ pub const JSValue = enum(u64) {
|
||||
pub fn isUInt32AsAnyInt(this: JSValue) bool {
|
||||
return cppFn("isUInt32AsAnyInt", .{this});
|
||||
}
|
||||
pub fn isInt32(this: JSValue) bool {
|
||||
return cppFn("isInt32", .{this});
|
||||
|
||||
pub fn asEncoded(this: JSValue) Encoded {
|
||||
return @bitCast(Encoded, this);
|
||||
}
|
||||
|
||||
pub fn isInt32(this: JSValue) bool {
|
||||
return (@bitCast(c_ulonglong, @enumToInt(this)) & @as(c_ulonglong, 18446181123756130304)) == @as(c_ulonglong, 18446181123756130304);
|
||||
}
|
||||
|
||||
pub fn isInt32AsAnyInt(this: JSValue) bool {
|
||||
return cppFn("isInt32AsAnyInt", .{this});
|
||||
}
|
||||
|
||||
pub fn isNumber(this: JSValue) bool {
|
||||
return cppFn("isNumber", .{this});
|
||||
return (@bitCast(c_ulonglong, @enumToInt(this)) & @as(c_ulonglong, 18446181123756130304)) != 0;
|
||||
}
|
||||
|
||||
pub fn isError(this: JSValue) bool {
|
||||
return cppFn("isError", .{this});
|
||||
}
|
||||
@@ -2707,7 +2644,7 @@ pub const JSValue = enum(u64) {
|
||||
const Thenable = fn (
|
||||
global: [*c]JSGlobalObject,
|
||||
ctx: ?*anyopaque,
|
||||
arguments_ptr: JSC.JSValue,
|
||||
arguments_ptr: [*c]*anyopaque,
|
||||
arguments_len: usize,
|
||||
) callconv(.C) void;
|
||||
pub fn _then(this: JSValue, global: *JSGlobalObject, ctx: ?*anyopaque, resolve: Thenable, reject: Thenable) void {
|
||||
@@ -2718,23 +2655,21 @@ pub const JSValue = enum(u64) {
|
||||
fn resolve(
|
||||
globalThis: [*c]JSGlobalObject,
|
||||
ptr: ?*anyopaque,
|
||||
arguments_ptr_: JSC.JSValue,
|
||||
arguments_ptr: [*c]*anyopaque,
|
||||
arguments_len: usize,
|
||||
) callconv(.C) void {
|
||||
@setRuntimeSafety(false);
|
||||
var arguments_ptr = @intToPtr([*]const JSC.JSValue, @enumToInt(arguments_ptr_));
|
||||
onResolve(bun.cast(*Then, ptr.?), globalThis, arguments_ptr[0..arguments_len]);
|
||||
onResolve(bun.cast(*Then, ptr.?), globalThis, @ptrCast([*]const JSC.JSValue, arguments_ptr)[0..arguments_len]);
|
||||
}
|
||||
|
||||
pub fn reject(
|
||||
globalThis: [*c]JSGlobalObject,
|
||||
ptr: ?*anyopaque,
|
||||
arguments_ptr_: JSC.JSValue,
|
||||
arguments_ptr: [*c]*anyopaque,
|
||||
arguments_len: usize,
|
||||
) callconv(.C) void {
|
||||
@setRuntimeSafety(false);
|
||||
var arguments_ptr = @intToPtr([*]const JSC.JSValue, @enumToInt(arguments_ptr_));
|
||||
onReject(bun.cast(*Then, ptr.?), globalThis, arguments_ptr[0..arguments_len]);
|
||||
onReject(bun.cast(*Then, ptr.?), globalThis, @ptrCast([*]const JSC.JSValue, arguments_ptr)[0..arguments_len]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2815,21 +2750,69 @@ pub const JSValue = enum(u64) {
|
||||
}
|
||||
|
||||
pub fn asNumber(this: JSValue) f64 {
|
||||
if (this.isInt32()) {
|
||||
return @intToFloat(f64, this.toInt32());
|
||||
}
|
||||
|
||||
if (isNumber(this)) {
|
||||
return asDouble(this);
|
||||
}
|
||||
|
||||
if (this.isUndefinedOrNull()) {
|
||||
return 0.0;
|
||||
} else if (this.isBoolean()) {
|
||||
return if (asBoolean(this)) 1.0 else 0.0;
|
||||
}
|
||||
|
||||
return cppFn("asNumber", .{
|
||||
this,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn asDouble(this: JSValue) f64 {
|
||||
return @bitCast(f64, @enumToInt(this) - comptime (@as(c_longlong, 1) << @intCast(@import("std").math.Log2Int(c_longlong), 49)));
|
||||
}
|
||||
|
||||
pub fn asPtr(this: JSValue, comptime Pointer: type) *Pointer {
|
||||
return @intToPtr(*Pointer, @bitCast(usize, this.asDouble()));
|
||||
}
|
||||
|
||||
pub fn fromPtrAddress(addr: anytype) JSValue {
|
||||
return jsNumber(@bitCast(f64, @as(usize, addr)));
|
||||
}
|
||||
|
||||
pub fn fromPtr(addr: anytype) JSValue {
|
||||
return fromPtrAddress(@ptrToInt(addr));
|
||||
}
|
||||
|
||||
pub fn toBoolean(this: JSValue) bool {
|
||||
return cppFn("toBoolean", .{
|
||||
if (isUndefinedOrNull(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return asBoolean(this);
|
||||
}
|
||||
|
||||
pub fn asBoolean(this: JSValue) bool {
|
||||
return @enumToInt(this) == @bitCast(c_longlong, @as(c_longlong, (@as(c_int, 2) | @as(c_int, 4)) | @as(c_int, 1)));
|
||||
}
|
||||
|
||||
pub fn toInt32(this: JSValue) i32 {
|
||||
if (this.isInt32()) {
|
||||
return asInt32(this);
|
||||
}
|
||||
|
||||
if (this.isNumber()) {
|
||||
return @truncate(i32, @floatToInt(i64, asDouble(this)));
|
||||
}
|
||||
|
||||
return cppFn("toInt32", .{
|
||||
this,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn toInt32(this: JSValue) i32 {
|
||||
return cppFn("toInt32", .{
|
||||
this,
|
||||
});
|
||||
pub fn asInt32(this: JSValue) i32 {
|
||||
return @bitCast(i32, @truncate(c_int, @enumToInt(this)));
|
||||
}
|
||||
|
||||
pub inline fn toU16(this: JSValue) u16 {
|
||||
@@ -2875,15 +2858,15 @@ pub const JSValue = enum(u64) {
|
||||
}
|
||||
|
||||
pub inline fn asRef(this: JSValue) C_API.JSValueRef {
|
||||
return @intToPtr(C_API.JSValueRef, @intCast(usize, @enumToInt(this)));
|
||||
return @intToPtr(C_API.JSValueRef, @bitCast(usize, @enumToInt(this)));
|
||||
}
|
||||
|
||||
pub inline fn c(this: C_API.JSValueRef) JSValue {
|
||||
return @intToEnum(JSValue, @ptrToInt(this));
|
||||
return @intToEnum(JSValue, @bitCast(JSValue.Type, @ptrToInt(this)));
|
||||
}
|
||||
|
||||
pub inline fn fromRef(this: C_API.JSValueRef) JSValue {
|
||||
return @intToEnum(JSValue, @ptrToInt(this));
|
||||
return @intToEnum(JSValue, @bitCast(JSValue.Type, @ptrToInt(this)));
|
||||
}
|
||||
|
||||
pub inline fn asObjectRef(this: JSValue) C_API.JSObjectRef {
|
||||
@@ -2894,6 +2877,7 @@ pub const JSValue = enum(u64) {
|
||||
/// It knows not to free it
|
||||
/// This mimicks the implementation in JavaScriptCore's C++
|
||||
pub inline fn ensureStillAlive(this: JSValue) void {
|
||||
if (this.isEmpty() or this.isNumber() or this.isBoolean() or this.isUndefinedOrNull()) return;
|
||||
std.mem.doNotOptimizeAway(@ptrCast(C_API.JSObjectRef, this.asVoid()));
|
||||
}
|
||||
|
||||
@@ -2903,13 +2887,14 @@ pub const JSValue = enum(u64) {
|
||||
@panic("JSValue is null");
|
||||
}
|
||||
}
|
||||
return @intToPtr(*anyopaque, @enumToInt(this));
|
||||
return @intToPtr(*anyopaque, @bitCast(usize, @enumToInt(this)));
|
||||
}
|
||||
|
||||
pub const Extern = [_][]const u8{ "fromInt64NoTruncate", "fromUInt64NoTruncate", "toUInt64NoTruncate", "asPromise", "toInt64", "_then", "put", "makeWithNameAndPrototype", "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "getReadableStreamState", "getWritableStreamState", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" };
|
||||
pub const Extern = [_][]const u8{ "createUninitializedUint8Array", "fromInt64NoTruncate", "fromUInt64NoTruncate", "toUInt64NoTruncate", "asPromise", "toInt64", "_then", "put", "makeWithNameAndPrototype", "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "getReadableStreamState", "getWritableStreamState", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" };
|
||||
};
|
||||
|
||||
extern "c" fn Microtask__run(*Microtask, *JSGlobalObject) void;
|
||||
extern "c" fn Microtask__run_default(*MicrotaskForDefaultGlobalObject, *JSGlobalObject) void;
|
||||
|
||||
pub const Microtask = opaque {
|
||||
pub const name = "Zig::JSMicrotaskCallback";
|
||||
@@ -2924,6 +2909,16 @@ pub const Microtask = opaque {
|
||||
}
|
||||
};
|
||||
|
||||
pub const MicrotaskForDefaultGlobalObject = opaque {
|
||||
pub fn run(this: *MicrotaskForDefaultGlobalObject, global_object: *JSGlobalObject) void {
|
||||
if (comptime is_bindgen) {
|
||||
return;
|
||||
}
|
||||
|
||||
return Microtask__run_default(this, global_object);
|
||||
}
|
||||
};
|
||||
|
||||
pub const PropertyName = extern struct {
|
||||
pub const shim = Shimmer("JSC", "PropertyName", @This());
|
||||
bytes: shim.Bytes,
|
||||
@@ -3103,18 +3098,18 @@ pub const VM = extern struct {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn throwError(vm: *VM, global_object: *JSGlobalObject, scope: *ThrowScope, message: [*]const u8, len: usize) bool {
|
||||
pub fn throwError(vm: *VM, global_object: *JSGlobalObject, value: JSValue) void {
|
||||
return cppFn("throwError", .{
|
||||
vm,
|
||||
|
||||
global_object,
|
||||
scope,
|
||||
|
||||
message,
|
||||
len,
|
||||
value,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn releaseWeakRefs(vm: *VM) void {
|
||||
return cppFn("releaseWeakRefs", .{vm});
|
||||
}
|
||||
|
||||
pub fn drainMicrotasks(
|
||||
vm: *VM,
|
||||
) void {
|
||||
@@ -3130,7 +3125,7 @@ pub const VM = extern struct {
|
||||
vm,
|
||||
});
|
||||
}
|
||||
pub const Extern = [_][]const u8{ "doWork", "deferGC", "holdAPILock", "runGC", "generateHeapSnapshot", "isJITEnabled", "deleteAllCode", "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError", "drainMicrotasks", "whenIdle", "shrinkFootprint", "setExecutionTimeLimit", "clearExecutionTimeLimit" };
|
||||
pub const Extern = [_][]const u8{ "releaseWeakRefs", "throwError", "doWork", "deferGC", "holdAPILock", "runGC", "generateHeapSnapshot", "isJITEnabled", "deleteAllCode", "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError", "drainMicrotasks", "whenIdle", "shrinkFootprint", "setExecutionTimeLimit", "clearExecutionTimeLimit" };
|
||||
};
|
||||
|
||||
pub const ThrowScope = extern struct {
|
||||
@@ -3206,59 +3201,39 @@ pub const CatchScope = extern struct {
|
||||
};
|
||||
};
|
||||
|
||||
pub const CallFrame = extern struct {
|
||||
pub const shim = Shimmer("JSC", "CallFrame", @This());
|
||||
bytes: shim.Bytes,
|
||||
const cppFn = shim.cppFn;
|
||||
pub const CallFrame = opaque {
|
||||
/// The value is generated in `make sizegen`
|
||||
/// The value is 6.
|
||||
/// On ARM64_32, the value is something else but it really doesn't matter for our case
|
||||
/// However, I don't want this to subtly break amidst future upgrades to JavaScriptCore
|
||||
const arguments_offset = 6;
|
||||
const thisValue_offset = arguments_offset - 1;
|
||||
const argumentsCount_offset = thisValue_offset - 1;
|
||||
const alignment = std.meta.alignment([]const JSC.JSValue);
|
||||
|
||||
pub const include = "JavaScriptCore/CallFrame.h";
|
||||
pub const name = "JSC::CallFrame";
|
||||
pub const namespace = "JSC";
|
||||
|
||||
pub inline fn argumentsCount(call_frame: *const CallFrame) usize {
|
||||
return cppFn("argumentsCount", .{
|
||||
call_frame,
|
||||
});
|
||||
}
|
||||
pub inline fn uncheckedArgument(call_frame: *const CallFrame, i: u16) JSValue {
|
||||
return cppFn("uncheckedArgument", .{ call_frame, i });
|
||||
}
|
||||
pub inline fn argument(call_frame: *const CallFrame, i: u16) JSValue {
|
||||
return cppFn("argument", .{
|
||||
call_frame,
|
||||
i,
|
||||
});
|
||||
}
|
||||
pub inline fn thisValue(call_frame: *const CallFrame) ?JSValue {
|
||||
return cppFn("thisValue", .{
|
||||
call_frame,
|
||||
});
|
||||
pub fn argumentsPtr(self: *const CallFrame) [*]const JSC.JSValue {
|
||||
return @ptrCast([*]const JSC.JSValue, @alignCast(alignment, self)) + arguments_offset;
|
||||
}
|
||||
|
||||
pub inline fn setThisValue(call_frame: *CallFrame, new_this: JSValue) ?JSValue {
|
||||
return cppFn("setThisValue", .{
|
||||
call_frame,
|
||||
new_this,
|
||||
});
|
||||
}
|
||||
pub inline fn newTarget(call_frame: *const CallFrame) ?JSValue {
|
||||
return cppFn("newTarget", .{
|
||||
call_frame,
|
||||
});
|
||||
pub fn callee(self: *const CallFrame) JSC.JSValue {
|
||||
return (@ptrCast([*]const JSC.JSValue, @alignCast(alignment, self)) + arguments_offset - 1)[0];
|
||||
}
|
||||
|
||||
pub inline fn setNewTarget(call_frame: *CallFrame, target: JSValue) ?JSValue {
|
||||
return cppFn("setNewTarget", .{
|
||||
call_frame,
|
||||
target,
|
||||
});
|
||||
pub fn arguments(self: *const CallFrame) []const JSC.JSValue {
|
||||
return self.argumentsPtr()[0..self.argumentsCount()];
|
||||
}
|
||||
pub inline fn jsCallee(call_frame: *const CallFrame) *JSObject {
|
||||
return cppFn("jsCallee", .{
|
||||
call_frame,
|
||||
});
|
||||
|
||||
pub fn argument(self: *const CallFrame, comptime i: comptime_int) JSC.JSValue {
|
||||
return self.argumentsPtr()[i];
|
||||
}
|
||||
|
||||
pub fn this(self: *const CallFrame) JSC.JSValue {
|
||||
return (@ptrCast([*]const JSC.JSValue, @alignCast(alignment, self)) + thisValue_offset)[0];
|
||||
}
|
||||
|
||||
pub fn argumentsCount(self: *const CallFrame) usize {
|
||||
return (@ptrCast([*]const usize, @alignCast(alignment, self)) + argumentsCount_offset)[0];
|
||||
}
|
||||
pub const Extern = [_][]const u8{ "argumentsCount", "uncheckedArgument", "argument", "thisValue", "newTarget", "jsCallee", "setNewTarget", "setThisValue" };
|
||||
};
|
||||
|
||||
// pub const WellKnownSymbols = extern struct {
|
||||
@@ -3478,6 +3453,47 @@ pub const ExternalStringImpl = extern struct {
|
||||
};
|
||||
};
|
||||
|
||||
pub const JSArray = struct {
|
||||
pub fn from(globalThis: *JSGlobalObject, arguments: []const JSC.JSValue) JSValue {
|
||||
return JSC.JSValue.c(JSC.C.JSObjectMakeArray(globalThis.ref(), arguments.len, @ptrCast([*]const JSC.C.JSObjectRef, arguments.ptr), null));
|
||||
}
|
||||
};
|
||||
|
||||
const private = struct {
|
||||
pub extern fn Bun__CreateFFIFunction(
|
||||
globalObject: *JSGlobalObject,
|
||||
symbolName: ?*const ZigString,
|
||||
argCount: u32,
|
||||
functionPointer: *const anyopaque,
|
||||
) *anyopaque;
|
||||
|
||||
pub extern fn Bun__CreateFFIFunctionValue(
|
||||
globalObject: *JSGlobalObject,
|
||||
symbolName: ?*const ZigString,
|
||||
argCount: u32,
|
||||
functionPointer: *const anyopaque,
|
||||
) JSValue;
|
||||
};
|
||||
pub fn NewFunctionPtr(
|
||||
globalObject: *JSGlobalObject,
|
||||
symbolName: ?*const ZigString,
|
||||
argCount: u32,
|
||||
functionPointer: anytype,
|
||||
) *anyopaque {
|
||||
if (comptime JSC.is_bindgen) unreachable;
|
||||
return private.Bun__CreateFFIFunction(globalObject, symbolName, argCount, @ptrCast(*const anyopaque, functionPointer));
|
||||
}
|
||||
|
||||
pub fn NewFunction(
|
||||
globalObject: *JSGlobalObject,
|
||||
symbolName: ?*const ZigString,
|
||||
argCount: u32,
|
||||
functionPointer: anytype,
|
||||
) JSValue {
|
||||
if (comptime JSC.is_bindgen) unreachable;
|
||||
return private.Bun__CreateFFIFunctionValue(globalObject, symbolName, argCount, @ptrCast(*const anyopaque, functionPointer));
|
||||
}
|
||||
|
||||
pub const ObjectPrototype = _JSCellStub("ObjectPrototype");
|
||||
pub const FunctionPrototype = _JSCellStub("FunctionPrototype");
|
||||
pub const ArrayPrototype = _JSCellStub("ArrayPrototype");
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Canon Inc.
|
||||
* Copyright (C) 2015 Igalia S.L.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
@getter
|
||||
function highWaterMark()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const highWaterMark = @getByIdDirectPrivate(this, "highWaterMark");
|
||||
if (highWaterMark === @undefined)
|
||||
@throwTypeError("ByteLengthQueuingStrategy.highWaterMark getter called on incompatible |this| value.");
|
||||
|
||||
return highWaterMark;
|
||||
}
|
||||
|
||||
function size(chunk)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
return chunk.byteLength;
|
||||
}
|
||||
|
||||
function initializeByteLengthQueuingStrategy(parameters)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@putByIdDirectPrivate(this, "highWaterMark", @extractHighWaterMarkFromQueuingStrategyInit(parameters));
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Canon Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
@getter
|
||||
function highWaterMark()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const highWaterMark = @getByIdDirectPrivate(this, "highWaterMark");
|
||||
if (highWaterMark === @undefined)
|
||||
@throwTypeError("CountQueuingStrategy.highWaterMark getter called on incompatible |this| value.");
|
||||
|
||||
return highWaterMark;
|
||||
}
|
||||
|
||||
function size()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
function initializeCountQueuingStrategy(parameters)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@putByIdDirectPrivate(this, "highWaterMark", @extractHighWaterMarkFromQueuingStrategyInit(parameters));
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Canon Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function initializeReadableByteStreamController(stream, underlyingByteSource, highWaterMark)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (arguments.length !== 4 && arguments[3] !== @isReadableStream)
|
||||
@throwTypeError("ReadableByteStreamController constructor should not be called directly");
|
||||
|
||||
return @privateInitializeReadableByteStreamController.@call(this, stream, underlyingByteSource, highWaterMark);
|
||||
}
|
||||
|
||||
function enqueue(chunk)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableByteStreamController(this))
|
||||
throw @makeThisTypeError("ReadableByteStreamController", "enqueue");
|
||||
|
||||
if (@getByIdDirectPrivate(this, "closeRequested"))
|
||||
@throwTypeError("ReadableByteStreamController is requested to close");
|
||||
|
||||
if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== @streamReadable)
|
||||
@throwTypeError("ReadableStream is not readable");
|
||||
|
||||
if (!@isObject(chunk) || !@ArrayBuffer.@isView(chunk))
|
||||
@throwTypeError("Provided chunk is not a TypedArray");
|
||||
|
||||
return @readableByteStreamControllerEnqueue(this, chunk);
|
||||
}
|
||||
|
||||
function error(error)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableByteStreamController(this))
|
||||
throw @makeThisTypeError("ReadableByteStreamController", "error");
|
||||
|
||||
if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== @streamReadable)
|
||||
@throwTypeError("ReadableStream is not readable");
|
||||
|
||||
@readableByteStreamControllerError(this, error);
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableByteStreamController(this))
|
||||
throw @makeThisTypeError("ReadableByteStreamController", "close");
|
||||
|
||||
if (@getByIdDirectPrivate(this, "closeRequested"))
|
||||
@throwTypeError("Close has already been requested");
|
||||
|
||||
if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== @streamReadable)
|
||||
@throwTypeError("ReadableStream is not readable");
|
||||
|
||||
@readableByteStreamControllerClose(this);
|
||||
}
|
||||
|
||||
@getter
|
||||
function byobRequest()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableByteStreamController(this))
|
||||
throw @makeGetterTypeError("ReadableByteStreamController", "byobRequest");
|
||||
|
||||
|
||||
var request = @getByIdDirectPrivate(this, "byobRequest");
|
||||
if (request === @undefined) {
|
||||
var pending = @getByIdDirectPrivate(this, "pendingPullIntos");
|
||||
const firstDescriptor = pending.peek();
|
||||
if (firstDescriptor) {
|
||||
const view = new @Uint8Array(firstDescriptor.buffer,
|
||||
firstDescriptor.byteOffset + firstDescriptor.bytesFilled,
|
||||
firstDescriptor.byteLength - firstDescriptor.bytesFilled);
|
||||
@putByIdDirectPrivate(this, "byobRequest", new @ReadableStreamBYOBRequest(this, view, @isReadableStream));
|
||||
}
|
||||
}
|
||||
|
||||
return @getByIdDirectPrivate(this, "byobRequest");
|
||||
}
|
||||
|
||||
@getter
|
||||
function desiredSize()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableByteStreamController(this))
|
||||
throw @makeGetterTypeError("ReadableByteStreamController", "desiredSize");
|
||||
|
||||
return @readableByteStreamControllerGetDesiredSize(this);
|
||||
}
|
||||
@@ -0,0 +1,705 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Canon Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
// @internal
|
||||
|
||||
function privateInitializeReadableByteStreamController(stream, underlyingByteSource, highWaterMark)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStream(stream))
|
||||
@throwTypeError("ReadableByteStreamController needs a ReadableStream");
|
||||
|
||||
// readableStreamController is initialized with null value.
|
||||
if (@getByIdDirectPrivate(stream, "readableStreamController") !== null)
|
||||
@throwTypeError("ReadableStream already has a controller");
|
||||
|
||||
@putByIdDirectPrivate(this, "controlledReadableStream", stream);
|
||||
@putByIdDirectPrivate(this, "underlyingByteSource", underlyingByteSource);
|
||||
@putByIdDirectPrivate(this, "pullAgain", false);
|
||||
@putByIdDirectPrivate(this, "pulling", false);
|
||||
@readableByteStreamControllerClearPendingPullIntos(this);
|
||||
@putByIdDirectPrivate(this, "queue", @newQueue());
|
||||
@putByIdDirectPrivate(this, "started", false);
|
||||
@putByIdDirectPrivate(this, "closeRequested", false);
|
||||
|
||||
let hwm = @toNumber(highWaterMark);
|
||||
if (@isNaN(hwm) || hwm < 0)
|
||||
@throwRangeError("highWaterMark value is negative or not a number");
|
||||
@putByIdDirectPrivate(this, "strategyHWM", hwm);
|
||||
|
||||
let autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
|
||||
if (autoAllocateChunkSize !== @undefined) {
|
||||
autoAllocateChunkSize = @toNumber(autoAllocateChunkSize);
|
||||
if (autoAllocateChunkSize <= 0 || autoAllocateChunkSize === @Infinity || autoAllocateChunkSize === -@Infinity)
|
||||
@throwRangeError("autoAllocateChunkSize value is negative or equal to positive or negative infinity");
|
||||
}
|
||||
@putByIdDirectPrivate(this, "autoAllocateChunkSize", autoAllocateChunkSize);
|
||||
@putByIdDirectPrivate(this, "pendingPullIntos", @createFIFO());
|
||||
|
||||
const controller = this;
|
||||
const startResult = @promiseInvokeOrNoopNoCatch(underlyingByteSource, "start", [this]).@then(() => {
|
||||
@putByIdDirectPrivate(controller, "started", true);
|
||||
@assert(!@getByIdDirectPrivate(controller, "pulling"));
|
||||
@assert(!@getByIdDirectPrivate(controller, "pullAgain"));
|
||||
@readableByteStreamControllerCallPullIfNeeded(controller);
|
||||
}, (error) => {
|
||||
if (@getByIdDirectPrivate(stream, "state") === @streamReadable)
|
||||
@readableByteStreamControllerError(controller, error);
|
||||
});
|
||||
|
||||
@putByIdDirectPrivate(this, "cancel", @readableByteStreamControllerCancel);
|
||||
@putByIdDirectPrivate(this, "pull", @readableByteStreamControllerPull);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function privateInitializeReadableStreamBYOBRequest(controller, view)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@putByIdDirectPrivate(this, "associatedReadableByteStreamController", controller);
|
||||
@putByIdDirectPrivate(this, "view", view);
|
||||
}
|
||||
|
||||
function isReadableByteStreamController(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// Same test mechanism as in isReadableStreamDefaultController (ReadableStreamInternals.js).
|
||||
// See corresponding function for explanations.
|
||||
return @isObject(controller) && !!@getByIdDirectPrivate(controller, "underlyingByteSource");
|
||||
}
|
||||
|
||||
function isReadableStreamBYOBRequest(byobRequest)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// Same test mechanism as in isReadableStreamDefaultController (ReadableStreamInternals.js).
|
||||
// See corresponding function for explanations.
|
||||
return @isObject(byobRequest) && !!@getByIdDirectPrivate(byobRequest, "associatedReadableByteStreamController");
|
||||
}
|
||||
|
||||
function isReadableStreamBYOBReader(reader)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// Spec tells to return true only if reader has a readIntoRequests internal slot.
|
||||
// However, since it is a private slot, it cannot be checked using hasOwnProperty().
|
||||
// Since readIntoRequests is initialized with an empty array, the following test is ok.
|
||||
return @isObject(reader) && !!@getByIdDirectPrivate(reader, "readIntoRequests");
|
||||
}
|
||||
|
||||
function readableByteStreamControllerCancel(controller, reason)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
var pendingPullIntos = @getByIdDirectPrivate(controller, "pendingPullIntos");
|
||||
var first = pendingPullIntos.peek();
|
||||
if (first)
|
||||
first.bytesFilled = 0;
|
||||
|
||||
@putByIdDirectPrivate(controller, "queue", @newQueue());
|
||||
return @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, "underlyingByteSource"), "cancel", [reason]);
|
||||
}
|
||||
|
||||
function readableByteStreamControllerError(controller, e)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable);
|
||||
@readableByteStreamControllerClearPendingPullIntos(controller);
|
||||
@putByIdDirectPrivate(controller, "queue", @newQueue());
|
||||
@readableStreamError(@getByIdDirectPrivate(controller, "controlledReadableStream"), e);
|
||||
}
|
||||
|
||||
function readableByteStreamControllerClose(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(!@getByIdDirectPrivate(controller, "closeRequested"));
|
||||
@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable);
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "queue").size > 0) {
|
||||
@putByIdDirectPrivate(controller, "closeRequested", true);
|
||||
return;
|
||||
}
|
||||
|
||||
var first = @getByIdDirectPrivate(controller, "pendingPullIntos")?.peek();
|
||||
if (first) {
|
||||
if (first.bytesFilled > 0) {
|
||||
const e = @makeTypeError("Close requested while there remain pending bytes");
|
||||
@readableByteStreamControllerError(controller, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
|
||||
}
|
||||
|
||||
function readableByteStreamControllerClearPendingPullIntos(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@readableByteStreamControllerInvalidateBYOBRequest(controller);
|
||||
var existing = @getByIdDirectPrivate(controller, "pendingPullIntos");
|
||||
if (existing !== @undefined) {
|
||||
existing.clear();
|
||||
} else {
|
||||
@putByIdDirectPrivate(controller, "pendingPullIntos", @createFIFO());
|
||||
}
|
||||
}
|
||||
|
||||
function readableByteStreamControllerGetDesiredSize(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
const state = @getByIdDirectPrivate(stream, "state");
|
||||
|
||||
if (state === @streamErrored)
|
||||
return null;
|
||||
if (state === @streamClosed)
|
||||
return 0;
|
||||
|
||||
return @getByIdDirectPrivate(controller, "strategyHWM") - @getByIdDirectPrivate(controller, "queue").size;
|
||||
}
|
||||
|
||||
function readableStreamHasBYOBReader(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const reader = @getByIdDirectPrivate(stream, "reader");
|
||||
return reader !== @undefined && @isReadableStreamBYOBReader(reader);
|
||||
}
|
||||
|
||||
function readableStreamHasDefaultReader(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const reader = @getByIdDirectPrivate(stream, "reader");
|
||||
return reader !== @undefined && @isReadableStreamDefaultReader(reader);
|
||||
}
|
||||
|
||||
function readableByteStreamControllerHandleQueueDrain(controller) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable);
|
||||
if (!@getByIdDirectPrivate(controller, "queue").size && @getByIdDirectPrivate(controller, "closeRequested"))
|
||||
@readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
|
||||
else
|
||||
@readableByteStreamControllerCallPullIfNeeded(controller);
|
||||
}
|
||||
|
||||
function readableByteStreamControllerPull(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
@assert(@readableStreamHasDefaultReader(stream));
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "queue").size > 0) {
|
||||
@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests")?.isEmpty());
|
||||
const entry = @getByIdDirectPrivate(controller, "queue").content.shift();
|
||||
@getByIdDirectPrivate(controller, "queue").size -= entry.byteLength;
|
||||
@readableByteStreamControllerHandleQueueDrain(controller);
|
||||
let view;
|
||||
try {
|
||||
view = new @Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
|
||||
} catch (error) {
|
||||
return @Promise.@reject(error);
|
||||
}
|
||||
return @createFulfilledPromise({ value: view, done: false });
|
||||
}
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "autoAllocateChunkSize") !== @undefined) {
|
||||
let buffer;
|
||||
try {
|
||||
buffer = @createUninitializedArrayBuffer(@getByIdDirectPrivate(controller, "autoAllocateChunkSize"));
|
||||
} catch (error) {
|
||||
return @Promise.@reject(error);
|
||||
}
|
||||
const pullIntoDescriptor = {
|
||||
buffer,
|
||||
byteOffset: 0,
|
||||
byteLength: @getByIdDirectPrivate(controller, "autoAllocateChunkSize"),
|
||||
bytesFilled: 0,
|
||||
elementSize: 1,
|
||||
ctor: @Uint8Array,
|
||||
readerType: 'default'
|
||||
};
|
||||
@getByIdDirectPrivate(controller, "pendingPullIntos").push(pullIntoDescriptor);
|
||||
}
|
||||
|
||||
const promise = @readableStreamAddReadRequest(stream);
|
||||
@readableByteStreamControllerCallPullIfNeeded(controller);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function readableByteStreamControllerShouldCallPull(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
|
||||
if (@getByIdDirectPrivate(stream, "state") !== @streamReadable)
|
||||
return false;
|
||||
if (@getByIdDirectPrivate(controller, "closeRequested"))
|
||||
return false;
|
||||
if (!@getByIdDirectPrivate(controller, "started"))
|
||||
return false;
|
||||
if (@readableStreamHasDefaultReader(stream) && (@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests")?.isNotEmpty() || !!@getByIdDirectPrivate(reader, "bunNativePtr")))
|
||||
return true;
|
||||
if (@readableStreamHasBYOBReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readIntoRequests")?.isNotEmpty())
|
||||
return true;
|
||||
if (@readableByteStreamControllerGetDesiredSize(controller) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function readableByteStreamControllerCallPullIfNeeded(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@readableByteStreamControllerShouldCallPull(controller))
|
||||
return;
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "pulling")) {
|
||||
@putByIdDirectPrivate(controller, "pullAgain", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@assert(!@getByIdDirectPrivate(controller, "pullAgain"));
|
||||
@putByIdDirectPrivate(controller, "pulling", true);
|
||||
@promiseInvokeOrNoop(@getByIdDirectPrivate(controller, "underlyingByteSource"), "pull", [controller]).@then(() => {
|
||||
@putByIdDirectPrivate(controller, "pulling", false);
|
||||
if (@getByIdDirectPrivate(controller, "pullAgain")) {
|
||||
@putByIdDirectPrivate(controller, "pullAgain", false);
|
||||
@readableByteStreamControllerCallPullIfNeeded(controller);
|
||||
}
|
||||
}, (error) => {
|
||||
if (@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable)
|
||||
@readableByteStreamControllerError(controller, error);
|
||||
});
|
||||
}
|
||||
|
||||
function transferBufferToCurrentRealm(buffer)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// FIXME: Determine what should be done here exactly (what is already existing in current
|
||||
// codebase and what has to be added). According to spec, Transfer operation should be
|
||||
// performed in order to transfer buffer to current realm. For the moment, simply return
|
||||
// received buffer.
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function readableStreamReaderKind(reader) {
|
||||
"use strict";
|
||||
|
||||
|
||||
if (!!@getByIdDirectPrivate(reader, "readRequests"))
|
||||
return @getByIdDirectPrivate(reader, "bunNativePtr") ? 3 : 1;
|
||||
|
||||
if (!!@getByIdDirectPrivate(reader, "readIntoRequests"))
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
function readableByteStreamControllerEnqueue(controller, chunk)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
@assert(!@getByIdDirectPrivate(controller, "closeRequested"));
|
||||
@assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
|
||||
var reader = @getByIdDirectPrivate(stream, "reader");
|
||||
|
||||
|
||||
switch (reader ? @readableStreamReaderKind(reader) : 0) {
|
||||
/* default reader */
|
||||
case 1: {
|
||||
if (!@getByIdDirectPrivate(reader, "readRequests")?.isNotEmpty())
|
||||
@readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);
|
||||
else {
|
||||
@assert(!@getByIdDirectPrivate(controller, "queue").content.size());
|
||||
const transferredView = chunk.constructor === @Uint8Array ? chunk : new @Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
||||
@readableStreamFulfillReadRequest(stream, transferredView, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* BYOB */
|
||||
case 2: {
|
||||
@readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);
|
||||
@readableByteStreamControllerProcessPullDescriptors(controller);
|
||||
break;
|
||||
}
|
||||
|
||||
/* NativeReader */
|
||||
case 3: {
|
||||
// reader.@enqueueNative(@getByIdDirectPrivate(reader, "bunNativePtr"), chunk);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
@assert(!@isReadableStreamLocked(stream));
|
||||
@readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spec name: readableByteStreamControllerEnqueueChunkToQueue.
|
||||
function readableByteStreamControllerEnqueueChunk(controller, buffer, byteOffset, byteLength)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@getByIdDirectPrivate(controller, "queue").content.push({
|
||||
buffer: buffer,
|
||||
byteOffset: byteOffset,
|
||||
byteLength: byteLength
|
||||
});
|
||||
@getByIdDirectPrivate(controller, "queue").size += byteLength;
|
||||
}
|
||||
|
||||
function readableByteStreamControllerRespondWithNewView(controller, view)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@getByIdDirectPrivate(controller, "pendingPullIntos").isNotEmpty());
|
||||
|
||||
let firstDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos").peek();
|
||||
|
||||
if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset)
|
||||
@throwRangeError("Invalid value for view.byteOffset");
|
||||
|
||||
if (firstDescriptor.byteLength !== view.byteLength)
|
||||
@throwRangeError("Invalid value for view.byteLength");
|
||||
|
||||
firstDescriptor.buffer = view.buffer;
|
||||
@readableByteStreamControllerRespondInternal(controller, view.byteLength);
|
||||
}
|
||||
|
||||
function readableByteStreamControllerRespond(controller, bytesWritten)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
bytesWritten = @toNumber(bytesWritten);
|
||||
|
||||
if (@isNaN(bytesWritten) || bytesWritten === @Infinity || bytesWritten < 0 )
|
||||
@throwRangeError("bytesWritten has an incorrect value");
|
||||
|
||||
@assert(@getByIdDirectPrivate(controller, "pendingPullIntos").isNotEmpty());
|
||||
|
||||
@readableByteStreamControllerRespondInternal(controller, bytesWritten);
|
||||
}
|
||||
|
||||
function readableByteStreamControllerRespondInternal(controller, bytesWritten)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
let firstDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos").peek();
|
||||
let stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
|
||||
if (@getByIdDirectPrivate(stream, "state") === @streamClosed) {
|
||||
if (bytesWritten !== 0)
|
||||
@throwTypeError("bytesWritten is different from 0 even though stream is closed");
|
||||
@readableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
|
||||
} else {
|
||||
@assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
|
||||
@readableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
function readableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength)
|
||||
@throwRangeError("bytesWritten value is too great");
|
||||
|
||||
@assert(@getByIdDirectPrivate(controller, "pendingPullIntos").isEmpty() || @getByIdDirectPrivate(controller, "pendingPullIntos").peek() === pullIntoDescriptor);
|
||||
@readableByteStreamControllerInvalidateBYOBRequest(controller);
|
||||
pullIntoDescriptor.bytesFilled += bytesWritten;
|
||||
|
||||
if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize)
|
||||
return;
|
||||
|
||||
@readableByteStreamControllerShiftPendingDescriptor(controller);
|
||||
const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
|
||||
|
||||
if (remainderSize > 0) {
|
||||
const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
|
||||
const remainder = @cloneArrayBuffer(pullIntoDescriptor.buffer, end - remainderSize, remainderSize);
|
||||
@readableByteStreamControllerEnqueueChunk(controller, remainder, 0, remainder.byteLength);
|
||||
}
|
||||
|
||||
pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);
|
||||
pullIntoDescriptor.bytesFilled -= remainderSize;
|
||||
@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, "controlledReadableStream"), pullIntoDescriptor);
|
||||
@readableByteStreamControllerProcessPullDescriptors(controller);
|
||||
}
|
||||
|
||||
function readableByteStreamControllerRespondInClosedState(controller, firstDescriptor)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
firstDescriptor.buffer = @transferBufferToCurrentRealm(firstDescriptor.buffer);
|
||||
@assert(firstDescriptor.bytesFilled === 0);
|
||||
|
||||
if (@readableStreamHasBYOBReader(@getByIdDirectPrivate(controller, "controlledReadableStream"))) {
|
||||
while (@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "reader"), "readIntoRequests")?.isNotEmpty()) {
|
||||
let pullIntoDescriptor = @readableByteStreamControllerShiftPendingDescriptor(controller);
|
||||
@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, "controlledReadableStream"), pullIntoDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spec name: readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue (shortened for readability).
|
||||
function readableByteStreamControllerProcessPullDescriptors(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(!@getByIdDirectPrivate(controller, "closeRequested"));
|
||||
while (@getByIdDirectPrivate(controller, "pendingPullIntos").isNotEmpty()) {
|
||||
if (@getByIdDirectPrivate(controller, "queue").size === 0)
|
||||
return;
|
||||
let pullIntoDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos").peek();
|
||||
if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {
|
||||
@readableByteStreamControllerShiftPendingDescriptor(controller);
|
||||
@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, "controlledReadableStream"), pullIntoDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spec name: readableByteStreamControllerFillPullIntoDescriptorFromQueue (shortened for readability).
|
||||
function readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const currentAlignedBytes = pullIntoDescriptor.bytesFilled - (pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize);
|
||||
const maxBytesToCopy = @getByIdDirectPrivate(controller, "queue").size < pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled ?
|
||||
@getByIdDirectPrivate(controller, "queue").size : pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled;
|
||||
const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
|
||||
const maxAlignedBytes = maxBytesFilled - (maxBytesFilled % pullIntoDescriptor.elementSize);
|
||||
let totalBytesToCopyRemaining = maxBytesToCopy;
|
||||
let ready = false;
|
||||
|
||||
if (maxAlignedBytes > currentAlignedBytes) {
|
||||
totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
|
||||
ready = true;
|
||||
}
|
||||
|
||||
while (totalBytesToCopyRemaining > 0) {
|
||||
let headOfQueue = @getByIdDirectPrivate(controller, "queue").content.peek();
|
||||
const bytesToCopy = totalBytesToCopyRemaining < headOfQueue.byteLength ? totalBytesToCopyRemaining : headOfQueue.byteLength;
|
||||
// Copy appropriate part of pullIntoDescriptor.buffer to headOfQueue.buffer.
|
||||
// Remark: this implementation is not completely aligned on the definition of CopyDataBlockBytes
|
||||
// operation of ECMAScript (the case of Shared Data Block is not considered here, but it doesn't seem to be an issue).
|
||||
const destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
|
||||
// FIXME: As indicated in comments of bug 172717, access to set is not safe. However, using prototype.@set.@call does
|
||||
// not work (@set is undefined). A safe way to do that is needed.
|
||||
new @Uint8Array(pullIntoDescriptor.buffer).set(new @Uint8Array(headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy), destStart);
|
||||
|
||||
if (headOfQueue.byteLength === bytesToCopy)
|
||||
@getByIdDirectPrivate(controller, "queue").content.shift();
|
||||
else {
|
||||
headOfQueue.byteOffset += bytesToCopy;
|
||||
headOfQueue.byteLength -= bytesToCopy;
|
||||
}
|
||||
|
||||
@getByIdDirectPrivate(controller, "queue").size -= bytesToCopy;
|
||||
@assert(@getByIdDirectPrivate(controller, "pendingPullIntos").isEmpty() || @getByIdDirectPrivate(controller, "pendingPullIntos").peek() === pullIntoDescriptor);
|
||||
@readableByteStreamControllerInvalidateBYOBRequest(controller);
|
||||
pullIntoDescriptor.bytesFilled += bytesToCopy;
|
||||
totalBytesToCopyRemaining -= bytesToCopy;
|
||||
}
|
||||
|
||||
if (!ready) {
|
||||
@assert(@getByIdDirectPrivate(controller, "queue").size === 0);
|
||||
@assert(pullIntoDescriptor.bytesFilled > 0);
|
||||
@assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);
|
||||
}
|
||||
|
||||
return ready;
|
||||
}
|
||||
|
||||
// Spec name: readableByteStreamControllerShiftPendingPullInto (renamed for consistency).
|
||||
function readableByteStreamControllerShiftPendingDescriptor(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
let descriptor = @getByIdDirectPrivate(controller, "pendingPullIntos").shift();
|
||||
@readableByteStreamControllerInvalidateBYOBRequest(controller);
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
function readableByteStreamControllerInvalidateBYOBRequest(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "byobRequest") === @undefined)
|
||||
return;
|
||||
const byobRequest = @getByIdDirectPrivate(controller, "byobRequest");
|
||||
@putByIdDirectPrivate(byobRequest, "associatedReadableByteStreamController", @undefined);
|
||||
@putByIdDirectPrivate(byobRequest, "view", @undefined);
|
||||
@putByIdDirectPrivate(controller, "byobRequest", @undefined);
|
||||
}
|
||||
|
||||
// Spec name: readableByteStreamControllerCommitPullIntoDescriptor (shortened for readability).
|
||||
function readableByteStreamControllerCommitDescriptor(stream, pullIntoDescriptor)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@getByIdDirectPrivate(stream, "state") !== @streamErrored);
|
||||
let done = false;
|
||||
if (@getByIdDirectPrivate(stream, "state") === @streamClosed) {
|
||||
@assert(!pullIntoDescriptor.bytesFilled);
|
||||
done = true;
|
||||
}
|
||||
let filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);
|
||||
if (pullIntoDescriptor.readerType === "default")
|
||||
@readableStreamFulfillReadRequest(stream, filledView, done);
|
||||
else {
|
||||
@assert(pullIntoDescriptor.readerType === "byob");
|
||||
@readableStreamFulfillReadIntoRequest(stream, filledView, done);
|
||||
}
|
||||
}
|
||||
|
||||
// Spec name: readableByteStreamControllerConvertPullIntoDescriptor (shortened for readability).
|
||||
function readableByteStreamControllerConvertDescriptor(pullIntoDescriptor)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(pullIntoDescriptor.bytesFilled <= pullIntoDescriptor.byteLength);
|
||||
@assert(pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize === 0);
|
||||
|
||||
return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, pullIntoDescriptor.bytesFilled / pullIntoDescriptor.elementSize);
|
||||
}
|
||||
|
||||
function readableStreamFulfillReadIntoRequest(stream, chunk, done)
|
||||
{
|
||||
"use strict";
|
||||
const readIntoRequest = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readIntoRequests").shift();
|
||||
@fulfillPromise(readIntoRequest, { value: chunk, done: done });
|
||||
}
|
||||
|
||||
function readableStreamBYOBReaderRead(reader, view)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(reader, "ownerReadableStream");
|
||||
@assert(!!stream);
|
||||
|
||||
@putByIdDirectPrivate(stream, "disturbed", true);
|
||||
if (@getByIdDirectPrivate(stream, "state") === @streamErrored)
|
||||
return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
|
||||
|
||||
return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(stream, "readableStreamController"), view);
|
||||
}
|
||||
|
||||
function readableByteStreamControllerPullInto(controller, view)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
let elementSize = 1;
|
||||
// Spec describes that in the case where view is a TypedArray, elementSize
|
||||
// should be set to the size of an element (e.g. 2 for UInt16Array). For
|
||||
// DataView, BYTES_PER_ELEMENT is undefined, contrary to the same property
|
||||
// for TypedArrays.
|
||||
// FIXME: Getting BYTES_PER_ELEMENT like this is not safe (property is read-only
|
||||
// but can be modified if the prototype is redefined). A safe way of getting
|
||||
// it would be to determine which type of ArrayBufferView view is an instance
|
||||
// of based on typed arrays private variables. However, this is not possible due
|
||||
// to bug 167697, which prevents access to typed arrays through their private
|
||||
// names unless public name has already been met before.
|
||||
if (view.BYTES_PER_ELEMENT !== @undefined)
|
||||
elementSize = view.BYTES_PER_ELEMENT;
|
||||
|
||||
// FIXME: Getting constructor like this is not safe. A safe way of getting
|
||||
// it would be to determine which type of ArrayBufferView view is an instance
|
||||
// of, and to assign appropriate constructor based on this (e.g. ctor =
|
||||
// @Uint8Array). However, this is not possible due to bug 167697, which
|
||||
// prevents access to typed arrays through their private names unless public
|
||||
// name has already been met before.
|
||||
const ctor = view.constructor;
|
||||
|
||||
const pullIntoDescriptor = {
|
||||
buffer: view.buffer,
|
||||
byteOffset: view.byteOffset,
|
||||
byteLength: view.byteLength,
|
||||
bytesFilled: 0,
|
||||
elementSize,
|
||||
ctor,
|
||||
readerType: 'byob'
|
||||
};
|
||||
|
||||
var pending = @getByIdDirectPrivate(controller, "pendingPullIntos");
|
||||
if (pending?.isNotEmpty()) {
|
||||
pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);
|
||||
pending.push(pullIntoDescriptor);
|
||||
return @readableStreamAddReadIntoRequest(stream);
|
||||
}
|
||||
|
||||
if (@getByIdDirectPrivate(stream, "state") === @streamClosed) {
|
||||
const emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
|
||||
return @createFulfilledPromise({ value: emptyView, done: true });
|
||||
}
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "queue").size > 0) {
|
||||
if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {
|
||||
const filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);
|
||||
@readableByteStreamControllerHandleQueueDrain(controller);
|
||||
return @createFulfilledPromise({ value: filledView, done: false });
|
||||
}
|
||||
if (@getByIdDirectPrivate(controller, "closeRequested")) {
|
||||
const e = @makeTypeError("Closing stream has been requested");
|
||||
@readableByteStreamControllerError(controller, e);
|
||||
return @Promise.@reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);
|
||||
@getByIdDirectPrivate(controller, "pendingPullIntos").push(pullIntoDescriptor);
|
||||
const promise = @readableStreamAddReadIntoRequest(stream);
|
||||
@readableByteStreamControllerCallPullIfNeeded(controller);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function readableStreamAddReadIntoRequest(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@isReadableStreamBYOBReader(@getByIdDirectPrivate(stream, "reader")));
|
||||
@assert(@getByIdDirectPrivate(stream, "state") === @streamReadable || @getByIdDirectPrivate(stream, "state") === @streamClosed);
|
||||
|
||||
const readRequest = @newPromise();
|
||||
@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readIntoRequests").push(readRequest);
|
||||
|
||||
return readRequest;
|
||||
}
|
||||
496
src/javascript/jsc/bindings/builtins/js/ReadableStream.js
Normal file
496
src/javascript/jsc/bindings/builtins/js/ReadableStream.js
Normal file
@@ -0,0 +1,496 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Canon Inc.
|
||||
* Copyright (C) 2015 Igalia.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function initializeReadableStream(underlyingSource, strategy)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (underlyingSource === @undefined)
|
||||
underlyingSource = { };
|
||||
if (strategy === @undefined)
|
||||
strategy = { };
|
||||
|
||||
if (!@isObject(underlyingSource))
|
||||
@throwTypeError("ReadableStream constructor takes an object as first argument");
|
||||
|
||||
if (strategy !== @undefined && !@isObject(strategy))
|
||||
@throwTypeError("ReadableStream constructor takes an object as second argument, if any");
|
||||
|
||||
@putByIdDirectPrivate(this, "state", @streamReadable);
|
||||
|
||||
@putByIdDirectPrivate(this, "reader", @undefined);
|
||||
|
||||
@putByIdDirectPrivate(this, "storedError", @undefined);
|
||||
|
||||
@putByIdDirectPrivate(this, "disturbed", false);
|
||||
|
||||
// Initialized with null value to enable distinction with undefined case.
|
||||
@putByIdDirectPrivate(this, "readableStreamController", null);
|
||||
|
||||
|
||||
// FIXME: We should introduce https://streams.spec.whatwg.org/#create-readable-stream.
|
||||
// For now, we emulate this with underlyingSource with private properties.
|
||||
if (@getByIdDirectPrivate(underlyingSource, "pull") !== @undefined) {
|
||||
|
||||
const size = @getByIdDirectPrivate(strategy, "size");
|
||||
const highWaterMark = @getByIdDirectPrivate(strategy, "highWaterMark");
|
||||
@setupReadableStreamDefaultController(this, underlyingSource, size, highWaterMark !== @undefined ? highWaterMark : 1, @getByIdDirectPrivate(underlyingSource, "start"), @getByIdDirectPrivate(underlyingSource, "pull"), @getByIdDirectPrivate(underlyingSource, "cancel"));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
const type = underlyingSource.type;
|
||||
const typeString = @toString(type);
|
||||
|
||||
if (typeString === "bytes") {
|
||||
// if (!@readableByteStreamAPIEnabled())
|
||||
// @throwTypeError("ReadableByteStreamController is not implemented");
|
||||
|
||||
if (strategy.highWaterMark === @undefined)
|
||||
strategy.highWaterMark = 0;
|
||||
if (strategy.size !== @undefined)
|
||||
@throwRangeError("Strategy for a ReadableByteStreamController cannot have a size");
|
||||
|
||||
let readableByteStreamControllerConstructor = @ReadableByteStreamController;
|
||||
|
||||
@putByIdDirectPrivate(this, "readableStreamController", new @ReadableByteStreamController(this, underlyingSource, strategy.highWaterMark, @isReadableStream));
|
||||
} else if (type === @undefined) {
|
||||
if (strategy.highWaterMark === @undefined)
|
||||
strategy.highWaterMark = 1;
|
||||
|
||||
@setupReadableStreamDefaultController(this, underlyingSource, strategy.size, strategy.highWaterMark, underlyingSource.start, underlyingSource.pull, underlyingSource.cancel);
|
||||
} else
|
||||
@throwRangeError("Invalid type for underlying source");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@globalPrivate
|
||||
function readableStreamToArray(stream) {
|
||||
"use strict";
|
||||
|
||||
if (@getByIdDirectPrivate(stream, "state") === @streamClosed) {
|
||||
return null;
|
||||
}
|
||||
var reader = stream.getReader();
|
||||
|
||||
var manyResult = reader.readMany();
|
||||
|
||||
var processManyResult = (0, (async function(manyResult) {
|
||||
if (result.done) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var chunks = result.value;
|
||||
|
||||
while (true) {
|
||||
var thisResult = await reader.read();
|
||||
if (thisResult.done) {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
chunks.push(thisResult.value);
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}));
|
||||
|
||||
|
||||
if (manyResult && @isPromise(manyResult)) {
|
||||
return manyResult.then(processManyResult);
|
||||
}
|
||||
|
||||
if (manyResult && manyResult.done) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return processManyResult(manyResult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@globalPrivate
|
||||
function consumeReadableStream(nativePtr, nativeType, inputStream) {
|
||||
"use strict";
|
||||
const symbol = Symbol.for("Bun.consumeReadableStreamPrototype");
|
||||
var cached = globalThis[symbol];
|
||||
if (!cached) {
|
||||
cached = globalThis[symbol] = [];
|
||||
}
|
||||
var Prototype = cached[nativeType];
|
||||
if (Prototype === @undefined) {
|
||||
var [doRead, doError, doReadMany, doClose, onClose, deinit] = globalThis[Symbol.for("Bun.lazy")](nativeType);
|
||||
|
||||
Prototype = class NativeReadableStreamSink {
|
||||
constructor(reader, ptr) {
|
||||
this.#ptr = ptr;
|
||||
this.#reader = reader;
|
||||
this.#didClose = false;
|
||||
|
||||
this.handleError = this._handleError.bind(this);
|
||||
this.handleClosed = this._handleClosed.bind(this);
|
||||
this.processResult = this._processResult.bind(this);
|
||||
|
||||
reader.closed.then(this.handleClosed, this.handleError);
|
||||
}
|
||||
|
||||
handleError;
|
||||
handleClosed;
|
||||
_handleClosed() {
|
||||
if (this.#didClose) return;
|
||||
this.#didClose = true;
|
||||
var ptr = this.#ptr;
|
||||
this.#ptr = 0;
|
||||
doClose(ptr);
|
||||
deinit(ptr);
|
||||
}
|
||||
|
||||
_handleError(error) {
|
||||
if (this.#didClose) return;
|
||||
this.#didClose = true;
|
||||
var ptr = this.#ptr;
|
||||
this.#ptr = 0;
|
||||
doError(ptr, error);
|
||||
deinit(ptr);
|
||||
}
|
||||
|
||||
#ptr;
|
||||
#didClose = false;
|
||||
#reader;
|
||||
|
||||
_handleReadMany({value, done, size}) {
|
||||
if (done) {
|
||||
this.handleClosed();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.#didClose) return;
|
||||
|
||||
|
||||
doReadMany(this.#ptr, value, done, size);
|
||||
}
|
||||
|
||||
|
||||
read() {
|
||||
if (!this.#ptr) return @throwTypeError("ReadableStreamSink is already closed");
|
||||
|
||||
return this.processResult(this.#reader.read());
|
||||
|
||||
}
|
||||
|
||||
_processResult(result) {
|
||||
if (result && @isPromise(result)) {
|
||||
const flags = @getPromiseInternalField(result, @promiseFieldFlags);
|
||||
if (flags & @promiseStateFulfilled) {
|
||||
const fulfilledValue = @getPromiseInternalField(result, @promiseFieldReactionsOrResult);
|
||||
if (fulfilledValue) {
|
||||
result = fulfilledValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result && @isPromise(result)) {
|
||||
result.then(this.processResult, this.handleError);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (result.done) {
|
||||
this.handleClosed();
|
||||
return 0;
|
||||
} else if (result.value) {
|
||||
return result.value;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
readMany() {
|
||||
if (!this.#ptr) return @throwTypeError("ReadableStreamSink is already closed");
|
||||
return this.processResult(this.#reader.readMany());
|
||||
}
|
||||
};
|
||||
|
||||
const minlength = nativeType + 1;
|
||||
if (cached.length < minlength) {
|
||||
cached.length = minlength;
|
||||
}
|
||||
@putByValDirect(cached, nativeType, Prototype);
|
||||
}
|
||||
|
||||
if (@isReadableStreamLocked(inputStream)) {
|
||||
@throwTypeError("Cannot start reading from a locked stream");
|
||||
}
|
||||
|
||||
return new Prototype(inputStream.getReader(), nativePtr);
|
||||
}
|
||||
|
||||
@globalPrivate
|
||||
function createEmptyReadableStream() {
|
||||
var stream = new @ReadableStream({
|
||||
pull() {},
|
||||
start() {},
|
||||
cancel() {},
|
||||
});
|
||||
@readableStreamClose(stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
@globalPrivate
|
||||
function createNativeReadableStream(nativePtr, nativeType, autoAllocateChunkSize) {
|
||||
"use strict";
|
||||
var cached = globalThis[Symbol.for("Bun.nativeReadableStreamPrototype")] ||= new @Map;
|
||||
var Prototype = cached.@get(nativeType);
|
||||
if (Prototype === @undefined) {
|
||||
var [pull, start, cancel, setClose, deinit] = globalThis[Symbol.for("Bun.lazy")](nativeType);
|
||||
var closer = [false];
|
||||
var handleResult;
|
||||
function handleNativeReadableStreamPromiseResult(val) {
|
||||
"use strict";
|
||||
var {c, v} = this;
|
||||
this.c = @undefined;
|
||||
this.v = @undefined;
|
||||
handleResult(val, c, v);
|
||||
}
|
||||
|
||||
handleResult = function handleResult(result, controller, view) {
|
||||
"use strict";
|
||||
|
||||
if (result && @isPromise(result)) {
|
||||
return result.then(handleNativeReadableStreamPromiseResult.bind({c: controller, v: view}), (err) => controller.error(err));
|
||||
} else if (result !== false) {
|
||||
if (view && view.byteLength === result) {
|
||||
controller.byobRequest.respondWithNewView(view);
|
||||
} else {
|
||||
controller.byobRequest.respond(result);
|
||||
}
|
||||
}
|
||||
|
||||
if (closer[0] || result === false) {
|
||||
@enqueueJob(() => controller.close());
|
||||
closer[0] = false;
|
||||
}
|
||||
};
|
||||
|
||||
Prototype = class NativeReadableStreamSource {
|
||||
constructor(tag, autoAllocateChunkSize) {
|
||||
this.pull = this.pull_.bind(tag);
|
||||
this.cancel = this.cancel_.bind(tag);
|
||||
this.autoAllocateChunkSize = autoAllocateChunkSize;
|
||||
}
|
||||
|
||||
pull;
|
||||
cancel;
|
||||
|
||||
type = "bytes";
|
||||
autoAllocateChunkSize = 0;
|
||||
|
||||
static startSync = start;
|
||||
|
||||
pull_(controller) {
|
||||
closer[0] = false;
|
||||
var result;
|
||||
|
||||
const view = controller.byobRequest.view;
|
||||
try {
|
||||
result = pull(this, view, closer);
|
||||
} catch(err) {
|
||||
return controller.error(err);
|
||||
}
|
||||
|
||||
return handleResult(result, controller, view);
|
||||
}
|
||||
|
||||
cancel_(reason) {
|
||||
cancel(this, reason);
|
||||
}
|
||||
|
||||
static registry = new FinalizationRegistry(deinit);
|
||||
}
|
||||
cached.@set(nativeType, Prototype);
|
||||
}
|
||||
|
||||
// either returns the chunk size
|
||||
// or throws an error
|
||||
// should never return a Promise
|
||||
const chunkSize = Prototype.startSync(nativePtr, autoAllocateChunkSize);
|
||||
|
||||
// empty file, no need for native back-and-forth on this
|
||||
if (chunkSize === 0) {
|
||||
return @createEmptyReadableStream();
|
||||
}
|
||||
|
||||
var instance = new Prototype(nativePtr, chunkSize);
|
||||
Prototype.registry.register(instance, nativePtr);
|
||||
var stream = new @ReadableStream(instance);
|
||||
@putByIdDirectPrivate(stream, "bunNativeType", nativeType);
|
||||
@putByIdDirectPrivate(stream, "bunNativePtr", nativePtr);
|
||||
return stream;
|
||||
}
|
||||
|
||||
function cancel(reason)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStream(this))
|
||||
return @Promise.@reject(@makeThisTypeError("ReadableStream", "cancel"));
|
||||
|
||||
if (@isReadableStreamLocked(this))
|
||||
return @Promise.@reject(@makeTypeError("ReadableStream is locked"));
|
||||
|
||||
return @readableStreamCancel(this, reason);
|
||||
}
|
||||
|
||||
function getReader(options)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStream(this))
|
||||
throw @makeThisTypeError("ReadableStream", "getReader");
|
||||
|
||||
const mode = @toDictionary(options, { }, "ReadableStream.getReader takes an object as first argument").mode;
|
||||
if (mode === @undefined)
|
||||
return new @ReadableStreamDefaultReader(this);
|
||||
|
||||
// String conversion is required by spec, hence double equals.
|
||||
if (mode == 'byob')
|
||||
return new @ReadableStreamBYOBReader(this);
|
||||
|
||||
|
||||
@throwTypeError("Invalid mode is specified");
|
||||
}
|
||||
|
||||
function pipeThrough(streams, options)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const transforms = streams;
|
||||
|
||||
const readable = transforms["readable"];
|
||||
if (!@isReadableStream(readable))
|
||||
throw @makeTypeError("readable should be ReadableStream");
|
||||
|
||||
const writable = transforms["writable"];
|
||||
const internalWritable = @getInternalWritableStream(writable);
|
||||
if (!@isWritableStream(internalWritable))
|
||||
throw @makeTypeError("writable should be WritableStream");
|
||||
|
||||
let preventClose = false;
|
||||
let preventAbort = false;
|
||||
let preventCancel = false;
|
||||
let signal;
|
||||
if (!@isUndefinedOrNull(options)) {
|
||||
if (!@isObject(options))
|
||||
throw @makeTypeError("options must be an object");
|
||||
|
||||
preventAbort = !!options["preventAbort"];
|
||||
preventCancel = !!options["preventCancel"];
|
||||
preventClose = !!options["preventClose"];
|
||||
|
||||
signal = options["signal"];
|
||||
if (signal !== @undefined && !@isAbortSignal(signal))
|
||||
throw @makeTypeError("options.signal must be AbortSignal");
|
||||
}
|
||||
|
||||
if (!@isReadableStream(this))
|
||||
throw @makeThisTypeError("ReadableStream", "pipeThrough");
|
||||
|
||||
if (@isReadableStreamLocked(this))
|
||||
throw @makeTypeError("ReadableStream is locked");
|
||||
|
||||
if (@isWritableStreamLocked(internalWritable))
|
||||
throw @makeTypeError("WritableStream is locked");
|
||||
|
||||
@readableStreamPipeToWritableStream(this, internalWritable, preventClose, preventAbort, preventCancel, signal);
|
||||
|
||||
return readable;
|
||||
}
|
||||
|
||||
function pipeTo(destination)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// FIXME: https://bugs.webkit.org/show_bug.cgi?id=159869.
|
||||
// Built-in generator should be able to parse function signature to compute the function length correctly.
|
||||
let options = arguments[1];
|
||||
|
||||
let preventClose = false;
|
||||
let preventAbort = false;
|
||||
let preventCancel = false;
|
||||
let signal;
|
||||
if (!@isUndefinedOrNull(options)) {
|
||||
if (!@isObject(options))
|
||||
return @Promise.@reject(@makeTypeError("options must be an object"));
|
||||
|
||||
try {
|
||||
preventAbort = !!options["preventAbort"];
|
||||
preventCancel = !!options["preventCancel"];
|
||||
preventClose = !!options["preventClose"];
|
||||
|
||||
signal = options["signal"];
|
||||
} catch(e) {
|
||||
return @Promise.@reject(e);
|
||||
}
|
||||
|
||||
if (signal !== @undefined && !@isAbortSignal(signal))
|
||||
return @Promise.@reject(@makeTypeError("options.signal must be AbortSignal"));
|
||||
}
|
||||
|
||||
const internalDestination = @getInternalWritableStream(destination);
|
||||
if (!@isWritableStream(internalDestination))
|
||||
return @Promise.@reject(@makeTypeError("ReadableStream pipeTo requires a WritableStream"));
|
||||
|
||||
if (!@isReadableStream(this))
|
||||
return @Promise.@reject(@makeThisTypeError("ReadableStream", "pipeTo"));
|
||||
|
||||
if (@isReadableStreamLocked(this))
|
||||
return @Promise.@reject(@makeTypeError("ReadableStream is locked"));
|
||||
|
||||
if (@isWritableStreamLocked(internalDestination))
|
||||
return @Promise.@reject(@makeTypeError("WritableStream is locked"));
|
||||
|
||||
return @readableStreamPipeToWritableStream(this, internalDestination, preventClose, preventAbort, preventCancel, signal);
|
||||
}
|
||||
|
||||
function tee()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStream(this))
|
||||
throw @makeThisTypeError("ReadableStream", "tee");
|
||||
|
||||
return @readableStreamTee(this, false);
|
||||
}
|
||||
|
||||
@getter
|
||||
function locked()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStream(this))
|
||||
throw @makeGetterTypeError("ReadableStream", "locked");
|
||||
|
||||
return @isReadableStreamLocked(this);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Canon Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function initializeReadableStreamBYOBReader(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStream(stream))
|
||||
@throwTypeError("ReadableStreamBYOBReader needs a ReadableStream");
|
||||
if (!@isReadableByteStreamController(@getByIdDirectPrivate(stream, "readableStreamController")))
|
||||
@throwTypeError("ReadableStreamBYOBReader needs a ReadableByteStreamController");
|
||||
if (@isReadableStreamLocked(stream))
|
||||
@throwTypeError("ReadableStream is locked");
|
||||
|
||||
@readableStreamReaderGenericInitialize(this, stream);
|
||||
@putByIdDirectPrivate(this, "readIntoRequests", @createFIFO());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function cancel(reason)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamBYOBReader(this))
|
||||
return @Promise.@reject(@makeThisTypeError("ReadableStreamBYOBReader", "cancel"));
|
||||
|
||||
if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
|
||||
return @Promise.@reject(@makeTypeError("cancel() called on a reader owned by no readable stream"));
|
||||
|
||||
return @readableStreamReaderGenericCancel(this, reason);
|
||||
}
|
||||
|
||||
function read(view)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamBYOBReader(this))
|
||||
return @Promise.@reject(@makeThisTypeError("ReadableStreamBYOBReader", "read"));
|
||||
|
||||
if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
|
||||
return @Promise.@reject(@makeTypeError("read() called on a reader owned by no readable stream"));
|
||||
|
||||
if (!@isObject(view))
|
||||
return @Promise.@reject(@makeTypeError("Provided view is not an object"));
|
||||
|
||||
if (!@ArrayBuffer.@isView(view))
|
||||
return @Promise.@reject(@makeTypeError("Provided view is not an ArrayBufferView"));
|
||||
|
||||
if (view.byteLength === 0)
|
||||
return @Promise.@reject(@makeTypeError("Provided view cannot have a 0 byteLength"));
|
||||
|
||||
return @readableStreamBYOBReaderRead(this, view);
|
||||
}
|
||||
|
||||
function releaseLock()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamBYOBReader(this))
|
||||
throw @makeThisTypeError("ReadableStreamBYOBReader", "releaseLock");
|
||||
|
||||
if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
|
||||
return;
|
||||
|
||||
if (@getByIdDirectPrivate(this, "readIntoRequests")?.isNotEmpty())
|
||||
@throwTypeError("There are still pending read requests, cannot release the lock");
|
||||
|
||||
@readableStreamReaderGenericRelease(this);
|
||||
}
|
||||
|
||||
@getter
|
||||
function closed()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamBYOBReader(this))
|
||||
return @Promise.@reject(@makeGetterTypeError("ReadableStreamBYOBReader", "closed"));
|
||||
|
||||
return @getByIdDirectPrivate(this, "closedPromiseCapability").@promise;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Canon Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function initializeReadableStreamBYOBRequest(controller, view)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (arguments.length !== 3 && arguments[2] !== @isReadableStream)
|
||||
@throwTypeError("ReadableStreamBYOBRequest constructor should not be called directly");
|
||||
|
||||
return @privateInitializeReadableStreamBYOBRequest.@call(this, controller, view);
|
||||
}
|
||||
|
||||
function respond(bytesWritten)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamBYOBRequest(this))
|
||||
throw @makeThisTypeError("ReadableStreamBYOBRequest", "respond");
|
||||
|
||||
if (@getByIdDirectPrivate(this, "associatedReadableByteStreamController") === @undefined)
|
||||
@throwTypeError("ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined");
|
||||
|
||||
return @readableByteStreamControllerRespond(@getByIdDirectPrivate(this, "associatedReadableByteStreamController"), bytesWritten);
|
||||
}
|
||||
|
||||
function respondWithNewView(view)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamBYOBRequest(this))
|
||||
throw @makeThisTypeError("ReadableStreamBYOBRequest", "respond");
|
||||
|
||||
if (@getByIdDirectPrivate(this, "associatedReadableByteStreamController") === @undefined)
|
||||
@throwTypeError("ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined");
|
||||
|
||||
if (!@isObject(view))
|
||||
@throwTypeError("Provided view is not an object");
|
||||
|
||||
if (!@ArrayBuffer.@isView(view))
|
||||
@throwTypeError("Provided view is not an ArrayBufferView");
|
||||
|
||||
return @readableByteStreamControllerRespondWithNewView(@getByIdDirectPrivate(this, "associatedReadableByteStreamController"), view);
|
||||
}
|
||||
|
||||
@getter
|
||||
function view()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamBYOBRequest(this))
|
||||
throw @makeGetterTypeError("ReadableStreamBYOBRequest", "view");
|
||||
|
||||
return @getByIdDirectPrivate(this, "view");
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Canon Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function initializeReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (arguments.length !== 5 && arguments[4] !== @isReadableStream)
|
||||
@throwTypeError("ReadableStreamDefaultController constructor should not be called directly");
|
||||
|
||||
return @privateInitializeReadableStreamDefaultController.@call(this, stream, underlyingSource, size, highWaterMark);
|
||||
}
|
||||
|
||||
function enqueue(chunk)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultController(this))
|
||||
throw @makeThisTypeError("ReadableStreamDefaultController", "enqueue");
|
||||
|
||||
if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))
|
||||
@throwTypeError("ReadableStreamDefaultController is not in a state where chunk can be enqueued");
|
||||
|
||||
return @readableStreamDefaultControllerEnqueue(this, chunk);
|
||||
}
|
||||
|
||||
function error(error)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultController(this))
|
||||
throw @makeThisTypeError("ReadableStreamDefaultController", "error");
|
||||
|
||||
@readableStreamDefaultControllerError(this, error);
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultController(this))
|
||||
throw @makeThisTypeError("ReadableStreamDefaultController", "close");
|
||||
|
||||
if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))
|
||||
@throwTypeError("ReadableStreamDefaultController is not in a state where it can be closed");
|
||||
|
||||
@readableStreamDefaultControllerClose(this);
|
||||
}
|
||||
|
||||
@getter
|
||||
function desiredSize()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultController(this))
|
||||
throw @makeGetterTypeError("ReadableStreamDefaultController", "desiredSize");
|
||||
|
||||
return @readableStreamDefaultControllerGetDesiredSize(this);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Canon Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function initializeReadableStreamDefaultReader(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStream(stream))
|
||||
@throwTypeError("ReadableStreamDefaultReader needs a ReadableStream");
|
||||
if (@isReadableStreamLocked(stream))
|
||||
@throwTypeError("ReadableStream is locked");
|
||||
|
||||
@readableStreamReaderGenericInitialize(this, stream);
|
||||
@putByIdDirectPrivate(this, "readRequests", @createFIFO());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function cancel(reason)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultReader(this))
|
||||
return @Promise.@reject(@makeThisTypeError("ReadableStreamDefaultReader", "cancel"));
|
||||
|
||||
if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
|
||||
return @Promise.@reject(@makeTypeError("cancel() called on a reader owned by no readable stream"));
|
||||
|
||||
return @readableStreamReaderGenericCancel(this, reason);
|
||||
}
|
||||
|
||||
function readMany()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultReader(this))
|
||||
@throwTypeError("ReadableStreamDefaultReader.readMany() should not be called directly");
|
||||
|
||||
const stream = @getByIdDirectPrivate(this, "ownerReadableStream");
|
||||
if (!stream)
|
||||
@throwTypeError("readMany() called on a reader owned by no readable stream");
|
||||
|
||||
const state = @getByIdDirectPrivate(stream, "state");
|
||||
@putByIdDirectPrivate(stream, "disturbed", true);
|
||||
if (state === @streamClosed)
|
||||
return {value: [], size: 0, done: true};
|
||||
else if (state === @streamErrored) {
|
||||
throw @getByIdDirectPrivate(stream, "storedError");
|
||||
}
|
||||
|
||||
var controller = @getByIdDirectPrivate(stream, "readableStreamController");
|
||||
|
||||
const content = @getByIdDirectPrivate(controller, "queue").content;
|
||||
var size = @getByIdDirectPrivate(controller, "queue").size;
|
||||
var values = content.toArray(false);
|
||||
var length = values.length;
|
||||
|
||||
if (length > 0) {
|
||||
@resetQueue(@getByIdDirectPrivate(controller, "queue"));
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "closeRequested"))
|
||||
@readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
|
||||
else
|
||||
@readableStreamDefaultControllerCallPullIfNeeded(controller);
|
||||
} else {
|
||||
return controller.@pull(controller).@then(({value, done}) => {
|
||||
if (done) {
|
||||
return {value: [], size: 0, done: true};
|
||||
}
|
||||
var queue = @getByIdDirectPrivate(controller, "queue");
|
||||
const content = [value].concat(queue.content.toArray(false));
|
||||
var size = queue.size;
|
||||
@resetQueue(queue);
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "closeRequested"))
|
||||
@readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
|
||||
else
|
||||
@readableStreamDefaultControllerCallPullIfNeeded(controller);
|
||||
controller = @undefined;
|
||||
|
||||
return {value: values, size: size, done: false};
|
||||
});
|
||||
}
|
||||
|
||||
controller = @undefined;
|
||||
|
||||
return {value: values, size, done: false};
|
||||
}
|
||||
|
||||
function read()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultReader(this))
|
||||
return @Promise.@reject(@makeThisTypeError("ReadableStreamDefaultReader", "read"));
|
||||
if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
|
||||
return @Promise.@reject(@makeTypeError("read() called on a reader owned by no readable stream"));
|
||||
|
||||
return @readableStreamDefaultReaderRead(this);
|
||||
}
|
||||
|
||||
function releaseLock()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultReader(this))
|
||||
throw @makeThisTypeError("ReadableStreamDefaultReader", "releaseLock");
|
||||
|
||||
if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
|
||||
return;
|
||||
|
||||
if (@getByIdDirectPrivate(this, "readRequests")?.isNotEmpty())
|
||||
@throwTypeError("There are still pending read requests, cannot release the lock");
|
||||
|
||||
@readableStreamReaderGenericRelease(this);
|
||||
}
|
||||
|
||||
@getter
|
||||
function closed()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStreamDefaultReader(this))
|
||||
return @Promise.@reject(@makeGetterTypeError("ReadableStreamDefaultReader", "closed"));
|
||||
|
||||
return @getByIdDirectPrivate(this, "closedPromiseCapability").@promise;
|
||||
}
|
||||
@@ -0,0 +1,817 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Canon Inc. All rights reserved.
|
||||
* Copyright (C) 2015 Igalia.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// @internal
|
||||
|
||||
function readableStreamReaderGenericInitialize(reader, stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@putByIdDirectPrivate(reader, "ownerReadableStream", stream);
|
||||
@putByIdDirectPrivate(stream, "reader", reader);
|
||||
if (@getByIdDirectPrivate(stream, "state") === @streamReadable)
|
||||
@putByIdDirectPrivate(reader, "closedPromiseCapability", @newPromiseCapability(@Promise));
|
||||
else if (@getByIdDirectPrivate(stream, "state") === @streamClosed)
|
||||
@putByIdDirectPrivate(reader, "closedPromiseCapability", { @promise: @Promise.@resolve() });
|
||||
else {
|
||||
@assert(@getByIdDirectPrivate(stream, "state") === @streamErrored);
|
||||
@putByIdDirectPrivate(reader, "closedPromiseCapability", { @promise: @newHandledRejectedPromise(@getByIdDirectPrivate(stream, "storedError")) });
|
||||
}
|
||||
}
|
||||
|
||||
function privateInitializeReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
if (!@isReadableStream(stream))
|
||||
@throwTypeError("ReadableStreamDefaultController needs a ReadableStream");
|
||||
|
||||
// readableStreamController is initialized with null value.
|
||||
if (@getByIdDirectPrivate(stream, "readableStreamController") !== null)
|
||||
@throwTypeError("ReadableStream already has a controller");
|
||||
|
||||
|
||||
|
||||
@putByIdDirectPrivate(this, "controlledReadableStream", stream);
|
||||
@putByIdDirectPrivate(this, "underlyingSource", underlyingSource);
|
||||
@putByIdDirectPrivate(this, "queue", @newQueue());
|
||||
@putByIdDirectPrivate(this, "started", false);
|
||||
@putByIdDirectPrivate(this, "closeRequested", false);
|
||||
@putByIdDirectPrivate(this, "pullAgain", false);
|
||||
@putByIdDirectPrivate(this, "pulling", false);
|
||||
@putByIdDirectPrivate(this, "strategy", @validateAndNormalizeQueuingStrategy(size, highWaterMark));
|
||||
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller, starting from step 6.
|
||||
// The other part is implemented in privateInitializeReadableStreamDefaultController.
|
||||
function setupReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark, startMethod, pullMethod, cancelMethod)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const controller = new @ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark, @isReadableStream);
|
||||
const startAlgorithm = () => @promiseInvokeOrNoopMethodNoCatch(underlyingSource, startMethod, [controller]);
|
||||
const pullAlgorithm = () => @promiseInvokeOrNoopMethod(underlyingSource, pullMethod, [controller]);
|
||||
const cancelAlgorithm = (reason) => @promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]);
|
||||
|
||||
@putByIdDirectPrivate(controller, "pullAlgorithm", pullAlgorithm);
|
||||
@putByIdDirectPrivate(controller, "cancelAlgorithm", cancelAlgorithm);
|
||||
@putByIdDirectPrivate(controller, "pull", @readableStreamDefaultControllerPull);
|
||||
@putByIdDirectPrivate(controller, "cancel", @readableStreamDefaultControllerCancel);
|
||||
@putByIdDirectPrivate(stream, "readableStreamController", controller);
|
||||
|
||||
startAlgorithm().@then(() => {
|
||||
@putByIdDirectPrivate(controller, "started", true);
|
||||
@assert(!@getByIdDirectPrivate(controller, "pulling"));
|
||||
@assert(!@getByIdDirectPrivate(controller, "pullAgain"));
|
||||
@readableStreamDefaultControllerCallPullIfNeeded(controller);
|
||||
|
||||
}, (error) => {
|
||||
@readableStreamDefaultControllerError(controller, error);
|
||||
});
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerError(controller, error)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
if (@getByIdDirectPrivate(stream, "state") !== @streamReadable)
|
||||
return;
|
||||
@putByIdDirectPrivate(controller, "queue", @newQueue());
|
||||
@readableStreamError(stream, error);
|
||||
}
|
||||
|
||||
function readableStreamPipeTo(stream, sink)
|
||||
{
|
||||
"use strict";
|
||||
@assert(@isReadableStream(stream));
|
||||
|
||||
const reader = new @ReadableStreamDefaultReader(stream);
|
||||
|
||||
@getByIdDirectPrivate(reader, "closedPromiseCapability").@promise.@then(() => { }, (e) => { sink.error(e); });
|
||||
|
||||
function doPipe() {
|
||||
@readableStreamDefaultReaderRead(reader).@then(function(result) {
|
||||
if (result.done) {
|
||||
sink.close();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sink.enqueue(result.value);
|
||||
} catch (e) {
|
||||
sink.error("ReadableStream chunk enqueueing in the sink failed");
|
||||
return;
|
||||
}
|
||||
doPipe();
|
||||
}, function(e) {
|
||||
sink.error(e);
|
||||
});
|
||||
}
|
||||
doPipe();
|
||||
}
|
||||
|
||||
function acquireReadableStreamDefaultReader(stream)
|
||||
{
|
||||
return new @ReadableStreamDefaultReader(stream);
|
||||
}
|
||||
|
||||
// FIXME: Replace readableStreamPipeTo by below function.
|
||||
// This method implements the latest https://streams.spec.whatwg.org/#readable-stream-pipe-to.
|
||||
function readableStreamPipeToWritableStream(source, destination, preventClose, preventAbort, preventCancel, signal)
|
||||
{
|
||||
@assert(@isReadableStream(source));
|
||||
@assert(@isWritableStream(destination));
|
||||
@assert(!@isReadableStreamLocked(source));
|
||||
@assert(!@isWritableStreamLocked(destination));
|
||||
@assert(signal === @undefined || @isAbortSignal(signal));
|
||||
|
||||
if (@getByIdDirectPrivate(source, "underlyingByteSource") !== @undefined)
|
||||
return @Promise.@reject("Piping to a readable bytestream is not supported");
|
||||
|
||||
let pipeState = { source : source, destination : destination, preventAbort : preventAbort, preventCancel : preventCancel, preventClose : preventClose, signal : signal };
|
||||
|
||||
pipeState.reader = @acquireReadableStreamDefaultReader(source);
|
||||
pipeState.writer = @acquireWritableStreamDefaultWriter(destination);
|
||||
|
||||
@putByIdDirectPrivate(source, "disturbed", true);
|
||||
|
||||
pipeState.finalized = false;
|
||||
pipeState.shuttingDown = false;
|
||||
pipeState.promiseCapability = @newPromiseCapability(@Promise);
|
||||
pipeState.pendingReadPromiseCapability = @newPromiseCapability(@Promise);
|
||||
pipeState.pendingReadPromiseCapability.@resolve.@call();
|
||||
pipeState.pendingWritePromise = @Promise.@resolve();
|
||||
|
||||
if (signal !== @undefined) {
|
||||
const algorithm = () => {
|
||||
if (pipeState.finalized)
|
||||
return;
|
||||
|
||||
const error = @makeDOMException("AbortError", "abort pipeTo from signal");
|
||||
|
||||
@pipeToShutdownWithAction(pipeState, () => {
|
||||
const shouldAbortDestination = !pipeState.preventAbort && @getByIdDirectPrivate(pipeState.destination, "state") === "writable";
|
||||
const promiseDestination = shouldAbortDestination ? @writableStreamAbort(pipeState.destination, error) : @Promise.@resolve();
|
||||
|
||||
const shouldAbortSource = !pipeState.preventCancel && @getByIdDirectPrivate(pipeState.source, "state") === @streamReadable;
|
||||
const promiseSource = shouldAbortSource ? @readableStreamCancel(pipeState.source, error) : @Promise.@resolve();
|
||||
|
||||
let promiseCapability = @newPromiseCapability(@Promise);
|
||||
let shouldWait = true;
|
||||
let handleResolvedPromise = () => {
|
||||
if (shouldWait) {
|
||||
shouldWait = false;
|
||||
return;
|
||||
}
|
||||
promiseCapability.@resolve.@call();
|
||||
}
|
||||
let handleRejectedPromise = (e) => {
|
||||
promiseCapability.@reject.@call(@undefined, e);
|
||||
}
|
||||
promiseDestination.@then(handleResolvedPromise, handleRejectedPromise);
|
||||
promiseSource.@then(handleResolvedPromise, handleRejectedPromise);
|
||||
return promiseCapability.@promise;
|
||||
}, error);
|
||||
};
|
||||
if (@whenSignalAborted(signal, algorithm))
|
||||
return pipeState.promiseCapability.@promise;
|
||||
}
|
||||
|
||||
@pipeToErrorsMustBePropagatedForward(pipeState);
|
||||
@pipeToErrorsMustBePropagatedBackward(pipeState);
|
||||
@pipeToClosingMustBePropagatedForward(pipeState);
|
||||
@pipeToClosingMustBePropagatedBackward(pipeState);
|
||||
|
||||
@pipeToLoop(pipeState);
|
||||
|
||||
return pipeState.promiseCapability.@promise;
|
||||
}
|
||||
|
||||
function pipeToLoop(pipeState)
|
||||
{
|
||||
if (pipeState.shuttingDown)
|
||||
return;
|
||||
|
||||
@pipeToDoReadWrite(pipeState).@then((result) => {
|
||||
if (result)
|
||||
@pipeToLoop(pipeState);
|
||||
});
|
||||
}
|
||||
|
||||
function pipeToDoReadWrite(pipeState)
|
||||
{
|
||||
@assert(!pipeState.shuttingDown);
|
||||
|
||||
pipeState.pendingReadPromiseCapability = @newPromiseCapability(@Promise);
|
||||
@getByIdDirectPrivate(pipeState.writer, "readyPromise").@promise.@then(() => {
|
||||
if (pipeState.shuttingDown) {
|
||||
pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@readableStreamDefaultReaderRead(pipeState.reader).@then((result) => {
|
||||
const canWrite = !result.done && @getByIdDirectPrivate(pipeState.writer, "stream") !== @undefined;
|
||||
pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, canWrite);
|
||||
if (!canWrite)
|
||||
return;
|
||||
|
||||
pipeState.pendingWritePromise = @writableStreamDefaultWriterWrite(pipeState.writer, result.value);
|
||||
}, (e) => {
|
||||
pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
|
||||
});
|
||||
}, (e) => {
|
||||
pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
|
||||
});
|
||||
return pipeState.pendingReadPromiseCapability.@promise;
|
||||
}
|
||||
|
||||
function pipeToErrorsMustBePropagatedForward(pipeState)
|
||||
{
|
||||
const action = () => {
|
||||
pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
|
||||
const error = @getByIdDirectPrivate(pipeState.source, "storedError");
|
||||
if (!pipeState.preventAbort) {
|
||||
@pipeToShutdownWithAction(pipeState, () => @writableStreamAbort(pipeState.destination, error), error);
|
||||
return;
|
||||
}
|
||||
@pipeToShutdown(pipeState, error);
|
||||
};
|
||||
|
||||
if (@getByIdDirectPrivate(pipeState.source, "state") === @streamErrored) {
|
||||
action();
|
||||
return;
|
||||
}
|
||||
|
||||
@getByIdDirectPrivate(pipeState.reader, "closedPromiseCapability").@promise.@then(@undefined, action);
|
||||
}
|
||||
|
||||
function pipeToErrorsMustBePropagatedBackward(pipeState)
|
||||
{
|
||||
const action = () => {
|
||||
const error = @getByIdDirectPrivate(pipeState.destination, "storedError");
|
||||
if (!pipeState.preventCancel) {
|
||||
@pipeToShutdownWithAction(pipeState, () => @readableStreamCancel(pipeState.source, error), error);
|
||||
return;
|
||||
}
|
||||
@pipeToShutdown(pipeState, error);
|
||||
};
|
||||
if (@getByIdDirectPrivate(pipeState.destination, "state") === "errored") {
|
||||
action();
|
||||
return;
|
||||
}
|
||||
@getByIdDirectPrivate(pipeState.writer, "closedPromise").@promise.@then(@undefined, action);
|
||||
}
|
||||
|
||||
function pipeToClosingMustBePropagatedForward(pipeState)
|
||||
{
|
||||
const action = () => {
|
||||
pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
|
||||
const error = @getByIdDirectPrivate(pipeState.source, "storedError");
|
||||
if (!pipeState.preventClose) {
|
||||
@pipeToShutdownWithAction(pipeState, () => @writableStreamDefaultWriterCloseWithErrorPropagation(pipeState.writer));
|
||||
return;
|
||||
}
|
||||
@pipeToShutdown(pipeState);
|
||||
};
|
||||
if (@getByIdDirectPrivate(pipeState.source, "state") === @streamClosed) {
|
||||
action();
|
||||
return;
|
||||
}
|
||||
@getByIdDirectPrivate(pipeState.reader, "closedPromiseCapability").@promise.@then(action, @undefined);
|
||||
}
|
||||
|
||||
function pipeToClosingMustBePropagatedBackward(pipeState)
|
||||
{
|
||||
if (!@writableStreamCloseQueuedOrInFlight(pipeState.destination) && @getByIdDirectPrivate(pipeState.destination, "state") !== "closed")
|
||||
return;
|
||||
|
||||
// @assert no chunks have been read/written
|
||||
|
||||
const error = @makeTypeError("closing is propagated backward");
|
||||
if (!pipeState.preventCancel) {
|
||||
@pipeToShutdownWithAction(pipeState, () => @readableStreamCancel(pipeState.source, error), error);
|
||||
return;
|
||||
}
|
||||
@pipeToShutdown(pipeState, error);
|
||||
}
|
||||
|
||||
function pipeToShutdownWithAction(pipeState, action)
|
||||
{
|
||||
if (pipeState.shuttingDown)
|
||||
return;
|
||||
|
||||
pipeState.shuttingDown = true;
|
||||
|
||||
const hasError = arguments.length > 2;
|
||||
const error = arguments[2];
|
||||
const finalize = () => {
|
||||
const promise = action();
|
||||
promise.@then(() => {
|
||||
if (hasError)
|
||||
@pipeToFinalize(pipeState, error);
|
||||
else
|
||||
@pipeToFinalize(pipeState);
|
||||
}, (e) => {
|
||||
@pipeToFinalize(pipeState, e);
|
||||
});
|
||||
};
|
||||
|
||||
if (@getByIdDirectPrivate(pipeState.destination, "state") === "writable" && !@writableStreamCloseQueuedOrInFlight(pipeState.destination)) {
|
||||
pipeState.pendingReadPromiseCapability.@promise.@then(() => {
|
||||
pipeState.pendingWritePromise.@then(finalize, finalize);
|
||||
}, (e) => @pipeToFinalize(pipeState, e));
|
||||
return;
|
||||
}
|
||||
|
||||
finalize();
|
||||
}
|
||||
|
||||
function pipeToShutdown(pipeState)
|
||||
{
|
||||
if (pipeState.shuttingDown)
|
||||
return;
|
||||
|
||||
pipeState.shuttingDown = true;
|
||||
|
||||
const hasError = arguments.length > 1;
|
||||
const error = arguments[1];
|
||||
const finalize = () => {
|
||||
if (hasError)
|
||||
@pipeToFinalize(pipeState, error);
|
||||
else
|
||||
@pipeToFinalize(pipeState);
|
||||
};
|
||||
|
||||
if (@getByIdDirectPrivate(pipeState.destination, "state") === "writable" && !@writableStreamCloseQueuedOrInFlight(pipeState.destination)) {
|
||||
pipeState.pendingReadPromiseCapability.@promise.@then(() => {
|
||||
pipeState.pendingWritePromise.@then(finalize, finalize);
|
||||
}, (e) => @pipeToFinalize(pipeState, e));
|
||||
return;
|
||||
}
|
||||
finalize();
|
||||
}
|
||||
|
||||
function pipeToFinalize(pipeState)
|
||||
{
|
||||
@writableStreamDefaultWriterRelease(pipeState.writer);
|
||||
@readableStreamReaderGenericRelease(pipeState.reader);
|
||||
|
||||
// Instead of removing the abort algorithm as per spec, we make it a no-op which is equivalent.
|
||||
pipeState.finalized = true;
|
||||
|
||||
if (arguments.length > 1)
|
||||
pipeState.promiseCapability.@reject.@call(@undefined, arguments[1]);
|
||||
else
|
||||
pipeState.promiseCapability.@resolve.@call();
|
||||
}
|
||||
|
||||
function readableStreamTee(stream, shouldClone)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@isReadableStream(stream));
|
||||
@assert(typeof(shouldClone) === "boolean");
|
||||
|
||||
const reader = new @ReadableStreamDefaultReader(stream);
|
||||
|
||||
const teeState = {
|
||||
closedOrErrored: false,
|
||||
canceled1: false,
|
||||
canceled2: false,
|
||||
reason1: @undefined,
|
||||
reason2: @undefined,
|
||||
};
|
||||
|
||||
teeState.cancelPromiseCapability = @newPromiseCapability(@Promise);
|
||||
|
||||
const pullFunction = @readableStreamTeePullFunction(teeState, reader, shouldClone);
|
||||
|
||||
const branch1Source = { };
|
||||
@putByIdDirectPrivate(branch1Source, "pull", pullFunction);
|
||||
@putByIdDirectPrivate(branch1Source, "cancel", @readableStreamTeeBranch1CancelFunction(teeState, stream));
|
||||
|
||||
const branch2Source = { };
|
||||
@putByIdDirectPrivate(branch2Source, "pull", pullFunction);
|
||||
@putByIdDirectPrivate(branch2Source, "cancel", @readableStreamTeeBranch2CancelFunction(teeState, stream));
|
||||
|
||||
const branch1 = new @ReadableStream(branch1Source);
|
||||
const branch2 = new @ReadableStream(branch2Source);
|
||||
|
||||
@getByIdDirectPrivate(reader, "closedPromiseCapability").@promise.@then(@undefined, function(e) {
|
||||
if (teeState.closedOrErrored)
|
||||
return;
|
||||
@readableStreamDefaultControllerError(branch1.@readableStreamController, e);
|
||||
@readableStreamDefaultControllerError(branch2.@readableStreamController, e);
|
||||
teeState.closedOrErrored = true;
|
||||
if (!teeState.canceled1 || !teeState.canceled2)
|
||||
teeState.cancelPromiseCapability.@resolve.@call();
|
||||
});
|
||||
|
||||
// Additional fields compared to the spec, as they are needed within pull/cancel functions.
|
||||
teeState.branch1 = branch1;
|
||||
teeState.branch2 = branch2;
|
||||
|
||||
return [branch1, branch2];
|
||||
}
|
||||
|
||||
function readableStreamTeePullFunction(teeState, reader, shouldClone)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
return function() {
|
||||
@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), function(result) {
|
||||
@assert(@isObject(result));
|
||||
@assert(typeof result.done === "boolean");
|
||||
if (result.done && !teeState.closedOrErrored) {
|
||||
if (!teeState.canceled1)
|
||||
@readableStreamDefaultControllerClose(teeState.branch1.@readableStreamController);
|
||||
if (!teeState.canceled2)
|
||||
@readableStreamDefaultControllerClose(teeState.branch2.@readableStreamController);
|
||||
teeState.closedOrErrored = true;
|
||||
if (!teeState.canceled1 || !teeState.canceled2)
|
||||
teeState.cancelPromiseCapability.@resolve.@call();
|
||||
}
|
||||
if (teeState.closedOrErrored)
|
||||
return;
|
||||
if (!teeState.canceled1)
|
||||
@readableStreamDefaultControllerEnqueue(teeState.branch1.@readableStreamController, result.value);
|
||||
if (!teeState.canceled2)
|
||||
@readableStreamDefaultControllerEnqueue(teeState.branch2.@readableStreamController, shouldClone ? @structuredCloneForStream(result.value) : result.value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function readableStreamTeeBranch1CancelFunction(teeState, stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
return function(r) {
|
||||
teeState.canceled1 = true;
|
||||
teeState.reason1 = r;
|
||||
if (teeState.canceled2) {
|
||||
@readableStreamCancel(stream, [teeState.reason1, teeState.reason2]).@then(
|
||||
teeState.cancelPromiseCapability.@resolve,
|
||||
teeState.cancelPromiseCapability.@reject);
|
||||
}
|
||||
return teeState.cancelPromiseCapability.@promise;
|
||||
}
|
||||
}
|
||||
|
||||
function readableStreamTeeBranch2CancelFunction(teeState, stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
return function(r) {
|
||||
teeState.canceled2 = true;
|
||||
teeState.reason2 = r;
|
||||
if (teeState.canceled1) {
|
||||
@readableStreamCancel(stream, [teeState.reason1, teeState.reason2]).@then(
|
||||
teeState.cancelPromiseCapability.@resolve,
|
||||
teeState.cancelPromiseCapability.@reject);
|
||||
}
|
||||
return teeState.cancelPromiseCapability.@promise;
|
||||
}
|
||||
}
|
||||
|
||||
function isReadableStream(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// Spec tells to return true only if stream has a readableStreamController internal slot.
|
||||
// However, since it is a private slot, it cannot be checked using hasOwnProperty().
|
||||
// Therefore, readableStreamController is initialized with null value.
|
||||
return @isObject(stream) && @getByIdDirectPrivate(stream, "readableStreamController") !== @undefined;
|
||||
}
|
||||
|
||||
function isReadableStreamDefaultReader(reader)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// Spec tells to return true only if reader has a readRequests internal slot.
|
||||
// However, since it is a private slot, it cannot be checked using hasOwnProperty().
|
||||
// Since readRequests is initialized with an empty array, the following test is ok.
|
||||
return @isObject(reader) && !!@getByIdDirectPrivate(reader, "readRequests");
|
||||
}
|
||||
|
||||
function isReadableStreamDefaultController(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// Spec tells to return true only if controller has an underlyingSource internal slot.
|
||||
// However, since it is a private slot, it cannot be checked using hasOwnProperty().
|
||||
// underlyingSource is obtained in ReadableStream constructor: if undefined, it is set
|
||||
// to an empty object. Therefore, following test is ok.
|
||||
return @isObject(controller) && !!@getByIdDirectPrivate(controller, "underlyingSource");
|
||||
}
|
||||
|
||||
function readableStreamError(stream, error)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@isReadableStream(stream));
|
||||
@assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
|
||||
@putByIdDirectPrivate(stream, "state", @streamErrored);
|
||||
@putByIdDirectPrivate(stream, "storedError", error);
|
||||
|
||||
if (!@getByIdDirectPrivate(stream, "reader"))
|
||||
return;
|
||||
|
||||
const reader = @getByIdDirectPrivate(stream, "reader");
|
||||
|
||||
if (@isReadableStreamDefaultReader(reader)) {
|
||||
const requests = @getByIdDirectPrivate(reader, "readRequests");
|
||||
@putByIdDirectPrivate(reader, "readRequests", @createFIFO());
|
||||
for (var request = requests.shift(); request; request = requests.shift())
|
||||
@rejectPromise(request, error);
|
||||
} else {
|
||||
@assert(@isReadableStreamBYOBReader(reader));
|
||||
const requests = @getByIdDirectPrivate(reader, "readIntoRequests");
|
||||
@putByIdDirectPrivate(reader, "readIntoRequests", @createFIFO());
|
||||
for (var request = requests.shift(); request; request = requests.shift())
|
||||
@rejectPromise(request, error);
|
||||
}
|
||||
|
||||
@getByIdDirectPrivate(reader, "closedPromiseCapability").@reject.@call(@undefined, error);
|
||||
const promise = @getByIdDirectPrivate(reader, "closedPromiseCapability").@promise;
|
||||
@markPromiseAsHandled(promise);
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerShouldCallPull(controller)
|
||||
{
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
|
||||
if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller))
|
||||
return false;
|
||||
if (!@getByIdDirectPrivate(controller, "started"))
|
||||
return false;
|
||||
if ((!@isReadableStreamLocked(stream) || !@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests")?.isNotEmpty()) && @readableStreamDefaultControllerGetDesiredSize(controller) <= 0)
|
||||
return false;
|
||||
const desiredSize = @readableStreamDefaultControllerGetDesiredSize(controller);
|
||||
@assert(desiredSize !== null);
|
||||
return desiredSize > 0;
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerCallPullIfNeeded(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
// FIXME: use @readableStreamDefaultControllerShouldCallPull
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
|
||||
if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller))
|
||||
return;
|
||||
if (!@getByIdDirectPrivate(controller, "started"))
|
||||
return;
|
||||
if ((!@isReadableStreamLocked(stream) || !@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests")?.isNotEmpty()) && @readableStreamDefaultControllerGetDesiredSize(controller) <= 0)
|
||||
return;
|
||||
|
||||
if (@getByIdDirectPrivate(controller, "pulling")) {
|
||||
@putByIdDirectPrivate(controller, "pullAgain", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@assert(!@getByIdDirectPrivate(controller, "pullAgain"));
|
||||
@putByIdDirectPrivate(controller, "pulling", true);
|
||||
|
||||
@getByIdDirectPrivate(controller, "pullAlgorithm").@call(@undefined).@then(function() {
|
||||
@putByIdDirectPrivate(controller, "pulling", false);
|
||||
if (@getByIdDirectPrivate(controller, "pullAgain")) {
|
||||
@putByIdDirectPrivate(controller, "pullAgain", false);
|
||||
@readableStreamDefaultControllerCallPullIfNeeded(controller);
|
||||
}
|
||||
}, function(error) {
|
||||
@readableStreamDefaultControllerError(controller, error);
|
||||
});
|
||||
}
|
||||
|
||||
function isReadableStreamLocked(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@isReadableStream(stream));
|
||||
return !!@getByIdDirectPrivate(stream, "reader");
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerGetDesiredSize(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
const state = @getByIdDirectPrivate(stream, "state");
|
||||
|
||||
if (state === @streamErrored)
|
||||
return null;
|
||||
if (state === @streamClosed)
|
||||
return 0;
|
||||
|
||||
return @getByIdDirectPrivate(controller, "strategy").highWaterMark - @getByIdDirectPrivate(controller, "queue").size;
|
||||
}
|
||||
|
||||
|
||||
function readableStreamReaderGenericCancel(reader, reason)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(reader, "ownerReadableStream");
|
||||
@assert(!!stream);
|
||||
return @readableStreamCancel(stream, reason);
|
||||
}
|
||||
|
||||
function readableStreamCancel(stream, reason)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@putByIdDirectPrivate(stream, "disturbed", true);
|
||||
const state = @getByIdDirectPrivate(stream, "state");
|
||||
if (state === @streamClosed)
|
||||
return @Promise.@resolve();
|
||||
if (state === @streamErrored)
|
||||
return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
|
||||
@readableStreamClose(stream);
|
||||
return @getByIdDirectPrivate(stream, "readableStreamController").@cancel(@getByIdDirectPrivate(stream, "readableStreamController"), reason).@then(function() { });
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerCancel(controller, reason)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@putByIdDirectPrivate(controller, "queue", @newQueue());
|
||||
return @getByIdDirectPrivate(controller, "cancelAlgorithm").@call(@undefined, reason);
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerPull(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
var queue = @getByIdDirectPrivate(controller, "queue");
|
||||
if (queue.isNotEmpty()) {
|
||||
const chunk = @dequeueValue(queue);
|
||||
if (@getByIdDirectPrivate(controller, "closeRequested") && queue.isEmpty())
|
||||
@readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
|
||||
else
|
||||
@readableStreamDefaultControllerCallPullIfNeeded(controller);
|
||||
|
||||
return @createFulfilledPromise({ value: chunk, done: false });
|
||||
}
|
||||
const pendingPromise = @readableStreamAddReadRequest(@getByIdDirectPrivate(controller, "controlledReadableStream"));
|
||||
@readableStreamDefaultControllerCallPullIfNeeded(controller);
|
||||
return pendingPromise;
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerClose(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));
|
||||
@putByIdDirectPrivate(controller, "closeRequested", true);
|
||||
if (@getByIdDirectPrivate(controller, "queue")?.isEmpty())
|
||||
@readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
|
||||
}
|
||||
|
||||
function readableStreamClose(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
|
||||
@putByIdDirectPrivate(stream, "state", @streamClosed);
|
||||
const reader = @getByIdDirectPrivate(stream, "reader");
|
||||
|
||||
if (!reader)
|
||||
return;
|
||||
|
||||
if (@isReadableStreamDefaultReader(reader)) {
|
||||
const requests = @getByIdDirectPrivate(reader, "readRequests");
|
||||
@putByIdDirectPrivate(reader, "readRequests", @createFIFO());
|
||||
|
||||
for (var request = requests.shift(); request; request = requests.shift())
|
||||
@fulfillPromise(request, { value: @undefined, done: true });
|
||||
}
|
||||
|
||||
@getByIdDirectPrivate(reader, "closedPromiseCapability").@resolve.@call();
|
||||
}
|
||||
|
||||
function readableStreamFulfillReadRequest(stream, chunk, done)
|
||||
{
|
||||
"use strict";
|
||||
const readRequest = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").shift();
|
||||
@fulfillPromise(readRequest, { value: chunk, done: done });
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerEnqueue(controller, chunk)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
|
||||
// this is checked by callers
|
||||
@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));
|
||||
|
||||
if (@isReadableStreamLocked(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests")?.isNotEmpty()) {
|
||||
@readableStreamFulfillReadRequest(stream, chunk, false);
|
||||
@readableStreamDefaultControllerCallPullIfNeeded(controller);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
let chunkSize = 1;
|
||||
if (@getByIdDirectPrivate(controller, "strategy").size !== @undefined)
|
||||
chunkSize = @getByIdDirectPrivate(controller, "strategy").size(chunk);
|
||||
@enqueueValueWithSize(@getByIdDirectPrivate(controller, "queue"), chunk, chunkSize);
|
||||
}
|
||||
catch(error) {
|
||||
@readableStreamDefaultControllerError(controller, error);
|
||||
throw error;
|
||||
}
|
||||
@readableStreamDefaultControllerCallPullIfNeeded(controller);
|
||||
}
|
||||
|
||||
function readableStreamDefaultReaderRead(reader)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
const stream = @getByIdDirectPrivate(reader, "ownerReadableStream");
|
||||
@assert(!!stream);
|
||||
const state = @getByIdDirectPrivate(stream, "state");
|
||||
|
||||
@putByIdDirectPrivate(stream, "disturbed", true);
|
||||
if (state === @streamClosed)
|
||||
return @createFulfilledPromise({ value: @undefined, done: true });
|
||||
if (state === @streamErrored)
|
||||
return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
|
||||
@assert(state === @streamReadable);
|
||||
|
||||
return @getByIdDirectPrivate(stream, "readableStreamController").@pull(@getByIdDirectPrivate(stream, "readableStreamController"));
|
||||
}
|
||||
|
||||
function readableStreamAddReadRequest(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@isReadableStreamDefaultReader(@getByIdDirectPrivate(stream, "reader")));
|
||||
@assert(@getByIdDirectPrivate(stream, "state") == @streamReadable);
|
||||
|
||||
const readRequest = @newPromise();
|
||||
|
||||
@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").push(readRequest);
|
||||
|
||||
return readRequest;
|
||||
}
|
||||
|
||||
function isReadableStreamDisturbed(stream)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(@isReadableStream(stream));
|
||||
return @getByIdDirectPrivate(stream, "disturbed");
|
||||
}
|
||||
|
||||
function readableStreamReaderGenericRelease(reader)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
@assert(!!@getByIdDirectPrivate(reader, "ownerReadableStream"));
|
||||
@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(reader, "ownerReadableStream"), "reader") === reader);
|
||||
|
||||
if (@getByIdDirectPrivate(@getByIdDirectPrivate(reader, "ownerReadableStream"), "state") === @streamReadable)
|
||||
@getByIdDirectPrivate(reader, "closedPromiseCapability").@reject.@call(@undefined, @makeTypeError("releasing lock of reader whose stream is still in readable state"));
|
||||
else
|
||||
@putByIdDirectPrivate(reader, "closedPromiseCapability", { @promise: @newHandledRejectedPromise(@makeTypeError("reader released lock")) });
|
||||
|
||||
const promise = @getByIdDirectPrivate(reader, "closedPromiseCapability").@promise;
|
||||
@markPromiseAsHandled(promise);
|
||||
@putByIdDirectPrivate(@getByIdDirectPrivate(reader, "ownerReadableStream"), "reader", @undefined);
|
||||
@putByIdDirectPrivate(reader, "ownerReadableStream", @undefined);
|
||||
}
|
||||
|
||||
function readableStreamDefaultControllerCanCloseOrEnqueue(controller)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
return !@getByIdDirectPrivate(controller, "closeRequested") && @getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user