diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | bench/snippets/buffer-read.js | 77 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/Buffer.cpp | 11 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/Buffer.h | 24 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/BunBuiltins.h | 99 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/BunClientData.cpp | 1 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/BunClientData.h | 4 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/JSBuffer.cpp | 615 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/JSBuffer.h | 2 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp | 537 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h | 442 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/builtins/README.md | 30 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/builtins/js/JSBufferPrototype.js | 236 | ||||
-rw-r--r-- | src/javascript/jsc/node/buffer.zig | 611 | ||||
-rw-r--r-- | src/javascript/jsc/test/jest.zig | 3 |
15 files changed, 1637 insertions, 1071 deletions
@@ -185,6 +185,7 @@ HOMEBREW_PREFIX ?= $(BREW_PREFIX_PATH) SRC_DIR := src/javascript/jsc/bindings OBJ_DIR := src/javascript/jsc/bindings-obj +SRC_PATH := $(realpath $(SRC_DIR)) SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp) SRC_WEBCORE_FILES := $(wildcard $(SRC_DIR)/webcore/*.cpp) OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES)) @@ -274,7 +275,7 @@ PLATFORM_LINKER_FLAGS += -DDU_DISABLE_RENAMING=1 \ endif - +SHARED_LIB_EXTENSION = .so JSC_BINDINGS = $(JSC_FILES) $(BINDINGS_OBJ) @@ -284,6 +285,7 @@ DEBUG_FLAGS= ifeq ($(OS_NAME), darwin) RELEASE_FLAGS += -Wl,-dead_strip -Wl,-dead_strip_dylibs DEBUG_FLAGS += -Wl,-dead_strip -Wl,-dead_strip_dylibs + SHARED_LIB_EXTENSION = .dylib endif @@ -291,6 +293,8 @@ endif + + ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MIMALLOC_FILE_PATH) \ $(BUN_DEPS_OUT_DIR)/picohttpparser.o \ -L$(BUN_DEPS_OUT_DIR) \ @@ -298,7 +302,9 @@ ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MIMALLOC_FILE_PATH) \ -lz \ -larchive \ -lssl \ - -lbase64 + -lbase64 \ + -ltcc \ + -L/Users/jarred/Build/tinycc ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO) -lcrypto @@ -353,6 +359,9 @@ base64: $(CXX) $(CXXFLAGS) $(CFLAGS) -c neonbase64.cc -g -fPIC -emit-llvm && \ $(AR) rcvs $(BUN_DEPS_OUT_DIR)/libbase64.a ./*.bc +generate-builtins: + $(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 + vendor-without-check: api analytics node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive libbacktrace lolhtml usockets uws base64 prepare-types: @@ -378,6 +387,9 @@ boringssl-copy: boringssl: boringssl-build boringssl-copy boringssl-debug: boringssl-build-debug boringssl-copy +compile-ffi-test: + clang -O3 -shared -undefined dynamic_lookup -o /tmp/libffi-test$(SHARED_LIB_EXTENSION) ./integration/bunjs-only-snippets/ffi-test.c + libbacktrace: cd $(BUN_DEPS_DIR)/libbacktrace && \ CFLAGS="$(CFLAGS)" CC=$(CC) ./configure --disable-shared --enable-static --with-pic && \ diff --git a/bench/snippets/buffer-read.js b/bench/snippets/buffer-read.js new file mode 100644 index 000000000..314f1d69e --- /dev/null +++ b/bench/snippets/buffer-read.js @@ -0,0 +1,77 @@ +// import { Buffer } from "buffer"; +var buf = new Buffer(1024); +// var buf = new Uint8Array(1024); +var view = new DataView(buf.buffer); +var INTERVAL = 9999999; +var time = (name, fn) => { + for (let i = 0; i < INTERVAL; i++) fn(); + + console.time(name.padEnd("DataView.readBigUInt64 (LE)".length)); + for (let i = 0; i < INTERVAL; i++) fn(); + console.timeEnd(name.padEnd("DataView.readBigUInt64 (LE)".length)); +}; + +console.log( + `Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, + "\n" +); +var array = new Uint8Array(1024); +time("Buffer[] ", () => buf[0]); +time("Uint8Array[]", () => array[0]); +console.log(""); + +time("Buffer.getBigInt64BE ", () => buf.readBigInt64BE(0)); +time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false)); +console.log(""); + +time("Buffer.readBigInt64LE ", () => buf.readBigInt64LE(0)); +time("DataView.readBigInt64 (LE)", () => view.getBigInt64(0, true)); +console.log(""); +time("Buffer.getBigUInt64BE ", () => buf.readBigUInt64BE(0)); +time("DataView.getBigUInt64 (BE)", () => view.getBigUint64(0, false)); +console.log(""); +time("Buffer.readBigUInt64LE ", () => buf.readBigUInt64LE(0)); +time("DataView.readBigUInt64 (LE)", () => view.getBigUint64(0, true)); +console.log(""); +time("Buffer.getDoubleBE ", () => buf.readDoubleBE(0)); +time("DataView.getDouble (BE)", () => view.getFloat64(0, false)); +console.log(""); +time("Buffer.readDoubleLE ", () => buf.readDoubleLE(0)); +time("DataView.readDouble (LE)", () => view.getFloat64(0, true)); +console.log(""); +time("Buffer.getFloatBE ", () => buf.readFloatBE(0)); +time("DataView.getFloat (BE)", () => view.getFloat32(0, false)); +console.log(""); +time("Buffer.readFloatLE ", () => buf.readFloatLE(0)); +time("DataView.readFloat (LE)", () => view.getFloat32(0, true)); +console.log(""); +time("Buffer.getInt16BE ", () => buf.readInt16BE(0)); +time("DataView.getInt16 (BE)", () => view.getInt16(0, false)); +console.log(""); +time("Buffer.readInt16LE ", () => buf.readInt16LE(0)); +time("DataView.readInt16 (LE)", () => view.getInt16(0, true)); +console.log(""); +time("Buffer.getInt32BE ", () => buf.readInt32BE(0)); +time("DataView.getInt32 (BE)", () => view.getInt32(0, false)); +console.log(""); +time("Buffer.readInt32LE ", () => buf.readInt32LE(0)); +time("DataView.readInt32 (LE)", () => view.getInt32(0, true)); +console.log(""); +time("Buffer.readInt8 ", () => buf.readInt8(0)); +time("DataView.readInt (t8)", () => view.getInt8(0)); +console.log(""); +time("Buffer.getUInt16BE ", () => buf.readUInt16BE(0)); +time("DataView.getUInt16 (BE)", () => view.getUint16(0, false)); +console.log(""); +time("Buffer.readUInt16LE ", () => buf.readUInt16LE(0)); +time("DataView.readUInt16 (LE)", () => view.getUint16(0, true)); +console.log(""); +time("Buffer.getUInt32BE ", () => buf.readUInt32BE(0)); +time("DataView.getUInt32 (BE)", () => view.getUint32(0, false)); +console.log(""); +time("Buffer.readUInt32LE ", () => buf.readUInt32LE(0)); +time("DataView.getUInt32 (LE)", () => view.getUint32(0, true)); +console.log(""); +time("Buffer.readUInt8 ", () => buf.readUInt8(0)); +time("DataView.getUInt (t8)", () => view.getUint8(0)); +console.log(""); diff --git a/src/javascript/jsc/bindings/Buffer.cpp b/src/javascript/jsc/bindings/Buffer.cpp index e20807b50..28b49791f 100644 --- a/src/javascript/jsc/bindings/Buffer.cpp +++ b/src/javascript/jsc/bindings/Buffer.cpp @@ -7,17 +7,17 @@ #include "root.h" #include "Buffer.h" -#include "JavaScriptCore/JSArrayBufferViewInlines.h" +#include "JavaScriptCore/Uint8Array.h" namespace WebCore { -Ref<Buffer> Buffer::create(JSC::JSGlobalObject* globalObject, RefPtr<ArrayBuffer>&& arrayBuffer, size_t byteOffset, size_t length) +Ref<Buffer> Buffer::create(JSC::JSGlobalObject* globalObject, JSC::JSUint8Array* array, size_t byteOffset, size_t length) { - return adoptRef(*new Buffer(globalObject, WTFMove(arrayBuffer), byteOffset, length)); + return adoptRef(*new Buffer(globalObject, array, byteOffset, length)); } -Ref<Buffer> Buffer::create(JSC::JSGlobalObject* globalObject, RefPtr<ArrayBuffer>&& arrayBuffer) +Ref<Buffer> Buffer::create(JSC::JSGlobalObject* globalObject, JSC::JSUint8Array* array) { - return create(globalObject, WTFMove(arrayBuffer), 0, arrayBuffer->byteLength()); + return create(globalObject, array, 0, array->byteLength()); } int32_t static write(WTF::StringView view, size_t offset, size_t length, BufferEncodingType encodingType) @@ -26,7 +26,6 @@ int32_t static write(WTF::StringView view, size_t offset, size_t length, BufferE Buffer::~Buffer() { - m_arrayBuffer->deref(); } Ref<Buffer> Buffer::createEmpty(JSC::JSGlobalObject* globalObject) diff --git a/src/javascript/jsc/bindings/Buffer.h b/src/javascript/jsc/bindings/Buffer.h index 8efc95787..6babb4e90 100644 --- a/src/javascript/jsc/bindings/Buffer.h +++ b/src/javascript/jsc/bindings/Buffer.h @@ -10,13 +10,13 @@ #include "BufferEncodingType.h" #include "JavaScriptCore/GenericTypedArrayView.h" -extern "C" JSC__JSValue Bun__encoding__toStringUTF16(const uint8_t* input, size_t len, JSC__JSGlobalObject* globalObject); -extern "C" JSC__JSValue Bun__encoding__toStringUTF8(const uint8_t* input, size_t len, JSC__JSGlobalObject* globalObject); -extern "C" JSC__JSValue Bun__encoding__toStringASCII(const uint8_t* input, size_t len, JSC__JSGlobalObject* globalObject); -extern "C" JSC__JSValue Bun__encoding__toStringLatin1(const uint8_t* input, size_t len, JSC__JSGlobalObject* globalObject); -extern "C" JSC__JSValue Bun__encoding__toStringHex(const uint8_t* input, size_t len, JSC__JSGlobalObject* globalObject); -extern "C" JSC__JSValue Bun__encoding__toStringBase64(const uint8_t* input, size_t len, JSC__JSGlobalObject* globalObject); -extern "C" JSC__JSValue Bun__encoding__toStringURLSafeBase64(const uint8_t* input, size_t len, JSC__JSGlobalObject* globalObject); +extern "C" JSC::EncodedJSValue Bun__encoding__toStringUTF16(const uint8_t* input, size_t len, JSC::JSGlobalObject* globalObject); +extern "C" JSC::EncodedJSValue Bun__encoding__toStringUTF8(const uint8_t* input, size_t len, JSC::JSGlobalObject* globalObject); +extern "C" JSC::EncodedJSValue Bun__encoding__toStringASCII(const uint8_t* input, size_t len, JSC::JSGlobalObject* globalObject); +extern "C" JSC::EncodedJSValue Bun__encoding__toStringLatin1(const uint8_t* input, size_t len, JSC::JSGlobalObject* globalObject); +extern "C" JSC::EncodedJSValue Bun__encoding__toStringHex(const uint8_t* input, size_t len, JSC::JSGlobalObject* globalObject); +extern "C" JSC::EncodedJSValue Bun__encoding__toStringBase64(const uint8_t* input, size_t len, JSC::JSGlobalObject* globalObject); +extern "C" JSC::EncodedJSValue Bun__encoding__toStringURLSafeBase64(const uint8_t* input, size_t len, JSC::JSGlobalObject* globalObject); namespace WebCore { @@ -27,8 +27,8 @@ public: static int32_t write(WTF::StringView view, size_t offset, size_t length, BufferEncodingType encodingType); - static Ref<Buffer> create(JSC::JSGlobalObject* globalObject, RefPtr<ArrayBuffer>&&, size_t byteOffset, size_t length); - static Ref<Buffer> create(JSC::JSGlobalObject* globalObject, RefPtr<ArrayBuffer>&&); + static Ref<Buffer> create(JSC::JSGlobalObject* globalObject, JSC::JSUint8Array*, size_t byteOffset, size_t length); + static Ref<Buffer> create(JSC::JSGlobalObject* globalObject, JSC::JSUint8Array*); static Ref<Buffer> createEmpty(JSC::JSGlobalObject* globalObject); static Ref<Buffer> create(JSC::JSGlobalObject* globalObject, UChar* ptr, size_t len, BufferEncodingType encoding); @@ -37,14 +37,14 @@ public: static Ref<Buffer> create(JSC::JSGlobalObject* globalObject, WTF::StringView&, BufferEncodingType encoding); static Ref<Buffer> create(JSC::JSGlobalObject* globalObject, WTF::String&, BufferEncodingType encoding); - Buffer(JSC::JSGlobalObject* globalObject, RefPtr<ArrayBuffer>&& arrayBuffer, size_t byteOffset, + Buffer(JSC::JSGlobalObject* globalObject, JSC::JSUint8Array* array, size_t byteOffset, size_t length) - : m_arrayBuffer(WTFMove(arrayBuffer)) + : m_array(array) { } - RefPtr<JSC::ArrayBuffer> m_arrayBuffer; + JSC::JSUint8Array* m_array; }; }
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/BunBuiltins.h b/src/javascript/jsc/bindings/BunBuiltins.h new file mode 100644 index 000000000..c5e22599b --- /dev/null +++ b/src/javascript/jsc/bindings/BunBuiltins.h @@ -0,0 +1,99 @@ +#pragma once + +namespace WebCore { + +class ExtendedDOMClientIsoSubspaces; +class ExtendedDOMIsoSubspaces; + +class DOMWrapperWorld; +} + +#include "root.h" +#include "JSBufferPrototypeBuiltins.h" + +namespace WebCore { + +class JSBuiltinFunctions { +public: + explicit JSBuiltinFunctions(JSC::VM& vm) + : m_vm(vm) + , m_jsBufferPrototypeBuiltins(m_vm) + // , m_byteLengthQueuingStrategyBuiltins(m_vm) + // , m_countQueuingStrategyBuiltins(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_jsDOMBindingInternalsBuiltins(m_vm) + // , m_textDecoderStreamBuiltins(m_vm) + // , m_textEncoderStreamBuiltins(m_vm) + { + // m_jsBufferPrototypeBuiltins.exportNames(); + + // m_readableByteStreamInternalsBuiltins.exportNames(); + // m_readableStreamInternalsBuiltins.exportNames(); + // m_streamInternalsBuiltins.exportNames(); + // m_transformStreamInternalsBuiltins.exportNames(); + // m_writableStreamInternalsBuiltins.exportNames(); + // m_jsDOMBindingInternalsBuiltins.exportNames(); + } + + // ByteLengthQueuingStrategyBuiltinsWrapper& byteLengthQueuingStrategyBuiltins() { return m_byteLengthQueuingStrategyBuiltins; } + // CountQueuingStrategyBuiltinsWrapper& countQueuingStrategyBuiltins() { return m_countQueuingStrategyBuiltins; } + // 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; } + // JSDOMBindingInternalsBuiltinsWrapper& jsDOMBindingInternalsBuiltins() { return m_jsDOMBindingInternalsBuiltins; } + // TextDecoderStreamBuiltinsWrapper& textDecoderStreamBuiltins() { return m_textDecoderStreamBuiltins; } + // TextEncoderStreamBuiltinsWrapper& textEncoderStreamBuiltins() { return m_textEncoderStreamBuiltins; } + JSBufferPrototypeBuiltinsWrapper& jsBufferPrototypeBuiltins() { return m_jsBufferPrototypeBuiltins; } + +private: + JSC::VM& m_vm; + JSBufferPrototypeBuiltinsWrapper m_jsBufferPrototypeBuiltins; + // ByteLengthQueuingStrategyBuiltinsWrapper m_byteLengthQueuingStrategyBuiltins; + // CountQueuingStrategyBuiltinsWrapper m_countQueuingStrategyBuiltins; + // 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; + // JSDOMBindingInternalsBuiltinsWrapper m_jsDOMBindingInternalsBuiltins; + // TextDecoderStreamBuiltinsWrapper m_textDecoderStreamBuiltins; + // TextEncoderStreamBuiltinsWrapper m_textEncoderStreamBuiltins; +}; + +}
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/BunClientData.cpp b/src/javascript/jsc/bindings/BunClientData.cpp index dd12d9e0c..807525a21 100644 --- a/src/javascript/jsc/bindings/BunClientData.cpp +++ b/src/javascript/jsc/bindings/BunClientData.cpp @@ -40,6 +40,7 @@ JSVMClientData::JSVMClientData(VM& vm) , m_heapData(JSHeapData::ensureHeapData(vm.heap)) , CLIENT_ISO_SUBSPACE_INIT(m_domConstructorSpace) , m_clientSubspaces(makeUnique<ExtendedDOMClientIsoSubspaces>()) + , m_builtinFunctions(vm) { } diff --git a/src/javascript/jsc/bindings/BunClientData.h b/src/javascript/jsc/bindings/BunClientData.h index 1db788f73..800514efa 100644 --- a/src/javascript/jsc/bindings/BunClientData.h +++ b/src/javascript/jsc/bindings/BunClientData.h @@ -23,6 +23,8 @@ class DOMWrapperWorld; #include "JavaScriptCore/WeakInlines.h" #include "JavaScriptCore/IsoSubspacePerVM.h" +#include "BunBuiltins.h" + namespace WebCore { using namespace JSC; using namespace Zig; @@ -77,6 +79,7 @@ public: JSHeapData& heapData() { return *m_heapData; } BunBuiltinNames& builtinNames() { return m_builtinNames; } + JSBuiltinFunctions& builtinFunctions() { return m_builtinFunctions; } WebCore::DOMWrapperWorld& normalWorld() { return *m_normalWorld; } @@ -94,6 +97,7 @@ public: private: BunBuiltinNames m_builtinNames; + JSBuiltinFunctions m_builtinFunctions; JSHeapData* m_heapData; diff --git a/src/javascript/jsc/bindings/JSBuffer.cpp b/src/javascript/jsc/bindings/JSBuffer.cpp index 05cc1f23a..2b8fa2088 100644 --- a/src/javascript/jsc/bindings/JSBuffer.cpp +++ b/src/javascript/jsc/bindings/JSBuffer.cpp @@ -28,8 +28,10 @@ #include "wtf/GetPtr.h" #include "wtf/PointerPreparations.h" #include "wtf/URL.h" +#include "JSBufferPrototypeBuiltins.h" #include "JSBufferEncodingType.h" +#include "JavaScriptCore/BuiltinNames.h" #if ENABLE(MEDIA_SOURCE) #include "BufferMediaSource.h" @@ -56,60 +58,16 @@ static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_fill); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_includes); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_indexOf); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_lastIndexOf); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readBigInt64BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readBigInt64LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readBigUInt64BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readBigUInt64LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readDoubleBE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readDoubleLE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readFloatBE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readFloatLE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt16BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt16LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt32BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt32LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt8); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readIntBE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readIntLE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt16BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt16LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt32BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt32LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt8); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readUIntBE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_readUIntLE); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_swap16); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_swap32); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_swap64); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_toString); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_write); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeBigInt64BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeBigInt64LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeBigUInt64BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeBigUInt64LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeDoubleBE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeDoubleLE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeFloatBE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeFloatLE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt16BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt16LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt32BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt32LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt8); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeIntBE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeIntLE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt16BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt16LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt32BE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt32LE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt8); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUIntBE); -static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUIntLE); namespace WebCore { using namespace JSC; -template<> class IDLOperation<JSBuffer> { +template<> class IDLOperation<WebCore::JSBuffer> { public: using ClassParameter = JSC::JSUint8Array*; using Operation = JSC::EncodedJSValue(JSC::JSGlobalObject*, JSC::CallFrame*, ClassParameter); @@ -153,7 +111,7 @@ public: } static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSC::JSType::Uint8ArrayType), StructureFlags), info(), JSC::MayHaveIndexedAccessors); } private: @@ -173,85 +131,86 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_allocBody(JSC::JSG } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_alloc, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_allocBody>(*lexicalGlobalObject, *callFrame, "alloc"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_allocBody>(*lexicalGlobalObject, *callFrame, "alloc"); } -static inline JSC::EncodedJSValue jsBufferConstructorFunction_allocUnsafeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferConstructorFunction_allocUnsafeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSValue::encode(jsUndefined()); } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_allocUnsafe, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_allocUnsafeBody>(*lexicalGlobalObject, *callFrame, "allocUnsafe"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_allocUnsafeBody>(*lexicalGlobalObject, *callFrame, "allocUnsafe"); } -static inline JSC::EncodedJSValue jsBufferConstructorFunction_allocUnsafeSlowBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferConstructorFunction_allocUnsafeSlowBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSValue::encode(jsUndefined()); } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_allocUnsafeSlow, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_allocUnsafeSlowBody>(*lexicalGlobalObject, *callFrame, "allocUnsafeSlow"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_allocUnsafeSlowBody>(*lexicalGlobalObject, *callFrame, "allocUnsafeSlow"); } -static inline JSC::EncodedJSValue jsBufferConstructorFunction_byteLengthBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferConstructorFunction_byteLengthBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSValue::encode(jsUndefined()); } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_byteLength, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_byteLengthBody>(*lexicalGlobalObject, *callFrame, "byteLength"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_byteLengthBody>(*lexicalGlobalObject, *callFrame, "byteLength"); } -static inline JSC::EncodedJSValue jsBufferConstructorFunction_compareBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferConstructorFunction_compareBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSValue::encode(jsUndefined()); } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_compare, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_compareBody>(*lexicalGlobalObject, *callFrame, "compare"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_compareBody>(*lexicalGlobalObject, *callFrame, "compare"); } -static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSValue::encode(jsUndefined()); } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_concat, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_concatBody>(*lexicalGlobalObject, *callFrame, "concat"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_concatBody>(*lexicalGlobalObject, *callFrame, "concat"); } -static inline JSC::EncodedJSValue jsBufferConstructorFunction_fromBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferConstructorFunction_fromBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSValue::encode(jsUndefined()); } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_from, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_fromBody>(*lexicalGlobalObject, *callFrame, "from"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_fromBody>(*lexicalGlobalObject, *callFrame, "from"); } -static inline JSC::EncodedJSValue jsBufferConstructorFunction_isBufferBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferConstructorFunction_isBufferBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSValue::encode(jsUndefined()); } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isBuffer, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_isBufferBody>(*lexicalGlobalObject, *callFrame, "isBuffer"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_isBufferBody>(*lexicalGlobalObject, *callFrame, "isBuffer"); } -static inline JSC::EncodedJSValue jsBufferConstructorFunction_isEncodingBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferConstructorFunction_isEncodingBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSValue::encode(jsUndefined()); } JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isEncoding, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { - return IDLOperation<JSBuffer>::call<jsBufferConstructorFunction_isEncodingBody>(*lexicalGlobalObject, *callFrame, "isEncoding"); + return IDLOperation<WebCore::JSBuffer>::call<jsBufferConstructorFunction_isEncodingBody>(*lexicalGlobalObject, *callFrame, "isEncoding"); } using JSBufferConstructor = JSDOMConstructor<JSBuffer>; /* Hash table for constructor */ static const HashTableValue JSBufferConstructorTableValues[] = { + { "construct", static_cast<unsigned>(JSC::PropertyAttribute::Builtin, JSC::PropertyAttribute::DontEnum, JSC::PropertyAttribute::DontDelete), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBufferConstructorCodeGenerator), (intptr_t)(3) } }, { "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_allocUnsafeSlow), (intptr_t)(1) } }, @@ -259,8 +218,6 @@ static const HashTableValue JSBufferConstructorTableValues[] = { { "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::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_from), (intptr_t)(3) } }, - { "isBuffer", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isBuffer), (intptr_t)(1) } }, - { "isEncoding", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isEncoding), (intptr_t)(1) } }, }; // new Buffer() @@ -322,16 +279,23 @@ static inline EncodedJSValue constructBufferFromLength(JSGlobalObject* lexicalGl return JSValue::encode(jsUndefined()); } - auto arrayBuffer = JSC::ArrayBuffer::tryCreate(length, 1); - if (!arrayBuffer) { + auto globalObject = reinterpret_cast<WebCore::JSDOMGlobalObject*>(lexicalGlobalObject); + + JSC::MarkedArgumentBuffer args; + + auto* baseStructure = globalObject->m_typedArrayUint8.get(globalObject); + auto arrayBufferView = JSC::JSUint8Array::createUninitialized(globalObject, baseStructure, length); + + if (!arrayBufferView) { throwOutOfMemoryError(lexicalGlobalObject, throwScope); return JSValue::encode(jsUndefined()); } - auto uint8Array = JSC::JSUint8Array::create(lexicalGlobalObject, lexicalGlobalObject->typedArrayStructure(JSC::TypeUint8), WTFMove(arrayBuffer), 0, length); - uint8Array->setPrototypeDirect(vm, JSBuffer::prototype(vm, *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject))); + auto* subclassStructure = JSC::InternalFunction::createSubclassStructure(lexicalGlobalObject, arrayBufferView, WebCore::getDOMStructure<JSBuffer>(vm, *globalObject)); - return JSC::JSValue::encode(uint8Array); + auto buffer = JSBuffer::create(subclassStructure, globalObject, Buffer::create(globalObject, WTFMove(arrayBufferView))); + + return JSC::JSValue::encode(buffer); } // new Buffer(string[, encoding]) @@ -388,6 +352,7 @@ template<> void JSBufferConstructor::initializeProperties(VM& vm, JSDOMGlobalObj JSString* nameString = jsNontrivialString(vm, "Buffer"_s); m_originalName.set(vm, this, nameString); putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); + putDirect(vm, vm.propertyNames->prototype, JSBuffer::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete); reifyStaticProperties(vm, JSBuffer::info(), JSBufferConstructorTableValues, *this); } @@ -399,29 +364,30 @@ bool JSBuffer__isBuffer(JSC::JSGlobalObject* global, JSC::EncodedJSValue value) return !!jsBuffer; } -const ClassInfo JSBuffer::s_info = { "Buffer"_s, JSC::getUint8ArrayClassInfo(), nullptr, nullptr, CREATE_METHOD_TABLE(JSBuffer) }; +const ClassInfo JSBuffer::s_info + = { "Buffer"_s, JSC::getUint8ArrayClassInfo(), nullptr, nullptr, CREATE_METHOD_TABLE(JSBuffer) }; -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_compareBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_compareBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_copyBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_copyBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_equalsBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_equalsBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_includesBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_includesBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -430,142 +396,33 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_includesBody(JSC::JS return JSC::JSValue::encode(JSC::JSValue(reinterpret_cast<uint8_t*>(castedThis->vector())[0])); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_indexOfBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_lastIndexOfBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readBigInt64BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readBigInt64LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readBigUInt64BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readBigUInt64LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readDoubleBEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readDoubleLEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readFloatBEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readFloatLEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readInt16BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readInt16LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readInt32BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_indexOfBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readInt32LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_lastIndexOfBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readInt8Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap16Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readIntBEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap32Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readIntLEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap64Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); return JSC::JSValue::encode(jsUndefined()); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readUInt16BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readUInt16LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readUInt32BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readUInt32LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readUInt8Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readUIntBEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_readUIntLEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap16Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap32Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap64Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) + +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); uint32_t offset = 0; @@ -670,7 +527,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS RELEASE_AND_RETURN(scope, JSC::JSValue::encode(retValue)); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) +static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<WebCore::JSBuffer>::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); uint32_t offset = 0; @@ -797,116 +654,6 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlo RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::jsNumber(written))); } -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBigInt64BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBigInt64LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBigUInt64BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBigUInt64LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeDoubleBEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeDoubleLEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeFloatBEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeFloatLEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeInt16BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeInt16LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeInt32BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeInt32LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeInt8Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeIntBEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeIntLEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeUInt16BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeUInt16LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeUInt32BEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeUInt32LEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeUInt8Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeUIntBEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} -static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeUIntLEBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSBuffer>::ClassParameter castedThis) -{ - auto& vm = JSC::getVM(lexicalGlobalObject); - return JSC::JSValue::encode(jsUndefined()); -} JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_compare, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { @@ -936,94 +683,6 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_lastIndexOf, (JSGlobalObject { return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_lastIndexOfBody>(*lexicalGlobalObject, *callFrame, "lastIndexOf"); } -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readBigInt64BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readBigInt64BEBody>(*lexicalGlobalObject, *callFrame, "readBigInt64BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readBigInt64LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readBigInt64LEBody>(*lexicalGlobalObject, *callFrame, "readBigInt64LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readBigUInt64BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readBigUInt64BEBody>(*lexicalGlobalObject, *callFrame, "readBigUInt64BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readBigUInt64LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readBigUInt64LEBody>(*lexicalGlobalObject, *callFrame, "readBigUInt64LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readDoubleBE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readDoubleBEBody>(*lexicalGlobalObject, *callFrame, "readDoubleBE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readDoubleLE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readDoubleLEBody>(*lexicalGlobalObject, *callFrame, "readDoubleLE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readFloatBE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readFloatBEBody>(*lexicalGlobalObject, *callFrame, "readFloatBE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readFloatLE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readFloatLEBody>(*lexicalGlobalObject, *callFrame, "readFloatLE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt16BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readInt16BEBody>(*lexicalGlobalObject, *callFrame, "readInt16BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt16LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readInt16LEBody>(*lexicalGlobalObject, *callFrame, "readInt16LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt32BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readInt32BEBody>(*lexicalGlobalObject, *callFrame, "readInt32BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt32LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readInt32LEBody>(*lexicalGlobalObject, *callFrame, "readInt32LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readInt8, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readInt8Body>(*lexicalGlobalObject, *callFrame, "readInt8"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readIntBE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readIntBEBody>(*lexicalGlobalObject, *callFrame, "readIntBE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readIntLE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readIntLEBody>(*lexicalGlobalObject, *callFrame, "readIntLE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt16BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readUInt16BEBody>(*lexicalGlobalObject, *callFrame, "readUInt16BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt16LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readUInt16LEBody>(*lexicalGlobalObject, *callFrame, "readUInt16LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt32BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readUInt32BEBody>(*lexicalGlobalObject, *callFrame, "readUInt32BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt32LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readUInt32LEBody>(*lexicalGlobalObject, *callFrame, "readUInt32LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readUInt8, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readUInt8Body>(*lexicalGlobalObject, *callFrame, "readUInt8"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readUIntBE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readUIntBEBody>(*lexicalGlobalObject, *callFrame, "readUIntBE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_readUIntLE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_readUIntLEBody>(*lexicalGlobalObject, *callFrame, "readUIntLE"); -} JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_swap16, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_swap16Body>(*lexicalGlobalObject, *callFrame, "swap16"); @@ -1044,94 +703,6 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_write, (JSGlobalObject * lexi { return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeBody>(*lexicalGlobalObject, *callFrame, "write"); } -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeBigInt64BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeBigInt64BEBody>(*lexicalGlobalObject, *callFrame, "writeBigInt64BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeBigInt64LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeBigInt64LEBody>(*lexicalGlobalObject, *callFrame, "writeBigInt64LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeBigUInt64BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeBigUInt64BEBody>(*lexicalGlobalObject, *callFrame, "writeBigUInt64BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeBigUInt64LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeBigUInt64LEBody>(*lexicalGlobalObject, *callFrame, "writeBigUInt64LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeDoubleBE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeDoubleBEBody>(*lexicalGlobalObject, *callFrame, "writeDoubleBE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeDoubleLE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeDoubleLEBody>(*lexicalGlobalObject, *callFrame, "writeDoubleLE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeFloatBE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeFloatBEBody>(*lexicalGlobalObject, *callFrame, "writeFloatBE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeFloatLE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeFloatLEBody>(*lexicalGlobalObject, *callFrame, "writeFloatLE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt16BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeInt16BEBody>(*lexicalGlobalObject, *callFrame, "writeInt16BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt16LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeInt16LEBody>(*lexicalGlobalObject, *callFrame, "writeInt16LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt32BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeInt32BEBody>(*lexicalGlobalObject, *callFrame, "writeInt32BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt32LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeInt32LEBody>(*lexicalGlobalObject, *callFrame, "writeInt32LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeInt8, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeInt8Body>(*lexicalGlobalObject, *callFrame, "writeInt8"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeIntBE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeIntBEBody>(*lexicalGlobalObject, *callFrame, "writeIntBE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeIntLE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeIntLEBody>(*lexicalGlobalObject, *callFrame, "writeIntLE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt16BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeUInt16BEBody>(*lexicalGlobalObject, *callFrame, "writeUInt16BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt16LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeUInt16LEBody>(*lexicalGlobalObject, *callFrame, "writeUInt16LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt32BE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeUInt32BEBody>(*lexicalGlobalObject, *callFrame, "writeUInt32BE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt32LE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeUInt32LEBody>(*lexicalGlobalObject, *callFrame, "writeUInt32LE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUInt8, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeUInt8Body>(*lexicalGlobalObject, *callFrame, "writeUInt8"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUIntBE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeUIntBEBody>(*lexicalGlobalObject, *callFrame, "writeUIntBE"); -} -JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_writeUIntLE, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) -{ - return IDLOperation<JSBuffer>::call<jsBufferPrototypeFunction_writeUIntLEBody>(*lexicalGlobalObject, *callFrame, "writeUIntLE"); -} /* Hash table for prototype */ @@ -1144,55 +715,50 @@ static const HashTableValue JSBufferPrototypeTableValues[] { "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) } }, - { "readBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readBigInt64BE), (intptr_t)(2) } }, - { "readBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readBigInt64LE), (intptr_t)(2) } }, - { "readBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readBigUInt64BE), (intptr_t)(2) } }, - { "readBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readBigUInt64LE), (intptr_t)(2) } }, - { "readDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readDoubleBE), (intptr_t)(2) } }, - { "readDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readDoubleLE), (intptr_t)(2) } }, - { "readFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readFloatBE), (intptr_t)(2) } }, - { "readFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readFloatLE), (intptr_t)(2) } }, - { "readInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readInt16BE), (intptr_t)(2) } }, - { "readInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readInt16LE), (intptr_t)(2) } }, - { "readInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readInt32BE), (intptr_t)(2) } }, - { "readInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readInt32LE), (intptr_t)(2) } }, - { "readInt8", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readInt8), (intptr_t)(2) } }, - { "readIntBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readIntBE), (intptr_t)(2) } }, - { "readIntLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readIntLE), (intptr_t)(2) } }, - { "readUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readUInt16BE), (intptr_t)(2) } }, - { "readUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readUInt16LE), (intptr_t)(2) } }, - { "readUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readUInt32BE), (intptr_t)(2) } }, - { "readUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readUInt32LE), (intptr_t)(2) } }, - { "readUInt8", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readUInt8), (intptr_t)(2) } }, - { "readUIntBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readUIntBE), (intptr_t)(2) } }, - { "readUIntLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_readUIntLE), (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) } }, { "write", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_write), (intptr_t)(4) } }, - { "writeBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeBigInt64BE), (intptr_t)(2) } }, - { "writeBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeBigInt64LE), (intptr_t)(2) } }, - { "writeBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeBigUInt64BE), (intptr_t)(2) } }, - { "writeBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeBigUInt64LE), (intptr_t)(2) } }, - { "writeDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeDoubleBE), (intptr_t)(2) } }, - { "writeDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeDoubleLE), (intptr_t)(2) } }, - { "writeFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeFloatBE), (intptr_t)(2) } }, - { "writeFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeFloatLE), (intptr_t)(2) } }, - { "writeInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeInt16BE), (intptr_t)(2) } }, - { "writeInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeInt16LE), (intptr_t)(2) } }, - { "writeInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeInt32BE), (intptr_t)(2) } }, - { "writeInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeInt32LE), (intptr_t)(2) } }, - { "writeInt8", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeInt8), (intptr_t)(2) } }, - { "writeIntBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeIntBE), (intptr_t)(2) } }, - { "writeIntLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeIntLE), (intptr_t)(2) } }, - { "writeUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeUInt16BE), (intptr_t)(2) } }, - { "writeUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeUInt16LE), (intptr_t)(2) } }, - { "writeUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeUInt32BE), (intptr_t)(2) } }, - { "writeUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeUInt32LE), (intptr_t)(2) } }, - { "writeUInt8", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeUInt8), (intptr_t)(2) } }, - { "writeUIntBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeUIntBE), (intptr_t)(2) } }, - { "writeUIntLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_writeUIntLE), (intptr_t)(2) } }, + { "readBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64BECodeGenerator), (intptr_t)(2) } }, + { "readBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(2) } }, + { "readBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64BECodeGenerator), (intptr_t)(3) } }, + { "readBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(3) } }, + { "readDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleBECodeGenerator), (intptr_t)(3) } }, + { "readDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(3) } }, + { "readFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatBECodeGenerator), (intptr_t)(3) } }, + { "readFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(3) } }, + { "readInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16BECodeGenerator), (intptr_t)(3) } }, + { "readInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(3) } }, + { "readInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32BECodeGenerator), (intptr_t)(1) } }, + { "readInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } }, + { "readInt8", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt8CodeGenerator), (intptr_t)(1) } }, + { "readUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } }, + { "readUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } }, + { "readUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } }, + { "readUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } }, + { "readUInt8", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } }, + { "slice", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } }, + { "subarray", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSubarrayCodeGenerator), (intptr_t)(2) } }, + { "toJSON", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeToJSONCodeGenerator), (intptr_t)(2) } }, + { "writeBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64BECodeGenerator), (intptr_t)(2) } }, + { "writeBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64LECodeGenerator), (intptr_t)(2) } }, + { "writeBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(2) } }, + { "writeBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(2) } }, + { "writeDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleBECodeGenerator), (intptr_t)(2) } }, + { "writeDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(2) } }, + { "writeFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatBECodeGenerator), (intptr_t)(2) } }, + { "writeFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(2) } }, + { "writeInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16BECodeGenerator), (intptr_t)(2) } }, + { "writeInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16LECodeGenerator), (intptr_t)(2) } }, + { "writeInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32BECodeGenerator), (intptr_t)(2) } }, + { "writeInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32LECodeGenerator), (intptr_t)(2) } }, + { "writeInt8", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt8CodeGenerator), (intptr_t)(2) } }, + { "writeUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(2) } }, + { "writeUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(2) } }, + { "writeUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(2) } }, + { "writeUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(2) } }, + { "writeUInt8", static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(0) } }, }; void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis) @@ -1200,14 +766,13 @@ void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis) Base::finishCreation(vm); reifyStaticProperties(vm, JSBuffer::info(), JSBufferPrototypeTableValues, *this); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); - this->setPrototypeDirect(vm, globalThis->m_typedArrayUint8.prototype(globalThis)); } const ClassInfo JSBufferPrototype::s_info = { "Buffer"_s, nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferPrototype) }; JSObject* JSBuffer::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) { - return JSBufferPrototype::create(vm, &globalObject, JSBufferPrototype::createStructure(vm, &globalObject, globalObject.m_typedArrayUint8.prototype(&globalObject))); + return JSBufferPrototype::create(vm, &globalObject, JSBufferPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); } JSObject* JSBuffer::prototype(VM& vm, JSDOMGlobalObject& globalObject) diff --git a/src/javascript/jsc/bindings/JSBuffer.h b/src/javascript/jsc/bindings/JSBuffer.h index 52c48e945..d17c6e65b 100644 --- a/src/javascript/jsc/bindings/JSBuffer.h +++ b/src/javascript/jsc/bindings/JSBuffer.h @@ -55,7 +55,7 @@ public: static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray); + return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSC::JSType::Uint8ArrayType), StructureFlags), info(), JSC::MayHaveIndexedAccessors); } static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*); diff --git a/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp new file mode 100644 index 000000000..25dda8bbc --- /dev/null +++ b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp @@ -0,0 +1,537 @@ +/* + * Copyright (c) 2016 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 "JSBufferPrototypeBuiltins.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_jsBufferPrototypeBufferConstructorCodeConstructAbility = JSC::ConstructAbility::CanConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeBufferConstructorCodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeBufferConstructorCodeLength = 181; +static const JSC::Intrinsic s_jsBufferPrototypeBufferConstructorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeBufferConstructorCode = + "(function (arrayBuffer, byteOffset, byteLength) {\n" \ + " console.log(\"hi\")\n" \ + " return Reflect.construct(this, [arrayBuffer, byteOffset, byteLength], @Uint8Array.prototype.constructor);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeSetBigUint64CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeSetBigUint64CodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeSetBigUint64CodeLength = 170; +static const JSC::Intrinsic s_jsBufferPrototypeSetBigUint64CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeSetBigUint64Code = + "(function (offset, value, le) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, le);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt8CodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadInt8CodeLength = 143; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt8Code = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt8(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt8CodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadUInt8CodeLength = 144; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt8Code = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint8(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadInt16LECodeLength = 150; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt16LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset, true);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt16BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadInt16BECodeLength = 144; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt16BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadUInt16LECodeLength = 151; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt16LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset, true);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadUInt16BECodeLength = 145; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt16BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadInt32LECodeLength = 150; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt32LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset, true);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt32BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadInt32BECodeLength = 144; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt32BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadUInt32LECodeLength = 151; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt32LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset, true);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadUInt32BECodeLength = 145; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt32BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadFloatLECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadFloatLECodeLength = 152; +static const JSC::Intrinsic s_jsBufferPrototypeReadFloatLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadFloatLECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset, true);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadFloatBECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadFloatBECodeLength = 146; +static const JSC::Intrinsic s_jsBufferPrototypeReadFloatBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadFloatBECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleLECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadDoubleLECodeLength = 152; +static const JSC::Intrinsic s_jsBufferPrototypeReadDoubleLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadDoubleLECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset, true);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleBECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadDoubleBECodeLength = 146; +static const JSC::Intrinsic s_jsBufferPrototypeReadDoubleBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadDoubleBECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadBigInt64LECodeLength = 153; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigInt64LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset, true);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadBigInt64BECodeLength = 147; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigInt64BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadBigUInt64LECodeLength = 154; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigUInt64LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset, true);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadBigUInt64BECodeLength = 148; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigUInt64BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteInt8CodeLength = 171; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt8Code = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt8(offset, value);\n" \ + " return offset + 1;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteUInt8CodeLength = 172; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt8Code = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint8(offset, value);\n" \ + " return offset + 1;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteInt16LECodeLength = 178; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt16LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value, true);\n" \ + " return offset + 2;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteInt16BECodeLength = 172; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt16BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value);\n" \ + " return offset + 2;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteUInt16LECodeLength = 179; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt16LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value, true);\n" \ + " return offset + 2;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteUInt16BECodeLength = 173; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt16BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value);\n" \ + " return offset + 2;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteInt32LECodeLength = 178; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt32LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value, true);\n" \ + " return offset + 4;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteInt32BECodeLength = 172; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt32BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value);\n" \ + " return offset + 4;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteUInt32LECodeLength = 179; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt32LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value, true);\n" \ + " return offset + 4;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteUInt32BECodeLength = 173; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt32BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value);\n" \ + " return offset + 4;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteFloatLECodeLength = 180; +static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteFloatLECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value, true);\n" \ + " return offset + 4;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteFloatBECodeLength = 174; +static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteFloatBECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value);\n" \ + " return offset + 4;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteDoubleLECodeLength = 180; +static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteDoubleLECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value, true);\n" \ + " return offset + 8;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteDoubleBECodeLength = 174; +static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteDoubleBECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value);\n" \ + " return offset + 8;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteBigInt64LECodeLength = 181; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigInt64LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value, true);\n" \ + " return offset + 8;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteBigInt64BECodeLength = 175; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigInt64BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value);\n" \ + " return offset + 8;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteBigUInt64LECodeLength = 182; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigUInt64LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, true);\n" \ + " return offset + 8;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteBigUInt64BECodeLength = 176; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigUInt64BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value);\n" \ + " return offset + 8;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeSliceCodeLength = 152; +static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeSliceCode = + "(function (start, end) {\n" \ + " \"use strict\";\n" \ + " if (start === undefined && end === undefined) {\n" \ + " return this;\n" \ + " }\n" \ + "\n" \ + " return this.subarray(start, end);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeSubarrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeSubarrayCodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeSubarrayCodeLength = 247; +static const JSC::Intrinsic s_jsBufferPrototypeSubarrayCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeSubarrayCode = + "(function (start, end) {\n" \ + " \"use strict\";\n" \ + " \n" \ + " var array = new @Uint8Array(this.buffer, this.byteOffset + (start || 0), (end || this.byteLength) - (start || 0));\n" \ + " @setPrototypeDirect.@call(\n" \ + " array,\n" \ + " Buffer.prototype\n" \ + " );\n" \ + " return array;\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeToJSONCodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeToJSONCodeLength = 118; +static const JSC::Intrinsic s_jsBufferPrototypeToJSONCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeToJSONCode = + "(function () {\n" \ + " \"use strict\";\n" \ + " const type = \"Buffer\";\n" \ + " const data = @Array.from(this);\n" \ + " return { type, data };\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().jsBufferPrototypeBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().jsBufferPrototypeBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + + +} // namespace WebCore diff --git a/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h new file mode 100644 index 000000000..2c7efe0ff --- /dev/null +++ b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h @@ -0,0 +1,442 @@ +/* + * Copyright (c) 2016 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 { + +/* JSBufferPrototype */ +extern const char* const s_jsBufferPrototypeBufferConstructorCode; +extern const int s_jsBufferPrototypeBufferConstructorCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeBufferConstructorCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeBufferConstructorCodeConstructorKind; +extern const char* const s_jsBufferPrototypeSetBigUint64Code; +extern const int s_jsBufferPrototypeSetBigUint64CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeSetBigUint64CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeSetBigUint64CodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadInt8Code; +extern const int s_jsBufferPrototypeReadInt8CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt8CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt8CodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadUInt8Code; +extern const int s_jsBufferPrototypeReadUInt8CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt8CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt8CodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadInt16LECode; +extern const int s_jsBufferPrototypeReadInt16LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt16LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt16LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadInt16BECode; +extern const int s_jsBufferPrototypeReadInt16BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt16BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt16BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadUInt16LECode; +extern const int s_jsBufferPrototypeReadUInt16LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadUInt16BECode; +extern const int s_jsBufferPrototypeReadUInt16BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadInt32LECode; +extern const int s_jsBufferPrototypeReadInt32LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt32LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt32LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadInt32BECode; +extern const int s_jsBufferPrototypeReadInt32BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt32BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt32BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadUInt32LECode; +extern const int s_jsBufferPrototypeReadUInt32LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadUInt32BECode; +extern const int s_jsBufferPrototypeReadUInt32BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadFloatLECode; +extern const int s_jsBufferPrototypeReadFloatLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadFloatLECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadFloatBECode; +extern const int s_jsBufferPrototypeReadFloatBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadFloatBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadFloatBECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadDoubleLECode; +extern const int s_jsBufferPrototypeReadDoubleLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleLECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadDoubleBECode; +extern const int s_jsBufferPrototypeReadDoubleBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleBECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadBigInt64LECode; +extern const int s_jsBufferPrototypeReadBigInt64LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadBigInt64BECode; +extern const int s_jsBufferPrototypeReadBigInt64BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadBigUInt64LECode; +extern const int s_jsBufferPrototypeReadBigUInt64LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeReadBigUInt64BECode; +extern const int s_jsBufferPrototypeReadBigUInt64BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteInt8Code; +extern const int s_jsBufferPrototypeWriteInt8CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt8CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteUInt8Code; +extern const int s_jsBufferPrototypeWriteUInt8CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteInt16LECode; +extern const int s_jsBufferPrototypeWriteInt16LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteInt16BECode; +extern const int s_jsBufferPrototypeWriteInt16BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteUInt16LECode; +extern const int s_jsBufferPrototypeWriteUInt16LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteUInt16BECode; +extern const int s_jsBufferPrototypeWriteUInt16BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteInt32LECode; +extern const int s_jsBufferPrototypeWriteInt32LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteInt32BECode; +extern const int s_jsBufferPrototypeWriteInt32BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteUInt32LECode; +extern const int s_jsBufferPrototypeWriteUInt32LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteUInt32BECode; +extern const int s_jsBufferPrototypeWriteUInt32BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteFloatLECode; +extern const int s_jsBufferPrototypeWriteFloatLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteFloatBECode; +extern const int s_jsBufferPrototypeWriteFloatBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteDoubleLECode; +extern const int s_jsBufferPrototypeWriteDoubleLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteDoubleBECode; +extern const int s_jsBufferPrototypeWriteDoubleBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteBigInt64LECode; +extern const int s_jsBufferPrototypeWriteBigInt64LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteBigInt64BECode; +extern const int s_jsBufferPrototypeWriteBigInt64BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteBigUInt64LECode; +extern const int s_jsBufferPrototypeWriteBigUInt64LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKind; +extern const char* const s_jsBufferPrototypeWriteBigUInt64BECode; +extern const int s_jsBufferPrototypeWriteBigUInt64BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKind; +extern const char* const s_jsBufferPrototypeSliceCode; +extern const int s_jsBufferPrototypeSliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeSliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind; +extern const char* const s_jsBufferPrototypeSubarrayCode; +extern const int s_jsBufferPrototypeSubarrayCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeSubarrayCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeSubarrayCodeConstructorKind; +extern const char* const s_jsBufferPrototypeToJSONCode; +extern const int s_jsBufferPrototypeToJSONCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeToJSONCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeToJSONCodeConstructorKind; + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_DATA(macro) \ + macro(Buffer, jsBufferPrototypeBufferConstructor, 3) \ + macro(setBigUint64, jsBufferPrototypeSetBigUint64, 3) \ + macro(readInt8, jsBufferPrototypeReadInt8, 1) \ + macro(readUInt8, jsBufferPrototypeReadUInt8, 1) \ + macro(readInt16LE, jsBufferPrototypeReadInt16LE, 1) \ + macro(readInt16BE, jsBufferPrototypeReadInt16BE, 1) \ + macro(readUInt16LE, jsBufferPrototypeReadUInt16LE, 1) \ + macro(readUInt16BE, jsBufferPrototypeReadUInt16BE, 1) \ + macro(readInt32LE, jsBufferPrototypeReadInt32LE, 1) \ + macro(readInt32BE, jsBufferPrototypeReadInt32BE, 1) \ + macro(readUInt32LE, jsBufferPrototypeReadUInt32LE, 1) \ + macro(readUInt32BE, jsBufferPrototypeReadUInt32BE, 1) \ + macro(readFloatLE, jsBufferPrototypeReadFloatLE, 1) \ + macro(readFloatBE, jsBufferPrototypeReadFloatBE, 1) \ + macro(readDoubleLE, jsBufferPrototypeReadDoubleLE, 1) \ + macro(readDoubleBE, jsBufferPrototypeReadDoubleBE, 1) \ + macro(readBigInt64LE, jsBufferPrototypeReadBigInt64LE, 1) \ + macro(readBigInt64BE, jsBufferPrototypeReadBigInt64BE, 1) \ + macro(readBigUInt64LE, jsBufferPrototypeReadBigUInt64LE, 1) \ + macro(readBigUInt64BE, jsBufferPrototypeReadBigUInt64BE, 1) \ + macro(writeInt8, jsBufferPrototypeWriteInt8, 2) \ + macro(writeUInt8, jsBufferPrototypeWriteUInt8, 2) \ + macro(writeInt16LE, jsBufferPrototypeWriteInt16LE, 2) \ + macro(writeInt16BE, jsBufferPrototypeWriteInt16BE, 2) \ + macro(writeUInt16LE, jsBufferPrototypeWriteUInt16LE, 2) \ + macro(writeUInt16BE, jsBufferPrototypeWriteUInt16BE, 2) \ + macro(writeInt32LE, jsBufferPrototypeWriteInt32LE, 2) \ + macro(writeInt32BE, jsBufferPrototypeWriteInt32BE, 2) \ + macro(writeUInt32LE, jsBufferPrototypeWriteUInt32LE, 2) \ + macro(writeUInt32BE, jsBufferPrototypeWriteUInt32BE, 2) \ + macro(writeFloatLE, jsBufferPrototypeWriteFloatLE, 2) \ + macro(writeFloatBE, jsBufferPrototypeWriteFloatBE, 2) \ + macro(writeDoubleLE, jsBufferPrototypeWriteDoubleLE, 2) \ + macro(writeDoubleBE, jsBufferPrototypeWriteDoubleBE, 2) \ + macro(writeBigInt64LE, jsBufferPrototypeWriteBigInt64LE, 2) \ + macro(writeBigInt64BE, jsBufferPrototypeWriteBigInt64BE, 2) \ + macro(writeBigUInt64LE, jsBufferPrototypeWriteBigUInt64LE, 2) \ + macro(writeBigUInt64BE, jsBufferPrototypeWriteBigUInt64BE, 2) \ + macro(slice, jsBufferPrototypeSlice, 2) \ + macro(subarray, jsBufferPrototypeSubarray, 2) \ + macro(toJSON, jsBufferPrototypeToJSON, 0) \ + +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BUFFER 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_SETBIGUINT64 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT8 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT8 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT16LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT16BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT16LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT16BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT32LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT32BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT32LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT32BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READFLOATLE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READFLOATBE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READDOUBLELE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READDOUBLEBE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGINT64LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGINT64BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGUINT64LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGUINT64BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT8 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT8 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT16LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT16BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT16LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT16BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT32LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT32BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT32LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT32BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEFLOATLE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEFLOATBE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEDOUBLELE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEDOUBLEBE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGINT64LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGINT64BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGUINT64LE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGUINT64BE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_SLICE 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_SUBARRAY 1 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_TOJSON 1 + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(macro) \ + macro(jsBufferPrototypeBufferConstructorCode, Buffer, static_cast<const char*>(nullptr), s_jsBufferPrototypeBufferConstructorCodeLength) \ + macro(jsBufferPrototypeSetBigUint64Code, setBigUint64, static_cast<const char*>(nullptr), s_jsBufferPrototypeSetBigUint64CodeLength) \ + macro(jsBufferPrototypeReadInt8Code, readInt8, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadInt8CodeLength) \ + macro(jsBufferPrototypeReadUInt8Code, readUInt8, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadUInt8CodeLength) \ + macro(jsBufferPrototypeReadInt16LECode, readInt16LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadInt16LECodeLength) \ + macro(jsBufferPrototypeReadInt16BECode, readInt16BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadInt16BECodeLength) \ + macro(jsBufferPrototypeReadUInt16LECode, readUInt16LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadUInt16LECodeLength) \ + macro(jsBufferPrototypeReadUInt16BECode, readUInt16BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadUInt16BECodeLength) \ + macro(jsBufferPrototypeReadInt32LECode, readInt32LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadInt32LECodeLength) \ + macro(jsBufferPrototypeReadInt32BECode, readInt32BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadInt32BECodeLength) \ + macro(jsBufferPrototypeReadUInt32LECode, readUInt32LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadUInt32LECodeLength) \ + macro(jsBufferPrototypeReadUInt32BECode, readUInt32BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadUInt32BECodeLength) \ + macro(jsBufferPrototypeReadFloatLECode, readFloatLE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadFloatLECodeLength) \ + macro(jsBufferPrototypeReadFloatBECode, readFloatBE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadFloatBECodeLength) \ + macro(jsBufferPrototypeReadDoubleLECode, readDoubleLE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadDoubleLECodeLength) \ + macro(jsBufferPrototypeReadDoubleBECode, readDoubleBE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadDoubleBECodeLength) \ + macro(jsBufferPrototypeReadBigInt64LECode, readBigInt64LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadBigInt64LECodeLength) \ + macro(jsBufferPrototypeReadBigInt64BECode, readBigInt64BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadBigInt64BECodeLength) \ + macro(jsBufferPrototypeReadBigUInt64LECode, readBigUInt64LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadBigUInt64LECodeLength) \ + macro(jsBufferPrototypeReadBigUInt64BECode, readBigUInt64BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeReadBigUInt64BECodeLength) \ + macro(jsBufferPrototypeWriteInt8Code, writeInt8, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteInt8CodeLength) \ + macro(jsBufferPrototypeWriteUInt8Code, writeUInt8, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteUInt8CodeLength) \ + macro(jsBufferPrototypeWriteInt16LECode, writeInt16LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteInt16LECodeLength) \ + macro(jsBufferPrototypeWriteInt16BECode, writeInt16BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteInt16BECodeLength) \ + macro(jsBufferPrototypeWriteUInt16LECode, writeUInt16LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteUInt16LECodeLength) \ + macro(jsBufferPrototypeWriteUInt16BECode, writeUInt16BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteUInt16BECodeLength) \ + macro(jsBufferPrototypeWriteInt32LECode, writeInt32LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteInt32LECodeLength) \ + macro(jsBufferPrototypeWriteInt32BECode, writeInt32BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteInt32BECodeLength) \ + macro(jsBufferPrototypeWriteUInt32LECode, writeUInt32LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteUInt32LECodeLength) \ + macro(jsBufferPrototypeWriteUInt32BECode, writeUInt32BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteUInt32BECodeLength) \ + macro(jsBufferPrototypeWriteFloatLECode, writeFloatLE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteFloatLECodeLength) \ + macro(jsBufferPrototypeWriteFloatBECode, writeFloatBE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteFloatBECodeLength) \ + macro(jsBufferPrototypeWriteDoubleLECode, writeDoubleLE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteDoubleLECodeLength) \ + macro(jsBufferPrototypeWriteDoubleBECode, writeDoubleBE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteDoubleBECodeLength) \ + macro(jsBufferPrototypeWriteBigInt64LECode, writeBigInt64LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteBigInt64LECodeLength) \ + macro(jsBufferPrototypeWriteBigInt64BECode, writeBigInt64BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteBigInt64BECodeLength) \ + macro(jsBufferPrototypeWriteBigUInt64LECode, writeBigUInt64LE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteBigUInt64LECodeLength) \ + macro(jsBufferPrototypeWriteBigUInt64BECode, writeBigUInt64BE, static_cast<const char*>(nullptr), s_jsBufferPrototypeWriteBigUInt64BECodeLength) \ + macro(jsBufferPrototypeSliceCode, slice, static_cast<const char*>(nullptr), s_jsBufferPrototypeSliceCodeLength) \ + macro(jsBufferPrototypeSubarrayCode, subarray, static_cast<const char*>(nullptr), s_jsBufferPrototypeSubarrayCodeLength) \ + macro(jsBufferPrototypeToJSONCode, toJSON, static_cast<const char*>(nullptr), s_jsBufferPrototypeToJSONCodeLength) \ + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(macro) \ + macro(Buffer) \ + macro(readBigInt64BE) \ + macro(readBigInt64LE) \ + macro(readBigUInt64BE) \ + macro(readBigUInt64LE) \ + macro(readDoubleBE) \ + macro(readDoubleLE) \ + macro(readFloatBE) \ + macro(readFloatLE) \ + macro(readInt16BE) \ + macro(readInt16LE) \ + macro(readInt32BE) \ + macro(readInt32LE) \ + macro(readInt8) \ + macro(readUInt16BE) \ + macro(readUInt16LE) \ + macro(readUInt32BE) \ + macro(readUInt32LE) \ + macro(readUInt8) \ + macro(setBigUint64) \ + macro(slice) \ + macro(subarray) \ + macro(toJSON) \ + macro(writeBigInt64BE) \ + macro(writeBigInt64LE) \ + macro(writeBigUInt64BE) \ + macro(writeBigUInt64LE) \ + macro(writeDoubleBE) \ + macro(writeDoubleLE) \ + macro(writeFloatBE) \ + macro(writeFloatLE) \ + macro(writeInt16BE) \ + macro(writeInt16LE) \ + macro(writeInt32BE) \ + macro(writeInt32LE) \ + macro(writeInt8) \ + macro(writeUInt16BE) \ + macro(writeUInt16LE) \ + macro(writeUInt32BE) \ + macro(writeUInt32LE) \ + macro(writeUInt8) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class JSBufferPrototypeBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit JSBufferPrototypeBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES) +#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { })) + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_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_JSBUFFERPROTOTYPE_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_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_JSBUFFERPROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* JSBufferPrototypeBuiltinsWrapper::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_JSBUFFERPROTOTYPE_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void JSBufferPrototypeBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} + +} // namespace WebCore diff --git a/src/javascript/jsc/bindings/builtins/README.md b/src/javascript/jsc/bindings/builtins/README.md new file mode 100644 index 000000000..8ec32e8b5 --- /dev/null +++ b/src/javascript/jsc/bindings/builtins/README.md @@ -0,0 +1,30 @@ +# JavaScript Builtins + +JavaScript files in [./js](./js) use JavaScriptCore's builtins syntax + +```js +@getter +function foo() { + return @getByIdDirectPrivate(this, "superSecret"); +} +``` + +It looks kind of like decorators but they're not. They let you directly call engine intrinsics and help with avoiding prototype pollution issues. + +V8 has a [similar feature](https://v8.dev/blog/embedded-builtins) (they use `%` instead of `@`) + +They usually are accompanied by a C++ file. + +The `js` directory is necessary for the bindings generator to work. + +To regenerate the builtins, run this from Bun's project root (where the `Makefile` is) + +```bash +make generate-builtins +``` + +You'll want to also rebuild all the C++ bindings or you will get strange crashes on start + +```bash +make clean-bindings +``` diff --git a/src/javascript/jsc/bindings/builtins/js/JSBufferPrototype.js b/src/javascript/jsc/bindings/builtins/js/JSBufferPrototype.js new file mode 100644 index 000000000..2c4519c0f --- /dev/null +++ b/src/javascript/jsc/bindings/builtins/js/JSBufferPrototype.js @@ -0,0 +1,236 @@ +/* + * 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. ``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. + */ + +// ^ that comment is required or the builtins generator will have a fit. +// +// + + + + +// note: the _view inline getter is structured this way for performance +// using a getter + +function setBigUint64(offset, value, le) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, le); +} +function readInt8(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt8(offset); +} +function readUInt8(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint8(offset); +} +function readInt16LE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset, true); +} +function readInt16BE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset); +} +function readUInt16LE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset, true); +} +function readUInt16BE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset); +} +function readInt32LE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset, true); +} +function readInt32BE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset); +} +function readUInt32LE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset, true); +} +function readUInt32BE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset); +} +function readFloatLE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset, true); +} +function readFloatBE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset); +} +function readDoubleLE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset, true); +} +function readDoubleBE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset); +} +function readBigInt64LE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset, true); +} +function readBigInt64BE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset); +} +function readBigUInt64LE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset, true); +} +function readBigUInt64BE(offset) { + "use strict"; + return (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset); +} +function writeInt8(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt8(offset, value); + return offset + 1; +} +function writeUInt8(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint8(offset, value); + return offset + 1; +} +function writeInt16LE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value, true); + return offset + 2; +} +function writeInt16BE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value); + return offset + 2; +} +function writeUInt16LE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value, true); + return offset + 2; +} +function writeUInt16BE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value); + return offset + 2; +} +function writeInt32LE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value, true); + return offset + 4; +} +function writeInt32BE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value); + return offset + 4; +} +function writeUInt32LE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value, true); + return offset + 4; +} +function writeUInt32BE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value); + return offset + 4; +} + +function writeFloatLE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value, true); + return offset + 4; +} + +function writeFloatBE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value); + return offset + 4; +} + +function writeDoubleLE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value, true); + return offset + 8; +} + +function writeDoubleBE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value); + return offset + 8; +} + +function writeBigInt64LE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value, true); + return offset + 8; +} + +function writeBigInt64BE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value); + return offset + 8; +} + +function writeBigUInt64LE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, true); + return offset + 8; +} + +function writeBigUInt64BE(value, offset) { + "use strict"; + (this._view ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value); + return offset + 8; +} + +function slice(start, end) { + "use strict"; + if (start === undefined && end === undefined) { + return this; + } + + return this.subarray(start, end); +} + +function subarray(start, end) { + "use strict"; + + var array = new @Uint8Array(this.buffer, this.byteOffset + (start || 0), (end || this.byteLength) - (start || 0)); + @setPrototypeDirect.@call( + array, + Buffer.prototype + ); + return array; +} + +function toJSON() { + "use strict"; + const type = "Buffer"; + const data = @Array.from(this); + return { type, data }; +} diff --git a/src/javascript/jsc/node/buffer.zig b/src/javascript/jsc/node/buffer.zig index 0d2c9932f..a275e8a0d 100644 --- a/src/javascript/jsc/node/buffer.zig +++ b/src/javascript/jsc/node/buffer.zig @@ -9,545 +9,108 @@ const Environment = bun.Environment; const C = bun.C; const Syscall = @import("./syscall.zig"); const os = std.os; -const Buffer = JSC.ArrayBuffer; const JSGlobalObject = JSC.JSGlobalObject; const ArgumentsSlice = JSC.Node.ArgumentsSlice; -const BufferStaticFunctionEnum = JSC.Node.DeclEnum(BufferStatic); - -fn BufferStatic_wrap(comptime FunctionEnum: BufferStaticFunctionEnum) NodeFSFunction { - const Function = @field(BufferStatic, @tagName(BufferStaticFunctionEnum)); - const FunctionType = @TypeOf(Function); - - const function: std.builtin.TypeInfo.Fn = comptime @typeInfo(FunctionType).Fn; - comptime if (function.args.len != 3) @compileError("Expected 3 arguments"); - const Arguments = comptime function.args[1].arg_type.?; - const FormattedName = comptime [1]u8{std.ascii.toUpper(@tagName(BufferStaticFunctionEnum)[0])} ++ @tagName(BufferStaticFunctionEnum)[1..]; - const Result = JSC.JSValue; - - const NodeBindingClosure = struct { - pub fn bind( - _: void, - ctx: JSC.C.JSContextRef, - _: JSC.C.JSObjectRef, - _: JSC.C.JSObjectRef, - arguments: []const JSC.C.JSValueRef, - exception: JSC.C.ExceptionRef, - ) JSC.C.JSValueRef { - var slice = ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]); - - defer { - // TODO: fix this - for (arguments) |arg| { - JSC.C.JSValueUnprotect(ctx, arg); - } - slice.arena.deinit(); - } - - const args = if (comptime Arguments != void) - (Arguments.fromJS(ctx, &slice, exception) orelse return null) - else - Arguments{}; - if (exception.* != null) return null; - - const result: Result = Function( - ctx.ptr(), - args, - exception, - ); - if (exception.* != null) { - return null; - } - - return result.asObjectRef(); - } - }; - - return NodeBindingClosure.bind; -} - -pub const BufferStatic = struct { - pub const Arguments = struct { - pub const Alloc = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Alloc {} - }; - pub const AllocUnsafe = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?AllocUnsafe {} - }; - pub const AllocUnsafeSlow = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?AllocUnsafeSlow {} - }; - pub const Compare = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Compare {} - }; - pub const Concat = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Concat {} - }; - pub const IsEncoding = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?IsEncoding {} - }; - }; - pub fn alloc(globalThis: *JSGlobalObject, args: Arguments.Alloc, exception: JSC.C.ExceptionRef) JSC.JSValue {} - pub fn allocUnsafe(globalThis: *JSGlobalObject, args: Arguments.AllocUnsafe, exception: JSC.C.ExceptionRef) JSC.JSValue {} - pub fn allocUnsafeSlow(globalThis: *JSGlobalObject, args: Arguments.AllocUnsafeSlow, exception: JSC.C.ExceptionRef) JSC.JSValue {} - pub fn compare(globalThis: *JSGlobalObject, args: Arguments.Compare, exception: JSC.C.ExceptionRef) JSC.JSValue {} - pub fn concat(globalThis: *JSGlobalObject, args: Arguments.Concat, exception: JSC.C.ExceptionRef) JSC.JSValue {} - pub fn isEncoding(globalThis: *JSGlobalObject, args: Arguments.IsEncoding, exception: JSC.C.ExceptionRef) JSC.JSValue {} - - pub const Class = JSC.NewClass( - void, - .{ .name = "Buffer" }, - .{ - .alloc = .{ .name = "alloc", .rfn = BufferStatic_wrap(.alloc) }, - .allocUnsafe = .{ .name = "allocUnsafe", .rfn = BufferStatic_wrap(.allocUnsafe) }, - .allocUnsafeSlow = .{ .name = "allocUnsafeSlow", .rfn = BufferStatic_wrap(.allocUnsafeSlow) }, - .compare = .{ .name = "compare", .rfn = BufferStatic_wrap(.compare) }, - .concat = .{ .name = "concat", .rfn = BufferStatic_wrap(.concat) }, - .isEncoding = .{ .name = "isEncoding", .rfn = BufferStatic_wrap(.isEncoding) }, - }, - .{ ._poolSize = .{ .name = "_poolSize", .get = .{ .name = "get", .rfn = BufferStatic.getPoolSize }, .set = .{ .name = "set", .rfn = BufferStatic.setPoolSize } } }, - ); -}; - -pub const BufferPrototype = struct { - const Arguments = struct { - pub const Compare = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Compare { - return null; - } - }; - pub const Copy = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Copy { - return null; - } - }; - pub const Equals = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Equals { - return null; - } - }; - pub const Fill = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Fill { - return null; - } - }; - pub const Includes = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Includes { - return null; - } - }; - pub const IndexOf = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?IndexOf { - return null; - } - }; - pub const LastIndexOf = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?LastIndexOf { - return null; - } - }; - pub const Swap16 = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Swap16 { - return null; - } - }; - pub const Swap32 = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Swap32 { - return null; - } - }; - pub const Swap64 = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Swap64 { - return null; - } - }; - pub const Write = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Write { - return null; - } - }; - pub const Read = struct { - pub fn fromJS(ctx: JSC.C.JSContextRef, arguments: *ArgumentsSlice, exception: JSC.C.ExceptionRef) ?Read { - return null; - } - }; - - pub fn WriteInt(comptime kind: Int) type { - return struct { - const This = @This(); - const Value = Int.native.get(kind); - }; - } - pub fn ReadInt(comptime kind: Int) type { - return struct { - const This = @This(); - const Value = Int.native.get(kind); - }; - } - }; - pub fn compare(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Compare) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); +/// These functions are called in JSBuffer.cpp +/// `CALL_WRITE_FN` is the macro which ultimately calls it +pub const Write = struct { + pub export fn Bun__Buffer__write__BigInt64BE(input: [*]u8, value: i64) void { + std.mem.writeIntBig(i64, input[0..8], value); } - pub fn copy(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Copy) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__BigInt64LE(input: [*]u8, value: i64) void { + std.mem.writeIntLittle(i64, input[0..8], value); } - pub fn equals(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Equals) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__BigUInt64BE(input: [*]u8, value: u64) void { + std.mem.writeIntBig(u64, input[0..8], value); } - pub fn fill(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Fill) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__BigUInt64LE(input: [*]u8, value: u64) void { + std.mem.writeIntLittle(u64, input[0..8], value); } - pub fn includes(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Includes) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__DoubleBE(input: [*]u8, value: f64) void { + std.mem.writeIntBig(u64, input[0..8], @bitCast(u64, value)); } - pub fn indexOf(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.IndexOf) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__DoubleLE(input: [*]u8, value: f64) void { + std.mem.writeIntLittle(u64, input[0..8], @bitCast(u64, value)); } - pub fn lastIndexOf(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.LastIndexOf) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__FloatBE(input: [*]u8, value: f64) void { + std.mem.writeIntBig(i32, input[0..4], @bitCast(i32, @floatCast(f32, value))); } - pub fn swap16(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Swap16) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__FloatLE(input: [*]u8, value: f64) void { + std.mem.writeIntLittle(i32, input[0..4], @bitCast(i32, @floatCast(f32, value))); } - pub fn swap32(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Swap32) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__Int16BE(input: [*]u8, value: i32) void { + std.mem.writeIntBig(i16, input[0..2], @intCast(i16, value)); } - pub fn swap64(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Swap64) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__Int16LE(input: [*]u8, value: i32) void { + std.mem.writeIntLittle(i16, input[0..2], @intCast(i16, value)); } - pub fn write(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Write) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__Int32BE(input: [*]u8, value: i32) void { + std.mem.writeIntBig(i32, input[0..4], value); } - pub fn read(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Read) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); + pub export fn Bun__Buffer__write__Int32LE(input: [*]u8, value: i32) void { + std.mem.writeIntLittle(i32, input[0..4], value); + } + pub export fn Bun__Buffer__write__Int64LE(input: [*]u8, value: i64) void { + std.mem.writeIntLittle(i64, input[0..8], value); + } + pub export fn Bun__Buffer__write__Int8(input: [*]u8, value: i32) void { + std.mem.writeIntNative(i8, input[0..1], @truncate(i8, value)); + } + pub export fn Bun__Buffer__write__Int8LE(input: [*]u8, value: i32) void { + std.mem.writeIntLittle(i8, input[0..1], @truncate(i8, value)); + } + pub export fn Bun__Buffer__write__UInt16BE(input: [*]u8, value: i32) void { + std.mem.writeIntBig(u16, input[0..2], @truncate(u16, @bitCast(u32, value))); + } + pub export fn Bun__Buffer__write__UInt16LE(input: [*]u8, value: i32) void { + std.mem.writeIntLittle(u16, input[0..2], @truncate(u16, @bitCast(u32, value))); + } + pub export fn Bun__Buffer__write__UInt32BE(input: [*]u8, value: i32) void { + std.mem.writeIntBig(u32, input[0..4], @bitCast(u32, value)); + } + pub export fn Bun__Buffer__write__UInt32LE(input: [*]u8, value: i32) void { + std.mem.writeIntLittle(u32, input[0..4], @bitCast(u32, value)); + } + pub export fn Bun__Buffer__write__UInt64BE(input: [*]u8, value: u64) void { + std.mem.writeIntBig(u64, input[0..8], value); + } + pub export fn Bun__Buffer__write__UInt64LE(input: [*]u8, value: u64) void { + std.mem.writeIntLittle(u64, input[0..8], value); + } + pub export fn Bun__Buffer__write__UInt8BE(input: [*]u8, value: i32) void { + std.mem.writeIntBig(u8, input[0..1], @bitCast(u8, @truncate(i8, value))); + } + pub export fn Bun__Buffer__write__UInt8LE(input: [*]u8, value: i32) void { + std.mem.writeIntLittle(u8, input[0..1], @bitCast(u8, @truncate(i8, value))); } - - fn writeIntAny(this: *Buffer, comptime kind: Int, args: Arguments.WriteInt(kind)) JSC.JSValue {} - fn readIntAny(this: *Buffer, comptime kind: Int, args: Arguments.ReadInt(kind)) JSC.JSValue {} - - pub const Class = JSC.NewClass( - void, - .{ .name = "Buffer" }, - .{ - .compare = .{ - .name = "compare", - .rfn = wrap(BufferPrototype.compare), - }, - .copy = .{ - .name = "copy", - .rfn = wrap(BufferPrototype.copy), - }, - .equals = .{ - .name = "equals", - .rfn = wrap(BufferPrototype.equals), - }, - .fill = .{ - .name = "fill", - .rfn = wrap(BufferPrototype.fill), - }, - .includes = .{ - .name = "includes", - .rfn = wrap(BufferPrototype.includes), - }, - .indexOf = .{ - .name = "indexOf", - .rfn = wrap(BufferPrototype.indexOf), - }, - .lastIndexOf = .{ - .name = "lastIndexOf", - .rfn = wrap(BufferPrototype.lastIndexOf), - }, - .swap16 = .{ - .name = "swap16", - .rfn = wrap(BufferPrototype.swap16), - }, - .swap32 = .{ - .name = "swap32", - .rfn = wrap(BufferPrototype.swap32), - }, - .swap64 = .{ - .name = "swap64", - .rfn = wrap(BufferPrototype.swap64), - }, - .write = .{ - .name = "write", - .rfn = wrap(BufferPrototype.write), - }, - .read = .{ - .name = "read", - .rfn = wrap(BufferPrototype.read), - }, - - // -- Write -- - .writeBigInt64BE = .{ - .name = "writeBigInt64BE", - .rfn = writeWrap(Int.BigInt64BE), - }, - .writeBigInt64LE = .{ - .name = "writeBigInt64LE", - .rfn = writeWrap(Int.BigInt64LE), - }, - .writeBigUInt64BE = .{ - .name = "writeBigUInt64BE", - .rfn = writeWrap(Int.BigUInt64BE), - }, - .writeBigUInt64LE = .{ - .name = "writeBigUInt64LE", - .rfn = writeWrap(Int.BigUInt64LE), - }, - .writeDoubleBE = .{ - .name = "writeDoubleBE", - .rfn = writeWrap(Int.DoubleBE), - }, - .writeDoubleLE = .{ - .name = "writeDoubleLE", - .rfn = writeWrap(Int.DoubleLE), - }, - .writeFloatBE = .{ - .name = "writeFloatBE", - .rfn = writeWrap(Int.FloatBE), - }, - .writeFloatLE = .{ - .name = "writeFloatLE", - .rfn = writeWrap(Int.FloatLE), - }, - .writeInt8 = .{ - .name = "writeInt8", - .rfn = writeWrap(Int.Int8), - }, - .writeInt16BE = .{ - .name = "writeInt16BE", - .rfn = writeWrap(Int.Int16BE), - }, - .writeInt16LE = .{ - .name = "writeInt16LE", - .rfn = writeWrap(Int.Int16LE), - }, - .writeInt32BE = .{ - .name = "writeInt32BE", - .rfn = writeWrap(Int.Int32BE), - }, - .writeInt32LE = .{ - .name = "writeInt32LE", - .rfn = writeWrap(Int.Int32LE), - }, - .writeIntBE = .{ - .name = "writeIntBE", - .rfn = writeWrap(Int.IntBE), - }, - .writeIntLE = .{ - .name = "writeIntLE", - .rfn = writeWrap(Int.IntLE), - }, - .writeUInt8 = .{ - .name = "writeUInt8", - .rfn = writeWrap(Int.UInt8), - }, - .writeUInt16BE = .{ - .name = "writeUInt16BE", - .rfn = writeWrap(Int.UInt16BE), - }, - .writeUInt16LE = .{ - .name = "writeUInt16LE", - .rfn = writeWrap(Int.UInt16LE), - }, - .writeUInt32BE = .{ - .name = "writeUInt32BE", - .rfn = writeWrap(Int.UInt32BE), - }, - .writeUInt32LE = .{ - .name = "writeUInt32LE", - .rfn = writeWrap(Int.UInt32LE), - }, - .writeUIntBE = .{ - .name = "writeUIntBE", - .rfn = writeWrap(Int.UIntBE), - }, - .writeUIntLE = .{ - .name = "writeUIntLE", - .rfn = writeWrap(Int.UIntLE), - }, - - // -- Read -- - .readBigInt64BE = .{ - .name = "readBigInt64BE", - .rfn = readWrap(Int.BigInt64BE), - }, - .readBigInt64LE = .{ - .name = "readBigInt64LE", - .rfn = readWrap(Int.BigInt64LE), - }, - .readBigUInt64BE = .{ - .name = "readBigUInt64BE", - .rfn = readWrap(Int.BigUInt64BE), - }, - .readBigUInt64LE = .{ - .name = "readBigUInt64LE", - .rfn = readWrap(Int.BigUInt64LE), - }, - .readDoubleBE = .{ - .name = "readDoubleBE", - .rfn = readWrap(Int.DoubleBE), - }, - .readDoubleLE = .{ - .name = "readDoubleLE", - .rfn = readWrap(Int.DoubleLE), - }, - .readFloatBE = .{ - .name = "readFloatBE", - .rfn = readWrap(Int.FloatBE), - }, - .readFloatLE = .{ - .name = "readFloatLE", - .rfn = readWrap(Int.FloatLE), - }, - .readInt8 = .{ - .name = "readInt8", - .rfn = readWrap(Int.Int8), - }, - .readInt16BE = .{ - .name = "readInt16BE", - .rfn = readWrap(Int.Int16BE), - }, - .readInt16LE = .{ - .name = "readInt16LE", - .rfn = readWrap(Int.Int16LE), - }, - .readInt32BE = .{ - .name = "readInt32BE", - .rfn = readWrap(Int.Int32BE), - }, - .readInt32LE = .{ - .name = "readInt32LE", - .rfn = readWrap(Int.Int32LE), - }, - .readIntBE = .{ - .name = "readIntBE", - .rfn = readWrap(Int.IntBE), - }, - .readIntLE = .{ - .name = "readIntLE", - .rfn = readWrap(Int.IntLE), - }, - .readUInt8 = .{ - .name = "readUInt8", - .rfn = readWrap(Int.UInt8), - }, - .readUInt16BE = .{ - .name = "readUInt16BE", - .rfn = readWrap(Int.UInt16BE), - }, - .readUInt16LE = .{ - .name = "readUInt16LE", - .rfn = readWrap(Int.UInt16LE), - }, - .readUInt32BE = .{ - .name = "readUInt32BE", - .rfn = readWrap(Int.UInt32BE), - }, - .readUInt32LE = .{ - .name = "readUInt32LE", - .rfn = readWrap(Int.UInt32LE), - }, - .readUIntBE = .{ - .name = "readUIntBE", - .rfn = readWrap(Int.UIntBE), - }, - .readUIntLE = .{ - .name = "readUIntLE", - .rfn = readWrap(Int.UIntLE), - }, - }, - .{}, - ); }; -const Int = enum { - BigInt64BE, - BigInt64LE, - BigUInt64BE, - BigUInt64LE, - DoubleBE, - DoubleLE, - FloatBE, - FloatLE, - Int8, - Int16BE, - Int16LE, - Int32BE, - Int32LE, - IntBE, - IntLE, - UInt8, - UInt16BE, - UInt16LE, - UInt32BE, - UInt32LE, - UIntBE, - UIntLE, - - const NativeMap = std.EnumArray(Int, type); - pub const native: NativeMap = brk: { - var map = NativeMap.initUndefined(); - map.set(.BigInt64BE, i64); - map.set(.BigInt64LE, i64); - map.set(.BigUInt64BE, u64); - map.set(.BigUInt64LE, u64); - map.set(.DoubleBE, f64); - map.set(.DoubleLE, f64); - map.set(.FloatBE, f32); - map.set(.FloatLE, f32); - map.set(.Int8, i8); - map.set(.Int16BE, i16); - map.set(.Int16LE, i16); - map.set(.Int32BE, u32); - map.set(.Int32LE, u32); - map.set(.IntBE, i32); - map.set(.IntLE, i32); - map.set(.UInt8, u8); - map.set(.UInt16BE, u16); - map.set(.UInt16LE, u16); - map.set(.UInt32BE, u32); - map.set(.UInt32LE, u32); - map.set(.UIntBE, u32); - map.set(.UIntLE, u32); - break :brk map; - }; -}; +comptime { + if (!JSC.is_bindgen) { + _ = Write.Bun__Buffer__write__BigInt64BE; + _ = Write.Bun__Buffer__write__BigInt64LE; + _ = Write.Bun__Buffer__write__BigUInt64BE; + _ = Write.Bun__Buffer__write__BigUInt64LE; + _ = Write.Bun__Buffer__write__DoubleBE; + _ = Write.Bun__Buffer__write__DoubleLE; + _ = Write.Bun__Buffer__write__FloatBE; + _ = Write.Bun__Buffer__write__FloatLE; + _ = Write.Bun__Buffer__write__Int16BE; + _ = Write.Bun__Buffer__write__Int16LE; + _ = Write.Bun__Buffer__write__Int32BE; + _ = Write.Bun__Buffer__write__Int32LE; + _ = Write.Bun__Buffer__write__Int64LE; + _ = Write.Bun__Buffer__write__Int8; + _ = Write.Bun__Buffer__write__Int8LE; + _ = Write.Bun__Buffer__write__UInt16BE; + _ = Write.Bun__Buffer__write__UInt16LE; + _ = Write.Bun__Buffer__write__UInt32BE; + _ = Write.Bun__Buffer__write__UInt32LE; + _ = Write.Bun__Buffer__write__UInt64BE; + _ = Write.Bun__Buffer__write__UInt64LE; + _ = Write.Bun__Buffer__write__UInt8BE; + _ = Write.Bun__Buffer__write__UInt8LE; + } +} diff --git a/src/javascript/jsc/test/jest.zig b/src/javascript/jsc/test/jest.zig index 1857f3e2a..a07a4bcac 100644 --- a/src/javascript/jsc/test/jest.zig +++ b/src/javascript/jsc/test/jest.zig @@ -556,7 +556,8 @@ pub const ExpectPrototype = struct { return js.JSValueMakeUndefined(ctx); } var expect_ = getAllocator(ctx).create(Expect) catch unreachable; - js.JSValueProtect(ctx, arguments[0]); + if (JSC.JSValue.c(arguments[0]).isCell()) + js.JSValueProtect(ctx, arguments[0]); expect_.* = .{ .value = arguments[0], .scope = DescribeScope.active, |