diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/javascript/jsc/bindings/BunBuiltinNames.h | 88 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/JSCInlines.h | 2 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/bindings-generator.zig | 50 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers-cpp.h | 2 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers.h | 489 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers.zig | 9 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/helpers.h | 1 |
7 files changed, 363 insertions, 278 deletions
diff --git a/src/javascript/jsc/bindings/BunBuiltinNames.h b/src/javascript/jsc/bindings/BunBuiltinNames.h index 9619f62a6..708a37381 100644 --- a/src/javascript/jsc/bindings/BunBuiltinNames.h +++ b/src/javascript/jsc/bindings/BunBuiltinNames.h @@ -20,66 +20,66 @@ using namespace JSC; #define BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \ - macro(filePath) \ - macro(syscall) \ - macro(errno) \ - macro(code) \ - macro(path) \ - macro(dir) \ - macro(versions) \ + macro(addEventListener) \ macro(argv) \ - macro(execArgv) \ - macro(nextTick) \ - macro(version) \ - macro(title) \ - macro(pid) \ - macro(ppid) \ + macro(basename) \ macro(chdir) \ - macro(cwd) \ - macro(process) \ - macro(map) \ - macro(addEventListener) \ - macro(removeEventListener) \ - macro(prependEventListener) \ - macro(write) \ - macro(end) \ macro(close) \ - macro(destroy) \ + macro(code) \ + macro(connect) \ macro(cork) \ - macro(uncork) \ - macro(isPaused) \ - macro(read) \ - macro(pipe) \ - macro(unpipe) \ - macro(once) \ - macro(on) \ - macro(unshift) \ - macro(resume) \ - macro(pause) \ - macro(basename) \ + macro(cwd) \ + macro(delimiter) \ + macro(destroy) \ + macro(dir) \ macro(dirname) \ - macro(file) \ + macro(end) \ + macro(errno) \ + macro(execArgv) \ macro(extname) \ + macro(file) \ + macro(filePath) \ macro(format) \ + macro(get) \ macro(isAbsolute) \ + macro(isPaused) \ + macro(isWindows) \ macro(join) \ + macro(map) \ + macro(nextTick) \ macro(normalize) \ + macro(on) \ + macro(once) \ + macro(options) \ macro(parse) \ + macro(patch) \ + macro(path) \ + macro(pause) \ + macro(pid) \ + macro(pipe) \ + macro(port) \ + macro(post) \ + macro(ppid) \ + macro(prependEventListener) \ + macro(process) \ + macro(put) \ + macro(read) \ macro(relative) \ + macro(removeEventListener) \ macro(resolve) \ - macro(url) \ + macro(resume) \ macro(sep) \ - macro(delimiter) \ + macro(syscall) \ + macro(title) \ macro(toNamespacedPath) \ - macro(isWindows) \ - macro(get) \ - macro(put) \ - macro(post) \ - macro(patch) \ macro(trace) \ - macro(connect) \ - macro(options) \ - macro(port) \ + macro(uncork) \ + macro(unpipe) \ + macro(unshift) \ + macro(url) \ + macro(version) \ + macro(versions) \ + macro(write) \ BUN_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) \ class BunBuiltinNames { diff --git a/src/javascript/jsc/bindings/JSCInlines.h b/src/javascript/jsc/bindings/JSCInlines.h index f45088ecc..8e989aa6a 100644 --- a/src/javascript/jsc/bindings/JSCInlines.h +++ b/src/javascript/jsc/bindings/JSCInlines.h @@ -20,7 +20,7 @@ * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once diff --git a/src/javascript/jsc/bindings/bindings-generator.zig b/src/javascript/jsc/bindings/bindings-generator.zig index 4fbfd413a..4e44fb9c0 100644 --- a/src/javascript/jsc/bindings/bindings-generator.zig +++ b/src/javascript/jsc/bindings/bindings-generator.zig @@ -15,19 +15,49 @@ const Allocator = std.mem.Allocator; pub const bindgen = true; +const JSC = @import("../../../jsc.zig"); + +const Classes = JSC.GlobalClasses; + pub fn main() anyerror!void { var allocator = std.heap.c_allocator; const src: std.builtin.SourceLocation = @src(); - const paths = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, "headers.h" }; - const paths2 = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, "headers-cpp.h" }; + { + const paths = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, "headers.h" }; + const paths2 = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, "headers-cpp.h" }; - const cpp = try std.fs.createFileAbsolute(try std.fs.path.join(allocator, &paths2), .{}); - const file = try std.fs.createFileAbsolute(try std.fs.path.join(allocator, &paths), .{}); + const cpp = try std.fs.createFileAbsolute(try std.fs.path.join(allocator, &paths2), .{}); + const file = try std.fs.createFileAbsolute(try std.fs.path.join(allocator, &paths), .{}); - const HeaderGenerator = HeaderGen( - Bindings, - Exports, - "src/javascript/jsc/bindings/bindings.zig", - ); - HeaderGenerator.exec(HeaderGenerator{}, file, cpp); + const HeaderGenerator = HeaderGen( + Bindings, + Exports, + "src/javascript/jsc/bindings/bindings.zig", + ); + HeaderGenerator.exec(HeaderGenerator{}, file, cpp); + } + // TODO: finish this + const use_cpp_generator = false; + if (use_cpp_generator) { + comptime var i: usize = 0; + inline while (i < Classes.len) : (i += 1) { + const Class = Classes[i]; + const paths = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, Class.name ++ ".generated.h" }; + var headerFilePath = try std.fs.path.join( + allocator, + &paths, + ); + var implFilePath = try std.fs.path.join( + allocator, + &[_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, Class.name ++ ".generated.cpp" }, + ); + var headerFile = try std.fs.createFileAbsolute(headerFilePath, .{}); + var header_writer = headerFile.writer(); + var implFile = try std.fs.createFileAbsolute(implFilePath, .{}); + try Class.@"generateC++Header"(header_writer); + try Class.@"generateC++Class"(implFile.writer()); + headerFile.close(); + implFile.close(); + } + } } diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h index 421914228..4375e000e 100644 --- a/src/javascript/jsc/bindings/headers-cpp.h +++ b/src/javascript/jsc/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1648033260 +//-- AUTOGENERATED FILE -- 1648167213 // clang-format off #pragma once diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h index d04a3dc67..369f34ad9 100644 --- a/src/javascript/jsc/bindings/headers.h +++ b/src/javascript/jsc/bindings/headers.h @@ -1,17 +1,17 @@ // clang-format: off -//-- AUTOGENERATED FILE -- 1648033260 +//-- AUTOGENERATED FILE -- 1648167213 #pragma once +#include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdbool.h> #ifdef __cplusplus - #define AUTO_EXTERN_C extern "C" - #define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak)) +#define AUTO_EXTERN_C extern "C" +#define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak)) #else - #define AUTO_EXTERN_C - #define AUTO_EXTERN_C_ZIG __attribute__((weak)) +#define AUTO_EXTERN_C +#define AUTO_EXTERN_C_ZIG __attribute__((weak)) #endif #define ZIG_DECL AUTO_EXTERN_C_ZIG #define CPP_DECL AUTO_EXTERN_C @@ -26,232 +26,279 @@ typedef void* JSClassRef; #include <JavaScriptCore/JSClassRef.h> #endif #include "headers-handwritten.h" - typedef struct bJSC__SourceCode { unsigned char bytes[24]; } bJSC__SourceCode; - typedef char* bJSC__SourceCode_buf; - typedef struct bWTF__URL { unsigned char bytes[40]; } bWTF__URL; - typedef char* bWTF__URL_buf; - typedef struct bJSC__JSModuleRecord { unsigned char bytes[216]; } bJSC__JSModuleRecord; - typedef char* bJSC__JSModuleRecord_buf; - typedef struct bJSC__ThrowScope { unsigned char bytes[8]; } bJSC__ThrowScope; - typedef char* bJSC__ThrowScope_buf; - typedef struct bJSC__CallFrame { unsigned char bytes[8]; } bJSC__CallFrame; - typedef char* bJSC__CallFrame_buf; - typedef struct bJSC__JSFunction { unsigned char bytes[32]; } bJSC__JSFunction; - typedef char* bJSC__JSFunction_buf; - typedef struct bJSC__PropertyName { unsigned char bytes[8]; } bJSC__PropertyName; - typedef char* bJSC__PropertyName_buf; - typedef struct bJSC__JSGlobalObject { unsigned char bytes[2400]; } bJSC__JSGlobalObject; - typedef char* bJSC__JSGlobalObject_buf; - typedef struct bJSC__JSCell { unsigned char bytes[8]; } bJSC__JSCell; - typedef char* bJSC__JSCell_buf; - typedef struct bJSC__CatchScope { unsigned char bytes[8]; } bJSC__CatchScope; - typedef char* bJSC__CatchScope_buf; - typedef struct bWTF__String { unsigned char bytes[8]; } bWTF__String; - typedef char* bWTF__String_buf; - typedef struct bWTF__StringView { unsigned char bytes[16]; } bWTF__StringView; - typedef char* bWTF__StringView_buf; - typedef struct bJSC__JSModuleLoader { unsigned char bytes[16]; } bJSC__JSModuleLoader; - typedef char* bJSC__JSModuleLoader_buf; - typedef struct bInspector__ScriptArguments { unsigned char bytes[32]; } bInspector__ScriptArguments; - typedef char* bInspector__ScriptArguments_buf; - typedef struct bJSC__Exception { unsigned char bytes[40]; } bJSC__Exception; - typedef char* bJSC__Exception_buf; - typedef struct bJSC__VM { unsigned char bytes[48824]; } bJSC__VM; - typedef char* bJSC__VM_buf; - typedef struct bJSC__JSString { unsigned char bytes[16]; } bJSC__JSString; - typedef char* bJSC__JSString_buf; - typedef struct bJSC__SourceOrigin { unsigned char bytes[48]; } bJSC__SourceOrigin; - typedef char* bJSC__SourceOrigin_buf; - typedef struct bWTF__ExternalStringImpl { unsigned char bytes[32]; } bWTF__ExternalStringImpl; - typedef char* bWTF__ExternalStringImpl_buf; - typedef struct bJSC__JSInternalPromise { unsigned char bytes[32]; } bJSC__JSInternalPromise; - typedef char* bJSC__JSInternalPromise_buf; - typedef struct bWTF__StringImpl { unsigned char bytes[24]; } bWTF__StringImpl; - typedef char* bWTF__StringImpl_buf; - typedef struct bJSC__JSPromise { unsigned char bytes[32]; } bJSC__JSPromise; - typedef char* bJSC__JSPromise_buf; - typedef struct bJSC__JSObject { unsigned char bytes[16]; } bJSC__JSObject; - typedef char* bJSC__JSObject_buf; - typedef struct bJSC__Identifier { unsigned char bytes[8]; } bJSC__Identifier; - typedef char* bJSC__Identifier_buf; +typedef struct bJSC__SourceCode { + unsigned char bytes[24]; +} bJSC__SourceCode; +typedef char* bJSC__SourceCode_buf; +typedef struct bWTF__URL { + unsigned char bytes[40]; +} bWTF__URL; +typedef char* bWTF__URL_buf; +typedef struct bJSC__JSModuleRecord { + unsigned char bytes[216]; +} bJSC__JSModuleRecord; +typedef char* bJSC__JSModuleRecord_buf; +typedef struct bJSC__ThrowScope { + unsigned char bytes[8]; +} bJSC__ThrowScope; +typedef char* bJSC__ThrowScope_buf; +typedef struct bJSC__CallFrame { + unsigned char bytes[8]; +} bJSC__CallFrame; +typedef char* bJSC__CallFrame_buf; +typedef struct bJSC__JSFunction { + unsigned char bytes[32]; +} bJSC__JSFunction; +typedef char* bJSC__JSFunction_buf; +typedef struct bJSC__PropertyName { + unsigned char bytes[8]; +} bJSC__PropertyName; +typedef char* bJSC__PropertyName_buf; +typedef struct bJSC__JSGlobalObject { + unsigned char bytes[2400]; +} bJSC__JSGlobalObject; +typedef char* bJSC__JSGlobalObject_buf; +typedef struct bJSC__JSCell { + unsigned char bytes[8]; +} bJSC__JSCell; +typedef char* bJSC__JSCell_buf; +typedef struct bJSC__CatchScope { + unsigned char bytes[8]; +} bJSC__CatchScope; +typedef char* bJSC__CatchScope_buf; +typedef struct bWTF__String { + unsigned char bytes[8]; +} bWTF__String; +typedef char* bWTF__String_buf; +typedef struct bWTF__StringView { + unsigned char bytes[16]; +} bWTF__StringView; +typedef char* bWTF__StringView_buf; +typedef struct bJSC__JSModuleLoader { + unsigned char bytes[16]; +} bJSC__JSModuleLoader; +typedef char* bJSC__JSModuleLoader_buf; +typedef struct bInspector__ScriptArguments { + unsigned char bytes[32]; +} bInspector__ScriptArguments; +typedef char* bInspector__ScriptArguments_buf; +typedef struct bJSC__Exception { + unsigned char bytes[40]; +} bJSC__Exception; +typedef char* bJSC__Exception_buf; +typedef struct bJSC__VM { + unsigned char bytes[48824]; +} bJSC__VM; +typedef char* bJSC__VM_buf; +typedef struct bJSC__JSString { + unsigned char bytes[16]; +} bJSC__JSString; +typedef char* bJSC__JSString_buf; +typedef struct bJSC__SourceOrigin { + unsigned char bytes[48]; +} bJSC__SourceOrigin; +typedef char* bJSC__SourceOrigin_buf; +typedef struct bWTF__ExternalStringImpl { + unsigned char bytes[32]; +} bWTF__ExternalStringImpl; +typedef char* bWTF__ExternalStringImpl_buf; +typedef struct bJSC__JSInternalPromise { + unsigned char bytes[32]; +} bJSC__JSInternalPromise; +typedef char* bJSC__JSInternalPromise_buf; +typedef struct bWTF__StringImpl { + unsigned char bytes[24]; +} bWTF__StringImpl; +typedef char* bWTF__StringImpl_buf; +typedef struct bJSC__JSPromise { + unsigned char bytes[32]; +} bJSC__JSPromise; +typedef char* bJSC__JSPromise_buf; +typedef struct bJSC__JSObject { + unsigned char bytes[16]; +} bJSC__JSObject; +typedef char* bJSC__JSObject_buf; +typedef struct bJSC__Identifier { + unsigned char bytes[8]; +} bJSC__Identifier; +typedef char* bJSC__Identifier_buf; #ifndef __cplusplus - typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope - typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype - typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype - typedef ErrorableResolvedSource ErrorableResolvedSource; - typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype - typedef ErrorableZigString ErrorableZigString; - typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName - typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject - typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl - typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype - typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader - typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype - typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype - typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier - typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype - typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback - typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise - typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype - typedef SystemError SystemError; - typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell - typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin - typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord - typedef bWTF__String WTF__String; // WTF::String - typedef bWTF__URL WTF__URL; // WTF::URL - typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype - typedef Bun__Readable Bun__Readable; - typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise - typedef Bun__Writable Bun__Writable; - typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype - typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame - typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype - typedef bWTF__StringView WTF__StringView; // WTF::StringView - typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope - typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl - typedef bJSC__VM JSC__VM; // JSC::VM - typedef JSClassRef JSClassRef; - typedef Bun__ArrayBuffer Bun__ArrayBuffer; - typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject - typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction - typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype - typedef ZigException ZigException; - typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode - typedef uint64_t JSC__JSValue; - typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype - typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype - typedef ZigString ZigString; - typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype - typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments - typedef bJSC__Exception JSC__Exception; // JSC::Exception - typedef bJSC__JSString JSC__JSString; // JSC::JSString - typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype - typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype +typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope +typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype +typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype +typedef ErrorableResolvedSource ErrorableResolvedSource; +typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype +typedef ErrorableZigString ErrorableZigString; +typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName +typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject +typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl +typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype +typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader +typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype +typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype +typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier +typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype +typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback +typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise +typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype +typedef SystemError SystemError; +typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell +typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin +typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord +typedef bWTF__String WTF__String; // WTF::String +typedef bWTF__URL WTF__URL; // WTF::URL +typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype +typedef Bun__Readable Bun__Readable; +typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise +typedef Bun__Writable Bun__Writable; +typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype +typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame +typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype +typedef bWTF__StringView WTF__StringView; // WTF::StringView +typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope +typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl +typedef bJSC__VM JSC__VM; // JSC::VM +typedef JSClassRef JSClassRef; +typedef Bun__ArrayBuffer Bun__ArrayBuffer; +typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject +typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction +typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype +typedef ZigException ZigException; +typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode +typedef uint64_t JSC__JSValue; +typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype +typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype +typedef ZigString ZigString; +typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype +typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments +typedef bJSC__Exception JSC__Exception; // JSC::Exception +typedef bJSC__JSString JSC__JSString; // JSC::JSString +typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype +typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype #endif #ifdef __cplusplus - namespace JSC { - class JSCell; - class Exception; - class JSPromisePrototype; - class StringPrototype; - class GeneratorFunctionPrototype; - class ArrayPrototype; - class JSString; - class JSObject; - class AsyncIteratorPrototype; - class AsyncGeneratorFunctionPrototype; - class Identifier; - class JSPromise; - class RegExpPrototype; - class AsyncFunctionPrototype; - class CatchScope; - class VM; - class BigIntPrototype; - class SourceOrigin; - class ThrowScope; - class SetIteratorPrototype; - class AsyncGeneratorPrototype; - class PropertyName; - class MapIteratorPrototype; - class JSModuleRecord; - class JSInternalPromise; - class ArrayIteratorPrototype; - class JSFunction; - class JSModuleLoader; - class GeneratorPrototype; - class JSGlobalObject; - class SourceCode; - class FunctionPrototype; - class IteratorPrototype; - class CallFrame; - class ObjectPrototype; - } - namespace WTF { - class URL; - class StringImpl; - class String; - class StringView; - class ExternalStringImpl; - } - namespace Zig { - class JSMicrotaskCallback; - } - namespace Inspector { - class ScriptArguments; - } - - typedef ErrorableResolvedSource ErrorableResolvedSource; - typedef ErrorableZigString ErrorableZigString; - typedef SystemError SystemError; - typedef Bun__Readable Bun__Readable; - typedef Bun__Writable Bun__Writable; - typedef JSClassRef JSClassRef; - typedef Bun__ArrayBuffer Bun__ArrayBuffer; - typedef ZigException ZigException; - typedef uint64_t JSC__JSValue; - typedef ZigString ZigString; - using JSC__JSCell = JSC::JSCell; - using JSC__Exception = JSC::Exception; - using JSC__JSPromisePrototype = JSC::JSPromisePrototype; - using JSC__StringPrototype = JSC::StringPrototype; - using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype; - using JSC__ArrayPrototype = JSC::ArrayPrototype; - using JSC__JSString = JSC::JSString; - using JSC__JSObject = JSC::JSObject; - using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype; - using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype; - using JSC__Identifier = JSC::Identifier; - using JSC__JSPromise = JSC::JSPromise; - using JSC__RegExpPrototype = JSC::RegExpPrototype; - using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype; - using JSC__CatchScope = JSC::CatchScope; - using JSC__VM = JSC::VM; - using JSC__BigIntPrototype = JSC::BigIntPrototype; - using JSC__SourceOrigin = JSC::SourceOrigin; - using JSC__ThrowScope = JSC::ThrowScope; - using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype; - using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype; - using JSC__PropertyName = JSC::PropertyName; - using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype; - using JSC__JSModuleRecord = JSC::JSModuleRecord; - using JSC__JSInternalPromise = JSC::JSInternalPromise; - using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype; - using JSC__JSFunction = JSC::JSFunction; - using JSC__JSModuleLoader = JSC::JSModuleLoader; - using JSC__GeneratorPrototype = JSC::GeneratorPrototype; - using JSC__JSGlobalObject = JSC::JSGlobalObject; - using JSC__SourceCode = JSC::SourceCode; - using JSC__FunctionPrototype = JSC::FunctionPrototype; - using JSC__IteratorPrototype = JSC::IteratorPrototype; - using JSC__CallFrame = JSC::CallFrame; - using JSC__ObjectPrototype = JSC::ObjectPrototype; - using WTF__URL = WTF::URL; - using WTF__StringImpl = WTF::StringImpl; - using WTF__String = WTF::String; - using WTF__StringView = WTF::StringView; - using WTF__ExternalStringImpl = WTF::ExternalStringImpl; - using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback; - using Inspector__ScriptArguments = Inspector::ScriptArguments; +namespace JSC { +class JSCell; +class Exception; +class JSPromisePrototype; +class StringPrototype; +class GeneratorFunctionPrototype; +class ArrayPrototype; +class JSString; +class JSObject; +class AsyncIteratorPrototype; +class AsyncGeneratorFunctionPrototype; +class Identifier; +class JSPromise; +class RegExpPrototype; +class AsyncFunctionPrototype; +class CatchScope; +class VM; +class BigIntPrototype; +class SourceOrigin; +class ThrowScope; +class SetIteratorPrototype; +class AsyncGeneratorPrototype; +class PropertyName; +class MapIteratorPrototype; +class JSModuleRecord; +class JSInternalPromise; +class ArrayIteratorPrototype; +class JSFunction; +class JSModuleLoader; +class GeneratorPrototype; +class JSGlobalObject; +class SourceCode; +class FunctionPrototype; +class IteratorPrototype; +class CallFrame; +class ObjectPrototype; +} +namespace WTF { +class URL; +class StringImpl; +class String; +class StringView; +class ExternalStringImpl; +} +namespace Zig { +class JSMicrotaskCallback; +} +namespace Inspector { +class ScriptArguments; +} + +typedef ErrorableResolvedSource ErrorableResolvedSource; +typedef ErrorableZigString ErrorableZigString; +typedef SystemError SystemError; +typedef Bun__Readable Bun__Readable; +typedef Bun__Writable Bun__Writable; +typedef JSClassRef JSClassRef; +typedef Bun__ArrayBuffer Bun__ArrayBuffer; +typedef ZigException ZigException; +typedef uint64_t JSC__JSValue; +typedef ZigString ZigString; +using JSC__JSCell = JSC::JSCell; +using JSC__Exception = JSC::Exception; +using JSC__JSPromisePrototype = JSC::JSPromisePrototype; +using JSC__StringPrototype = JSC::StringPrototype; +using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype; +using JSC__ArrayPrototype = JSC::ArrayPrototype; +using JSC__JSString = JSC::JSString; +using JSC__JSObject = JSC::JSObject; +using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype; +using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype; +using JSC__Identifier = JSC::Identifier; +using JSC__JSPromise = JSC::JSPromise; +using JSC__RegExpPrototype = JSC::RegExpPrototype; +using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype; +using JSC__CatchScope = JSC::CatchScope; +using JSC__VM = JSC::VM; +using JSC__BigIntPrototype = JSC::BigIntPrototype; +using JSC__SourceOrigin = JSC::SourceOrigin; +using JSC__ThrowScope = JSC::ThrowScope; +using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype; +using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype; +using JSC__PropertyName = JSC::PropertyName; +using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype; +using JSC__JSModuleRecord = JSC::JSModuleRecord; +using JSC__JSInternalPromise = JSC::JSInternalPromise; +using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype; +using JSC__JSFunction = JSC::JSFunction; +using JSC__JSModuleLoader = JSC::JSModuleLoader; +using JSC__GeneratorPrototype = JSC::GeneratorPrototype; +using JSC__JSGlobalObject = JSC::JSGlobalObject; +using JSC__SourceCode = JSC::SourceCode; +using JSC__FunctionPrototype = JSC::FunctionPrototype; +using JSC__IteratorPrototype = JSC::IteratorPrototype; +using JSC__CallFrame = JSC::CallFrame; +using JSC__ObjectPrototype = JSC::ObjectPrototype; +using WTF__URL = WTF::URL; +using WTF__StringImpl = WTF::StringImpl; +using WTF__String = WTF::String; +using WTF__StringView = WTF::StringView; +using WTF__ExternalStringImpl = WTF::ExternalStringImpl; +using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback; +using Inspector__ScriptArguments = Inspector::ScriptArguments; #endif - #pragma mark - JSC::JSObject -CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (* ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2)); +CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (*ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2)); CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0); CPP_DECL JSC__JSValue JSC__JSObject__getDirect(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, const ZigString* arg2); CPP_DECL JSC__JSValue JSC__JSObject__getIndex(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, uint32_t arg2); CPP_DECL void JSC__JSObject__putRecord(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3, size_t arg4); -CPP_DECL JSC__JSValue ZigString__external(const ZigString* arg0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(void* arg0, void* arg1, size_t arg2)); +CPP_DECL JSC__JSValue ZigString__external(const ZigString* arg0, JSC__JSGlobalObject* arg1, void* arg2, void (*ArgFn3)(void* arg0, void* arg1, size_t arg2)); CPP_DECL JSC__JSValue ZigString__to16BitValue(const ZigString* arg0, JSC__JSGlobalObject* arg1); CPP_DECL JSC__JSValue ZigString__toErrorInstance(const ZigString* arg0, JSC__JSGlobalObject* arg1); CPP_DECL JSC__JSValue ZigString__toExternalU16(const uint16_t* arg0, size_t arg1, JSC__JSGlobalObject* arg2); CPP_DECL JSC__JSValue ZigString__toExternalValue(const ZigString* arg0, JSC__JSGlobalObject* arg1); -CPP_DECL JSC__JSValue ZigString__toExternalValueWithCallback(const ZigString* arg0, JSC__JSGlobalObject* arg1, void (* ArgFn2)(void* arg0, void* arg1, size_t arg2)); +CPP_DECL JSC__JSValue ZigString__toExternalValueWithCallback(const ZigString* arg0, JSC__JSGlobalObject* arg1, void (*ArgFn2)(void* arg0, void* arg1, size_t arg2)); CPP_DECL JSC__JSValue ZigString__toValue(const ZigString* arg0, JSC__JSGlobalObject* arg1); CPP_DECL JSC__JSValue ZigString__toValueGC(const ZigString* arg0, JSC__JSGlobalObject* arg1); CPP_DECL JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0, JSC__JSGlobalObject* arg1); @@ -343,7 +390,7 @@ CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSVal CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const unsigned char* arg6); CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const unsigned char* arg4); CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const unsigned char* arg3); -CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* arg3, JSC__JSValue (* ArgFn4)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2)); +CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* arg3, JSC__JSValue (*ArgFn4)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2)); CPP_DECL bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1); CPP_DECL bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1); @@ -428,7 +475,7 @@ CPP_DECL size_t WTF__String__length(WTF__String* arg0); #pragma mark - JSC::JSValue -CPP_DECL void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, JSC__JSValue JSValue2, size_t arg3), void (* ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, JSC__JSValue JSValue2, size_t arg3)); +CPP_DECL void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (*ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, JSC__JSValue JSValue2, size_t arg3), void (*ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, JSC__JSValue JSValue2, size_t arg3)); CPP_DECL bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, Bun__ArrayBuffer* arg2); CPP_DECL JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0); CPP_DECL JSC__JSInternalPromise* JSC__JSValue__asInternalPromise(JSC__JSValue JSValue0); @@ -445,7 +492,7 @@ CPP_DECL JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject* arg0, CPP_DECL JSC__JSValue JSC__JSValue__createTypeError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2); CPP_DECL bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell* arg1); CPP_DECL bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1); -CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, void* arg2, JSC__JSValue JSValue3)); +CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (*ArgFn3)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, void* arg2, JSC__JSValue JSValue3)); CPP_DECL JSC__JSValue JSC__JSValue__fromEntries(JSC__JSGlobalObject* arg0, ZigString* arg1, ZigString* arg2, size_t arg3, bool arg4); CPP_DECL void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2); CPP_DECL JSC__JSValue JSC__JSValue__getErrorsProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); @@ -529,13 +576,13 @@ CPP_DECL JSC__JSValue JSC__Exception__value(JSC__Exception* arg0); CPP_DECL void JSC__VM__clearExecutionTimeLimit(JSC__VM* arg0); CPP_DECL JSC__VM* JSC__VM__create(unsigned char HeapType0); -CPP_DECL void JSC__VM__deferGC(JSC__VM* arg0, void* arg1, void (* ArgFn2)(void* arg0)); +CPP_DECL void JSC__VM__deferGC(JSC__VM* arg0, void* arg1, void (*ArgFn2)(void* arg0)); CPP_DECL void JSC__VM__deinit(JSC__VM* arg0, JSC__JSGlobalObject* arg1); CPP_DECL void JSC__VM__deleteAllCode(JSC__VM* arg0, JSC__JSGlobalObject* arg1); CPP_DECL void JSC__VM__doWork(JSC__VM* arg0); CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM* arg0); CPP_DECL bool JSC__VM__executionForbidden(JSC__VM* arg0); -CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (* ArgFn2)(void* arg0)); +CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (*ArgFn2)(void* arg0)); CPP_DECL bool JSC__VM__isEntered(JSC__VM* arg0); CPP_DECL bool JSC__VM__isJITEnabled(); CPP_DECL JSC__JSValue JSC__VM__runGC(JSC__VM* arg0, bool arg1); @@ -543,7 +590,7 @@ CPP_DECL void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1); CPP_DECL void JSC__VM__setExecutionTimeLimit(JSC__VM* arg0, double arg1); CPP_DECL void JSC__VM__shrinkFootprint(JSC__VM* arg0); CPP_DECL bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const unsigned char* arg3, size_t arg4); -CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (* ArgFn1)()); +CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (*ArgFn1)()); #pragma mark - JSC::ThrowScope @@ -601,7 +648,7 @@ CPP_DECL size_t WTF__StringImpl__length(const WTF__StringImpl* arg0); CPP_DECL const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0); CPP_DECL const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0); -CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (* ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2)); +CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (*ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2)); CPP_DECL bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl* arg0); CPP_DECL bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl* arg0); CPP_DECL bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl* arg0); @@ -713,7 +760,6 @@ CPP_DECL ZigException ZigException__fromException(JSC__Exception* arg0); #pragma mark - Zig::ConsoleClient - #ifdef __cplusplus ZIG_DECL void Zig__ConsoleClient__count(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); @@ -734,7 +780,6 @@ ZIG_DECL void Zig__ConsoleClient__timeStamp(void* arg0, JSC__JSGlobalObject* arg #pragma mark - Bun__Timer - #ifdef __cplusplus ZIG_DECL JSC__JSValue Bun__Timer__clearInterval(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig index 8298b8caa..509249095 100644 --- a/src/javascript/jsc/bindings/headers.zig +++ b/src/javascript/jsc/bindings/headers.zig @@ -63,6 +63,15 @@ pub const Bun__ArrayBuffer = bindings.ArrayBuffer; pub const ptrdiff_t = c_long; pub const wchar_t = c_int; +pub const __uint16_t = c_ushort; +pub const __int32_t = c_int; +pub const __uint32_t = c_uint; +pub const __int64_t = c_longlong; +pub const __uint64_t = c_ulonglong; +pub const __mbstate_t = extern union { + __mbstate8: [128]u8, + _mbstateL: c_longlong, +}; pub const JSC__GeneratorPrototype = struct_JSC__GeneratorPrototype; diff --git a/src/javascript/jsc/bindings/helpers.h b/src/javascript/jsc/bindings/helpers.h index 11d728ac5..fc9174a38 100644 --- a/src/javascript/jsc/bindings/helpers.h +++ b/src/javascript/jsc/bindings/helpers.h @@ -108,6 +108,7 @@ static bool isTaggedExternalPtr(const unsigned char* ptr) return (reinterpret_cast<uintptr_t>(ptr) & (static_cast<uint64_t>(1) << 62)) != 0; } +// Switching to AtomString doesn't yield a perf benefit because we're recreating it each time. static const WTF::String toString(ZigString str) { if (str.len == 0 || str.ptr == nullptr) { |