diff options
author | 2022-04-28 18:24:12 -0700 | |
---|---|---|
committer | 2022-04-28 18:24:12 -0700 | |
commit | 93d41cbb4820c952402e274db68f92f1c55a798b (patch) | |
tree | 780783b560b391df4ec34034d8afa86bbfd8c0a9 | |
parent | 1f4ba5903539e367cd84b1ad175c4203d08b7881 (diff) | |
download | bun-93d41cbb4820c952402e274db68f92f1c55a798b.tar.gz bun-93d41cbb4820c952402e274db68f92f1c55a798b.tar.zst bun-93d41cbb4820c952402e274db68f92f1c55a798b.zip |
wip
20 files changed, 1601 insertions, 1049 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,20 @@ base64: $(CXX) $(CXXFLAGS) $(CFLAGS) -c neonbase64.cc -g -fPIC -emit-llvm && \ $(AR) rcvs $(BUN_DEPS_OUT_DIR)/libbase64.a ./*.bc +generate-builtins: + rm -f src/javascript/jsc/bindings/WebCoreBuiltins.cpp src/javascript/jsc/bindings/WebCoreBuiltins.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/WebCore*Builtins* || echo "" + $(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src/javascript/jsc/bindings/builtins/js) -o $(realpath src/javascript/jsc/bindings) --framework WebCore --force + $(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src/javascript/jsc/bindings/builtins/js) -o $(realpath src/javascript/jsc/bindings) --framework WebCore --wrappers-only + echo 'namespace Zig { class GlobalObject; }' > /tmp/1.h + cat /tmp/1.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h > src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h.1 + mv src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h.1 src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h + $(SED) -i -e 's/class JSDOMGlobalObject/using JSDOMGlobalObject = Zig::GlobalObject/' src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h +# Since we don't currently support web streams, we don't need this line +# so we comment it out + $(SED) -i -e 's/globalObject.addStaticGlobals/\/\/globalObject.addStaticGlobals/' src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp +# We delete this file because our script already builds all .cpp files +# We will get duplicate symbols if we don't delete it + rm src/javascript/jsc/bindings/WebCoreJSBuiltins.cpp 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 +398,9 @@ boringssl-copy: boringssl: boringssl-build boringssl-copy boringssl-debug: boringssl-build-debug boringssl-copy +compile-ffi-test: + clang -shared -undefined dynamic_lookup -o /tmp/bun-ffi-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.js b/bench/snippets/buffer.js new file mode 100644 index 000000000..4647249dd --- /dev/null +++ b/bench/snippets/buffer.js @@ -0,0 +1,129 @@ +// import { Buffer } from "buffer"; +var buf = new Buffer(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" +); + +time("Buffer.readBigInt64BE ", () => 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.readBigUInt64BE ", () => 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.readDoubleBE ", () => 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.readFloatBE ", () => 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.readInt16BE ", () => 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.readInt32BE ", () => 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.readUInt16BE ", () => 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.readUInt32BE ", () => 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(""); + +time("Buffer.writeBigInt64BE", () => buf.writeBigInt64BE(BigInt(0), 0)); +// time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false)); +// console.log(""); +time("Buffer.writeBigInt64LE", () => buf.writeBigInt64LE(BigInt(0), 0)); +// time("DataView.readBigInt64 (LE)", () => view.getBigInt64(0, true)); +// console.log(""); +time("Buffer.writeBigUInt64BE", () => buf.writeBigUInt64BE(BigInt(0), 0)); +// time("DataView.getBigUInt64 (BE)", () => view.getBigUint64(0, false)); +// console.log(""); +time("Buffer.writeBigUInt64LE", () => buf.writeBigUInt64LE(BigInt(0), 0)); +// time("DataView.readBigUInt64 (LE)", () => view.getBigUint64(0, true)); +// console.log(""); +time("Buffer.writeDoubleBE ", () => buf.writeDoubleBE(0, 0)); +// time("DataView.getDouble (BE)", () => view.getFloat64(0, false)); +// console.log(""); +time("Buffer.writeDoubleLE ", () => buf.writeDoubleLE(0, 0)); +// time("DataView.readDouble (LE)", () => view.getFloat64(0, true)); +// console.log(""); +time("Buffer.writeFloatBE ", () => buf.writeFloatBE(0, 0)); +// time("DataView.getFloat (BE)", () => view.getFloat32(0, false)); +// console.log(""); +time("Buffer.writeFloatLE ", () => buf.writeFloatLE(0, 0)); +// time("DataView.readFloat (LE)", () => view.getFloat32(0, true)); +// console.log(""); +time("Buffer.writeInt16BE ", () => buf.writeInt16BE(0, 0)); +// time("DataView.getInt16 (BE)", () => view.getInt16(0, false)); +// console.log(""); +time("Buffer.writeInt16LE ", () => buf.writeInt16LE(0, 0)); +// time("DataView.readInt16 (LE)", () => view.getInt16(0, true)); +// console.log(""); +time("Buffer.writeInt32BE ", () => buf.writeInt32BE(0, 0)); +// time("DataView.getInt32 (BE)", () => view.getInt32(0, false)); +// console.log(""); +time("Buffer.writeInt32LE ", () => buf.writeInt32LE(0, 0)); +// time("DataView.readInt32 (LE)", () => view.getInt32(0, true)); +// console.log(""); +time("Buffer.writeInt8 ", () => buf.writeInt8(0, 0)); +// time("DataView.readInt (t8)", () => view.getInt8(0)); +// console.log(""); +time("Buffer.writeUInt16BE ", () => buf.writeUInt16BE(0, 0)); +// time("DataView.getUInt16 (BE)", () => view.getUint16(0, false)); +// console.log(""); +time("Buffer.writeUInt16LE ", () => buf.writeUInt16LE(0, 0)); +// time("DataView.readUInt16 (LE)", () => view.getUint16(0, true)); +// console.log(""); +time("Buffer.writeUInt32BE ", () => buf.writeUInt32BE(0, 0)); +// time("DataView.getUInt32 (BE)", () => view.getUint32(0, false)); +// console.log(""); +time("Buffer.writeUInt32LE ", () => buf.writeUInt32LE(0, 0)); +// time("DataView.getUInt32 (LE)", () => view.getUint32(0, true)); +// console.log(""); +time("Buffer.writeUInt8 ", () => buf.writeUInt8(0, 0)); +// time("DataView.getUInt (t8)", () => view.getUint8(0)); +// console.log(""); + +buf.writeUInt8(10, 10); +console.assert(buf.readUInt8(10, 10) === 10); diff --git a/src/javascript/jsc/api/ffi.zig b/src/javascript/jsc/api/ffi.zig index a6191beb0..4062baadb 100644 --- a/src/javascript/jsc/api/ffi.zig +++ b/src/javascript/jsc/api/ffi.zig @@ -574,8 +574,6 @@ pub const FFI = struct { .{ "char*", ABIType{ .pointer = .{ .primitive = Primitive.Tag.char } } }, .{ "void*", ABIType{ .pointer = .{ .primitive = Primitive.Tag.@"void" } } }, - .{ "const char*", ABIType{ .pointer = .{ .is_const = true, .primitive = Primitive.Tag.char } } }, - .{ "const void*", ABIType{ .pointer = .{ .is_const = true, .primitive = Primitive.Tag.@"void" } } }, }, ); @@ -662,16 +660,12 @@ pub const FFI = struct { char: i8, int8_t: i8, uint8_t: u8, - int16_t: i16, uint16_t: u16, - int32_t: c_int, uint32_t: c_uint, - int64_t: i64, uint64_t: u64, - double: f64, float: f32, @@ -744,7 +738,7 @@ pub const FFI = struct { .bool => { try writer.print("BOOLEAN_TO_JSVALUE({s})", .{self.symbol}); }, - .int8_t, .uint8_t, .int16_t, .uint16_t, .int32_t, .uint32_t => { + .char, .int8_t, .uint8_t, .int16_t, .uint16_t, .int32_t, .uint32_t => { try writer.print("INT32_TO_JSVALUE({s})", .{self.symbol}); }, .int64_t => {}, diff --git a/src/javascript/jsc/bindings/Buffer.h b/src/javascript/jsc/bindings/Buffer.h index 8efc95787..8447f2fa3 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 { diff --git a/src/javascript/jsc/bindings/BunBuiltinNames.h b/src/javascript/jsc/bindings/BunBuiltinNames.h index 26d151319..f02a92e17 100644 --- a/src/javascript/jsc/bindings/BunBuiltinNames.h +++ b/src/javascript/jsc/bindings/BunBuiltinNames.h @@ -95,6 +95,7 @@ using namespace JSC; macro(version) \ macro(versions) \ macro(write) \ + macro(dataView) \ BUN_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) \ class BunBuiltinNames { diff --git a/src/javascript/jsc/bindings/BunBuiltins.h b/src/javascript/jsc/bindings/BunBuiltins.h new file mode 100644 index 000000000..d265ee353 --- /dev/null +++ b/src/javascript/jsc/bindings/BunBuiltins.h @@ -0,0 +1,2 @@ +#pragma once +#include "WebCoreJSBuiltins.h"
\ 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..1aa1c853b 100644 --- a/src/javascript/jsc/bindings/JSBuffer.cpp +++ b/src/javascript/jsc/bindings/JSBuffer.cpp @@ -30,6 +30,7 @@ #include "wtf/URL.h" #include "JSBufferEncodingType.h" +#include "JSBufferPrototypeBuiltins.h" #if ENABLE(MEDIA_SOURCE) #include "BufferMediaSource.h" @@ -56,55 +57,11 @@ 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; @@ -322,15 +279,20 @@ static inline EncodedJSValue constructBufferFromLength(JSGlobalObject* lexicalGl return JSValue::encode(jsUndefined()); } - auto arrayBuffer = JSC::ArrayBuffer::tryCreate(length, 1); + auto arrayBuffer = JSC::ArrayBuffer::tryCreateUninitialized(length, 1); if (!arrayBuffer) { throwOutOfMemoryError(lexicalGlobalObject, throwScope); return JSValue::encode(jsUndefined()); } + auto clientData = WebCore::clientData(vm); + auto uint8Array = JSC::JSUint8Array::create(lexicalGlobalObject, lexicalGlobalObject->typedArrayStructure(JSC::TypeUint8), WTFMove(arrayBuffer), 0, length); uint8Array->setPrototypeDirect(vm, JSBuffer::prototype(vm, *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject))); + auto* dataView = JSDataView::create(lexicalGlobalObject, lexicalGlobalObject->typedArrayStructure(JSC::TypeDataView), uint8Array->possiblySharedBuffer(), uint8Array->byteOffset(), uint8Array->length()); + uint8Array->putDirectWithoutTransition(vm, clientData->builtinNames().dataViewPublicName(), dataView, JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); + return JSC::JSValue::encode(uint8Array); } @@ -440,116 +402,6 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_lastIndexOfBody(JSC: 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) -{ - 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) -{ - 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) -{ - 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) -{ - 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) -{ - 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); @@ -797,116 +649,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 +678,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 +698,8 @@ 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 +712,56 @@ 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) } }, + { "readBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64BECodeGenerator), (intptr_t)(1) } }, + { "readBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } }, + { "readBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64BECodeGenerator), (intptr_t)(1) } }, + { "readBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } }, + { "readDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleBECodeGenerator), (intptr_t)(1) } }, + { "readDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } }, + { "readFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatBECodeGenerator), (intptr_t)(1) } }, + { "readFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } }, + { "readInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16BECodeGenerator), (intptr_t)(1) } }, + { "readInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } }, + { "readInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32BECodeGenerator), (intptr_t)(1) } }, + { "readInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } }, + { "readInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt8CodeGenerator), (intptr_t)(2) } }, + // { "readIntBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadIntBECodeGenerator), (intptr_t)(2) } }, + // { "readIntLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadIntLECodeGenerator), (intptr_t)(2) } }, + { "readUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } }, + { "readUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } }, + { "readUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } }, + { "readUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } }, + { "readUInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } }, + // { "readUIntBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUIntBECodeGenerator), (intptr_t)(2) } }, + // { "readUIntLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUIntLECodeGenerator), (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) } }, + + { "writeInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt8CodeGenerator), (intptr_t)(1) } }, + // { "writeIntBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteIntBECodeGenerator), (intptr_t)(2) } }, + // { "writeIntLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteIntLECodeGenerator), (intptr_t)(2) } }, + { "writeUInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } }, + // { "writeUIntBE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUIntBECodeGenerator), (intptr_t)(2) } }, + // { "writeUIntLE", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUIntLECodeGenerator), (intptr_t)(2) } }, + { "writeFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatBECodeGenerator), (intptr_t)(1) } }, + { "writeFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } }, + { "writeInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16BECodeGenerator), (intptr_t)(1) } }, + { "writeInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16LECodeGenerator), (intptr_t)(1) } }, + { "writeInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32BECodeGenerator), (intptr_t)(1) } }, + { "writeInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32LECodeGenerator), (intptr_t)(1) } }, + { "writeDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleBECodeGenerator), (intptr_t)(1) } }, + { "writeDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } }, + { "writeUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } }, + { "writeUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } }, + { "writeUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } }, + { "writeUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } }, + { "writeBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64BECodeGenerator), (intptr_t)(1) } }, + { "writeBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64LECodeGenerator), (intptr_t)(1) } }, + { "writeBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } }, + { "writeBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } }, }; void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis) diff --git a/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp new file mode 100644 index 000000000..91adcdb9c --- /dev/null +++ b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp @@ -0,0 +1,526 @@ +/* + * Copyright (c) 2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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_jsBufferPrototypeReadInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt8CodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadInt8CodeLength = 80; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt8Code = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getInt8(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt8CodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadUInt8CodeLength = 81; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt8Code = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getUint8(offset);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadInt16LECodeLength = 87; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt16LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.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 = 88; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt16BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getInt16(offset, false);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadUInt16LECodeLength = 88; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt16LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.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 = 89; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt16BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getUint16(offset, false);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadInt32LECodeLength = 87; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt32LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.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 = 88; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt32BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getInt32(offset, false);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadUInt32LECodeLength = 88; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt32LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.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 = 89; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt32BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getUint32(offset, false);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadFloatLECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadFloatLECodeLength = 89; +static const JSC::Intrinsic s_jsBufferPrototypeReadFloatLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadFloatLECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.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 = 90; +static const JSC::Intrinsic s_jsBufferPrototypeReadFloatBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadFloatBECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getFloat32(offset, false);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleLECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadDoubleLECodeLength = 89; +static const JSC::Intrinsic s_jsBufferPrototypeReadDoubleLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadDoubleLECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.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 = 90; +static const JSC::Intrinsic s_jsBufferPrototypeReadDoubleBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadDoubleBECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getFloat64(offset, false);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadBigInt64LECodeLength = 90; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigInt64LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.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 = 91; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigInt64BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getBigInt64(offset, false);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeReadBigUInt64LECodeLength = 91; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigUInt64LECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.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 = 92; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigUInt64BECode = + "(function (offset) {\n" \ + " \"use strict\";\n" \ + " return this.dataView.getBigUint64(offset, false);\n" \ + "})\n" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeWriteInt8CodeLength = 108; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt8Code = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 109; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt8Code = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 115; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt16LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 116; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt16BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.setInt16(offset, value, false);\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 = 116; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt16LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 117; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt16BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.setUint16(offset, value, false);\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 = 115; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt32LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 116; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt32BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.setInt32(offset, value, false);\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 = 116; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt32LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 117; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt32BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.setUint32(offset, value, false);\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 = 117; +static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteFloatLECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 118; +static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteFloatBECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.setFloat32(offset, value, false);\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 = 117; +static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteDoubleLECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 118; +static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteDoubleBECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.setFloat64(offset, value, false);\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 = 118; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigInt64LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 119; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigInt64BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.setBigInt64(offset, value, false);\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 = 119; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigUInt64LECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.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 = 120; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigUInt64BECode = + "(function (value, offset) {\n" \ + " \"use strict\";\n" \ + " this.dataView.setBigUint64(offset, value, false);\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" \ +; + +const JSC::ConstructAbility s_jsBufferPrototypeInitializeBunBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeInitializeBunBufferCodeConstructorKind = JSC::ConstructorKind::None; +const int s_jsBufferPrototypeInitializeBunBufferCodeLength = 45; +static const JSC::Intrinsic s_jsBufferPrototypeInitializeBunBufferCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeInitializeBunBufferCode = + "(function (parameters)\n" \ + "{\n" \ + " \"use strict\";\n" \ + "\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..6e11df53a --- /dev/null +++ b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h @@ -0,0 +1,433 @@ +/* + * Copyright (c) 2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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_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; +extern const char* const s_jsBufferPrototypeInitializeBunBufferCode; +extern const int s_jsBufferPrototypeInitializeBunBufferCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeInitializeBunBufferCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeInitializeBunBufferCodeConstructorKind; + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_DATA(macro) \ + 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) \ + macro(initializeBunBuffer, jsBufferPrototypeInitializeBunBuffer, 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_BUILTIN_JSBUFFERPROTOTYPE_INITIALIZEBUNBUFFER 1 + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(macro) \ + 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) \ + macro(jsBufferPrototypeInitializeBunBufferCode, initializeBunBuffer, static_cast<const char*>(nullptr), s_jsBufferPrototypeInitializeBunBufferCodeLength) \ + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(macro) \ + macro(initializeBunBuffer) \ + 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(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/WebCoreJSBuiltinInternals.cpp b/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp new file mode 100644 index 000000000..bf85a29ef --- /dev/null +++ b/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 "WebCoreJSBuiltinInternals.h" + +#include "JSDOMGlobalObject.h" +#include "WebCoreJSClientData.h" +#include <JavaScriptCore/HeapInlines.h> +#include <JavaScriptCore/JSCJSValueInlines.h> +#include <JavaScriptCore/SlotVisitorInlines.h> +#include <JavaScriptCore/StructureInlines.h> + +namespace WebCore { + +JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm) + : m_vm(vm) +{ + UNUSED_PARAM(vm); +} + +template<typename Visitor> +void JSBuiltinInternalFunctions::visit(Visitor& visitor) +{ + UNUSED_PARAM(visitor); +} + +template void JSBuiltinInternalFunctions::visit(AbstractSlotVisitor&); +template void JSBuiltinInternalFunctions::visit(SlotVisitor&); + +SUPPRESS_ASAN void JSBuiltinInternalFunctions::initialize(JSDOMGlobalObject& globalObject) +{ + UNUSED_PARAM(globalObject); + + JSVMClientData& clientData = *static_cast<JSVMClientData*>(m_vm.clientData); + JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = { + }; + //globalObject.addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals)); + UNUSED_PARAM(clientData); +} + +} // namespace WebCore diff --git a/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h b/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h new file mode 100644 index 000000000..86fb9b3c6 --- /dev/null +++ b/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h @@ -0,0 +1,52 @@ +namespace Zig { class GlobalObject; } +/* + * Copyright (c) 2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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/VM.h> +#include <JavaScriptCore/WeakInlines.h> + +namespace WebCore { + +using JSDOMGlobalObject = Zig::GlobalObject; + +class JSBuiltinInternalFunctions { +public: + explicit JSBuiltinInternalFunctions(JSC::VM&); + + template<typename Visitor> void visit(Visitor&); + void initialize(JSDOMGlobalObject&); + + +private: + JSC::VM& m_vm; +}; + +} // namespace WebCore diff --git a/src/javascript/jsc/bindings/WebCoreJSBuiltins.h b/src/javascript/jsc/bindings/WebCoreJSBuiltins.h new file mode 100644 index 000000000..f2fd32881 --- /dev/null +++ b/src/javascript/jsc/bindings/WebCoreJSBuiltins.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 "JSBufferPrototypeBuiltins.h" +#include <JavaScriptCore/VM.h> + +namespace WebCore { + +class JSBuiltinFunctions { +public: + explicit JSBuiltinFunctions(JSC::VM& vm) + : m_vm(vm) + , m_jsBufferPrototypeBuiltins(m_vm) + { + } + + JSBufferPrototypeBuiltinsWrapper& jsBufferPrototypeBuiltins() { return m_jsBufferPrototypeBuiltins; } + +private: + JSC::VM& m_vm; + JSBufferPrototypeBuiltinsWrapper m_jsBufferPrototypeBuiltins; +}; + +} // namespace WebCore diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index 8e522ab85..d613d6c61 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -87,7 +87,7 @@ #include "Process.h" #include "JavaScriptCore/RemoteInspectorServer.h" - +#include "WebCoreJSBuiltinInternals.h" #include "JSBuffer.h" using JSGlobalObject = JSC::JSGlobalObject; @@ -290,8 +290,10 @@ GlobalObject::GlobalObject(JSC::VM& vm, JSC::Structure* structure) , m_constructors(makeUnique<WebCore::DOMConstructors>()) , m_world(WebCore::DOMWrapperWorld::create(vm, WebCore::DOMWrapperWorld::Type::Normal)) , m_worldIsNormal(true) + , m_builtinInternalFunctions(vm) { + m_scriptExecutionContext = new WebCore::ScriptExecutionContext(&vm, this); } diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h index da67f93c1..e3914d447 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.h +++ b/src/javascript/jsc/bindings/ZigGlobalObject.h @@ -22,6 +22,7 @@ class ScriptExecutionContext; #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/JSTypeInfo.h" #include "JavaScriptCore/Structure.h" +#include "WebCoreJSBuiltinInternals.h" #include "ZigConsoleClient.h" @@ -125,8 +126,12 @@ public: JSC::JSPromiseRejectionOperation); void setConsole(void* console); void installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm); + WebCore::JSBuiltinInternalFunctions& builtinInternalFunctions() { return m_builtinInternalFunctions; } private: + void addBuiltinGlobals(JSC::VM&); + friend void WebCore::JSBuiltinInternalFunctions::initialize(Zig::GlobalObject&); + WebCore::JSBuiltinInternalFunctions m_builtinInternalFunctions; GlobalObject(JSC::VM& vm, JSC::Structure* structure); std::unique_ptr<WebCore::DOMConstructors> m_constructors; uint8_t m_worldIsNormal; diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index 840f9025e..63848164a 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -3488,11 +3488,3 @@ pub const WTF = struct { pub const Callback = struct { // zig: Value, }; - -const NodeBuffer = @import("../node/buffer.zig"); - -comptime { - if (!JSC.is_bindgen) { - std.testing.refAllDecls(NodeBuffer.Write); - } -} 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..b3ed53574 --- /dev/null +++ b/src/javascript/jsc/bindings/builtins/js/JSBufferPrototype.js @@ -0,0 +1,237 @@ +/* + * Copyright 2016 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +// ^ 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 readInt8(offset) { + "use strict"; + return this.dataView.getInt8(offset); +} +function readUInt8(offset) { + "use strict"; + return this.dataView.getUint8(offset); +} +function readInt16LE(offset) { + "use strict"; + return this.dataView.getInt16(offset, true); +} +function readInt16BE(offset) { + "use strict"; + return this.dataView.getInt16(offset, false); +} +function readUInt16LE(offset) { + "use strict"; + return this.dataView.getUint16(offset, true); +} +function readUInt16BE(offset) { + "use strict"; + return this.dataView.getUint16(offset, false); +} +function readInt32LE(offset) { + "use strict"; + return this.dataView.getInt32(offset, true); +} +function readInt32BE(offset) { + "use strict"; + return this.dataView.getInt32(offset, false); +} +function readUInt32LE(offset) { + "use strict"; + return this.dataView.getUint32(offset, true); +} +function readUInt32BE(offset) { + "use strict"; + return this.dataView.getUint32(offset, false); +} +function readFloatLE(offset) { + "use strict"; + return this.dataView.getFloat32(offset, true); +} +function readFloatBE(offset) { + "use strict"; + return this.dataView.getFloat32(offset, false); +} +function readDoubleLE(offset) { + "use strict"; + return this.dataView.getFloat64(offset, true); +} +function readDoubleBE(offset) { + "use strict"; + return this.dataView.getFloat64(offset, false); +} +function readBigInt64LE(offset) { + "use strict"; + return this.dataView.getBigInt64(offset, true); +} +function readBigInt64BE(offset) { + "use strict"; + return this.dataView.getBigInt64(offset, false); +} +function readBigUInt64LE(offset) { + "use strict"; + return this.dataView.getBigUint64(offset, true); +} +function readBigUInt64BE(offset) { + "use strict"; + return this.dataView.getBigUint64(offset, false); +} +function writeInt8(value, offset) { + "use strict"; + this.dataView.setInt8(offset, value); + return offset + 1; +} +function writeUInt8(value, offset) { + "use strict"; + this.dataView.setUint8(offset, value); + return offset + 1; +} +function writeInt16LE(value, offset) { + "use strict"; + this.dataView.setInt16(offset, value, true); + return offset + 2; +} +function writeInt16BE(value, offset) { + "use strict"; + this.dataView.setInt16(offset, value, false); + return offset + 2; +} +function writeUInt16LE(value, offset) { + "use strict"; + this.dataView.setUint16(offset, value, true); + return offset + 2; +} +function writeUInt16BE(value, offset) { + "use strict"; + this.dataView.setUint16(offset, value, false); + return offset + 2; +} +function writeInt32LE(value, offset) { + "use strict"; + this.dataView.setInt32(offset, value, true); + return offset + 4; +} +function writeInt32BE(value, offset) { + "use strict"; + this.dataView.setInt32(offset, value, false); + return offset + 4; +} +function writeUInt32LE(value, offset) { + "use strict"; + this.dataView.setUint32(offset, value, true); + return offset + 4; +} +function writeUInt32BE(value, offset) { + "use strict"; + this.dataView.setUint32(offset, value, false); + return offset + 4; +} + +function writeFloatLE(value, offset) { + "use strict"; + this.dataView.setFloat32(offset, value, true); + return offset + 4; +} + +function writeFloatBE(value, offset) { + "use strict"; + this.dataView.setFloat32(offset, value, false); + return offset + 4; +} + +function writeDoubleLE(value, offset) { + "use strict"; + this.dataView.setFloat64(offset, value, true); + return offset + 8; +} + +function writeDoubleBE(value, offset) { + "use strict"; + this.dataView.setFloat64(offset, value, false); + return offset + 8; +} + +function writeBigInt64LE(value, offset) { + "use strict"; + this.dataView.setBigInt64(offset, value, true); + return offset + 8; +} + +function writeBigInt64BE(value, offset) { + "use strict"; + this.dataView.setBigInt64(offset, value, false); + return offset + 8; +} + +function writeBigUInt64LE(value, offset) { + "use strict"; + this.dataView.setBigUint64(offset, value, true); + return offset + 8; +} + +function writeBigUInt64BE(value, offset) { + "use strict"; + this.dataView.setBigUint64(offset, value, false); + 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 + ); + array.dataView = new DataView(array.buffer, array.byteOffset, array.byteLength); + return array; +} + +function toJSON() { + "use strict"; + const type = "Buffer"; + const data = @Array.from(this); + return { type, data }; +} + +function initializeBunBuffer(parameters) +{ + "use strict"; + +} + diff --git a/src/javascript/jsc/bindings/root.h b/src/javascript/jsc/bindings/root.h index ec2d228f7..0e8f2b262 100644 --- a/src/javascript/jsc/bindings/root.h +++ b/src/javascript/jsc/bindings/root.h @@ -78,4 +78,5 @@ #define WTF_MAKE_ISO_ALLOCATED_EXPORT(className, a) WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(className); #define WTF_MAKE_ISO_ALLOCATED_IMPL(className) + #endif
\ No newline at end of file diff --git a/src/javascript/jsc/node/buffer.zig b/src/javascript/jsc/node/buffer.zig index 0d2c9932f..dfc3a7fe7 100644 --- a/src/javascript/jsc/node/buffer.zig +++ b/src/javascript/jsc/node/buffer.zig @@ -9,545 +9,6 @@ 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(); - } - pub fn copy(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Copy) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn equals(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Equals) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn fill(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Fill) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn includes(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Includes) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn indexOf(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.IndexOf) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn lastIndexOf(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.LastIndexOf) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn swap16(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Swap16) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn swap32(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Swap32) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn swap64(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Swap64) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn write(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Write) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - pub fn read(this: *Buffer, globalThis: *JSC.JSGlobalObject, args: Arguments.Read) JSC.JSValue { - _ = this; - _ = globalThis; - _ = args; - return JSC.JSValue.jsUndefined(); - } - - 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; - }; -}; |