mirror of
https://github.com/oven-sh/bun
synced 2026-02-07 01:18:51 +00:00
Compare commits
7 Commits
ciro/fix-a
...
jarred/tcc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
478266bc1b | ||
|
|
7f5a953e16 | ||
|
|
a69a0cc43b | ||
|
|
93d41cbb48 | ||
|
|
1f4ba59035 | ||
|
|
49432093ff | ||
|
|
a0ca8930bc |
28
Makefile
28
Makefile
@@ -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,21 @@ 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 '//clang-format off' > /tmp/1.h
|
||||
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 +399,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 && \
|
||||
|
||||
129
bench/snippets/buffer.js
Normal file
129
bench/snippets/buffer.js
Normal file
@@ -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);
|
||||
@@ -1,12 +1,176 @@
|
||||
import { describe, it, expect } from "bun:test";
|
||||
|
||||
it("buffer", () => {
|
||||
var buf = new Buffer(1024);
|
||||
var buf = new Buffer(20);
|
||||
// if this fails or infinitely loops, it means there is a memory issue with the JSC::Structure object
|
||||
expect(Object.keys(buf).length > 0).toBe(true);
|
||||
|
||||
expect(buf.write("hello world ")).toBe(12);
|
||||
expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world ");
|
||||
expect(buf.toString("base64url", 0, "hello world ".length)).toBe(
|
||||
btoa("hello world ")
|
||||
);
|
||||
|
||||
expect(buf instanceof Uint8Array).toBe(true);
|
||||
expect(buf instanceof Buffer).toBe(true);
|
||||
expect(buf.slice() instanceof Uint8Array).toBe(true);
|
||||
expect(buf.slice(0, 1) instanceof Buffer).toBe(true);
|
||||
expect(buf.slice(0, 1) instanceof Uint8Array).toBe(true);
|
||||
expect(buf.slice(0, 1) instanceof Buffer).toBe(true);
|
||||
});
|
||||
|
||||
it("Buffer", () => {
|
||||
var inputs = [
|
||||
"hello world",
|
||||
"hello world".repeat(100),
|
||||
`😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`,
|
||||
];
|
||||
var good = inputs.map((a) => new TextEncoder().encode(a));
|
||||
for (let i = 0; i < inputs.length; i++) {
|
||||
var input = inputs[i];
|
||||
expect(new Buffer(input).toString("utf8")).toBe(inputs[i]);
|
||||
expect(Array.from(new Buffer(input)).join(",")).toBe(good[i].join(","));
|
||||
}
|
||||
for (let i = 0; i < inputs.length; i++) {
|
||||
var input = inputs[i];
|
||||
expect(new Buffer(input, "ucs2").toString("utf8")).toBe(inputs[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it("Buffer.toBuffer throws", () => {
|
||||
const checks = [
|
||||
[],
|
||||
{},
|
||||
"foo",
|
||||
new Uint16Array(),
|
||||
new DataView(new Uint8Array(14).buffer),
|
||||
];
|
||||
for (let i = 0; i < checks.length; i++) {
|
||||
try {
|
||||
Buffer.toBuffer(checks[i]);
|
||||
expect(false).toBe(true);
|
||||
} catch (exception) {
|
||||
expect(exception.message).toBe("Expected Uint8Array");
|
||||
}
|
||||
}
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it("Buffer.toBuffer works", () => {
|
||||
var array = new Uint8Array(20);
|
||||
expect(array instanceof Buffer).toBe(false);
|
||||
var buf = Buffer.toBuffer(array);
|
||||
expect(array instanceof Buffer).toBe(true);
|
||||
// if this fails or infinitely loops, it means there is a memory issue with the JSC::Structure object
|
||||
expect(Object.keys(buf).length > 0).toBe(true);
|
||||
|
||||
expect(buf.write("hello world ")).toBe(12);
|
||||
expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world ");
|
||||
expect(buf.toString("base64url", 0, "hello world ".length)).toBe(
|
||||
btoa("hello world ")
|
||||
);
|
||||
|
||||
expect(buf instanceof Uint8Array).toBe(true);
|
||||
expect(buf instanceof Buffer).toBe(true);
|
||||
expect(buf.slice() instanceof Uint8Array).toBe(true);
|
||||
expect(buf.slice(0, 1) instanceof Buffer).toBe(true);
|
||||
expect(buf.slice(0, 1) instanceof Uint8Array).toBe(true);
|
||||
expect(buf.slice(0, 1) instanceof Buffer).toBe(true);
|
||||
expect(new Buffer(buf) instanceof Buffer).toBe(true);
|
||||
expect(new Buffer(buf.buffer) instanceof Buffer).toBe(true);
|
||||
});
|
||||
|
||||
it("writeInt", () => {
|
||||
var buf = new Buffer(1024);
|
||||
var data = new DataView(buf.buffer);
|
||||
buf.writeInt32BE(100);
|
||||
expect(data.getInt32(0, false)).toBe(100);
|
||||
buf.writeInt32BE(100);
|
||||
expect(data.getInt32(0, false)).toBe(100);
|
||||
var childBuf = buf.subarray(0, 4);
|
||||
expect(data.getInt32(0, false)).toBe(100);
|
||||
expect(childBuf.readInt32BE(0, false)).toBe(100);
|
||||
});
|
||||
|
||||
it("read", () => {
|
||||
var buf = new Buffer(1024);
|
||||
var data = new DataView(buf.buffer);
|
||||
function reset() {
|
||||
new Uint8Array(buf.buffer).fill(0);
|
||||
}
|
||||
data.setBigInt64(0, BigInt(1000), false);
|
||||
expect(buf.readBigInt64BE(0)).toBe(BigInt(1000));
|
||||
reset();
|
||||
|
||||
data.setBigInt64(0, BigInt(1000), false);
|
||||
expect(buf.readBigInt64LE(0)).toBe(BigInt(1000));
|
||||
reset();
|
||||
|
||||
data.setBigUint64(0, BigInt(1000), false);
|
||||
expect(buf.readBigUInt64BE(0)).toBe(BigInt(1000));
|
||||
reset();
|
||||
|
||||
data.setBigUint64(0, BigInt(1000), false);
|
||||
expect(buf.readBigUInt64LE(0)).toBe(BigInt(1000));
|
||||
reset();
|
||||
|
||||
data.setFloat64(0, 1000, false);
|
||||
expect(buf.readDoubleBE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setFloat64(0, 1000, true);
|
||||
expect(buf.readDoubleLE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setFloat32(0, 1000, false);
|
||||
expect(buf.readFloatBE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setFloat32(0, 1000, true);
|
||||
expect(buf.readFloatLE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setInt16(0, 1000, false);
|
||||
expect(buf.readInt16BE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setInt16(0, 1000, true);
|
||||
expect(buf.readInt16LE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setInt32(0, 1000, false);
|
||||
expect(buf.readInt32BE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setInt32(0, 1000, true);
|
||||
expect(buf.readInt32LE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setInt8(0, 100, false);
|
||||
expect(buf.readInt8(0)).toBe(100);
|
||||
reset();
|
||||
|
||||
data.setUint16(0, 1000, false);
|
||||
expect(buf.readUInt16BE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setUint16(0, 1000, true);
|
||||
expect(buf.readUInt16LE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setUint32(0, 1000, false);
|
||||
expect(buf.readUInt32BE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setUint32(0, 1000, true);
|
||||
expect(buf.readUInt32LE(0)).toBe(1000);
|
||||
reset();
|
||||
|
||||
data.setUint8(0, 255, false);
|
||||
expect(buf.readUInt8(0)).toBe(255);
|
||||
reset();
|
||||
|
||||
data.setUint8(0, 255, false);
|
||||
expect(buf.readUInt8(0)).toBe(255);
|
||||
reset();
|
||||
});
|
||||
|
||||
82
integration/bunjs-only-snippets/ffi-test.c
Normal file
82
integration/bunjs-only-snippets/ffi-test.c
Normal file
@@ -0,0 +1,82 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool returns_true();
|
||||
bool returns_false();
|
||||
char returns_42_char();
|
||||
float returns_42_float();
|
||||
double returns_42_double();
|
||||
uint8_t returns_42_uint8_t();
|
||||
int8_t returns_neg_42_int8_t();
|
||||
uint16_t returns_42_uint16_t();
|
||||
uint32_t returns_42_uint32_t();
|
||||
uint64_t returns_42_uint64_t();
|
||||
int16_t returns_neg_42_int16_t();
|
||||
int32_t returns_neg_42_int32_t();
|
||||
int64_t returns_neg_42_int64_t();
|
||||
|
||||
bool identity_bool_true();
|
||||
bool identity_bool_false();
|
||||
char identity_char(char a);
|
||||
float identity_float(float a);
|
||||
bool identity_bool(bool ident);
|
||||
double identity_double(double a);
|
||||
int8_t identity_int8_t(int8_t a);
|
||||
int16_t identity_int16_t(int16_t a);
|
||||
int32_t identity_int32_t(int32_t a);
|
||||
int64_t identity_int64_t(int64_t a);
|
||||
uint8_t identity_uint8_t(uint8_t a);
|
||||
uint16_t identity_uint16_t(uint16_t a);
|
||||
uint32_t identity_uint32_t(uint32_t a);
|
||||
uint64_t identity_uint64_t(uint64_t a);
|
||||
|
||||
char add_char(char a, char b);
|
||||
float add_float(float a, float b);
|
||||
double add_double(double a, double b);
|
||||
int8_t add_int8_t(int8_t a, int8_t b);
|
||||
int16_t add_int16_t(int16_t a, int16_t b);
|
||||
int32_t add_int32_t(int32_t a, int32_t b);
|
||||
int64_t add_int64_t(int64_t a, int64_t b);
|
||||
uint8_t add_uint8_t(uint8_t a, uint8_t b);
|
||||
uint16_t add_uint16_t(uint16_t a, uint16_t b);
|
||||
uint32_t add_uint32_t(uint32_t a, uint32_t b);
|
||||
uint64_t add_uint64_t(uint64_t a, uint64_t b);
|
||||
|
||||
int8_t returns_neg_42_int8_t() { return 42; }
|
||||
uint16_t returns_42_uint16_t() { return 42; }
|
||||
uint32_t returns_42_uint32_t() { return 42; }
|
||||
uint64_t returns_42_uint64_t() { return 42; }
|
||||
int16_t returns_neg_42_int16_t() { return -42; }
|
||||
int32_t returns_neg_42_int32_t() { return -42; }
|
||||
int64_t returns_neg_42_int64_t() { return -42; }
|
||||
bool returns_true() { return true; }
|
||||
bool returns_false() { return false; }
|
||||
char returns_42_char() { return '*'; }
|
||||
float returns_42_float() { return 42.0f; }
|
||||
double returns_42_double() { return (double)42.0; }
|
||||
uint8_t returns_42_uint8_t() { return (uint8_t)42; }
|
||||
|
||||
char identity_char(char a) { return a; }
|
||||
float identity_float(float a) { return a; }
|
||||
double identity_double(double a) { return a; }
|
||||
int8_t identity_int8_t(int8_t a) { return a; }
|
||||
int16_t identity_int16_t(int16_t a) { return a; }
|
||||
int32_t identity_int32_t(int32_t a) { return a; }
|
||||
int64_t identity_int64_t(int64_t a) { return a; }
|
||||
uint8_t identity_uint8_t(uint8_t a) { return a; }
|
||||
uint16_t identity_uint16_t(uint16_t a) { return a; }
|
||||
uint32_t identity_uint32_t(uint32_t a) { return a; }
|
||||
uint64_t identity_uint64_t(uint64_t a) { return a; }
|
||||
bool identity_bool(bool ident) { return ident; }
|
||||
|
||||
char add_char(char a, char b) { return a + b; }
|
||||
float add_float(float a, float b) { return a + b; }
|
||||
double add_double(double a, double b) { return a + b; }
|
||||
int8_t add_int8_t(int8_t a, int8_t b) { return a + b; }
|
||||
int16_t add_int16_t(int16_t a, int16_t b) { return a + b; }
|
||||
int32_t add_int32_t(int32_t a, int32_t b) { return a + b; }
|
||||
int64_t add_int64_t(int64_t a, int64_t b) { return a + b; }
|
||||
uint8_t add_uint8_t(uint8_t a, uint8_t b) { return a + b; }
|
||||
uint16_t add_uint16_t(uint16_t a, uint16_t b) { return a + b; }
|
||||
uint32_t add_uint32_t(uint32_t a, uint32_t b) { return a + b; }
|
||||
uint64_t add_uint64_t(uint64_t a, uint64_t b) { return a + b; }
|
||||
214
integration/bunjs-only-snippets/ffi.test.js
Normal file
214
integration/bunjs-only-snippets/ffi.test.js
Normal file
@@ -0,0 +1,214 @@
|
||||
import { describe, it, expect } from "bun:test";
|
||||
|
||||
it("ffi print", () => {
|
||||
Bun.dlprint({
|
||||
add: {
|
||||
params: ["int32_t", "int32_t"],
|
||||
return_type: "int32_t",
|
||||
},
|
||||
})[0];
|
||||
});
|
||||
|
||||
it("ffi run", () => {
|
||||
const {
|
||||
symbols: {
|
||||
returns_true,
|
||||
returns_false,
|
||||
returns_42_char,
|
||||
returns_42_float,
|
||||
returns_42_double,
|
||||
returns_42_uint8_t,
|
||||
returns_neg_42_int8_t,
|
||||
returns_42_uint16_t,
|
||||
returns_42_uint32_t,
|
||||
returns_42_uint64_t,
|
||||
returns_neg_42_int16_t,
|
||||
returns_neg_42_int32_t,
|
||||
returns_neg_42_int64_t,
|
||||
identity_char,
|
||||
identity_float,
|
||||
identity_bool,
|
||||
identity_double,
|
||||
identity_int8_t,
|
||||
identity_int16_t,
|
||||
identity_int32_t,
|
||||
identity_int64_t,
|
||||
identity_uint8_t,
|
||||
identity_uint16_t,
|
||||
identity_uint32_t,
|
||||
identity_uint64_t,
|
||||
add_char,
|
||||
add_float,
|
||||
add_double,
|
||||
add_int8_t,
|
||||
add_int16_t,
|
||||
add_int32_t,
|
||||
add_int64_t,
|
||||
add_uint8_t,
|
||||
add_uint16_t,
|
||||
add_uint32_t,
|
||||
add_uint64_t,
|
||||
},
|
||||
close,
|
||||
} = Bun.dlopen("/tmp/bun-ffi-test.dylib", {
|
||||
returns_true: {
|
||||
returns: "bool",
|
||||
expects: [],
|
||||
},
|
||||
returns_false: {
|
||||
returns: "bool",
|
||||
expects: [],
|
||||
},
|
||||
returns_42_char: {
|
||||
returns: "char",
|
||||
expects: [],
|
||||
},
|
||||
returns_42_float: {
|
||||
returns: "float",
|
||||
expects: [],
|
||||
},
|
||||
returns_42_double: {
|
||||
returns: "double",
|
||||
expects: [],
|
||||
},
|
||||
returns_42_uint8_t: {
|
||||
returns: "uint8_t",
|
||||
expects: [],
|
||||
},
|
||||
returns_neg_42_int8_t: {
|
||||
returns: "int8_t",
|
||||
expects: [],
|
||||
},
|
||||
returns_42_uint16_t: {
|
||||
returns: "uint16_t",
|
||||
expects: [],
|
||||
},
|
||||
returns_42_uint32_t: {
|
||||
returns: "uint32_t",
|
||||
expects: [],
|
||||
},
|
||||
returns_42_uint64_t: {
|
||||
returns: "uint64_t",
|
||||
expects: [],
|
||||
},
|
||||
returns_neg_42_int16_t: {
|
||||
returns: "int16_t",
|
||||
expects: [],
|
||||
},
|
||||
returns_neg_42_int32_t: {
|
||||
returns: "int32_t",
|
||||
expects: [],
|
||||
},
|
||||
returns_neg_42_int64_t: {
|
||||
returns: "int64_t",
|
||||
expects: [],
|
||||
},
|
||||
|
||||
identity_char: {
|
||||
returns: "char",
|
||||
expects: ["char"],
|
||||
},
|
||||
identity_float: {
|
||||
returns: "float",
|
||||
expects: ["float"],
|
||||
},
|
||||
identity_bool: {
|
||||
returns: "bool",
|
||||
expects: ["bool"],
|
||||
},
|
||||
identity_double: {
|
||||
returns: "double",
|
||||
expects: ["double"],
|
||||
},
|
||||
identity_int8_t: {
|
||||
returns: "int8_t",
|
||||
expects: ["int8_t"],
|
||||
},
|
||||
identity_int16_t: {
|
||||
returns: "int16_t",
|
||||
expects: ["int16_t"],
|
||||
},
|
||||
identity_int32_t: {
|
||||
returns: "int32_t",
|
||||
expects: ["int32_t"],
|
||||
},
|
||||
identity_int64_t: {
|
||||
returns: "int64_t",
|
||||
expects: ["int64_t"],
|
||||
},
|
||||
identity_uint8_t: {
|
||||
returns: "uint8_t",
|
||||
expects: ["uint8_t"],
|
||||
},
|
||||
identity_uint16_t: {
|
||||
returns: "uint16_t",
|
||||
expects: ["uint16_t"],
|
||||
},
|
||||
identity_uint32_t: {
|
||||
returns: "uint32_t",
|
||||
expects: ["uint32_t"],
|
||||
},
|
||||
identity_uint64_t: {
|
||||
returns: "uint64_t",
|
||||
expects: ["uint64_t"],
|
||||
},
|
||||
|
||||
add_char: {
|
||||
returns: "char",
|
||||
expects: ["char", "char"],
|
||||
},
|
||||
add_float: {
|
||||
returns: "float",
|
||||
expects: ["float", "float"],
|
||||
},
|
||||
add_double: {
|
||||
returns: "double",
|
||||
expects: ["double", "double"],
|
||||
},
|
||||
add_int8_t: {
|
||||
returns: "int8_t",
|
||||
expects: ["int8_t", "int8_t"],
|
||||
},
|
||||
add_int16_t: {
|
||||
returns: "int16_t",
|
||||
expects: ["int16_t", "int16_t"],
|
||||
},
|
||||
add_int32_t: {
|
||||
returns: "int32_t",
|
||||
expects: ["int32_t", "int32_t"],
|
||||
},
|
||||
add_int64_t: {
|
||||
returns: "int64_t",
|
||||
expects: ["int64_t", "int64_t"],
|
||||
},
|
||||
add_uint8_t: {
|
||||
returns: "uint8_t",
|
||||
expects: ["uint8_t", "uint8_t"],
|
||||
},
|
||||
add_uint16_t: {
|
||||
returns: "uint16_t",
|
||||
expects: ["uint16_t", "uint16_t"],
|
||||
},
|
||||
add_uint32_t: {
|
||||
returns: "uint32_t",
|
||||
expects: ["uint32_t", "uint32_t"],
|
||||
},
|
||||
add_uint64_t: {
|
||||
returns: "uint64_t",
|
||||
expects: ["uint64_t", "uint64_t"],
|
||||
},
|
||||
});
|
||||
expect(add_char(1, 1)).toBe(2);
|
||||
expect(add_float(1.1, 1.1)).toBe(2.2);
|
||||
expect(add_double(1.1, 1.1)).toBe(2.2);
|
||||
expect(add_int8_t(1, 1)).toBe(2);
|
||||
expect(add_int16_t(1, 1)).toBe(2);
|
||||
expect(add_int32_t(1, 1)).toBe(2);
|
||||
// expect(add_int64_t(1, 1)).toBe(2);
|
||||
expect(add_uint8_t(1, 1)).toBe(2);
|
||||
expect(add_uint16_t(1, 1)).toBe(2);
|
||||
expect(add_uint32_t(1, 1)).toBe(2);
|
||||
// expect(add_uint64_t(1, 1)).toBe(2);
|
||||
close();
|
||||
});
|
||||
``;
|
||||
107
src/javascript/jsc/api/FFI.h
Normal file
107
src/javascript/jsc/api/FFI.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// This is an auto-generated file
|
||||
//
|
||||
// clang-format off
|
||||
// This file is only compatible with 64 bit CPUs
|
||||
// It must be kept in sync with JSCJSValue.h
|
||||
// https://github.com/Jarred-Sumner/WebKit/blob/72c2052b781cbfd4af867ae79ac9de460e392fba/Source/JavaScriptCore/runtime/JSCJSValue.h#L455-L458
|
||||
|
||||
|
||||
#define IS_BIG_ENDIAN 0
|
||||
#define USE_JSVALUE64 1
|
||||
#define USE_JSVALUE32_64 0
|
||||
|
||||
/* 7.18.1.1 Exact-width integer types */
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned uint32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef int64_t intptr_t;
|
||||
typedef uint64_t uintptr_t;
|
||||
typedef uintptr_t size_t;
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define bool _bool
|
||||
|
||||
// This value is 2^49, used to encode doubles such that the encoded value will
|
||||
// begin with a 15-bit pattern within the range 0x0002..0xFFFC.
|
||||
#define DoubleEncodeOffsetBit (size_t)(49)
|
||||
#define DoubleEncodeOffset (int64_t)(1ll << DoubleEncodeOffsetBit)
|
||||
#define OtherTag 0x2
|
||||
#define BoolTag 0x4
|
||||
#define UndefinedTag 0x8
|
||||
#define TagValueFalse (OtherTag | BoolTag | false)
|
||||
#define TagValueTrue (OtherTag | BoolTag | true)
|
||||
#define TagValueUndefined (OtherTag | UndefinedTag)
|
||||
#define TagValueNull (OtherTag)
|
||||
|
||||
// If all bits in the mask are set, this indicates an integer number,
|
||||
// if any but not all are set this value is a double precision number.
|
||||
#define NumberTag 0xfffe000000000000ll
|
||||
|
||||
typedef void* JSCell;
|
||||
|
||||
typedef union EncodedJSValue {
|
||||
int64_t asInt64;
|
||||
#if USE_JSVALUE32_64
|
||||
double asDouble;
|
||||
#elif USE_JSVALUE64
|
||||
JSCell *ptr;
|
||||
#endif
|
||||
|
||||
#if IS_BIG_ENDIAN
|
||||
struct {
|
||||
int32_t tag;
|
||||
int32_t payload;
|
||||
} asBits;
|
||||
#else
|
||||
struct {
|
||||
int32_t payload;
|
||||
int32_t tag;
|
||||
} asBits;
|
||||
#endif
|
||||
|
||||
void* asPtr;
|
||||
} EncodedJSValue;
|
||||
|
||||
EncodedJSValue ValueUndefined = { TagValueUndefined };
|
||||
EncodedJSValue ValueTrue = { TagValueTrue };
|
||||
|
||||
|
||||
static EncodedJSValue INT32_TO_JSVALUE(int32_t val);
|
||||
static EncodedJSValue INT32_TO_JSVALUE(int32_t val) {
|
||||
EncodedJSValue res;
|
||||
res.asInt64 = NumberTag | (uint32_t)val;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define JSVALUE_IS_TRUE(i) (!!(i.asInt64 == ValueTrue))
|
||||
#define JSVALUE_TO_INT32(i) (int32_t)i.asInt64
|
||||
#define JSVALUE_TO_DOUBLE(i) ((double)(i.asInt64 - DoubleEncodeOffset))
|
||||
#define JSVALUE_TO_FLOAT(i) ((float)(i.asInt64 - DoubleEncodeOffset))
|
||||
|
||||
#define BOOLEAN_TO_JSVALUE(i) (i ? ValueTrue : ValueFalse)
|
||||
|
||||
#define DOUBLE_TO_JSVALUE(i) ((double)(i.asInt64 - DoubleEncodeOffset))
|
||||
#define FLOAT_TO_JSVALUE(i) ((float)(i.asInt64 - DoubleEncodeOffset))
|
||||
|
||||
|
||||
|
||||
|
||||
typedef void* JSContext;
|
||||
typedef EncodedJSValue* JSException;
|
||||
|
||||
|
||||
// typedef void* (^ArrayBufferLikeGetPtrFunction)(JSContext, EncodedJSValue);
|
||||
// static ArrayBufferLikeGetPtrFunction JSArrayBufferGetPtr = (ArrayBufferLikeGetPtrFunction)MEMORY_ADDRESS_FOR_GET_ARRAY_BUFFER_FUNCTION;
|
||||
// (*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
|
||||
|
||||
// This is an example of a function which does the bare minimum
|
||||
void* Bun__CallbackFunctionPlaceholder(JSContext ctx, EncodedJSValue function, EncodedJSValue thisObject, size_t argumentCount, const EncodedJSValue arguments[], JSException exception);
|
||||
void* Bun__CallbackFunctionPlaceholder(JSContext ctx, EncodedJSValue function, EncodedJSValue thisObject, size_t argumentCount, const EncodedJSValue arguments[], JSException exception) {
|
||||
return (void*)123;
|
||||
}
|
||||
@@ -1121,6 +1121,12 @@ pub const Class = NewClass(
|
||||
.sha = .{
|
||||
.rfn = JSC.wrapWithHasContainer(Crypto.SHA512_256, "hash", false, false),
|
||||
},
|
||||
.dlprint = .{
|
||||
.rfn = JSC.wrapWithHasContainer(JSC.FFI, "print", false, false),
|
||||
},
|
||||
.dlopen = .{
|
||||
.rfn = JSC.wrapWithHasContainer(JSC.FFI, "open", false, false),
|
||||
},
|
||||
},
|
||||
.{
|
||||
.main = .{
|
||||
|
||||
791
src/javascript/jsc/api/ffi.zig
Normal file
791
src/javascript/jsc/api/ffi.zig
Normal file
@@ -0,0 +1,791 @@
|
||||
const Bun = @This();
|
||||
const default_allocator = @import("../../../global.zig").default_allocator;
|
||||
const bun = @import("../../../global.zig");
|
||||
const Environment = bun.Environment;
|
||||
const NetworkThread = @import("http").NetworkThread;
|
||||
const Global = bun.Global;
|
||||
const strings = bun.strings;
|
||||
const string = bun.string;
|
||||
const Output = @import("../../../global.zig").Output;
|
||||
const MutableString = @import("../../../global.zig").MutableString;
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const IdentityContext = @import("../../../identity_context.zig").IdentityContext;
|
||||
const Fs = @import("../../../fs.zig");
|
||||
const Resolver = @import("../../../resolver/resolver.zig");
|
||||
const ast = @import("../../../import_record.zig");
|
||||
const NodeModuleBundle = @import("../../../node_module_bundle.zig").NodeModuleBundle;
|
||||
const MacroEntryPoint = @import("../../../bundler.zig").MacroEntryPoint;
|
||||
const logger = @import("../../../logger.zig");
|
||||
const Api = @import("../../../api/schema.zig").Api;
|
||||
const options = @import("../../../options.zig");
|
||||
const Bundler = @import("../../../bundler.zig").Bundler;
|
||||
const ServerEntryPoint = @import("../../../bundler.zig").ServerEntryPoint;
|
||||
const js_printer = @import("../../../js_printer.zig");
|
||||
const js_parser = @import("../../../js_parser.zig");
|
||||
const js_ast = @import("../../../js_ast.zig");
|
||||
const hash_map = @import("../../../hash_map.zig");
|
||||
const http = @import("../../../http.zig");
|
||||
const NodeFallbackModules = @import("../../../node_fallbacks.zig");
|
||||
const ImportKind = ast.ImportKind;
|
||||
const Analytics = @import("../../../analytics/analytics_thread.zig");
|
||||
const ZigString = @import("../../../jsc.zig").ZigString;
|
||||
const Runtime = @import("../../../runtime.zig");
|
||||
const Router = @import("./router.zig");
|
||||
const ImportRecord = ast.ImportRecord;
|
||||
const DotEnv = @import("../../../env_loader.zig");
|
||||
const ParseResult = @import("../../../bundler.zig").ParseResult;
|
||||
const PackageJSON = @import("../../../resolver/package_json.zig").PackageJSON;
|
||||
const MacroRemap = @import("../../../resolver/package_json.zig").MacroMap;
|
||||
const WebCore = @import("../../../jsc.zig").WebCore;
|
||||
const Request = WebCore.Request;
|
||||
const Response = WebCore.Response;
|
||||
const Headers = WebCore.Headers;
|
||||
const Fetch = WebCore.Fetch;
|
||||
const FetchEvent = WebCore.FetchEvent;
|
||||
const js = @import("../../../jsc.zig").C;
|
||||
const JSC = @import("../../../jsc.zig");
|
||||
const JSError = @import("../base.zig").JSError;
|
||||
const d = @import("../base.zig").d;
|
||||
const MarkedArrayBuffer = @import("../base.zig").MarkedArrayBuffer;
|
||||
const getAllocator = @import("../base.zig").getAllocator;
|
||||
const JSValue = @import("../../../jsc.zig").JSValue;
|
||||
const NewClass = @import("../base.zig").NewClass;
|
||||
const Microtask = @import("../../../jsc.zig").Microtask;
|
||||
const JSGlobalObject = @import("../../../jsc.zig").JSGlobalObject;
|
||||
const ExceptionValueRef = @import("../../../jsc.zig").ExceptionValueRef;
|
||||
const JSPrivateDataPtr = @import("../../../jsc.zig").JSPrivateDataPtr;
|
||||
const ZigConsoleClient = @import("../../../jsc.zig").ZigConsoleClient;
|
||||
const Node = @import("../../../jsc.zig").Node;
|
||||
const ZigException = @import("../../../jsc.zig").ZigException;
|
||||
const ZigStackTrace = @import("../../../jsc.zig").ZigStackTrace;
|
||||
const ErrorableResolvedSource = @import("../../../jsc.zig").ErrorableResolvedSource;
|
||||
const ResolvedSource = @import("../../../jsc.zig").ResolvedSource;
|
||||
const JSPromise = @import("../../../jsc.zig").JSPromise;
|
||||
const JSInternalPromise = @import("../../../jsc.zig").JSInternalPromise;
|
||||
const JSModuleLoader = @import("../../../jsc.zig").JSModuleLoader;
|
||||
const JSPromiseRejectionOperation = @import("../../../jsc.zig").JSPromiseRejectionOperation;
|
||||
const Exception = @import("../../../jsc.zig").Exception;
|
||||
const ErrorableZigString = @import("../../../jsc.zig").ErrorableZigString;
|
||||
const ZigGlobalObject = @import("../../../jsc.zig").ZigGlobalObject;
|
||||
const VM = @import("../../../jsc.zig").VM;
|
||||
const JSFunction = @import("../../../jsc.zig").JSFunction;
|
||||
const Config = @import("../config.zig");
|
||||
const URL = @import("../../../url.zig").URL;
|
||||
const Transpiler = @import("./transpiler.zig");
|
||||
const VirtualMachine = @import("../javascript.zig").VirtualMachine;
|
||||
const IOTask = JSC.IOTask;
|
||||
const ComptimeStringMap = @import("../../../comptime_string_map.zig").ComptimeStringMap;
|
||||
|
||||
const TCC = @import("../../../../tcc.zig");
|
||||
|
||||
pub const FFI = struct {
|
||||
dylib: std.DynLib,
|
||||
functions: std.StringArrayHashMapUnmanaged(Function) = .{},
|
||||
closed: bool = false,
|
||||
|
||||
pub const Class = JSC.NewClass(
|
||||
FFI,
|
||||
.{ .name = "class" },
|
||||
.{ .call = JSC.wrapWithHasContainer(FFI, "close", false, true) },
|
||||
.{},
|
||||
);
|
||||
|
||||
pub fn close(this: *FFI) JSValue {
|
||||
if (this.closed) {
|
||||
return JSC.JSValue.jsUndefined();
|
||||
}
|
||||
this.closed = true;
|
||||
this.dylib.close();
|
||||
|
||||
for (this.functions.values()) |*val| {
|
||||
VirtualMachine.vm.allocator.free(bun.constStrToU8(std.mem.span(val.base_name)));
|
||||
|
||||
val.arg_types.deinit(VirtualMachine.vm.allocator);
|
||||
}
|
||||
this.functions.deinit(VirtualMachine.vm.allocator);
|
||||
|
||||
return JSC.JSValue.jsUndefined();
|
||||
}
|
||||
|
||||
pub fn print(global: *JSGlobalObject, object: JSC.JSValue) JSValue {
|
||||
const allocator = VirtualMachine.vm.allocator;
|
||||
|
||||
if (object.isEmptyOrUndefinedOrNull() or !object.isObject()) {
|
||||
return JSC.toInvalidArguments("Expected an options object with symbol names", .{}, global.ref());
|
||||
}
|
||||
|
||||
var symbols = std.StringArrayHashMapUnmanaged(Function){};
|
||||
if (generateSymbols(global, &symbols, object) catch JSC.JSValue.zero) |val| {
|
||||
// an error while validating symbols
|
||||
for (symbols.keys()) |key| {
|
||||
allocator.free(bun.constStrToU8(key));
|
||||
}
|
||||
symbols.clearAndFree(allocator);
|
||||
return val;
|
||||
}
|
||||
|
||||
var zig_strings = allocator.alloc(ZigString, symbols.count()) catch unreachable;
|
||||
for (symbols.values()) |*function, i| {
|
||||
var arraylist = std.ArrayList(u8).init(allocator);
|
||||
var writer = arraylist.writer();
|
||||
function.printSourceCode(&writer) catch {
|
||||
// an error while generating source code
|
||||
for (symbols.keys()) |key| {
|
||||
allocator.free(bun.constStrToU8(key));
|
||||
}
|
||||
for (zig_strings) |zig_string| {
|
||||
allocator.free(bun.constStrToU8(zig_string.slice()));
|
||||
}
|
||||
for (symbols.values()) |*function_| {
|
||||
function_.arg_types.deinit(allocator);
|
||||
}
|
||||
symbols.clearAndFree(allocator);
|
||||
allocator.free(zig_strings);
|
||||
return ZigString.init("Error while printing code").toErrorInstance(global);
|
||||
};
|
||||
zig_strings[i] = ZigString.init(arraylist.toOwnedSlice());
|
||||
}
|
||||
|
||||
const ret = JSC.JSValue.createStringArray(global, zig_strings.ptr, zig_strings.len, true);
|
||||
|
||||
for (symbols.keys()) |key| {
|
||||
allocator.free(bun.constStrToU8(key));
|
||||
}
|
||||
for (zig_strings) |zig_string| {
|
||||
allocator.free(bun.constStrToU8(zig_string.slice()));
|
||||
}
|
||||
for (symbols.values()) |*function_| {
|
||||
function_.arg_types.deinit(allocator);
|
||||
if (function_.step == .compiled) {
|
||||
allocator.free(function_.step.compiled.buf);
|
||||
}
|
||||
}
|
||||
symbols.clearAndFree(allocator);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// pub fn dlcompile(global: *JSGlobalObject, object: JSC.JSValue) JSValue {
|
||||
// const allocator = VirtualMachine.vm.allocator;
|
||||
|
||||
// if (object.isEmptyOrUndefinedOrNull() or !object.isObject()) {
|
||||
// return JSC.toInvalidArguments("Expected an options object with symbol names", .{}, global.ref());
|
||||
// }
|
||||
|
||||
// var symbols = std.StringArrayHashMapUnmanaged(Function){};
|
||||
// if (generateSymbols(global, &symbols, object) catch JSC.JSValue.zero) |val| {
|
||||
// // an error while validating symbols
|
||||
// for (symbols.keys()) |key| {
|
||||
// allocator.free(bun.constStrToU8(key));
|
||||
// }
|
||||
// symbols.clearAndFree(allocator);
|
||||
// return val;
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
pub fn open(global: *JSGlobalObject, name_str: ZigString, object: JSC.JSValue) JSC.JSValue {
|
||||
const allocator = VirtualMachine.vm.allocator;
|
||||
var name_slice = name_str.toSlice(allocator);
|
||||
defer name_slice.deinit();
|
||||
|
||||
if (name_slice.len == 0) {
|
||||
return JSC.toInvalidArguments("Invalid library name", .{}, global.ref());
|
||||
}
|
||||
|
||||
if (object.isEmptyOrUndefinedOrNull() or !object.isObject()) {
|
||||
return JSC.toInvalidArguments("Expected an options object with symbol names", .{}, global.ref());
|
||||
}
|
||||
|
||||
const name = name_slice.sliceZ();
|
||||
var symbols = std.StringArrayHashMapUnmanaged(Function){};
|
||||
if (generateSymbols(global, &symbols, object) catch JSC.JSValue.zero) |val| {
|
||||
// an error while validating symbols
|
||||
for (symbols.keys()) |key| {
|
||||
allocator.free(bun.constStrToU8(key));
|
||||
}
|
||||
symbols.clearAndFree(allocator);
|
||||
return val;
|
||||
}
|
||||
if (symbols.count() == 0) {
|
||||
return JSC.toInvalidArguments("Expected at least one symbol", .{}, global.ref());
|
||||
}
|
||||
|
||||
var dylib = std.DynLib.open(name) catch {
|
||||
return JSC.toInvalidArguments("Failed to open library", .{}, global.ref());
|
||||
};
|
||||
|
||||
var obj = JSC.JSValue.c(JSC.C.JSObjectMake(global.ref(), null, null));
|
||||
JSC.C.JSValueProtect(global.ref(), obj.asObjectRef());
|
||||
defer JSC.C.JSValueUnprotect(global.ref(), obj.asObjectRef());
|
||||
for (symbols.values()) |*function| {
|
||||
var resolved_symbol = dylib.lookup(*anyopaque, function.base_name) orelse {
|
||||
const ret = JSC.toInvalidArguments("Symbol \"{s}\" not found in \"{s}\"", .{ std.mem.span(function.base_name), name_slice.slice() }, global.ref());
|
||||
for (symbols.values()) |*value| {
|
||||
allocator.free(bun.constStrToU8(std.mem.span(value.base_name)));
|
||||
value.arg_types.clearAndFree(allocator);
|
||||
}
|
||||
symbols.clearAndFree(allocator);
|
||||
dylib.close();
|
||||
return ret;
|
||||
};
|
||||
|
||||
function.symbol_from_dynamic_library = resolved_symbol;
|
||||
function.compile(allocator) catch {
|
||||
const ret = JSC.toInvalidArguments("Failed to compile symbol \"{s}\" in \"{s}\"", .{ std.mem.span(function.base_name), name_slice.slice() }, global.ref());
|
||||
for (symbols.values()) |*value| {
|
||||
allocator.free(bun.constStrToU8(std.mem.span(value.base_name)));
|
||||
value.arg_types.clearAndFree(allocator);
|
||||
}
|
||||
symbols.clearAndFree(allocator);
|
||||
dylib.close();
|
||||
return ret;
|
||||
};
|
||||
switch (function.step) {
|
||||
.failed => |err| {
|
||||
for (symbols.values()) |*value| {
|
||||
allocator.free(bun.constStrToU8(std.mem.span(value.base_name)));
|
||||
value.arg_types.clearAndFree(allocator);
|
||||
}
|
||||
symbols.clearAndFree(allocator);
|
||||
dylib.close();
|
||||
return ZigString.init(err).toErrorInstance(global);
|
||||
},
|
||||
.pending => {
|
||||
for (symbols.values()) |*value| {
|
||||
allocator.free(bun.constStrToU8(std.mem.span(value.base_name)));
|
||||
value.arg_types.clearAndFree(allocator);
|
||||
}
|
||||
symbols.clearAndFree(allocator);
|
||||
dylib.close();
|
||||
return ZigString.init("Failed to compile (nothing happend!)").toErrorInstance(global);
|
||||
},
|
||||
.compiled => |compiled| {
|
||||
var callback = JSC.C.JSObjectMakeFunctionWithCallback(global.ref(), null, @ptrCast(JSC.C.JSObjectCallAsFunctionCallback, compiled.ptr));
|
||||
|
||||
obj.put(global, &ZigString.init(std.mem.span(function.base_name)), JSC.JSValue.cast(callback));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var lib = allocator.create(FFI) catch unreachable;
|
||||
lib.* = .{
|
||||
.dylib = dylib,
|
||||
.functions = symbols,
|
||||
};
|
||||
|
||||
var close_object = JSC.JSValue.c(Class.make(global.ref(), lib));
|
||||
|
||||
return JSC.JSValue.createObject2(global, &ZigString.init("close"), &ZigString.init("symbols"), close_object, obj);
|
||||
}
|
||||
pub fn generateSymbols(global: *JSGlobalObject, symbols: *std.StringArrayHashMapUnmanaged(Function), object: JSC.JSValue) !?JSValue {
|
||||
const allocator = VirtualMachine.vm.allocator;
|
||||
|
||||
var keys = JSC.C.JSObjectCopyPropertyNames(global.ref(), object.asObjectRef());
|
||||
defer JSC.C.JSPropertyNameArrayRelease(keys);
|
||||
const count = JSC.C.JSPropertyNameArrayGetCount(keys);
|
||||
|
||||
try symbols.ensureTotalCapacity(allocator, count);
|
||||
|
||||
var i: usize = 0;
|
||||
while (i < count) : (i += 1) {
|
||||
var property_name_ref = JSC.C.JSPropertyNameArrayGetNameAtIndex(keys, i);
|
||||
defer JSC.C.JSStringRelease(property_name_ref);
|
||||
const len = JSC.C.JSStringGetLength(property_name_ref);
|
||||
if (len == 0) continue;
|
||||
var prop = JSC.C.JSStringGetCharacters8Ptr(property_name_ref)[0..len];
|
||||
|
||||
var value = JSC.JSValue.c(JSC.C.JSObjectGetProperty(global.ref(), object.asObjectRef(), property_name_ref, null));
|
||||
if (value.isEmptyOrUndefinedOrNull()) {
|
||||
return JSC.toTypeError(JSC.Node.ErrorCode.ERR_INVALID_ARG_VALUE, "Expected an object for key \"{s}\"", .{prop}, global.ref());
|
||||
}
|
||||
|
||||
var abi_types = std.ArrayListUnmanaged(ABIType){};
|
||||
|
||||
if (value.get(global, "params")) |params| {
|
||||
if (params.isEmptyOrUndefinedOrNull() or !params.jsType().isArray()) {
|
||||
return ZigString.init("Expected an object with \"params\" as an array").toErrorInstance(global);
|
||||
}
|
||||
|
||||
var array = params.arrayIterator(global);
|
||||
|
||||
try abi_types.ensureTotalCapacityPrecise(allocator, array.len);
|
||||
while (array.next()) |val| {
|
||||
if (val.isEmptyOrUndefinedOrNull() or !val.jsType().isStringLike()) {
|
||||
abi_types.clearAndFree(allocator);
|
||||
return ZigString.init("param must be a string (type name)").toErrorInstance(global);
|
||||
}
|
||||
|
||||
var type_name = val.toSlice(global, allocator);
|
||||
defer type_name.deinit();
|
||||
abi_types.appendAssumeCapacity(ABIType.label.get(type_name.slice()) orelse {
|
||||
abi_types.clearAndFree(allocator);
|
||||
return JSC.toTypeError(JSC.Node.ErrorCode.ERR_INVALID_ARG_VALUE, "Unknown type {s}", .{type_name.slice()}, global.ref());
|
||||
});
|
||||
}
|
||||
}
|
||||
// var function
|
||||
var return_type = ABIType{ .primitive = .@"void" };
|
||||
|
||||
if (value.get(global, "return_type")) |ret_value| {
|
||||
var ret_slice = ret_value.toSlice(global, allocator);
|
||||
defer ret_slice.deinit();
|
||||
return_type = ABIType.label.get(ret_slice.slice()) orelse {
|
||||
abi_types.clearAndFree(allocator);
|
||||
return JSC.toTypeError(JSC.Node.ErrorCode.ERR_INVALID_ARG_VALUE, "Unknown return type {s}", .{ret_slice.slice()}, global.ref());
|
||||
};
|
||||
}
|
||||
|
||||
const function = Function{
|
||||
.base_name = try allocator.dupeZ(u8, prop),
|
||||
.arg_types = abi_types,
|
||||
.return_type = return_type,
|
||||
};
|
||||
symbols.putAssumeCapacity(std.mem.span(function.base_name), function);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
pub const Function = struct {
|
||||
symbol_from_dynamic_library: ?*anyopaque = null,
|
||||
base_name: [:0]const u8 = "",
|
||||
|
||||
return_type: ABIType,
|
||||
arg_types: std.ArrayListUnmanaged(ABIType) = .{},
|
||||
step: Step = Step{ .pending = {} },
|
||||
|
||||
pub const Step = union(enum) {
|
||||
pending: void,
|
||||
compiled: struct {
|
||||
ptr: *anyopaque,
|
||||
buf: []u8,
|
||||
},
|
||||
failed: []const u8,
|
||||
};
|
||||
|
||||
const FFI_HEADER: string = @embedFile("./FFI.h");
|
||||
pub inline fn ffiHeader() string {
|
||||
if (comptime Environment.isDebug) {
|
||||
var dirpath = std.fs.path.dirname(@src().file).?;
|
||||
var env = std.process.getEnvMap(default_allocator) catch unreachable;
|
||||
|
||||
const dir = std.mem.replaceOwned(
|
||||
u8,
|
||||
default_allocator,
|
||||
dirpath,
|
||||
"jarred",
|
||||
env.get("USER").?,
|
||||
) catch unreachable;
|
||||
var runtime_path = std.fs.path.join(default_allocator, &[_]string{ dir, "FFI.h" }) catch unreachable;
|
||||
const file = std.fs.openFileAbsolute(runtime_path, .{}) catch @panic("Missing bun/src/javascript/jsc/api/FFI.h.");
|
||||
defer file.close();
|
||||
return file.readToEndAlloc(default_allocator, (file.stat() catch unreachable).size) catch unreachable;
|
||||
} else {
|
||||
return FFI_HEADER;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handleTCCError(ctx: ?*anyopaque, message: [*c]const u8) callconv(.C) void {
|
||||
var this = bun.cast(*Function, ctx.?);
|
||||
this.step = .{ .failed = std.mem.span(message) };
|
||||
}
|
||||
|
||||
extern fn pthread_jit_write_protect_np(enable: bool) callconv(.C) void;
|
||||
|
||||
pub fn compile(
|
||||
this: *Function,
|
||||
allocator: std.mem.Allocator,
|
||||
) !void {
|
||||
var source_code = std.ArrayList(u8).init(allocator);
|
||||
var source_code_writer = source_code.writer();
|
||||
try this.printSourceCode(&source_code_writer);
|
||||
try source_code.append(0);
|
||||
defer source_code.deinit();
|
||||
var state = TCC.tcc_new() orelse return error.TCCMissing;
|
||||
TCC.tcc_set_error_func(state, this, handleTCCError);
|
||||
// defer TCC.tcc_delete(state);
|
||||
_ = TCC.tcc_set_output_type(state, TCC.TCC_OUTPUT_MEMORY);
|
||||
|
||||
const compilation_result = TCC.tcc_compile_string(
|
||||
state,
|
||||
source_code.items.ptr,
|
||||
);
|
||||
// did tcc report an error?
|
||||
if (this.step == .failed) {
|
||||
return;
|
||||
}
|
||||
|
||||
// did tcc report failure but never called the error callback?
|
||||
if (compilation_result == -1) {
|
||||
this.step = .{ .failed = "tcc returned -1, which means it failed" };
|
||||
return;
|
||||
}
|
||||
|
||||
_ = TCC.tcc_add_symbol(state, this.base_name, this.symbol_from_dynamic_library.?);
|
||||
|
||||
// i don't fully understand this, why it needs two calls
|
||||
// but that is the API
|
||||
var relocation_size = TCC.tcc_relocate(state, null);
|
||||
if (relocation_size > 0) {
|
||||
var bytes: []u8 = try allocator.rawAlloc(@intCast(usize, relocation_size), 16, 16, 0);
|
||||
if (comptime Environment.isAarch64 and Environment.isMac) {
|
||||
pthread_jit_write_protect_np(false);
|
||||
}
|
||||
_ = TCC.tcc_relocate(state, bytes.ptr);
|
||||
if (comptime Environment.isAarch64 and Environment.isMac) {
|
||||
pthread_jit_write_protect_np(true);
|
||||
}
|
||||
if (this.step == .failed) {
|
||||
allocator.free(bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
var formatted_symbol_name = try std.fmt.allocPrintZ(allocator, "bun_gen_{s}", .{std.mem.span(this.base_name)});
|
||||
defer allocator.free(formatted_symbol_name);
|
||||
var symbol = TCC.tcc_get_symbol(state, formatted_symbol_name) orelse {
|
||||
this.step = .{ .failed = "missing generated symbol in source code" };
|
||||
allocator.free(bytes);
|
||||
|
||||
return;
|
||||
};
|
||||
if (this.step == .failed) {
|
||||
allocator.free(bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
this.step = .{
|
||||
.compiled = .{
|
||||
.ptr = symbol,
|
||||
.buf = bytes,
|
||||
},
|
||||
};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn printSourceCode(
|
||||
this: *Function,
|
||||
writer: anytype,
|
||||
) !void {
|
||||
if (comptime Environment.isRelease) {
|
||||
try writer.writeAll(std.mem.span(FFI_HEADER));
|
||||
} else {
|
||||
try writer.writeAll(ffiHeader());
|
||||
}
|
||||
|
||||
// -- Generate the FFI function symbol
|
||||
try writer.writeAll("/* --- The Function To Call */\n");
|
||||
try this.return_type.typename(writer);
|
||||
try writer.writeAll(" ");
|
||||
try writer.writeAll(std.mem.span(this.base_name));
|
||||
try writer.writeAll("(");
|
||||
var first = true;
|
||||
for (this.arg_types.items) |arg, i| {
|
||||
if (!first) {
|
||||
try writer.writeAll(", ");
|
||||
}
|
||||
first = false;
|
||||
try arg.typename(writer);
|
||||
try writer.print(" arg{d}", .{i});
|
||||
}
|
||||
try writer.writeAll(");\n\n");
|
||||
|
||||
// -- Generate JavaScriptCore's C wrapper function
|
||||
try writer.writeAll("/* ---- Your Wrapper Function ---- */\nvoid* bun_gen_");
|
||||
try writer.writeAll(std.mem.span(this.base_name));
|
||||
try writer.writeAll("(JSContext ctx, EncodedJSValue function, EncodedJSValue thisObject, size_t argumentCount, const EncodedJSValue arguments[], void* exception);\n\n");
|
||||
|
||||
try writer.writeAll("void* bun_gen_");
|
||||
try writer.writeAll(std.mem.span(this.base_name));
|
||||
try writer.writeAll("(JSContext ctx, EncodedJSValue function, EncodedJSValue thisObject, size_t argumentCount, const EncodedJSValue arguments[], void* exception) {\n\n");
|
||||
var arg_buf: [512]u8 = undefined;
|
||||
arg_buf[0.."arguments[".len].* = "arguments[".*;
|
||||
for (this.arg_types.items) |arg, i| {
|
||||
try writer.writeAll(" ");
|
||||
try arg.typename(writer);
|
||||
var printed = std.fmt.bufPrintIntToSlice(arg_buf["arguments[".len..], i, 10, .lower, .{});
|
||||
arg_buf["arguments[".len + printed.len] = ']';
|
||||
try writer.print(" arg{d} = {};\n", .{ i, arg.toC(arg_buf[0 .. printed.len + "arguments[]".len]) });
|
||||
}
|
||||
|
||||
try writer.writeAll(" ");
|
||||
if (!(this.return_type == .primitive and this.return_type.primitive == .void)) {
|
||||
try this.return_type.typename(writer);
|
||||
try writer.writeAll(" return_value = ");
|
||||
}
|
||||
try writer.print("{s}(", .{std.mem.span(this.base_name)});
|
||||
first = true;
|
||||
for (this.arg_types.items) |_, i| {
|
||||
if (!first) {
|
||||
try writer.writeAll(", ");
|
||||
}
|
||||
first = false;
|
||||
try writer.print("arg{d}", .{i});
|
||||
}
|
||||
try writer.writeAll(");\n\n");
|
||||
|
||||
try writer.writeAll(" ");
|
||||
|
||||
try writer.writeAll("return ");
|
||||
|
||||
if (!(this.return_type == .primitive and this.return_type.primitive == .void)) {
|
||||
try writer.print("{}.asPtr", .{this.return_type.toJS("return_value")});
|
||||
} else {
|
||||
try writer.writeAll("ValueUndefined.asPtr");
|
||||
}
|
||||
|
||||
try writer.writeAll(";\n}\n\n");
|
||||
}
|
||||
};
|
||||
|
||||
pub const ABIType = union(enum) {
|
||||
primitive: Primitive.Tag,
|
||||
pointer: Pointer,
|
||||
|
||||
pub const label = ComptimeStringMap(
|
||||
ABIType,
|
||||
.{
|
||||
.{ "char", ABIType{ .primitive = Primitive.Tag.char } },
|
||||
.{ "bool", ABIType{ .primitive = Primitive.Tag.@"bool" } },
|
||||
|
||||
.{ "i8", ABIType{ .primitive = Primitive.Tag.int8_t } },
|
||||
.{ "u8", ABIType{ .primitive = Primitive.Tag.uint8_t } },
|
||||
.{ "i16", ABIType{ .primitive = Primitive.Tag.int16_t } },
|
||||
.{ "int", ABIType{ .primitive = Primitive.Tag.int32_t } },
|
||||
.{ "c_int", ABIType{ .primitive = Primitive.Tag.int32_t } },
|
||||
.{ "c_uint", ABIType{ .primitive = Primitive.Tag.uint32_t } },
|
||||
.{ "i32", ABIType{ .primitive = Primitive.Tag.int32_t } },
|
||||
.{ "i64", ABIType{ .primitive = Primitive.Tag.int64_t } },
|
||||
.{ "u16", ABIType{ .primitive = Primitive.Tag.uint16_t } },
|
||||
.{ "u32", ABIType{ .primitive = Primitive.Tag.uint32_t } },
|
||||
.{ "u64", ABIType{ .primitive = Primitive.Tag.uint64_t } },
|
||||
.{ "int8_t", ABIType{ .primitive = Primitive.Tag.int8_t } },
|
||||
.{ "isize", ABIType{ .primitive = Primitive.Tag.int64_t } },
|
||||
.{ "usize", ABIType{ .primitive = Primitive.Tag.uint64_t } },
|
||||
.{ "int16_t", ABIType{ .primitive = Primitive.Tag.int16_t } },
|
||||
.{ "int32_t", ABIType{ .primitive = Primitive.Tag.int32_t } },
|
||||
.{ "int64_t", ABIType{ .primitive = Primitive.Tag.int64_t } },
|
||||
.{ "uint8_t", ABIType{ .primitive = Primitive.Tag.uint8_t } },
|
||||
.{ "uint16_t", ABIType{ .primitive = Primitive.Tag.uint16_t } },
|
||||
.{ "uint32_t", ABIType{ .primitive = Primitive.Tag.uint32_t } },
|
||||
.{ "uint64_t", ABIType{ .primitive = Primitive.Tag.uint64_t } },
|
||||
|
||||
.{ "char*", ABIType{ .pointer = .{ .primitive = Primitive.Tag.char } } },
|
||||
.{ "void*", ABIType{ .pointer = .{ .primitive = Primitive.Tag.@"void" } } },
|
||||
},
|
||||
);
|
||||
|
||||
const ToJSFormatter = struct {
|
||||
symbol: []const u8,
|
||||
abi: ABIType,
|
||||
|
||||
pub fn format(self: ToJSFormatter, comptime fmt: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
|
||||
switch (self.abi) {
|
||||
.pointer => |ptr| {
|
||||
_ = ptr;
|
||||
},
|
||||
.primitive => |prim| {
|
||||
try prim.toJS(self.symbol).format(comptime fmt, opts, writer);
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const ToCFormatter = struct {
|
||||
symbol: []const u8,
|
||||
abi: ABIType,
|
||||
|
||||
pub fn format(self: ToCFormatter, comptime fmt: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
|
||||
try self.abi.primitive.toC(self.symbol).format(
|
||||
comptime fmt,
|
||||
opts,
|
||||
writer,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
pub fn toJS(
|
||||
this: ABIType,
|
||||
symbol: string,
|
||||
) ToJSFormatter {
|
||||
return ToJSFormatter{
|
||||
.symbol = symbol,
|
||||
.abi = this,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn toC(this: ABIType, symbol: string) ToCFormatter {
|
||||
return ToCFormatter{
|
||||
.symbol = symbol,
|
||||
.abi = this,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn typename(this: ABIType, writer: anytype) !void {
|
||||
switch (this) {
|
||||
.primitive => |prim| {
|
||||
try writer.writeAll(prim.typename());
|
||||
},
|
||||
.pointer => |ptr| {
|
||||
try ptr.typename(writer);
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const Pointer = struct {
|
||||
count: u8 = 1,
|
||||
primitive: Primitive.Tag,
|
||||
is_const: bool = false,
|
||||
|
||||
pub fn typename(this: Pointer, writer: anytype) !void {
|
||||
if (this.is_const) {
|
||||
try writer.writeAll("const ");
|
||||
}
|
||||
|
||||
var i: u8 = 0;
|
||||
while (i < this.count) {
|
||||
try writer.writeAll("*");
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
try writer.writeAll(" ");
|
||||
try writer.writeAll(this.primitive.typename());
|
||||
}
|
||||
};
|
||||
|
||||
pub const Primitive = union(Tag) {
|
||||
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,
|
||||
|
||||
void: *anyopaque,
|
||||
|
||||
bool: bool,
|
||||
|
||||
dynamic: struct {
|
||||
size: u32,
|
||||
alignment: u21,
|
||||
name: []const u8,
|
||||
},
|
||||
|
||||
pub const Tag = enum(i32) {
|
||||
char = 0,
|
||||
|
||||
int8_t = 1,
|
||||
uint8_t = 2,
|
||||
|
||||
int16_t = 3,
|
||||
uint16_t = 4,
|
||||
|
||||
int32_t = 5,
|
||||
uint32_t = 6,
|
||||
|
||||
int64_t = 7,
|
||||
uint64_t = 8,
|
||||
|
||||
double = 9,
|
||||
float = 10,
|
||||
|
||||
void = 11,
|
||||
dynamic = 12,
|
||||
|
||||
bool = 13,
|
||||
|
||||
const ToCFormatter = struct {
|
||||
symbol: string,
|
||||
tag: Tag,
|
||||
|
||||
pub fn format(self: ToCFormatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
|
||||
switch (self.tag) {
|
||||
.void => {},
|
||||
.bool => {
|
||||
try writer.print("JSVALUE_IS_TRUE({s})", .{self.symbol});
|
||||
},
|
||||
.char, .int8_t, .uint8_t, .int16_t, .uint16_t, .int32_t, .uint32_t => {
|
||||
try writer.print("JSVALUE_TO_INT32({s})", .{self.symbol});
|
||||
},
|
||||
.int64_t => {},
|
||||
.uint64_t => {},
|
||||
.double => {
|
||||
try writer.print("JSVALUE_TO_DOUBLE({s})", .{self.symbol});
|
||||
},
|
||||
.float => {
|
||||
try writer.print("JSVALUE_TO_FLOAT({s})", .{self.symbol});
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const ToJSFormatter = struct {
|
||||
symbol: []const u8,
|
||||
tag: Tag,
|
||||
|
||||
pub fn format(self: ToJSFormatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
|
||||
switch (self.tag) {
|
||||
.void => {},
|
||||
.bool => {
|
||||
try writer.print("BOOLEAN_TO_JSVALUE({s})", .{self.symbol});
|
||||
},
|
||||
.char, .int8_t, .uint8_t, .int16_t, .uint16_t, .int32_t, .uint32_t => {
|
||||
try writer.print("INT32_TO_JSVALUE({s})", .{self.symbol});
|
||||
},
|
||||
.int64_t => {},
|
||||
.uint64_t => {},
|
||||
.double => {
|
||||
try writer.print("DOUBLE_to_JSVALUE({s})", .{self.symbol});
|
||||
},
|
||||
.float => {
|
||||
try writer.print("FLOAT_to_JSVALUE({s})", .{self.symbol});
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub fn toC(this: Tag, symbol: string) ToCFormatter {
|
||||
return ToCFormatter{ .tag = this, .symbol = symbol };
|
||||
}
|
||||
|
||||
pub fn toJS(
|
||||
this: Tag,
|
||||
symbol: string,
|
||||
) ToJSFormatter {
|
||||
return ToJSFormatter{
|
||||
.tag = this,
|
||||
.symbol = symbol,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn typename(this: Tag) []const u8 {
|
||||
return switch (this) {
|
||||
.void => "void",
|
||||
.bool => "bool",
|
||||
.int8_t => "int8_t",
|
||||
.uint8_t => "uint8_t",
|
||||
.int16_t => "int16_t",
|
||||
.uint16_t => "uint16_t",
|
||||
.int32_t => "int32_t",
|
||||
.uint32_t => "uint32_t",
|
||||
.int64_t => "int64_t",
|
||||
.uint64_t => "uint64_t",
|
||||
.double => "float",
|
||||
.float => "double",
|
||||
.char => "int8_t",
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
BIN
src/javascript/jsc/api/libtcc1.a.macos-aarch64
Normal file
BIN
src/javascript/jsc/api/libtcc1.a.macos-aarch64
Normal file
Binary file not shown.
@@ -2511,7 +2511,7 @@ comptime {
|
||||
std.testing.refAllDecls(RefString);
|
||||
}
|
||||
|
||||
export fn MarkedArrayBuffer_deallocator(bytes_: *anyopaque, _: *anyopaque) void {
|
||||
pub export fn MarkedArrayBuffer_deallocator(bytes_: *anyopaque, _: *anyopaque) void {
|
||||
const mimalloc = @import("../../allocators/mimalloc.zig");
|
||||
// zig's memory allocator interface won't work here
|
||||
// mimalloc knows the size of things
|
||||
@@ -2568,6 +2568,7 @@ const SHA384 = JSC.API.Bun.Crypto.SHA384;
|
||||
const SHA256 = JSC.API.Bun.Crypto.SHA256;
|
||||
const SHA512_256 = JSC.API.Bun.Crypto.SHA512_256;
|
||||
const MD5_SHA1 = JSC.API.Bun.Crypto.MD5_SHA1;
|
||||
const FFI = JSC.FFI;
|
||||
|
||||
pub const JSPrivateDataPtr = TaggedPointerUnion(.{
|
||||
AttributeIterator,
|
||||
@@ -2614,6 +2615,7 @@ pub const JSPrivateDataPtr = TaggedPointerUnion(.{
|
||||
TextEncoder,
|
||||
TimeoutTask,
|
||||
Transpiler,
|
||||
FFI,
|
||||
});
|
||||
|
||||
pub inline fn GetJSPrivateData(comptime Type: type, ref: js.JSObjectRef) ?*Type {
|
||||
|
||||
@@ -9,14 +9,16 @@
|
||||
|
||||
#include "BufferEncodingType.h"
|
||||
#include "JavaScriptCore/GenericTypedArrayView.h"
|
||||
#include "JavaScriptCore/JSBase.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 JSBuffer__bufferFromPointerAndLengthAndDeinit(JSC::JSGlobalObject* lexicalGlobalObject, char* ptr, unsigned int length, void* ctx, JSTypedArrayBytesDeallocator bytesDeallocator);
|
||||
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 {
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ using namespace JSC;
|
||||
macro(version) \
|
||||
macro(versions) \
|
||||
macro(write) \
|
||||
macro(dataView) \
|
||||
BUN_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) \
|
||||
|
||||
class BunBuiltinNames {
|
||||
|
||||
2
src/javascript/jsc/bindings/BunBuiltins.h
Normal file
2
src/javascript/jsc/bindings/BunBuiltins.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include "WebCoreJSBuiltins.h"
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
690
src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp
Normal file
690
src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp
Normal file
@@ -0,0 +1,690 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "JSBufferPrototypeBuiltins.h"
|
||||
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/HeapInlines.h>
|
||||
#include <JavaScriptCore/IdentifierInlines.h>
|
||||
#include <JavaScriptCore/Intrinsic.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSCellInlines.h>
|
||||
#include <JavaScriptCore/StructureInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
const JSC::ConstructAbility s_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 = 309;
|
||||
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" \
|
||||
" if (Buffer[Symbol.species] !== Buffer) {\n" \
|
||||
" Buffer[Symbol.species] = Buffer;\n" \
|
||||
" }\n" \
|
||||
"\n" \
|
||||
" return new Buffer(this.buffer, this.byteOffset + (start || 0), (end || this.byteLength) - (start || 0));\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeUtf8WriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeUtf8WriteCodeLength = 105;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeUtf8WriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeUtf8WriteCode =
|
||||
"(function (text, offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.write(text, offset, length, \"utf8\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeUcs2WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeUcs2WriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeUcs2WriteCodeLength = 105;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeUcs2WriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeUcs2WriteCode =
|
||||
"(function (text, offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.write(text, offset, length, \"ucs2\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeUtf16leWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeUtf16leWriteCodeLength = 108;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeUtf16leWriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeUtf16leWriteCode =
|
||||
"(function (text, offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.write(text, offset, length, \"utf16le\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeLatin1WriteCodeLength = 107;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeLatin1WriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeLatin1WriteCode =
|
||||
"(function (text, offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.write(text, offset, length, \"latin1\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeAsciiWriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeAsciiWriteCodeLength = 106;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeAsciiWriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeAsciiWriteCode =
|
||||
"(function (text, offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.write(text, offset, length, \"ascii\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeBase64WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeBase64WriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeBase64WriteCodeLength = 107;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeBase64WriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeBase64WriteCode =
|
||||
"(function (text, offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.write(text, offset, length, \"base64\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeBase64urlWriteCodeLength = 110;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeBase64urlWriteCode =
|
||||
"(function (text, offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.write(text, offset, length, \"base64url\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeHexWriteCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeHexWriteCodeLength = 104;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeHexWriteCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeHexWriteCode =
|
||||
"(function (text, offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.write(text, offset, length, \"hex\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeUtf8SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeUtf8SliceCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeUtf8SliceCodeLength = 96;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeUtf8SliceCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeUtf8SliceCode =
|
||||
"(function (offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.toString(offset, length, \"utf8\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeUcs2SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeUcs2SliceCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeUcs2SliceCodeLength = 96;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeUcs2SliceCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeUcs2SliceCode =
|
||||
"(function (offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.toString(offset, length, \"ucs2\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeUtf16leSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeUtf16leSliceCodeLength = 99;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeUtf16leSliceCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeUtf16leSliceCode =
|
||||
"(function (offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.toString(offset, length, \"utf16le\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeLatin1SliceCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeLatin1SliceCodeLength = 98;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeLatin1SliceCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeLatin1SliceCode =
|
||||
"(function (offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.toString(offset, length, \"latin1\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeAsciiSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeAsciiSliceCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeAsciiSliceCodeLength = 97;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeAsciiSliceCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeAsciiSliceCode =
|
||||
"(function (offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.toString(offset, length, \"ascii\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeBase64SliceCodeLength = 98;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeBase64SliceCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeBase64SliceCode =
|
||||
"(function (offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.toString(offset, length, \"base64\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeBase64urlSliceCodeLength = 101;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeBase64urlSliceCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeBase64urlSliceCode =
|
||||
"(function (offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.toString(offset, length, \"base64url\");\n" \
|
||||
"})\n" \
|
||||
;
|
||||
|
||||
const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
|
||||
const JSC::ConstructorKind s_jsBufferPrototypeHexSliceCodeConstructorKind = JSC::ConstructorKind::None;
|
||||
const int s_jsBufferPrototypeHexSliceCodeLength = 95;
|
||||
static const JSC::Intrinsic s_jsBufferPrototypeHexSliceCodeIntrinsic = JSC::NoIntrinsic;
|
||||
const char* const s_jsBufferPrototypeHexSliceCode =
|
||||
"(function (offset, length) {\n" \
|
||||
" \"use strict\";\n" \
|
||||
" return this.toString(offset, length, \"hex\");\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
|
||||
555
src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h
Normal file
555
src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h
Normal file
@@ -0,0 +1,555 @@
|
||||
// clang-format off
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/BuiltinUtils.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
|
||||
|
||||
namespace JSC {
|
||||
class FunctionExecutable;
|
||||
}
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
/* JSBufferPrototype */
|
||||
extern const char* const s_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_jsBufferPrototypeUtf8WriteCode;
|
||||
extern const int s_jsBufferPrototypeUtf8WriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeUtf8WriteCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeUcs2WriteCode;
|
||||
extern const int s_jsBufferPrototypeUcs2WriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeUcs2WriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeUcs2WriteCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeUtf16leWriteCode;
|
||||
extern const int s_jsBufferPrototypeUtf16leWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeUtf16leWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeLatin1WriteCode;
|
||||
extern const int s_jsBufferPrototypeLatin1WriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeAsciiWriteCode;
|
||||
extern const int s_jsBufferPrototypeAsciiWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeAsciiWriteCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeBase64WriteCode;
|
||||
extern const int s_jsBufferPrototypeBase64WriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeBase64WriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeBase64WriteCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeBase64urlWriteCode;
|
||||
extern const int s_jsBufferPrototypeBase64urlWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeHexWriteCode;
|
||||
extern const int s_jsBufferPrototypeHexWriteCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeHexWriteCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeUtf8SliceCode;
|
||||
extern const int s_jsBufferPrototypeUtf8SliceCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeUtf8SliceCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeUtf8SliceCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeUcs2SliceCode;
|
||||
extern const int s_jsBufferPrototypeUcs2SliceCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeUcs2SliceCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeUcs2SliceCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeUtf16leSliceCode;
|
||||
extern const int s_jsBufferPrototypeUtf16leSliceCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeUtf16leSliceCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeLatin1SliceCode;
|
||||
extern const int s_jsBufferPrototypeLatin1SliceCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeLatin1SliceCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeAsciiSliceCode;
|
||||
extern const int s_jsBufferPrototypeAsciiSliceCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeAsciiSliceCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeAsciiSliceCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeBase64SliceCode;
|
||||
extern const int s_jsBufferPrototypeBase64SliceCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeBase64urlSliceCode;
|
||||
extern const int s_jsBufferPrototypeBase64urlSliceCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind;
|
||||
extern const char* const s_jsBufferPrototypeHexSliceCode;
|
||||
extern const int s_jsBufferPrototypeHexSliceCodeLength;
|
||||
extern const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility;
|
||||
extern const JSC::ConstructorKind s_jsBufferPrototypeHexSliceCodeConstructorKind;
|
||||
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(utf8Write, jsBufferPrototypeUtf8Write, 3) \
|
||||
macro(ucs2Write, jsBufferPrototypeUcs2Write, 3) \
|
||||
macro(utf16leWrite, jsBufferPrototypeUtf16leWrite, 3) \
|
||||
macro(latin1Write, jsBufferPrototypeLatin1Write, 3) \
|
||||
macro(asciiWrite, jsBufferPrototypeAsciiWrite, 3) \
|
||||
macro(base64Write, jsBufferPrototypeBase64Write, 3) \
|
||||
macro(base64urlWrite, jsBufferPrototypeBase64urlWrite, 3) \
|
||||
macro(hexWrite, jsBufferPrototypeHexWrite, 3) \
|
||||
macro(utf8Slice, jsBufferPrototypeUtf8Slice, 2) \
|
||||
macro(ucs2Slice, jsBufferPrototypeUcs2Slice, 2) \
|
||||
macro(utf16leSlice, jsBufferPrototypeUtf16leSlice, 2) \
|
||||
macro(latin1Slice, jsBufferPrototypeLatin1Slice, 2) \
|
||||
macro(asciiSlice, jsBufferPrototypeAsciiSlice, 2) \
|
||||
macro(base64Slice, jsBufferPrototypeBase64Slice, 2) \
|
||||
macro(base64urlSlice, jsBufferPrototypeBase64urlSlice, 2) \
|
||||
macro(hexSlice, jsBufferPrototypeHexSlice, 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_UTF8WRITE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UCS2WRITE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF16LEWRITE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_LATIN1WRITE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_ASCIIWRITE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64WRITE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64URLWRITE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_HEXWRITE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF8SLICE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UCS2SLICE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF16LESLICE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_LATIN1SLICE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_ASCIISLICE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64SLICE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64URLSLICE 1
|
||||
#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_HEXSLICE 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(jsBufferPrototypeUtf8WriteCode, utf8Write, static_cast<const char*>(nullptr), s_jsBufferPrototypeUtf8WriteCodeLength) \
|
||||
macro(jsBufferPrototypeUcs2WriteCode, ucs2Write, static_cast<const char*>(nullptr), s_jsBufferPrototypeUcs2WriteCodeLength) \
|
||||
macro(jsBufferPrototypeUtf16leWriteCode, utf16leWrite, static_cast<const char*>(nullptr), s_jsBufferPrototypeUtf16leWriteCodeLength) \
|
||||
macro(jsBufferPrototypeLatin1WriteCode, latin1Write, static_cast<const char*>(nullptr), s_jsBufferPrototypeLatin1WriteCodeLength) \
|
||||
macro(jsBufferPrototypeAsciiWriteCode, asciiWrite, static_cast<const char*>(nullptr), s_jsBufferPrototypeAsciiWriteCodeLength) \
|
||||
macro(jsBufferPrototypeBase64WriteCode, base64Write, static_cast<const char*>(nullptr), s_jsBufferPrototypeBase64WriteCodeLength) \
|
||||
macro(jsBufferPrototypeBase64urlWriteCode, base64urlWrite, static_cast<const char*>(nullptr), s_jsBufferPrototypeBase64urlWriteCodeLength) \
|
||||
macro(jsBufferPrototypeHexWriteCode, hexWrite, static_cast<const char*>(nullptr), s_jsBufferPrototypeHexWriteCodeLength) \
|
||||
macro(jsBufferPrototypeUtf8SliceCode, utf8Slice, static_cast<const char*>(nullptr), s_jsBufferPrototypeUtf8SliceCodeLength) \
|
||||
macro(jsBufferPrototypeUcs2SliceCode, ucs2Slice, static_cast<const char*>(nullptr), s_jsBufferPrototypeUcs2SliceCodeLength) \
|
||||
macro(jsBufferPrototypeUtf16leSliceCode, utf16leSlice, static_cast<const char*>(nullptr), s_jsBufferPrototypeUtf16leSliceCodeLength) \
|
||||
macro(jsBufferPrototypeLatin1SliceCode, latin1Slice, static_cast<const char*>(nullptr), s_jsBufferPrototypeLatin1SliceCodeLength) \
|
||||
macro(jsBufferPrototypeAsciiSliceCode, asciiSlice, static_cast<const char*>(nullptr), s_jsBufferPrototypeAsciiSliceCodeLength) \
|
||||
macro(jsBufferPrototypeBase64SliceCode, base64Slice, static_cast<const char*>(nullptr), s_jsBufferPrototypeBase64SliceCodeLength) \
|
||||
macro(jsBufferPrototypeBase64urlSliceCode, base64urlSlice, static_cast<const char*>(nullptr), s_jsBufferPrototypeBase64urlSliceCodeLength) \
|
||||
macro(jsBufferPrototypeHexSliceCode, hexSlice, static_cast<const char*>(nullptr), s_jsBufferPrototypeHexSliceCodeLength) \
|
||||
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(asciiSlice) \
|
||||
macro(asciiWrite) \
|
||||
macro(base64Slice) \
|
||||
macro(base64Write) \
|
||||
macro(base64urlSlice) \
|
||||
macro(base64urlWrite) \
|
||||
macro(hexSlice) \
|
||||
macro(hexWrite) \
|
||||
macro(initializeBunBuffer) \
|
||||
macro(latin1Slice) \
|
||||
macro(latin1Write) \
|
||||
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(toJSON) \
|
||||
macro(ucs2Slice) \
|
||||
macro(ucs2Write) \
|
||||
macro(utf16leSlice) \
|
||||
macro(utf16leWrite) \
|
||||
macro(utf8Slice) \
|
||||
macro(utf8Write) \
|
||||
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
|
||||
69
src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp
Normal file
69
src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#include "config.h"
|
||||
#include "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
|
||||
54
src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
Normal file
54
src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
Normal file
@@ -0,0 +1,54 @@
|
||||
//clang-format off
|
||||
namespace Zig { class GlobalObject; }
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <JavaScriptCore/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
|
||||
53
src/javascript/jsc/bindings/WebCoreJSBuiltins.h
Normal file
53
src/javascript/jsc/bindings/WebCoreJSBuiltins.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Apple Inc. All rights reserved.
|
||||
* Copyright (c) 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
|
||||
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -141,6 +141,10 @@ pub const ZigString = extern struct {
|
||||
return this.ptr[0..this.len];
|
||||
}
|
||||
|
||||
pub fn sliceZ(this: Slice) [:0]const u8 {
|
||||
return std.meta.assumeSentinel(this.ptr[0..this.len], 0);
|
||||
}
|
||||
|
||||
pub fn mut(this: Slice) []u8 {
|
||||
return @intToPtr([*]u8, @ptrToInt(this.ptr))[0..this.len];
|
||||
}
|
||||
@@ -2301,6 +2305,15 @@ pub const JSValue = enum(u64) {
|
||||
return cppFn("makeWithNameAndPrototype", .{ globalObject, class, instance, name_ });
|
||||
}
|
||||
|
||||
/// Must come from globally-allocated memory!
|
||||
pub fn createBuffer(globalObject: *JSGlobalObject, slice: []u8, allocator: std.mem.Allocator) JSValue {
|
||||
if (comptime JSC.is_bindgen) unreachable;
|
||||
@setRuntimeSafety(false);
|
||||
return JSBuffer__bufferFromPointerAndLengthAndDeinit(globalObject, slice.ptr, slice.len, allocator.ptr, JSC.MarkedArrayBuffer_deallocator);
|
||||
}
|
||||
|
||||
extern fn JSBuffer__bufferFromPointerAndLengthAndDeinit(*JSGlobalObject, [*]u8, usize, ?*anyopaque, JSC.C.JSTypedArrayBytesDeallocator) JSValue;
|
||||
|
||||
pub fn jsNumberWithType(comptime Number: type, number: Number) JSValue {
|
||||
return switch (comptime Number) {
|
||||
JSValue => number,
|
||||
|
||||
294
src/javascript/jsc/bindings/builtins/js/JSBufferPrototype.js
Normal file
294
src/javascript/jsc/bindings/builtins/js/JSBufferPrototype.js
Normal file
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Copyright 2022 Codeblog Corp. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
// ^ that comment is required or the builtins generator will have a fit.
|
||||
|
||||
// The fastest way as of April 2022 is to use DataView.
|
||||
// DataView has intrinsics that cause inlining
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Buffer[Symbol.species] ||= Buffer;
|
||||
|
||||
return new Buffer(this.buffer, this.byteOffset + (start || 0), (end || this.byteLength) - (start || 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function utf8Write(text, offset, length) {
|
||||
"use strict";
|
||||
return this.write(text, offset, length, "utf8");
|
||||
}
|
||||
function ucs2Write(text, offset, length) {
|
||||
"use strict";
|
||||
return this.write(text, offset, length, "ucs2");
|
||||
}
|
||||
function utf16leWrite(text, offset, length) {
|
||||
"use strict";
|
||||
return this.write(text, offset, length, "utf16le");
|
||||
}
|
||||
function latin1Write(text, offset, length) {
|
||||
"use strict";
|
||||
return this.write(text, offset, length, "latin1");
|
||||
}
|
||||
function asciiWrite(text, offset, length) {
|
||||
"use strict";
|
||||
return this.write(text, offset, length, "ascii");
|
||||
}
|
||||
function base64Write(text, offset, length) {
|
||||
"use strict";
|
||||
return this.write(text, offset, length, "base64");
|
||||
}
|
||||
function base64urlWrite(text, offset, length) {
|
||||
"use strict";
|
||||
return this.write(text, offset, length, "base64url");
|
||||
}
|
||||
function hexWrite(text, offset, length) {
|
||||
"use strict";
|
||||
return this.write(text, offset, length, "hex");
|
||||
}
|
||||
|
||||
function utf8Slice(offset, length) {
|
||||
"use strict";
|
||||
return this.toString(offset, length, "utf8");
|
||||
}
|
||||
function ucs2Slice(offset, length) {
|
||||
"use strict";
|
||||
return this.toString(offset, length, "ucs2");
|
||||
}
|
||||
function utf16leSlice(offset, length) {
|
||||
"use strict";
|
||||
return this.toString(offset, length, "utf16le");
|
||||
}
|
||||
function latin1Slice(offset, length) {
|
||||
"use strict";
|
||||
return this.toString(offset, length, "latin1");
|
||||
}
|
||||
function asciiSlice(offset, length) {
|
||||
"use strict";
|
||||
return this.toString(offset, length, "ascii");
|
||||
}
|
||||
function base64Slice(offset, length) {
|
||||
"use strict";
|
||||
return this.toString(offset, length, "base64");
|
||||
}
|
||||
function base64urlSlice(offset, length) {
|
||||
"use strict";
|
||||
return this.toString(offset, length, "base64url");
|
||||
}
|
||||
function hexSlice(offset, length) {
|
||||
"use strict";
|
||||
return this.toString(offset, length, "hex");
|
||||
}
|
||||
|
||||
function toJSON() {
|
||||
"use strict";
|
||||
const type = "Buffer";
|
||||
const data = @Array.from(this);
|
||||
return { type, data };
|
||||
}
|
||||
|
||||
function initializeBunBuffer(parameters)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//-- AUTOGENERATED FILE -- 1650803913
|
||||
//-- AUTOGENERATED FILE -- 1651208705
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -218,4 +218,17 @@ extern "C" int64_t Bun__encoding__writeUTF16AsUTF8(const UChar* ptr, size_t len,
|
||||
extern "C" int64_t Bun__encoding__writeLatin1AsASCII(const unsigned char* ptr, size_t len, unsigned char* to, size_t other_len);
|
||||
extern "C" int64_t Bun__encoding__writeUTF16AsASCII(const UChar* ptr, size_t len, unsigned char* to, size_t other_len);
|
||||
|
||||
extern "C" int64_t Bun__encoding__constructFromLatin1AsHex(void*, const unsigned char* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromUTF16AsHex(void*, const UChar* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromLatin1AsURLSafeBase64(void*, const unsigned char* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromUTF16AsURLSafeBase64(void*, const UChar* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromLatin1AsBase64(void*, const unsigned char* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromUTF16AsBase64(void*, const UChar* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromLatin1AsUTF16(void*, const unsigned char* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromUTF16AsUTF16(void*, const UChar* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromLatin1AsUTF8(void*, const unsigned char* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromUTF16AsUTF8(void*, const UChar* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromLatin1AsASCII(void*, const unsigned char* ptr, size_t len);
|
||||
extern "C" int64_t Bun__encoding__constructFromUTF16AsASCII(void*, const UChar* ptr, size_t len);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// clang-format: off
|
||||
//-- AUTOGENERATED FILE -- 1650803913
|
||||
//-- AUTOGENERATED FILE -- 1651208705
|
||||
#pragma once
|
||||
|
||||
#include <stddef.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
|
||||
@@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -650,6 +650,10 @@ pub const TextDecoder = struct {
|
||||
}
|
||||
};
|
||||
|
||||
/// This code is incredibly redundant
|
||||
/// We have different paths for creaitng a new buffer versus writing into an existing one
|
||||
/// That's mostly why all the duplication
|
||||
/// The majority of the business logic here is just shooting it off to the optimized functions
|
||||
pub const Encoder = struct {
|
||||
export fn Bun__encoding__writeLatin1AsHex(input: [*]const u8, len: usize, to: [*]u8, to_len: usize) i64 {
|
||||
return writeU8(input, len, to, to_len, .hex);
|
||||
@@ -688,6 +692,55 @@ pub const Encoder = struct {
|
||||
return writeU8(input, len, to, to_len, .ascii);
|
||||
}
|
||||
|
||||
export fn Bun__encoding__constructFromLatin1AsHex(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
|
||||
var slice = constructFromU8(input, len, .hex);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromLatin1AsASCII(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
|
||||
var slice = constructFromU8(input, len, .ascii);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromLatin1AsURLSafeBase64(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
|
||||
var slice = constructFromU8(input, len, .base64url);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromLatin1AsUTF16(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
|
||||
var slice = constructFromU8(input, len, .utf16le);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromLatin1AsUTF8(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
|
||||
var slice = constructFromU8(input, len, JSC.Node.Encoding.utf8);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromLatin1AsBase64(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
|
||||
var slice = constructFromU8(input, len, .base64);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromUTF16AsBase64(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
|
||||
var slice = constructFromU16(input, len, .base64);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromUTF16AsHex(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
|
||||
var slice = constructFromU16(input, len, .hex);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromUTF16AsURLSafeBase64(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
|
||||
var slice = constructFromU16(input, len, .base64url);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromUTF16AsUTF16(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
|
||||
var slice = constructFromU16(input, len, JSC.Node.Encoding.utf16le);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromUTF16AsUTF8(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
|
||||
var slice = constructFromU16(input, len, .utf8);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
export fn Bun__encoding__constructFromUTF16AsASCII(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
|
||||
var slice = constructFromU16(input, len, .utf8);
|
||||
return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
|
||||
}
|
||||
|
||||
export fn Bun__encoding__toStringUTF16(input: [*]const u8, len: usize, globalObject: *JSC.JSGlobalObject) JSValue {
|
||||
return toString(input, len, globalObject, JSC.Node.Encoding.utf16le);
|
||||
}
|
||||
@@ -867,7 +920,8 @@ pub const Encoder = struct {
|
||||
}
|
||||
|
||||
pub fn writeU16(input: [*]const u16, len: usize, to: [*]u8, to_len: usize, comptime encoding: JSC.Node.Encoding) i64 {
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
// TODO: increase temporary buffer size for larger amounts of data
|
||||
// defer {
|
||||
// if (comptime encoding.isBinaryToText()) {}
|
||||
@@ -880,7 +934,7 @@ pub const Encoder = struct {
|
||||
return @intCast(i32, strings.copyUTF16IntoUTF8(to[0..to_len], []const u16, input[0..len]).written);
|
||||
},
|
||||
// string is already encoded, just need to copy the data
|
||||
JSC.Node.Encoding.ascii, JSC.Node.Encoding.ucs2, JSC.Node.Encoding.buffer, JSC.Node.Encoding.utf16le => {
|
||||
.latin1, JSC.Node.Encoding.ascii, JSC.Node.Encoding.ucs2, JSC.Node.Encoding.buffer, JSC.Node.Encoding.utf16le => {
|
||||
strings.copyU16IntoU8(to[0..to_len], []const u16, input[0..len]);
|
||||
|
||||
return @intCast(i64, @minimum(len, to_len));
|
||||
@@ -900,60 +954,142 @@ pub const Encoder = struct {
|
||||
defer bun.default_allocator.free(transcoded);
|
||||
return writeU8(transcoded.ptr, transcoded.len, to, to_len, encoding);
|
||||
},
|
||||
else => return 0,
|
||||
// else => return &[_]u8{};
|
||||
}
|
||||
}
|
||||
// pub fn writeU8(input: [*]const u8, len: usize, to: [*]u8, to_len: usize, comptime encoding: JSC.Node.Encoding) callconv(.C) i32 {}
|
||||
|
||||
// pub fn toUTF8FromU16(comptime Slice: type, slice: Slice, out_ptr: *[*]u8) i32 {
|
||||
// var out = strings.toUTF8AllocWithType(
|
||||
// default_allocator,
|
||||
// Slice,
|
||||
// slice,
|
||||
// ) catch {
|
||||
// return -1;
|
||||
// };
|
||||
// out_ptr.* = out.ptr;
|
||||
// return @intCast(isize, out.len);
|
||||
// }
|
||||
pub fn constructFromU8(input: [*]const u8, len: usize, comptime encoding: JSC.Node.Encoding) []u8 {
|
||||
if (len == 0)
|
||||
return &[_]u8{};
|
||||
|
||||
// pub fn toUTF8FromLatin1(comptime Slice: type, slice: Slice, out_ptr: *[*]u8) i32 {
|
||||
// var latin1 = strings.allocateLatin1IntoUTF8(default_allocator, Slice, slice) catch return -1;
|
||||
// out_ptr.* = latin1.ptr;
|
||||
// return @intCast(isize, latin1.len);
|
||||
// }
|
||||
const allocator = VirtualMachine.vm.allocator;
|
||||
|
||||
// pub fn toUTF16FromLatin1(comptime Slice: type, slice: Slice, out_ptr: *[*]u8) i32 {
|
||||
// var latin1 = strings.toUTF(default_allocator, Slice, slice) catch return -1;
|
||||
// out_ptr.* = latin1.ptr;
|
||||
// return @intCast(isize, latin1.len);
|
||||
// }
|
||||
switch (comptime encoding) {
|
||||
JSC.Node.Encoding.buffer => {
|
||||
var to = allocator.alloc(u8, len) catch return &[_]u8{};
|
||||
@memcpy(to.ptr, input, len);
|
||||
|
||||
// pub fn toUTF16FromU8(slice: []const u8, out_ptr: *[*]u16) i32 {
|
||||
// if (strings.toUTF16Alloc(default_allocator, slice, true)) |result_| {
|
||||
// if (result_) |result| {
|
||||
// out_ptr.* = result.ptr;
|
||||
// return @intCast(isize, result.len);
|
||||
// }
|
||||
// } else |err| {
|
||||
// switch (err) {
|
||||
// error.InvalidByteSequence => {
|
||||
// return -2;
|
||||
// },
|
||||
// error.OutOfMemory => {
|
||||
// return -1;
|
||||
// },
|
||||
// else => {
|
||||
// return -3;
|
||||
// },
|
||||
// }
|
||||
// }
|
||||
return to;
|
||||
},
|
||||
.latin1, .ascii => {
|
||||
var to = allocator.alloc(u8, len) catch return &[_]u8{};
|
||||
@memcpy(to.ptr, input, len);
|
||||
|
||||
// Hoping this gets auto vectorized
|
||||
for (to[0..len]) |c, i| {
|
||||
to[i] = @as(u8, @truncate(u7, c));
|
||||
}
|
||||
|
||||
return to;
|
||||
},
|
||||
.utf8 => {
|
||||
// need to encode
|
||||
return strings.allocateLatin1IntoUTF8(allocator, []const u8, input[0..len]) catch return &[_]u8{};
|
||||
},
|
||||
// encode latin1 into UTF16
|
||||
// return as bytes
|
||||
JSC.Node.Encoding.ucs2, JSC.Node.Encoding.utf16le => {
|
||||
var to = allocator.alloc(u16, len) catch return &[_]u8{};
|
||||
_ = strings.copyLatin1IntoUTF16([]u16, to, []const u8, input[0..len]);
|
||||
return std.mem.sliceAsBytes(to[0..len]);
|
||||
},
|
||||
|
||||
JSC.Node.Encoding.hex => {
|
||||
if (len < 2)
|
||||
return &[_]u8{};
|
||||
|
||||
var to = allocator.alloc(u8, len / 2) catch return &[_]u8{};
|
||||
return to[0..strings.decodeHexToBytes(to, u8, input[0..len])];
|
||||
},
|
||||
|
||||
JSC.Node.Encoding.base64url => {
|
||||
var slice = strings.trim(input[0..len], "\r\n\t " ++ [_]u8{std.ascii.control_code.VT});
|
||||
if (slice.len == 0)
|
||||
return &[_]u8{};
|
||||
|
||||
if (strings.eqlComptime(slice[slice.len - 2 ..][0..2], "==")) {
|
||||
slice = slice[0 .. slice.len - 2];
|
||||
} else if (slice[slice.len - 1] == '=') {
|
||||
slice = slice[0 .. slice.len - 1];
|
||||
}
|
||||
|
||||
const to_len = bun.base64.urlsafe.decoder.calcSizeForSlice(slice) catch unreachable;
|
||||
var to = allocator.alloc(u8, to_len) catch return &[_]u8{};
|
||||
|
||||
const wrote = bun.base64.urlsafe.decode(to[0..to_len], slice) catch |err| brk: {
|
||||
if (err == error.NoSpaceLeft) {
|
||||
break :brk to_len;
|
||||
}
|
||||
|
||||
return &[_]u8{};
|
||||
};
|
||||
return to[0..wrote];
|
||||
},
|
||||
|
||||
JSC.Node.Encoding.base64 => {
|
||||
var slice = strings.trim(input[0..len], "\r\n\t " ++ [_]u8{std.ascii.control_code.VT});
|
||||
var outlen = bun.base64.decodeLen(slice);
|
||||
|
||||
var to = allocator.alloc(u8, outlen) catch return &[_]u8{};
|
||||
const written = bun.base64.decode(to[0..outlen], slice).written;
|
||||
return to[0..written];
|
||||
},
|
||||
// else => return 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn constructFromU16(input: [*]const u16, len: usize, comptime encoding: JSC.Node.Encoding) []u8 {
|
||||
if (len == 0)
|
||||
return &[_]u8{};
|
||||
|
||||
const allocator = VirtualMachine.vm.allocator;
|
||||
|
||||
switch (comptime encoding) {
|
||||
.utf8 => {
|
||||
return strings.toUTF8AllocWithType(allocator, []const u16, input[0..len]) catch return &[_]u8{};
|
||||
},
|
||||
JSC.Node.Encoding.latin1, JSC.Node.Encoding.buffer, JSC.Node.Encoding.ascii => {
|
||||
var to = allocator.alloc(u8, len) catch return &[_]u8{};
|
||||
@memcpy(to.ptr, input, len);
|
||||
for (to[0..len]) |c, i| {
|
||||
to[i] = @as(u8, @truncate(u7, c));
|
||||
}
|
||||
|
||||
return to;
|
||||
},
|
||||
// string is already encoded, just need to copy the data
|
||||
JSC.Node.Encoding.ucs2, JSC.Node.Encoding.utf16le => {
|
||||
var to = std.mem.sliceAsBytes(allocator.alloc(u16, len * 2) catch return &[_]u8{});
|
||||
@memcpy(to.ptr, std.mem.sliceAsBytes(input[0..len]).ptr, std.mem.sliceAsBytes(input[0..len]).len);
|
||||
return to;
|
||||
},
|
||||
|
||||
JSC.Node.Encoding.hex => {
|
||||
var to = allocator.alloc(u8, len * 2) catch return &[_]u8{};
|
||||
return to[0..strings.decodeHexToBytes(to, u16, input[0..len])];
|
||||
},
|
||||
|
||||
JSC.Node.Encoding.base64 => {
|
||||
|
||||
// very very slow case!
|
||||
// shouldn't really happen though
|
||||
var transcoded = strings.toUTF8Alloc(allocator, input[0..len]) catch return &[_]u8{};
|
||||
defer allocator.free(transcoded);
|
||||
return constructFromU8(transcoded.ptr, transcoded.len, .base64);
|
||||
},
|
||||
|
||||
JSC.Node.Encoding.base64url => {
|
||||
|
||||
// very very slow case!
|
||||
// shouldn't really happen though
|
||||
var transcoded = strings.toUTF8Alloc(allocator, input[0..len]) catch return &[_]u8{};
|
||||
defer allocator.free(transcoded);
|
||||
return constructFromU8(transcoded.ptr, transcoded.len, .base64url);
|
||||
},
|
||||
// else => return 0,
|
||||
}
|
||||
}
|
||||
|
||||
// var out = default_allocator.alloc(u16, slice.len) catch return -1;
|
||||
// strings.copyU8IntoU16(out, slice);
|
||||
// out_ptr.* = out.ptr;
|
||||
// return @intCast(isize, out.len);
|
||||
// }
|
||||
comptime {
|
||||
if (!JSC.is_bindgen) {
|
||||
_ = Bun__encoding__writeLatin1AsHex;
|
||||
@@ -976,6 +1112,19 @@ pub const Encoder = struct {
|
||||
_ = Bun__encoding__toStringHex;
|
||||
_ = Bun__encoding__toStringBase64;
|
||||
_ = Bun__encoding__toStringURLSafeBase64;
|
||||
|
||||
_ = Bun__encoding__constructFromLatin1AsHex;
|
||||
_ = Bun__encoding__constructFromLatin1AsASCII;
|
||||
_ = Bun__encoding__constructFromLatin1AsURLSafeBase64;
|
||||
_ = Bun__encoding__constructFromLatin1AsUTF16;
|
||||
_ = Bun__encoding__constructFromLatin1AsUTF8;
|
||||
_ = Bun__encoding__constructFromLatin1AsBase64;
|
||||
_ = Bun__encoding__constructFromUTF16AsBase64;
|
||||
_ = Bun__encoding__constructFromUTF16AsHex;
|
||||
_ = Bun__encoding__constructFromUTF16AsURLSafeBase64;
|
||||
_ = Bun__encoding__constructFromUTF16AsUTF16;
|
||||
_ = Bun__encoding__constructFromUTF16AsUTF8;
|
||||
_ = Bun__encoding__constructFromUTF16AsASCII;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ pub const API = struct {
|
||||
pub const Router = @import("./javascript/jsc/api/router.zig");
|
||||
pub const ServerConfig = @import("./javascript/jsc/api/server.zig").ServerConfig;
|
||||
};
|
||||
pub const FFI = @import("./javascript/jsc/api/ffi.zig").FFI;
|
||||
pub const Node = struct {
|
||||
pub usingnamespace @import("./javascript/jsc/node/types.zig");
|
||||
pub usingnamespace @import("./javascript/jsc/node/node_fs.zig");
|
||||
|
||||
30
tcc.zig
Normal file
30
tcc.zig
Normal file
@@ -0,0 +1,30 @@
|
||||
pub const TCCState = opaque {};
|
||||
pub const TCCErrorFunc = ?fn (?*anyopaque, [*c]const u8) callconv(.C) void;
|
||||
pub extern fn tcc_new() ?*TCCState;
|
||||
pub extern fn tcc_delete(s: *TCCState) void;
|
||||
pub extern fn tcc_set_lib_path(s: *TCCState, path: [*c]const u8) void;
|
||||
pub extern fn tcc_set_error_func(s: *TCCState, error_opaque: ?*anyopaque, error_func: TCCErrorFunc) void;
|
||||
pub extern fn tcc_get_error_func(s: *TCCState) TCCErrorFunc;
|
||||
pub extern fn tcc_get_error_opaque(s: *TCCState) ?*anyopaque;
|
||||
pub extern fn tcc_set_options(s: *TCCState, str: [*c]const u8) void;
|
||||
pub extern fn tcc_add_include_path(s: *TCCState, pathname: [*c]const u8) c_int;
|
||||
pub extern fn tcc_add_sysinclude_path(s: *TCCState, pathname: [*c]const u8) c_int;
|
||||
pub extern fn tcc_define_symbol(s: *TCCState, sym: [*c]const u8, value: [*c]const u8) void;
|
||||
pub extern fn tcc_undefine_symbol(s: *TCCState, sym: [*c]const u8) void;
|
||||
pub extern fn tcc_add_file(s: *TCCState, filename: [*c]const u8) c_int;
|
||||
pub extern fn tcc_compile_string(s: *TCCState, buf: [*c]const u8) c_int;
|
||||
pub extern fn tcc_set_output_type(s: *TCCState, output_type: c_int) c_int;
|
||||
pub extern fn tcc_add_library_path(s: *TCCState, pathname: [*c]const u8) c_int;
|
||||
pub extern fn tcc_add_library(s: *TCCState, libraryname: [*c]const u8) c_int;
|
||||
pub extern fn tcc_add_symbol(s: *TCCState, name: [*c]const u8, val: ?*const anyopaque) c_int;
|
||||
pub extern fn tcc_output_file(s: *TCCState, filename: [*c]const u8) c_int;
|
||||
pub extern fn tcc_run(s: *TCCState, argc: c_int, argv: [*c][*c]u8) c_int;
|
||||
pub extern fn tcc_relocate(s1: *TCCState, ptr: ?*anyopaque) c_int;
|
||||
pub extern fn tcc_get_symbol(s: *TCCState, name: [*c]const u8) ?*anyopaque;
|
||||
pub extern fn tcc_list_symbols(s: *TCCState, ctx: ?*anyopaque, symbol_cb: ?fn (?*anyopaque, [*c]const u8, ?*const anyopaque) callconv(.C) void) void;
|
||||
pub const TCC_OUTPUT_MEMORY = @as(c_int, 1);
|
||||
pub const TCC_OUTPUT_EXE = @as(c_int, 2);
|
||||
pub const TCC_OUTPUT_DLL = @as(c_int, 3);
|
||||
pub const TCC_OUTPUT_OBJ = @as(c_int, 4);
|
||||
pub const TCC_OUTPUT_PREPROCESS = @as(c_int, 5);
|
||||
pub const TCC_RELOCATE_AUTO = @import("std").zig.c_translation.cast(?*anyopaque, @as(c_int, 1));
|
||||
Reference in New Issue
Block a user