diff options
author | 2021-07-21 02:07:07 -0700 | |
---|---|---|
committer | 2021-07-21 02:07:07 -0700 | |
commit | a8a4f280469d4d3baf8ea6e9dbce9ec06bd3d868 (patch) | |
tree | 8a10690daafe99a8d908119f9bb855cd0f3d368a | |
parent | f2ea2027300949b919f9d595ce3039c8bc82d21a (diff) | |
download | bun-a8a4f280469d4d3baf8ea6e9dbce9ec06bd3d868.tar.gz bun-a8a4f280469d4d3baf8ea6e9dbce9ec06bd3d868.tar.zst bun-a8a4f280469d4d3baf8ea6e9dbce9ec06bd3d868.zip |
most of the bindings!
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | .vscode/c_cpp_properties.json | 14 | ||||
-rw-r--r-- | .vscode/settings.json | 13 | ||||
-rw-r--r-- | Makefile | 31 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/DefaultGlobal.cpp | 144 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/DefaultGlobal.zig | 1623 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/ZigGlobalObject.h | 65 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/bindings-generator.zig | 5 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/bindings.cpp | 510 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/bindings.zig | 1856 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/header-gen.zig | 559 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers-cpp.h | 194 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers.h | 804 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/sizes.zig | 38 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/static_export.zig | 8 | ||||
-rw-r--r-- | src/javascript/jsc/headergen/sizegen.cpp | 40 |
17 files changed, 3656 insertions, 2253 deletions
diff --git a/.gitignore b/.gitignore index 09eed84b8..7cfa806b2 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ outdir/ outcss .next txt.js -.idea
\ No newline at end of file +.idea +.vscode/cpp*
\ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 322f70c27..55a36b9e9 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -7,10 +7,10 @@ ], "includePath": [ "${workspaceFolder}/src/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/", - "${workspaceFolder}/src/JavaScript/jsc/WebKit/WebKitBuild/Release/WTF/Headers/**", + "${workspaceFolder}/src/JavaScript/jsc/WebKit/WebKitBuild/Release/WTF/Headers", "${workspaceFolder}/src/JavaScript/jsc/WebKit/WebKitBuild/Release/*", - "${workspaceFolder}/src/JavaScript/jsc/bindings/**", - "${workspaceFolder}/src/JavaScript/jsc/WebKit/Source/bmalloc/**", + "${workspaceFolder}/src/JavaScript/jsc/bindings/", + "${workspaceFolder}/src/JavaScript/jsc/WebKit/Source/bmalloc/", "${workspaceFolder}/src/javascript/jsc/WebKit/WebKitBuild/Release/ICU/Headers/" ], "browse": { @@ -24,7 +24,7 @@ "${workspaceFolder}/src/javascript/jsc/WebKit/WebKitBuild/Release/ICU/Headers/" ], "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" + "databaseFilename": ".vscode/cppdb" }, "defines": [ "STATICALLY_LINKED_WITH_JavaScriptCore=1", @@ -33,12 +33,14 @@ "NOMINMAX", "ENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0", "BUILDING_JSCONLY__", - "USE_FOUNDATION=1" + "USE_FOUNDATION=1", + "ASSERT_ENABLED=0", + "DU_DISABLE_RENAMING=1" ], "macFrameworkPath": [], "compilerPath": "/usr/local/opt/llvm/bin/clang", "cStandard": "c17", - "cppStandard": "c++17", + "cppStandard": "c++11", "intelliSenseMode": "macos-clang-x64" } ], diff --git a/.vscode/settings.json b/.vscode/settings.json index f1aa752e1..1b1f98485 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -29,6 +29,17 @@ }, "files.associations": { "*.idl": "cpp", - "memory": "cpp" + "memory": "cpp", + "iostream": "cpp", + "algorithm": "cpp", + "random": "cpp", + "ios": "cpp", + "filesystem": "cpp", + "__locale": "cpp", + "type_traits": "cpp", + "__mutex_base": "cpp", + "__string": "cpp", + "string": "cpp", + "string_view": "cpp" } } @@ -8,11 +8,14 @@ jsc: jsc-build jsc-bindings jsc-build: jsc-build-mac jsc-bindings: jsc-bindings-headers + jsc-bindings-mac + jsc-bindings-headers: zig build headers + jsc-build-mac: cd src/javascript/jsc/WebKit && ICU_INCLUDE_DIRS="/usr/local/opt/icu4c/include" ./Tools/Scripts/build-jsc --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON -DCMAKE_BUILD_TYPE=relwithdebinfo" && echo "Ignore the \"has no symbols\" errors" @@ -20,15 +23,8 @@ SRC_DIR := src/javascript/jsc/bindings OBJ_DIR := src/javascript/jsc/bindings-obj SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp) OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES)) - -jsc-bindings-mac: $(OBJ_FILES) - -# We do this outside of build.zig for performance reasons -# The C compilation stuff with build.zig is really slow and we don't need to run this as often as the rest -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp - clang++ -c -o $@ $< \ - -Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders \ - -Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/WTF/Headers \ +CLANG_FLAGS = -Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders \ + -Isrc/javascript/jsc/WebKit/WebKitBuild/Release/WTF/Headers \ -Isrc/javascript/jsc/WebKit/WebKitBuild/Release/ICU/Headers \ -DSTATICALLY_LINKED_WITH_JavaScriptCore=1 \ -DSTATICALLY_LINKED_WITH_WTF=1 \ @@ -40,7 +36,22 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp -Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/ \ -Isrc/JavaScript/jsc/bindings/ \ -Isrc/javascript/jsc/WebKit/Source/bmalloc \ - -std=gnu++17 + -std=gnu++17 \ + -stdlib=libc++ \ + -DDU_DISABLE_RENAMING=1 + +jsc-bindings-mac: $(OBJ_FILES) + +# We do this outside of build.zig for performance reasons +# The C compilation stuff with build.zig is really slow and we don't need to run this as often as the rest +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp + clang++ -c -o $@ $< \ + $(CLANG_FLAGS) + +sizegen: + clang++ src/javascript/jsc/headergen/sizegen.cpp -o /tmp/sizegen $(CLANG_FLAGS) + /tmp/sizegen > src/javascript/jsc/bindings/sizes.zig + speedy-prod-native-macos: cd src/deps; clang -c picohttpparser.c; cd ../../ @@ -1,4 +1,4 @@ -# Speedy - a fast web bundler +# Speedy - a fast web bundler & JavaScript runtime environment Speedy bundles & transpiles JavaScript, TypeScript, and CSS. Speedy is probably the fastest bundler out today. diff --git a/src/javascript/jsc/bindings/DefaultGlobal.cpp b/src/javascript/jsc/bindings/DefaultGlobal.cpp index 42e5c962c..9ca83d267 100644 --- a/src/javascript/jsc/bindings/DefaultGlobal.cpp +++ b/src/javascript/jsc/bindings/DefaultGlobal.cpp @@ -43,118 +43,34 @@ namespace Wundle { -const ClassInfo DefaultGlobal::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(DefaultGlobal) }; -const GlobalObjectMethodTable DefaultGlobal::s_globalObjectMethodTable = { - &supportsRichSourceInfo, - &shouldInterruptScript, - &javaScriptRuntimeFlags, - nullptr, // queueTaskToEventLoop - &shouldInterruptScriptBeforeTimeout, - &moduleLoaderImportModule, // moduleLoaderImportModule - &moduleLoaderResolve, // moduleLoaderResolve - &moduleLoaderFetch, // moduleLoaderFetch - &moduleLoaderCreateImportMetaProperties, // moduleLoaderCreateImportMetaProperties - &moduleLoaderEvaluate, // moduleLoaderEvaluate - nullptr, // promiseRejectionTracker - &reportUncaughtExceptionAtEventLoop, - ¤tScriptExecutionOwner, - &scriptExecutionStatus, - nullptr, // defaultLanguage - nullptr, // compileStreaming - nullptr, // instantiateStreaming +// const ClassInfo DefaultGlobal::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(DefaultGlobal) }; +// const GlobalObjectMethodTable DefaultGlobal::s_globalObjectMethodTable = { +// &supportsRichSourceInfo, +// &shouldInterruptScript, +// &javaScriptRuntimeFlags, +// nullptr, // queueTaskToEventLoop +// &shouldInterruptScriptBeforeTimeout, +// &moduleLoaderImportModule, // moduleLoaderImportModule +// &moduleLoaderResolve, // moduleLoaderResolve +// &moduleLoaderFetch, // moduleLoaderFetch +// &moduleLoaderCreateImportMetaProperties, // moduleLoaderCreateImportMetaProperties +// &moduleLoaderEvaluate, // moduleLoaderEvaluate +// nullptr, // promiseRejectionTracker +// &reportUncaughtExceptionAtEventLoop, +// ¤tScriptExecutionOwner, +// &scriptExecutionStatus, +// nullptr, // defaultLanguage +// nullptr, // compileStreaming +// nullptr, // instantiateStreaming +// }; + + +// void DefaultGlobal::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject, Exception* exception) {} +// JSC::Identifier DefaultGlobal::moduleLoaderResolve(JSGlobalObject* globalObject, JSModuleLoader* loader, JSValue key, JSValue referrer, JSValue val) { +// JSInternalPromise* DefaultGlobal::moduleLoaderImportModule(JSGlobalObject* globalObject, JSModuleLoader*, JSString* specifierValue, JSValue, const SourceOrigin& sourceOrigin) { +// JSInternalPromise* DefaultGlobal::moduleLoaderFetch(JSGlobalObject* globalObject, JSModuleLoader*, JSValue key, JSValue, JSValue) { +// JSC::JSObject* DefaultGlobal::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject, JSModuleLoader*loader, JSValue key, JSModuleRecord* record, JSValue value) { +// JSValue DefaultGlobal::moduleLoaderEvaluate(JSGlobalObject* globalObject, JSModuleLoader* moduleLoader, JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue resumeMode) { + +// using namespace JSC; }; - - -void DefaultGlobal::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject, Exception* exception) {} -JSC::Identifier DefaultGlobal::moduleLoaderResolve(JSGlobalObject* globalObject, JSModuleLoader* loader, JSValue key, JSValue referrer, JSValue val) { - String string = key.toWTFString(globalObject); - return JSC::Identifier::fromString(globalObject->vm(), string ); -} -JSInternalPromise* DefaultGlobal::moduleLoaderImportModule(JSGlobalObject* globalObject, JSModuleLoader*, JSString* specifierValue, JSValue, const SourceOrigin& sourceOrigin) { - return nullptr; -} -JSInternalPromise* DefaultGlobal::moduleLoaderFetch(JSGlobalObject* globalObject, JSModuleLoader*, JSValue key, JSValue, JSValue) { - return nullptr; -} -JSC::JSObject* DefaultGlobal::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject, JSModuleLoader*loader, JSValue key, JSModuleRecord* record, JSValue value) { - return nullptr; -} -JSValue DefaultGlobal::moduleLoaderEvaluate(JSGlobalObject* globalObject, JSModuleLoader* moduleLoader, JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue resumeMode) { - return jsNull(); -} - -using namespace JSC; - - -JSC::ObjectPrototype* JSC__JSGlobalObject__objectPrototype(JSC::JSGlobalObject* arg0) { - return arg0->objectPrototype(); -} -JSC::FunctionPrototype* JSC__JSGlobalObject__functionPrototype(JSC::JSGlobalObject* arg0) { - return arg0->functionPrototype(); -} -JSC::ArrayPrototype* JSC__JSGlobalObject__arrayPrototype(JSC::JSGlobalObject* arg0) { - return arg0->arrayPrototype(); -} -JSC::JSObject* JSC__JSGlobalObject__booleanPrototype(JSC::JSGlobalObject* arg0) { - return arg0->booleanPrototype(); -} -JSC::StringPrototype* JSC__JSGlobalObject__stringPrototype(JSC::JSGlobalObject* arg0) { - return arg0->stringPrototype(); -} -JSC::JSObject* JSC__JSGlobalObject__numberPrototype(JSC::JSGlobalObject* arg0) { - return arg0->numberPrototype(); -} -JSC::BigIntPrototype* JSC__JSGlobalObject__bigIntPrototype(JSC::JSGlobalObject* arg0) { - return arg0->bigIntPrototype(); -} -JSC::JSObject* JSC__JSGlobalObject__datePrototype(JSC::JSGlobalObject* arg0) { - return arg0->datePrototype(); -} -JSC::JSObject* JSC__JSGlobalObject__symbolPrototype(JSC::JSGlobalObject* arg0) { - return arg0->symbolPrototype(); -} -JSC::RegExpPrototype* JSC__JSGlobalObject__regExpPrototype(JSC::JSGlobalObject* arg0) { - return arg0->regExpPrototype(); -} -JSC::JSObject* JSC__JSGlobalObject__errorPrototype(JSC::JSGlobalObject* arg0) { - return arg0->errorPrototype(); -} -JSC::IteratorPrototype* JSC__JSGlobalObject__iteratorPrototype(JSC::JSGlobalObject* arg0) { - return arg0->iteratorPrototype(); -} -JSC::AsyncIteratorPrototype* JSC__JSGlobalObject__asyncIteratorPrototype(JSC::JSGlobalObject* arg0) { - return arg0->asyncIteratorPrototype(); -} -JSC::GeneratorFunctionPrototype* JSC__JSGlobalObject__generatorFunctionPrototype(JSC::JSGlobalObject* arg0) { - return arg0->generatorFunctionPrototype(); -} -JSC::GeneratorPrototype* JSC__JSGlobalObject__generatorPrototype(JSC::JSGlobalObject* arg0) { - return arg0->generatorPrototype(); -} -JSC::AsyncFunctionPrototype* JSC__JSGlobalObject__asyncFunctionPrototype(JSC::JSGlobalObject* arg0) { - return arg0->asyncFunctionPrototype(); -} -JSC::ArrayIteratorPrototype* JSC__JSGlobalObject__arrayIteratorPrototype(JSC::JSGlobalObject* arg0) { - return arg0->arrayIteratorPrototype(); -} -JSC::MapIteratorPrototype* JSC__JSGlobalObject__mapIteratorPrototype(JSC::JSGlobalObject* arg0) { - return arg0->mapIteratorPrototype(); -} -JSC::SetIteratorPrototype* JSC__JSGlobalObject__setIteratorPrototype(JSC::JSGlobalObject* arg0) { - return arg0->setIteratorPrototype(); -} -JSC::JSObject* JSC__JSGlobalObject__mapPrototype(JSC::JSGlobalObject* arg0) { - return arg0->mapPrototype(); -} -JSC::JSObject* JSC__JSGlobalObject__jsSetPrototype(JSC::JSGlobalObject* arg0) { - return arg0->jsSetPrototype(); -} -JSC::JSPromisePrototype* JSC__JSGlobalObject__promisePrototype(JSC::JSGlobalObject* arg0) { - return arg0->promisePrototype(); -} -JSC::AsyncGeneratorPrototype* JSC__JSGlobalObject__asyncGeneratorPrototype(JSC::JSGlobalObject* arg0) { - return arg0->asyncGeneratorPrototype(); -} -JSC::AsyncGeneratorFunctionPrototype* JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC::JSGlobalObject* arg0) { - return arg0->asyncGeneratorFunctionPrototype(); -} diff --git a/src/javascript/jsc/bindings/DefaultGlobal.zig b/src/javascript/jsc/bindings/DefaultGlobal.zig index 7a401fec1..e69de29bb 100644 --- a/src/javascript/jsc/bindings/DefaultGlobal.zig +++ b/src/javascript/jsc/bindings/DefaultGlobal.zig @@ -1,1623 +0,0 @@ -usingnamespace @import("./imports.zig"); - -const std = @import("std"); -const main = @import("root"); -const is_bindgen = std.meta.trait.hasDecls(main, .{"bindgen"}); -const hasRef = std.meta.trait.hasField("ref"); - -fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comptime Parent: type) type { - return struct { - pub const namespace = _namespace; - pub const name = _name; - - fn toCppType(comptime FromType: ?type) ?type { - return comptime brk: { - var NewReturnType = FromType orelse c_void; - - if (NewReturnType == c_void) { - break :brk FromType; - } - - var ReturnTypeInfo: std.builtin.TypeInfo = @typeInfo(FromType orelse c_void); - - if (ReturnTypeInfo == .Pointer and NewReturnType != *c_void) { - NewReturnType = ReturnTypeInfo.Pointer.child; - ReturnTypeInfo = @typeInfo(NewReturnType); - } - - switch (ReturnTypeInfo) { - .Union, - .Struct, - .Enum, - => { - if (@hasDecl(ReturnTypeInfo, "Type")) { - break :brk NewReturnType; - } - }, - else => {}, - } - - break :brk FromType; - }; - } - - pub inline fn getConvertibleType(comptime ZigType: type) type { - if (@typeInfo(ZigType) == .Struct) { - const Struct: std.builtin.TypeInfo.Struct = ChildType.Struct; - for (Struct.fields) |field| { - if (std.mem.eql(u8, field.name, "ref")) { - return field.field_type; - } - } - } - - return ZigType; - } - - fn pointerChild(comptime Type: type) type { - if (@typeInfo(Type) == .Pointer) { - return @typeInfo(Type).Pointer.child_type; - } - - return Type; - } - - pub inline fn toZigType(comptime ZigType: type, comptime CppType: type, value: CppType) *ZigType { - if (comptime hasRef(ZigType)) { - // *WTF::String => Wtf.String{ = value}, via casting instead of copying - if (comptime @typeInfo(CppType) == .Pointer and @typeInfo(ZigType) != .Pointer) { - return @bitCast(ZigType, @ptrToInt(value)); - } - } - - return @as(ZigType, value); - } - - pub inline fn zigFn(comptime typeName: []const u8, args: anytype) (@typeInfo(@TypeOf(@field(Parent, typeName))).Fn.return_type orelse void) { - const identifier = comptime std.fmt.comptimePrint("{s}__{s}__{s}", .{ namespace, name, typeName }); - const func = comptime @typeInfo(Parent).Struct.fields[std.meta.fieldIndex(Parent, typeName)].field_type; - const ReturnType = comptime @typeInfo(func).Fn.return_type orelse c_void; - - const Func: type = comptime brk: { - var FuncType: std.builtin.TypeInfo = @typeInfo(@TypeOf(func)); - var Fn: std.builtin.TypeInfo.Fn = FuncType.Fn; - - Fn.calling_convention = std.builtin.CallingConvention.C; - Fn.return_type = toCppType(Fn.return_type); - - const ArgsType = @TypeOf(args); - for (std.meta.fieldNames(args)) |field, i| { - Fn.args[i] = std.builtin.TypeInfo.FnArg{ - .is_generic = false, - .is_noalias = false, - .arg_type = @typeInfo(ArgsType).fields[i].field_type, - }; - } - FuncType.Fn = Fn; - break :brk @Type(FuncType); - }; - - comptime @export(Func, .{ .name = identifier }); - unreachable; - } - - pub inline fn cppFn(comptime typeName: []const u8, args: anytype) (ret: { - if (!@hasDecl(Parent, typeName)) { - @compileError(@typeName(Parent) ++ " is missing cppFn: " ++ typeName); - } - break :ret std.meta.declarationInfo(Parent, typeName).data.Fn.return_type; - }) { - if (comptime is_bindgen) { - unreachable; - } else { - const identifier = comptime std.fmt.comptimePrint("{s}__{s}__{s}", .{ namespace, name, typeName }); - const func = comptime @typeInfo(Parent).Struct.fields[std.meta.fieldIndex(Parent, typeName)].field_type; - const ReturnType = comptime @typeInfo(func).Fn.return_type orelse c_void; - - const Func: type = comptime brk: { - var FuncType: std.builtin.TypeInfo = @typeInfo(@TypeOf(func)); - var Fn: std.builtin.TypeInfo.Fn = FuncType.Fn; - - Fn.calling_convention = std.builtin.CallingConvention.C; - Fn.return_type = toCppType(Fn.return_type); - - const ArgsType = @TypeOf(args); - for (std.meta.fieldNames(args)) |field, i| { - Fn.args[i] = std.builtin.TypeInfo.FnArg{ - .is_generic = false, - .is_noalias = false, - .arg_type = @typeInfo(ArgsType).fields[i].field_type, - }; - } - FuncType.Fn = Fn; - break :brk @Type(FuncType); - }; - const Outgoing = comptime @extern(Func, std.builtin.ExternOptions{ .name = identifier }); - - return toZigType( - ReturnType, - @typeInfo(Func).Fn.return_type orelse void, - @call(.{}, Outgoing, args), - ); - } - } - }; -} - -pub const JSObject = opaque { - pub const shim = Shimmer("JSC", "JSObject", @This()); - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/JSObject.h>"; - pub const name = "JSC::JSObject"; - pub const namespace = "JSC"; - - pub fn hasProperty(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName) bool { - return cppFn("hasProperty", .{ this, globalThis, property_name }); - } - - pub fn getPropertyNames(this: *JSObject, globalThis: *JSGlobalObject) *PropertyNameArray { - return cppFn("getPropertyNames", .{ this, globalThis }); - } - - pub fn getArrayLength(this: *JSObject) usize { - return cppFn("getArrayLength", .{ - this, - }); - } - - // This get function only looks at the property map. - pub fn getDirect(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName) *JSValue { - return cppFn("getDirect", .{ - this, - property_name, - }); - } - pub fn putDirect(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName, value: *JSValue) bool { - return cppFn("putDirect", .{ - this, - property_name, - value, - }); - } - pub fn get(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName) *JSValue { - return cppFn("get", .{ - this, - property_name, - }); - } - pub fn getAtIndex(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName, i: u32) *JSValue { - return cppFn("getAtIndex", .{ - this, - property_name, - i, - }); - } - pub fn putAtIndex(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName, i: u32) bool { - return cppFn("putAtIndex", .{ - this, - property_name, - i, - }); - } - pub fn getIfExists(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName) ?*JSValue { - return cppFn("getIfExists", .{ - this, - property_name, - }); - } - - pub const Extern = [_][]const u8{ "hasProperty", "getPropertyNames", "getArrayLength", "getDirect", "putDirect", "get", "getAtIndex", "putAtIndex", "getIfExists" }; -}; - -pub const PropertyNameArray = opaque { - pub const shim = Shimmer("JSC", "PropertyNameArray", @This()); - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/PropertyNameArray.h>"; - pub const name = "JSC::PropertyNameArray"; - pub const namespace = "JSC"; - - pub fn length(this: *PropertyNameArray) usize { - return cppFn("length", .{this}); - } - - pub fn next(this: *PropertyNameArray, i: usize) ?*const PropertyName { - return cppFn("next", .{ this, i }); - } - - pub fn release(this: *PropertyNameArray) void { - return cppFn("release", .{this}); - } - - pub const Extern = [_][]const u8{ "length", "release", "next" }; -}; - -pub const JSCell = opaque { - pub const shim = Shimmer("JSC", "JSCell", @This()); - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/JSCell.h>"; - pub const name = "JSC::JSCell"; - pub const namespace = "JSC"; - - const CellType = enum(u8) { _ }; - - pub fn getObject(this: *JSCell) *JSObject { - return shim.cppFn("getObject", .{this}); - } - - pub fn getString(this: *JSCell, globalObject: *JSGlobalObject) *String { - return shim.cppFn("getString", .{ this, globalObject }); - } - - pub fn getType(this: *JSCell) u8 { - return shim.cppFn("getType", .{ - this, - }); - } - - pub const Extern = [_][]const u8{ "getObject", "getString", "getType" }; -}; - -pub const JSString = opaque { - pub const shim = Shimmer("JSC", "JSString", @This()); - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/JSString.h>"; - pub const name = "JSC::JSString"; - pub const namespace = "JSC"; - - pub fn getObject(this: *JSString) *JSObject { - return shim.cppFn("getObject", .{this}); - } - - pub fn eql(this: *const JSString, other: *const JSString) bool { - return shim.cppFn("eql", .{ this, other }); - } - - pub fn value(this: *JSString, globalObject: *JSGlobalObject) *String { - return shim.cppFn("value", .{ this, globalObject }); - } - - pub fn length(this: *const JSString) usize { - return shim.cppFn("length", .{ - this, - }); - } - - pub fn is8Bit(this: *const JSString) bool { - return shim.cppFn("is8Bit", .{ - this, - }); - } - - pub fn createFromOwnedString(vm: *VM, str: *StringImpl) bool { - return shim.cppFn("createFromOwnedString", .{ - vm, str, - }); - } - - pub fn createFromString(vm: *VM, str: *StringImpl) bool { - return shim.cppFn("createFromString", .{ - vm, str, - }); - } - - pub const Extern = [_][]const u8{ "getObject", "eql", "value", "length", "is8Bit", "createFromOwnedString", "createFromString" }; -}; - -pub const DefaultGlobalObject = opaque { - pub const shim = Shimmer("JSC", "JSGlobalObject", @This()); -}; - -pub const JSPromise = opaque { - pub const shim = Shimmer("JSC", "JSPromise", @This()); - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/JSPromise.h>"; - pub const name = "JSC::JSPromise"; - pub const namespace = "JSC"; - - pub const Status = enum(u32) { - Pending = 0, // Making this as 0, so that, we can change the status from Pending to others without masking. - Fulfilled = 1, - Rejected = 2, - }; - - pub fn status(this: *JSPromise, vm: *VM) Status { - return shim.cppFn("status", .{ this, vm }); - } - pub fn result(this: *JSPromise, vm: *VM) *JSValue { - return cppFn("result", .{ this, vm }); - } - pub fn isHandled(this: *JSPromise, vm: *VM) bool { - return cppFn("isHandled", .{ this, vm }); - } - - pub fn resolvedPromise(globalThis: *JSGlobalObject, value: *JSValue) *JSPromise { - return cppFn("resolvedPromise", .{ .globalThis = globalThis, .value = value }); - } - pub fn rejectedPromise(globalThis: *JSGlobalObject, value: *JSValue) *JSPromise { - return cppFn("rejectedPromise", .{ .globalThis = globalThis, .value = value }); - } - - pub fn resolve(globalThis: *JSGlobalObject, value: *JSValue) void { - cppFn("resolve", .{ .globalThis = globalThis, .value = value }); - } - pub fn reject(this: *JSPromise, globalThis: *JSGlobalObject, value: *JSValue) void { - cppFn("reject", .{ .this = this, .globalThis = globalThis, .value = value }); - } - pub fn rejectAsHandled(this: *JSPromise, globalThis: *JSGlobalObject, value: *JSValue) void { - cppFn("rejectAsHandled", .{ .this = this, .globalThis = globalThis, .value = value }); - } - pub fn rejectException(this: *JSPromise, globalThis: *JSGlobalObject, value: *Exception) void { - cppFn("rejectException", .{ .this = this, .globalThis = globalThis, .value = value }); - } - pub fn rejectAsHandledException(this: *JSPromise, globalThis: *JSGlobalObject, value: *Exception) void { - cppFn("rejectAsHandledException", .{ .this = this, .globalThis = globalThis, .value = value }); - } - - pub fn isInternal(this: *JSPromise, vm: *VM) bool { - return cppFn("isInternal", .{ this, vm }); - } - - pub fn createDeferred(globalThis: *JSGlobalObject, resolved: *JSFunction, rejected: *JSFunction, exception: *Exception) *JSPromise { - return cppFn("createDeferred", .{ - .globalThis = globalThis, - .resolve = resolved, - .reject = rejected, - .exception = exception, - }); - } - - pub const Extern = [_][]const u8{ "status", "result", "isHandled", "resolvedPromise", "rejectedPromise", "resolve", "reject", "rejectAsHandled", "rejectException", "rejectAsHandledException", "isInternal", "createDeferred" }; -}; - -// SourceProvider.h -pub const SourceType = enum(u8) { - Program = 0, - Module = 1, - WebAssembly = 2, -}; - -pub const SourceOrigin = opaque { - pub const shim = Shimmer("JSC", "SourceOrigin", @This()); - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/SourceOrigin.h>"; - pub const name = "JSC::SourceOrigin"; - pub const namespace = "JSC"; - - pub fn fromURL(url: *const URL) *const SourceOrigin { - return cppFn("fromURL", .{url}); - } - - pub const Extern = [_][]const u8{ - "fromURL", - }; -}; - -pub const SourceCode = opaque { - pub const shim = Shimmer("JSC", "SourceCode", @This()); - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/SourceProvider.h>"; - pub const name = "JSC::SourceCode"; - pub const namespace = "JSC"; - - pub fn fromString(source: *const String, origin: *const SourceOrigin, filename: *String, source_type: SourceType) *const SourceCode { - return cppFn("fromString", .{ source, origin, filename, source_type }); - } - - pub const Extern = [_][]const u8{ - "fromString", - }; -}; - -pub const JSFunction = opaque { - pub const shim = Shimmer("JSC", "JSFunction", @This()); - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/JSFunction.h>"; - pub const name = "JSC::JSFunction"; - pub const namespace = "JSC"; - - pub fn createFromSourceCode(source: *SourceCode, origin: *SourceOrigin, exception: ?*Exception) *JSFunction { - return cppFn("createFromSourceCode", .{ source, origin, exception }); - } - pub fn createFromNative( - vm: *VM, - globalthis: *JSGlobalObject, - argument_count: u32, - name_: *String, - func: *c_void, - ) *JSFunction { - return cppFn("createFromNative", .{ vm, globalthis, argument_count, name_, func }); - } - pub fn getName(this: *JSFunction, vm: *VM) *String { - return cppFn("getName", .{ this, vm }); - } - pub fn displayName(this: *JSFunction, vm: *VM) *String { - return cppFn("displayName", .{ this, vm }); - } - pub fn calculatedDisplayName(this: *JSFunction, vm: *VM) *String { - return cppFn("calculatedDisplayName", .{ this, vm }); - } - pub fn toString(this: *JSFunction, globalThis: *JSGlobalObject) *JSString { - return cppFn("toString", .{ this, globalThis }); - } - - pub fn callWithArgumentsAndThis( - function: *JSFunction, - thisValue: *JSValue, - globalThis: *JSGlobalObject, - arguments_ptr: [*]*JSValue, - arguments_len: usize, - exception: *?*Exception, - error_message: ?*const u8, - ) *JSValue { - return cppFn("callWithArgumentsAndThis", .{ - function, - globalThis, - thisValue, - arguments_ptr, - arguments_len, - exception, - error_message, - }); - } - - pub fn callWithArguments( - function: *JSFunction, - globalThis: *JSGlobalObject, - arguments_ptr: [*]*JSValue, - arguments_len: usize, - exception: *?*Exception, - error_message: ?*const u8, - ) *JSValue { - return cppFn("callWithArguments", .{ function, globalThis, arguments_ptr, arguments_len, exception, exception, error_message }); - } - - pub fn callWithThis( - function: *JSFunction, - globalThis: *JSGlobalObject, - thisValue: *JSValue, - exception: *?*Exception, - error_message: ?*const u8, - ) *JSValue { - return cppFn("callWithArguments", .{ - function, - globalThis, - thisValue, - exception, - error_message, - }); - } - - pub fn callWithoutAnyArgumentsOrThis( - function: *JSFunction, - globalThis: *JSGlobalObject, - exception: *?*Exception, - error_message: ?*const u8, - ) *JSValue { - return cppFn("callWithoutAnyArgumentsOrThis", .{ function, globalThis, exception, exception, error_message }); - } - - pub fn constructWithArgumentsAndNewTarget( - function: *JSFunction, - newTarget: *JSValue, - globalThis: *JSGlobalObject, - arguments_ptr: [*]*JSValue, - arguments_len: usize, - exception: *?*Exception, - error_message: ?*const u8, - ) *JSValue { - return cppFn("constructWithArgumentsAndNewTarget", .{ - function, - globalThis, - newTarget, - arguments_ptr, - arguments_len, - exception, - error_message, - }); - } - - pub fn constructWithArguments( - function: *JSFunction, - globalThis: *JSGlobalObject, - arguments_ptr: [*]*JSValue, - arguments_len: usize, - exception: *?*Exception, - error_message: ?*const u8, - ) *JSValue { - return cppFn("constructWithArguments", .{ function, globalThis, arguments_ptr, arguments_len, exception, exception, error_message }); - } - - pub fn constructWithNewTarget( - function: *JSFunction, - globalThis: *JSGlobalObject, - newTarget: *JSValue, - exception: *?*Exception, - error_message: ?*const u8, - ) *JSValue { - return cppFn("constructWithArguments", .{ - function, - globalThis, - newTarget, - exception, - error_message, - }); - } - - pub fn constructWithoutAnyArgumentsOrNewTarget( - function: *JSFunction, - globalThis: *JSGlobalObject, - exception: *?*Exception, - error_message: ?*const u8, - ) *JSValue { - return cppFn("constructWithoutAnyArgumentsOrNewTarget", .{ function, globalThis, exception, exception, error_message }); - } - - pub const Extern = [_][]const u8{ - "fromString", - "createFromSourceCode", - "createFromNative", - "getName", - "displayName", - "calculatedDisplayName", - "callWithArgumentsAndThis", - "callWithArguments", - "callWithThis", - "callWithoutAnyArgumentsOrThis", - "constructWithArgumentsAndNewTarget", - "constructWithArguments", - "constructWithNewTarget", - "constructWithoutAnyArgumentsOrNewTarget", - }; -}; - -pub const JSGlobalObject = opaque { - pub const shim = Shimmer("JSC", "JSGlobalObject", @This()); - - pub const include = "<JavaScriptCore/JSGlobalObject.h>"; - pub const name = "JSC::JSGlobalObject"; - pub const namespace = "JSC"; - - const cppFn = shim.cppFn; - - pub fn objectPrototype(this: *JSGlobalObject) *ObjectPrototype { - return cppFn("objectPrototype", .{this}); - } - pub fn functionPrototype(this: *JSGlobalObject) *FunctionPrototype { - return cppFn("functionPrototype", .{this}); - } - pub fn arrayPrototype(this: *JSGlobalObject) *ArrayPrototype { - return cppFn("arrayPrototype", .{this}); - } - pub fn booleanPrototype(this: *JSGlobalObject) *JSObject { - return cppFn("booleanPrototype", .{this}); - } - pub fn stringPrototype(this: *JSGlobalObject) *StringPrototype { - return cppFn("stringPrototype", .{this}); - } - pub fn numberPrototype(this: *JSGlobalObject) *JSObject { - return cppFn("numberPrototype", .{this}); - } - pub fn bigIntPrototype(this: *JSGlobalObject) *BigIntPrototype { - return cppFn("bigIntPrototype", .{this}); - } - pub fn datePrototype(this: *JSGlobalObject) *JSObject { - return cppFn("datePrototype", .{this}); - } - pub fn symbolPrototype(this: *JSGlobalObject) *JSObject { - return cppFn("symbolPrototype", .{this}); - } - pub fn regExpPrototype(this: *JSGlobalObject) *RegExpPrototype { - return cppFn("regExpPrototype", .{this}); - } - pub fn errorPrototype(this: *JSGlobalObject) *JSObject { - return cppFn("errorPrototype", .{this}); - } - pub fn iteratorPrototype(this: *JSGlobalObject) *IteratorPrototype { - return cppFn("iteratorPrototype", .{this}); - } - pub fn asyncIteratorPrototype(this: *JSGlobalObject) *AsyncIteratorPrototype { - return cppFn("asyncIteratorPrototype", .{this}); - } - pub fn generatorFunctionPrototype(this: *JSGlobalObject) *GeneratorFunctionPrototype { - return cppFn("generatorFunctionPrototype", .{this}); - } - pub fn generatorPrototype(this: *JSGlobalObject) *GeneratorPrototype { - return cppFn("generatorPrototype", .{this}); - } - pub fn asyncFunctionPrototype(this: *JSGlobalObject) *AsyncFunctionPrototype { - return cppFn("asyncFunctionPrototype", .{this}); - } - pub fn arrayIteratorPrototype(this: *JSGlobalObject) *ArrayIteratorPrototype { - return cppFn("arrayIteratorPrototype", .{this}); - } - pub fn mapIteratorPrototype(this: *JSGlobalObject) *MapIteratorPrototype { - return cppFn("mapIteratorPrototype", .{this}); - } - pub fn setIteratorPrototype(this: *JSGlobalObject) *SetIteratorPrototype { - return cppFn("setIteratorPrototype", .{this}); - } - pub fn mapPrototype(this: *JSGlobalObject) *JSObject { - return cppFn("mapPrototype", .{this}); - } - pub fn jsSetPrototype(this: *JSGlobalObject) *JSObject { - return cppFn("jsSetPrototype", .{this}); - } - pub fn promisePrototype(this: *JSGlobalObject) *JSPromisePrototype { - return cppFn("promisePrototype", .{this}); - } - pub fn asyncGeneratorPrototype(this: *JSGlobalObject) *AsyncGeneratorPrototype { - return cppFn("asyncGeneratorPrototype", .{this}); - } - pub fn asyncGeneratorFunctionPrototype(this: *JSGlobalObject) *AsyncGeneratorFunctionPrototype { - return cppFn("asyncGeneratorFunctionPrototype", .{this}); - } - - pub const Extern = [_][]const u8{ - "objectPrototype", - "functionPrototype", - "arrayPrototype", - "booleanPrototype", - "stringPrototype", - "numberPrototype", - "bigIntPrototype", - "datePrototype", - "symbolPrototype", - "regExpPrototype", - "errorPrototype", - "iteratorPrototype", - "asyncIteratorPrototype", - "generatorFunctionPrototype", - "generatorPrototype", - "asyncFunctionPrototype", - "arrayIteratorPrototype", - "mapIteratorPrototype", - "setIteratorPrototype", - "mapPrototype", - "jsSetPrototype", - "promisePrototype", - "asyncGeneratorPrototype", - "asyncGeneratorFunctionPrototype", - }; -}; - -fn _JSCellStub(comptime str: []const u8) type { - if (is_bindgen) { - return opaque { - pub const name = "JSC::" ++ str ++ ""; - }; - } else { - return struct {}; - } -} - -fn _Wundle(comptime str: []const u8) type { - if (is_bindgen) { - return opaque { - pub const name = "Wundle::" ++ str ++ ""; - }; - } else { - return struct {}; - } -} - -fn _WTF(comptime str: []const u8) type { - if (is_bindgen) { - return opaque { - pub const name = "WTF::" ++ str ++ ""; - }; - } else { - return struct {}; - } -} - -pub const URL = opaque { - pub const shim = Shimmer("WTF", "URL", @This()); - const cppFn = shim.cppFn; - pub const include = "<wtf/URL.h>"; - pub const name = "WTF::URL"; - pub const namespace = "WTF"; - - pub fn fromString(base: *const String, relative: *const String) *URL { - return cppFn("fromString", .{ base, relative }); - } - - pub fn fromFileSystemPath(file_system_path: *const StringView) *URL { - return cppFn("fromFileSystemPath", .{file_system_path}); - } - - pub fn isEmpty(this: *const URL) bool { - return cppFn("isEmpty", .{this}); - } - pub fn isValid(this: *const URL) bool { - return cppFn("isValid", .{this}); - } - - pub fn protocol(this: *URL) ?*const StringView { - return cppFn("protocol", .{this}); - } - pub fn encodedUser(this: *URL) ?*const StringView { - return cppFn("encodedUser", .{this}); - } - pub fn encodedPassword(this: *URL) ?*const StringView { - return cppFn("encodedPassword", .{this}); - } - pub fn host(this: *URL) ?*const StringView { - return cppFn("host", .{this}); - } - pub fn path(this: *URL) ?*const StringView { - return cppFn("path", .{this}); - } - pub fn lastPathComponent(this: *URL) ?*const StringView { - return cppFn("lastPathComponent", .{this}); - } - pub fn query(this: *URL) ?*const StringView { - return cppFn("query", .{this}); - } - pub fn fragmentIdentifier(this: *URL) ?*const StringView { - return cppFn("fragmentIdentifier", .{this}); - } - pub fn queryWithLeadingQuestionMark(this: *URL) ?*const StringView { - return cppFn("queryWithLeadingQuestionMark", .{this}); - } - pub fn fragmentIdentifierWithLeadingNumberSign(this: *URL) ?*const StringView { - return cppFn("fragmentIdentifierWithLeadingNumberSign", .{this}); - } - pub fn stringWithoutQueryOrFragmentIdentifier(this: *URL) ?*const StringView { - return cppFn("stringWithoutQueryOrFragmentIdentifier", .{this}); - } - pub fn stringWithoutFragmentIdentifier(this: *URL) ?*const StringView { - return cppFn("stringWithoutFragmentIdentifier", .{this}); - } - pub fn protocolHostAndPort(this: *URL) ?*const String { - return cppFn("protocolHostAndPort", .{this}); - } - pub fn hostAndPort(this: *URL) ?*const String { - return cppFn("hostAndPort", .{this}); - } - pub fn user(this: *URL) ?*const String { - return cppFn("user", .{this}); - } - pub fn password(this: *URL) ?*const String { - return cppFn("password", .{this}); - } - pub fn fileSystemPath(this: *URL) ?*const String { - return cppFn("fileSystemPath", .{this}); - } - - pub fn setProtocol(this: *URL, protocol_value: *const StringView) void { - return cppFn("setProtocol", .{ this, protocol_value }); - } - pub fn setHost(this: *URL, host_value: *const StringView) void { - return cppFn("setHost", .{ this, host_value }); - } - pub fn setHostAndPort(this: *URL, host_and_port_value: *const StringView) void { - return cppFn("setHostAndPort", .{ this, host_and_port_value }); - } - pub fn setUser(this: *URL, user_value: *const StringView) void { - return cppFn("setUser", .{ this, user_value }); - } - pub fn setPassword(this: *URL, password_value: *const StringView) void { - return cppFn("setPassword", .{ this, password_value }); - } - pub fn setPath(this: *URL, path_value: *const StringView) void { - return cppFn("setPath", .{ this, path_value }); - } - pub fn setQuery(this: *URL, query_value: *const StringView) void { - return cppFn("setQuery", .{ this, query_value }); - } - - pub fn truncatedForUseAsBase( - this: *URL, - ) *URL { - return cppFn("truncatedForUseAsBase", .{ - this, - }); - } - pub const Extern = [_][]const u8{ "fromFileSystemPath", "fromString", "isEmpty", "isValid", "protocol", "encodedUser", "encodedPassword", "host", "path", "lastPathComponent", "query", "fragmentIdentifier", "queryWithLeadingQuestionMark", "fragmentIdentifierWithLeadingNumberSign", "stringWithoutQueryOrFragmentIdentifier", "stringWithoutFragmentIdentifier", "protocolHostAndPort", "hostAndPort", "user", "password", "fileSystemPath", "setProtocol", "setHost", "setHostAndPort", "setUser", "setPassword", "setPath", "setQuery", "truncatedForUseAsBase" }; -}; - -pub const String = opaque { - pub const shim = Shimmer("WTF", "WTFString", @This()); - const cppFn = shim.cppFn; - pub const include = "<wtf/text/WTFString.h>"; - pub const name = "WTF::WTFString"; - pub const namespace = "WTF"; - - pub fn createWithoutCopyingFromPtr(str: [*]const u8, len: usize) *String { - return cppFn("createWithoutCopyingFromPtr", .{ str, len }); - } - - pub fn createFromExternalString(str: *StringImpl) *String { - return cppFn("createFromExternalString", .{str}); - } - - pub fn createWithoutCopying(str: []const u8) *String { - return @call(.{ .modifier = .always_inline }, createWithoutCopyingFromPtr, .{ str.ptr, str.len }); - } - - pub fn is8Bit(this: *String) bool { - return cppFn("is8Bit", .{this}); - } - pub fn is16Bit(this: *String) bool { - return cppFn("is16Bit", .{this}); - } - pub fn isExternal(this: *String) bool { - return cppFn("isExternal", .{this}); - } - pub fn isStatic(this: *String) bool { - return cppFn("isStatic", .{this}); - } - pub fn isEmpty(this: *String) bool { - return cppFn("isEmpty", .{this}); - } - pub fn length(this: *String) usize { - return cppFn("length", .{this}); - } - pub fn characters8(this: *String) ?[*]u8 { - return cppFn("characters8", .{this}); - } - pub fn characters16(this: *String) ?[*]u8 { - return cppFn("characters16", .{this}); - } - - pub fn eqlString(this: *String, other: *String) bool { - return cppFn("eqlString", .{ this, other }); - } - - pub fn eqlSlice(this: *String, other: [*]u8, other_len: usize) bool { - return cppFn("eqlSlice", .{ this, other, other_len }); - } - - pub fn impl( - this: *String, - ) *StringImpl { - return cppFn("impl", .{ - this, - }); - } - - pub fn slice(this: *String) []const u8 { - if (this.isEmpty()) return ""; - - if (this.is8Bit()) { - return if (this.characters8()) |ptr| ptr[0..this.length()] else ""; - } else { - return if (this.characters8()) |ptr| ptr[0..this.length()] else ""; - } - } - - pub const Extern = [_][]const u8{ - "is8Bit", - "is16Bit", - "isExternal", - "isStatic", - "isEmpty", - "length", - "characters8", - "characters16", - "createWithoutCopyingFromPtr", - "eqlString", - "eqlSlice", - "impl", - "createFromExternalString", - }; -}; - -pub const JSValue = opaque { - pub const shim = Shimmer("JSC", "JSValue", @This()); - pub const is_pointer = false; - pub const Type = u64; - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/JSValue.h>"; - pub const name = "JSC::JSValue"; - pub const namespace = "JSC"; - - pub fn jsNumber(number: anytype) *JSValue { - return switch (@TypeOf(number)) { - f64 => @call(.{ .modifier = .always_inline }, jsNumberFromDouble, .{number}), - u8 => @call(.{ .modifier = .always_inline }, jsNumberFromChar, .{number}), - u16 => @call(.{ .modifier = .always_inline }, jsNumberFromU16, .{number}), - i32 => @call(.{ .modifier = .always_inline }, jsNumberFromInt32, .{number}), - i64 => @call(.{ .modifier = .always_inline }, jsNumberFromInt64, .{number}), - u64 => @call(.{ .modifier = .always_inline }, jsNumberFromUint64, .{number}), - else => @compileError("Type transformation missing for number of type: " ++ @typeName(@TypeOf(number))), - }; - } - - pub fn jsNull() *JSValue { - return cppFn("jsNull", .{}); - } - pub fn jsUndefined() *JSValue { - return cppFn("jsUndefined", .{}); - } - pub fn jsTDZValue() *JSValue { - return cppFn("jsTDZValue", .{}); - } - pub fn jsBoolean(i: bool) *JSValue { - return cppFn("jsBoolean", .{i}); - } - pub fn jsDoubleNumber(i: f64) *JSValue { - return cppFn("jsDoubleNumber", .{i}); - } - - pub fn jsNumberFromDouble(i: f64) *JSValue { - return cppFn("jsNumberFromDouble", .{i}); - } - pub fn jsNumberFromChar(i: u8) *JSValue { - return cppFn("jsNumberFromChar", .{i}); - } - pub fn jsNumberFromU16(i: u16) *JSValue { - return cppFn("jsNumberFromU16", .{i}); - } - pub fn jsNumberFromInt32(i: i32) *JSValue { - return cppFn("jsNumberFromInt32", .{i}); - } - pub fn jsNumberFromInt64(i: i64) *JSValue { - return cppFn("jsNumberFromInt64", .{i}); - } - pub fn jsNumberFromUint64(i: u64) *JSValue { - return cppFn("jsNumberFromUint64", .{i}); - } - - pub fn isUndefined(this: *JSValue) bool { - return cppFn("isUndefined", .{this}); - } - pub fn isNull(this: *JSValue) bool { - return cppFn("isNull", .{this}); - } - pub fn isUndefinedOrNull(this: *JSValue) bool { - return cppFn("isUndefinedOrNull", .{this}); - } - pub fn isBoolean(this: *JSValue) bool { - return cppFn("isBoolean", .{this}); - } - pub fn isAnyInt(this: *JSValue) bool { - return cppFn("isAnyInt", .{this}); - } - pub fn isUInt32AsAnyInt(this: *JSValue) bool { - return cppFn("isUInt32AsAnyInt", .{this}); - } - pub fn isInt32AsAnyInt(this: *JSValue) bool { - return cppFn("isInt32AsAnyInt", .{this}); - } - pub fn isNumber(this: *JSValue) bool { - return cppFn("isNumber", .{this}); - } - pub fn isError(this: *JSValue) bool { - return cppFn("isError", .{this}); - } - pub fn isString(this: *JSValue) bool { - return cppFn("isString", .{this}); - } - pub fn isBigInt(this: *JSValue) bool { - return cppFn("isBigInt", .{this}); - } - pub fn isHeapBigInt(this: *JSValue) bool { - return cppFn("isHeapBigInt", .{this}); - } - pub fn isBigInt32(this: *JSValue) bool { - return cppFn("isBigInt32", .{this}); - } - pub fn isSymbol(this: *JSValue) bool { - return cppFn("isSymbol", .{this}); - } - pub fn isPrimitive(this: *JSValue) bool { - return cppFn("isPrimitive", .{this}); - } - pub fn isGetterSetter(this: *JSValue) bool { - return cppFn("isGetterSetter", .{this}); - } - pub fn isCustomGetterSetter(this: *JSValue) bool { - return cppFn("isCustomGetterSetter", .{this}); - } - pub fn isObject(this: *JSValue) bool { - return cppFn("isObject", .{this}); - } - - pub fn isCell(this: *JSValue) bool { - return cppFn("isCell", .{this}); - } - - pub fn asCell(this: *JSValue) *JSCell { - return cppFn("asCell", .{this}); - } - - // On exception, this returns the empty string. - pub fn toString(this: *JSValue, globalThis: *JSGlobalObject) *JSString { - return cppFn("toString", .{ this, globalThis }); - } - - // On exception, this returns null, to make exception checks faster. - pub fn toStringOrNull(this: *JSValue, globalThis: *JSGlobalObject) *JSString { - return cppFn("toStringOrNull", .{ this, globalThis }); - } - pub fn toPropertyKey(this: *JSValue, globalThis: *JSGlobalObject) *Identifier { - return cppFn("toPropertyKey", .{ this, globalThis }); - } - pub fn toPropertyKeyValue(this: *JSValue, globalThis: *JSGlobalObject) *JSValue { - return cppFn("toPropertyKeyValue", .{ this, globalThis }); - } - pub fn toObject(this: *JSValue, globalThis: *JSGlobalObject) *JSObject { - return cppFn("toObject", .{ this, globalThis }); - } - - pub fn toWTFString(this: *JSValue) *String { - return cppFn("toWTFString", .{this}); - } - - pub fn getPrototype(this: *JSValue, globalObject: *JSGlobalObject) *JSValue { - return cppFn("getPrototype", .{ this, globalObject }); - } - - pub fn getPropertyByPropertyName(this: *JSValue, property_name: *PropertyName, globalObject: *JSGlobalObject) *JSValue { - return cppFn("getPropertyByPropertyName", .{ this, property_name, globalObject }); - } - - pub fn eqlValue(this: *JSValue, other: *JSValue) bool { - return cppFn("eqlValue", .{ this, other }); - } - - pub fn eqlCell(this: *JSValue, other: *JSCell) bool { - return cppFn("eqlCell", .{ this, other }); - } - - pub fn asString(this: *JSValue) *JSString { - return cppFn("asString", .{ - this, - }); - } - - pub fn asObject(this: *JSValue) *JSString { - return cppFn("asString", .{ - this, - }); - } - - pub fn asNumber(this: *JSValue) *JSString { - return cppFn("asNumber", .{ - this, - }); - } - - pub fn encode(this: *JSValue) u64 { - return cppFn("encode", .{ - this, - }); - } - - pub const Extern = [_][]const u8{ "encode", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isUndefined", "isNull", "isUndefinedOrNull", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toWTFString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell" }; -}; - -pub const PropertyName = opaque { - pub const shim = Shimmer("JSC", "PropertyName", @This()); - - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/PropertyName.h>"; - pub const name = "JSC::PropertyName"; - pub const namespace = "JSC"; - - pub fn eqlToPropertyName(property_name: *PropertyName, other: *const PropertyName) bool { - return cppFn("eqlToPropertyName", .{ property_name, other }); - } - - pub fn eqlToIdentifier(property_name: *PropertyName, other: *const Identifier) bool { - return cppFn("eqlToIdentifier", .{ property_name, other }); - } - - pub fn publicName(property_name: *PropertyName) ?*StringImpl { - return cppFn("publicName", .{ - property_name, - }); - } - - pub fn uid(property_name: *PropertyName) ?*StringImpl { - return cppFn("uid", .{ - property_name, - }); - } - - pub const Extern = [_][]const u8{ "eqlToPropertyName", "eqlToIdentifier", "publicName", "uid" }; -}; - -pub const Error = opaque { - pub const shim = Shimmer("JSC", "JSGlobalObject", @This()); - - pub const Type = JSObject; - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/Error.h>"; - pub const name = "JSC::JSGlobalObject"; - pub const namespace = "JSC"; - - pub const ErrorType = enum(u8) { - Error = 0, - EvalError = 1, - RangeError = 2, - ReferenceError = 3, - SyntaxError = 4, - TypeError = 5, - URIError = 6, - AggregateError = 7, - OutOfMemoryError = 8, - }; - - pub fn createError(globalObject: *JSGlobalObject, error_type: ErrorType, message: *String) *JSObject { - return cppFn("createError", .{ globalObject, @enumToInt(error_type), message }); - } - - pub fn throwError( - globalObject: *JSGlobalObject, - err: *JSObject, - ) *JSObject { - return cppFn("throwError", .{ - globalObject, - err, - }); - } - - pub const Extern = [_][]const u8{ - "throwError", "createError", - }; -}; - -pub const Exception = opaque { - pub const shim = Shimmer("JSC", "Exception", @This()); - - pub const Type = JSObject; - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/Exception.h>"; - pub const name = "JSC::Exception"; - pub const namespace = "JSC"; - - pub const StackCaptureAction = enum(u8) { - CaptureStack = 0, - DoNotCaptureStack = 1, - }; - - pub fn create(globalObject: *JSGlobalObject, object: *JSObject, stack_capture: StackCaptureAction) *Exception { - return cppFn( - "create", - .{ globalObject, object, @enumToInt(stack_capture) }, - ); - } - - pub const Extern = [_][]const u8{ - "create", - }; -}; - -pub const VM = opaque { - pub const shim = Shimmer("JSC", "VM", @This()); - - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/VM.h>"; - pub const name = "JSC::VM"; - pub const namespace = "JSC"; - - pub const HeapType = enum(u8) { - SmallHeap = 0, - LargeHeap = 1, - }; - pub fn create(heap_type: HeapType) *VM { - return cppFn("create", .{@enumToInt(heap_type)}); - } - - pub fn deinit(vm: *VM) void { - return cppFn("deinit", .{vm}); - } - - pub fn setExecutionForbidden(vm: *VM, forbidden: bool) void { - cppFn("setExecutionForbidden", .{ vm, forbidden }); - } - - pub fn executionForbidden(vm: *VM) bool { - return cppFn("executionForbidden", .{ - vm, - }); - } - - pub fn isEntered(vm: *VM) bool { - return cppFn("isEntered", .{ - vm, - }); - } - - pub fn throwError(vm: *VM, scope: *ThrowScope, message: [*]const u8, len: usize) bool { - return cppFn("throwError", .{ - vm, - }); - } - - pub const Extern = [_][]const u8{ "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError" }; -}; - -pub const ExceptionScope = opaque { - pub const shim = Shimmer("JSC", "ExceptionScope", @This()); - - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/ExceptionScope.h>"; - pub const name = "JSC::ExceptionScope"; - pub const namespace = "JSC"; - - pub fn declareThrowScope( - vm: *VM, - function_name: [*]u8, - file: [*]u8, - line: usize, - ) *ThrowScope { - return cppFn("declareThrowScope", .{ vm, file, line }); - } - - pub fn declareCatchScope( - vm: *VM, - function_name: [*]u8, - file: [*]u8, - line: usize, - ) *CatchScope { - return cppFn("declareCatchScope", .{ vm, file, line }); - } - - pub fn release(this: *ExceptionScope) void { - return cppFn("release", .{this}); - } - - pub fn exception(this: *ExceptionScope) ?*Exception { - return cppFn("exception", .{this}); - } - - pub fn clearException(this: *ExceptionScope) void { - return cppFn("clearException", .{this}); - } - - pub const Extern = [_][]const u8{ - "release", - "declareThrowScope", "declareCatchScope", - "release", "exception", - "clearException", - }; -}; - -pub const ThrowScope = ExceptionScope; -pub const CatchScope = ExceptionScope; - -pub const CallFrame = opaque { - pub const shim = Shimmer("JSC", "CallFrame", @This()); - - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/CallFrame.h>"; - pub const name = "JSC::CallFrame"; - pub const namespace = "JSC"; - - pub inline fn argumentsCount(call_frame: *const CallFrame) usize { - return cppFn("argumentsCount", .{ - call_frame, - }); - } - pub inline fn uncheckedArgument(call_frame: *const CallFrame, i: u16) *JSValue { - return cppFn("uncheckedArgument", .{ call_frame, i }); - } - pub inline fn argument(call_frame: *const CallFrame, i: u16) *JSValue { - return cppFn("argument", .{ - call_frame, - }); - } - pub inline fn thisValue(call_frame: *const CallFrame) ?*JSValue { - return cppFn("thisValue", .{ - call_frame, - }); - } - pub inline fn newTarget(call_frame: *const CallFrame) ?*JSValue { - return cppFn("newTarget", .{ - call_frame, - }); - } - pub inline fn jsCallee(call_frame: *const CallFrame) *JSObject { - return cppFn("jsCallee", .{ - call_frame, - }); - } - pub const Extern = [_][]const u8{ "argumentsCount", "uncheckedArgument", "argument", "thisValue", "newTarget", "jsCallee" }; -}; - -// pub const WellKnownSymbols = opaque { -// pub const shim = Shimmer("JSC", "CommonIdentifiers", @This()); - -// -// - -// pub const include = "<JavaScriptCore/CommonIdentifiers.h>"; -// pub const name = "JSC::CommonIdentifiers"; -// pub const namespace = "JSC"; - -// pub var hasthis: *Identifier = shim.cppConst(Identifier, "hasInstance"); -// pub var isConcatSpreadable: Identifier = shim.cppConst(Identifier, "isConcatSpreadable"); -// pub var asyncIterator: Identifier = shim.cppConst(Identifier, "asyncIterator"); -// pub var iterator: Identifier = shim.cppConst(Identifier, "iterator"); -// pub var match: Identifier = shim.cppConst(Identifier, "match"); -// pub var matchAll: Identifier = shim.cppConst(Identifier, "matchAll"); -// pub var replace: Identifier = shim.cppConst(Identifier, "replace"); -// pub var search: Identifier = shim.cppConst(Identifier, "search"); -// pub var species: Identifier = shim.cppConst(Identifier, "species"); -// pub var split: Identifier = shim.cppConst(Identifier, "split"); -// pub var toPrimitive: Identifier = shim.cppConst(Identifier, "toPrimitive"); -// pub var toStringTag: Identifier = shim.cppConst(Identifier, "toStringTag"); -// pub var unscopable: Identifier = shim.cppConst(Identifier, "unscopabl"); - -// }; - -pub const EncodedJSValue = opaque { - pub const shim = Shimmer("JSC", "EncodedJSValue", @This()); - - pub const Type = u64; - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/VM.h>"; - pub const name = "JSC::VM"; - pub const namespace = "JSC"; -}; - -pub const Identifier = opaque { - pub const shim = Shimmer("JSC", "Identifier", @This()); - - const cppFn = shim.cppFn; - - pub const include = "<JavaScriptCore/Identifier.h>"; - pub const name = "JSC::Identifier"; - pub const namespace = "JSC"; - - pub fn fromString(vm: *VM, other: *String) *Identifier { - return cppFn("fromString", .{ vm, other }); - } - - pub fn fromSlice(vm: *VM, ptr: [*]u8, len: usize) *Identifier { - return cppFn("fromSlice", .{ vm, ptr, len }); - } - - pub fn fromUid(vm: *VM, other: *StringImpl) *Identifier { - return cppFn("fromString", .{ vm, other }); - } - - pub fn deinit(vm: *VM) void { - return cppFn("deinit", .{vm}); - } - - pub fn toString(identifier: *Identifier) *String { - return cppFn("toString", .{identifier}); - } - - pub fn length(identifier: *Identifier) usize { - return cppFn("length", .{identifier}); - } - - pub fn isNull(this: *Identifier) bool { - return cppFn("isNull", .{this}); - } - pub fn isEmpty(this: *Identifier) bool { - return cppFn("isEmpty", .{this}); - } - pub fn isSymbol(this: *Identifier) bool { - return cppFn("isSymbol", .{this}); - } - pub fn isPrivateName(this: *Identifier) bool { - return cppFn("isPrivateName", .{this}); - } - - pub fn eqlIdent(this: *Identifier, other: *Identifier) bool { - return cppFn("eqlIdent", .{ this, other }); - } - - pub fn neqlIdent(this: *Identifier, other: *Identifier) bool { - return cppFn("neqlIdent", .{ this, other }); - } - - pub fn eqlStringImpl(this: *Identifier, other: *StringImpl) bool { - return cppFn("eqlStringImpl", .{ this, other }); - } - - pub fn neqlStringImpl(this: *Identifier, other: *StringImpl) bool { - return cppFn("neqlStringImpl", .{ this, other }); - } - - pub fn eqlUTF8(this: *Identifier, other: [*]u8, other_len: usize) bool { - return cppFn("eqlUTF8", .{ this, other, other_len }); - } - - pub const Extern = [_][]const u8{ - "fromString", - "fromSlice", - "fromUid", - "deinit", - "toString", - "length", - "isNull", - "isEmpty", - "isSymbol", - "isPrivateName", - "eqlIdent", - "neqlIdent", - "eqlStringImpl", - "neqlStringImpl", - "eqlUTF8", - }; -}; - -pub const StringImpl = opaque { - pub const shim = Shimmer("WTF", "StringImpl", @This()); - - const cppFn = shim.cppFn; - - pub const include = "<WTF/text/StringImpl.h>"; - pub const name = "WTF::StringImpl"; - pub const namespace = "WTF"; - - pub fn is8Bit(this: *StringImpl) bool { - return cppFn("is8Bit", .{this}); - } - pub fn is16Bit(this: *StringImpl) bool { - return cppFn("is16Bit", .{this}); - } - pub fn isExternal(this: *StringImpl) bool { - return cppFn("isExternal", .{this}); - } - pub fn isStatic(this: *StringImpl) bool { - return cppFn("isStatic", .{this}); - } - pub fn isEmpty(this: *StringImpl) bool { - return cppFn("isEmpty", .{this}); - } - pub fn length(this: *StringImpl) usize { - return cppFn("length", .{this}); - } - pub fn characters8(this: *StringImpl) [*]u8 { - return cppFn("characters8", .{this}); - } - pub fn characters16(this: *StringImpl) [*]u16 { - return cppFn("characters16", .{this}); - } - - pub fn slice(this: *String) []const u8 { - if (this.isEmpty()) return ""; - - if (this.is8Bit()) { - return if (this.characters8()) |ptr| ptr[0..this.length()] else ""; - } else { - return if (this.characters8()) |ptr| ptr[0..this.length()] else ""; - } - } - - pub const Extern = [_][]const u8{ - "is8Bit", - "is16Bit", - "isExternal", - "isStatic", - "isEmpty", - "length", - "characters8", - "characters16", - }; -}; - -pub const StringView = opaque { - pub const shim = Shimmer("WTF", "StringView", @This()); - - const cppFn = shim.cppFn; - - pub const include = "<WTF/text/StringView.h>"; - pub const name = "WTF::StringView"; - pub const namespace = "WTF"; - - pub fn from8Bit(ptr: [*]const u8, len: usize) *StringView { - return cppFn("from8Bit", .{ ptr, len }); - } - - pub fn fromSlice(value: []const u8) *StringView { - return from8Bit(value.ptr, value.len); - } - - pub fn is8Bit(this: *StringView) bool { - return cppFn("is8Bit", .{this}); - } - pub fn is16Bit(this: *StringView) bool { - return cppFn("is16Bit", .{this}); - } - pub fn isEmpty(this: *StringView) bool { - return cppFn("isEmpty", .{this}); - } - pub fn length(this: *StringView) usize { - return cppFn("length", .{this}); - } - pub fn characters8(this: *StringView) ?[*]u8 { - return cppFn("characters8", .{this}); - } - pub fn characters16(this: *StringView) ?[*]u16 { - return cppFn("characters16", .{this}); - } - - pub fn slice(this: *StringView) []const u8 { - if (this.isEmpty()) return ""; - - if (this.is8Bit()) { - return if (this.characters8()) |ptr| ptr[0..this.length()] else ""; - } else { - return if (this.characters8()) |ptr| ptr[0..this.length()] else ""; - } - } - - pub const Extern = [_][]const u8{ - "from8Bit", - "is8Bit", - "is16Bit", - "isEmpty", - "length", - "characters8", - "characters16", - }; -}; - -pub const Cpp = struct { - pub const Function = fn ( - globalObject: *JSGlobalObject, - callframe: CallFrame, - ) *EncodedJSValue; - pub const Getter = fn ( - globalObject: *JSGlobalObject, - this: *EncodedJSValue, - propertyName: *PropertyName, - ) *EncodedJSValue; - pub const Setter = fn ( - globalObject: *JSGlobalObject, - this: *EncodedJSValue, - value: EncodedJSValue, - propertyName: *PropertyName, - ) bool; - - pub const Tag = enum { - Callback, - Constructor, - Getter, - Setter, - }; - - pub const LUTAttribute = enum { - Function, - Accessor, - CellProperty, - ClassStructure, - PropertyCallback, - }; - - pub const ZigValue = union(Tag) { - Callback: Function, - Constructor: Function, - Getter: Getter, - Setter: Setter, - }; -}; -pub const Callback = opaque { - // zig: Value, -}; - -const _JSGlobalObject = _Wundle("JSGlobalObject"); -const ObjectPrototype = _JSCellStub("ObjectPrototype"); -const FunctionPrototype = _JSCellStub("FunctionPrototype"); -const ArrayPrototype = _JSCellStub("ArrayPrototype"); -const StringPrototype = _JSCellStub("StringPrototype"); -const BigIntPrototype = _JSCellStub("BigIntPrototype"); -const RegExpPrototype = _JSCellStub("RegExpPrototype"); -const IteratorPrototype = _JSCellStub("IteratorPrototype"); -const AsyncIteratorPrototype = _JSCellStub("AsyncIteratorPrototype"); -const GeneratorFunctionPrototype = _JSCellStub("GeneratorFunctionPrototype"); -const GeneratorPrototype = _JSCellStub("GeneratorPrototype"); -const AsyncFunctionPrototype = _JSCellStub("AsyncFunctionPrototype"); -const ArrayIteratorPrototype = _JSCellStub("ArrayIteratorPrototype"); -const MapIteratorPrototype = _JSCellStub("MapIteratorPrototype"); -const SetIteratorPrototype = _JSCellStub("SetIteratorPrototype"); -const JSPromisePrototype = _JSCellStub("JSPromisePrototype"); -const AsyncGeneratorPrototype = _JSCellStub("AsyncGeneratorPrototype"); -const AsyncGeneratorFunctionPrototype = _JSCellStub("AsyncGeneratorFunctionPrototype"); diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h new file mode 100644 index 000000000..7436bc531 --- /dev/null +++ b/src/javascript/jsc/bindings/ZigGlobalObject.h @@ -0,0 +1,65 @@ +#pragma once + +namespace JSC { + class Structure; + class Identifier; + +} + + + +#include <JavaScriptCore/JSGlobalObject.h> + + + + +namespace Zig { + using namespace JSC; + +class GlobalObject final : public JSGlobalObject { +public: + using Base = JSGlobalObject; + + DECLARE_EXPORT_INFO; + static const GlobalObjectMethodTable s_globalObjectMethodTable; + + static constexpr bool needsDestruction = true; + template<typename CellType, SubspaceAccess mode> + static IsoSubspace* subspaceFor(VM& vm) + { + return vm.apiGlobalObjectSpace<mode>(); + } + + static GlobalObject* create(VM& vm, Structure* structure) + { + auto* object = new (NotNull, allocateCell<GlobalObject>(vm.heap)) GlobalObject(vm, structure); + object->finishCreation(vm); + return object; + } + + static Structure* createStructure(VM& vm, JSValue prototype) + { + auto* result = Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info()); + result->setTransitionWatchpointIsLikelyToBeFired(true); + return result; + } + + static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, Exception*); + + static JSInternalPromise* moduleLoaderImportModule(JSGlobalObject*, JSModuleLoader*, JSString* moduleNameValue, JSValue parameters, const SourceOrigin&); + static Identifier moduleLoaderResolve(JSGlobalObject*, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue); + static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue); + static JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*, JSModuleLoader*, JSValue, JSModuleRecord*, JSValue); + static JSValue moduleLoaderEvaluate(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue, JSValue, JSValue); + + +private: + GlobalObject(VM& vm, Structure* structure) + : Base(vm, structure, &s_globalObjectMethodTable) + { } +}; + +} + + + diff --git a/src/javascript/jsc/bindings/bindings-generator.zig b/src/javascript/jsc/bindings/bindings-generator.zig index 96a36cd59..71ece7a59 100644 --- a/src/javascript/jsc/bindings/bindings-generator.zig +++ b/src/javascript/jsc/bindings/bindings-generator.zig @@ -21,11 +21,14 @@ pub fn main() anyerror!void { var writer = stdout.writer(); 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 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, "src/javascript/jsc/bindings/bindings.zig", ); - HeaderGenerator.exec(HeaderGenerator{}, file); + HeaderGenerator.exec(HeaderGenerator{}, file, cpp); } diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp index ad35863e2..1cf55cff8 100644 --- a/src/javascript/jsc/bindings/bindings.cpp +++ b/src/javascript/jsc/bindings/bindings.cpp @@ -1,10 +1,514 @@ + +#include "headers.h" #include "root.h" -// namespace Bundler { -// class CustomGlobalObject : public JSC::JSGlobalObject { -// }; +#include <JavaScriptCore/ExceptionScope.h> +#include <JavaScriptCore/JSObject.h> +#include <JavaScriptCore/JSCInlines.h> +#include <wtf/text/WTFString.h> +#include <wtf/text/StringImpl.h> +#include <wtf/text/ExternalStringImpl.h> +#include <wtf/text/StringView.h> +#include <JavaScriptCore/Identifier.h> +#include <JavaScriptCore/VM.h> +#include <JavaScriptCore/VM.h> +#include <JavaScriptCore/WasmFaultSignalHandler.h> +#include <wtf/text/StringCommon.h> + +template<class To, class From> +To cast(From v) +{ + return *static_cast<To*>(static_cast<void*>(v)); +} + +template<class To, class From> +To ccast(From v) +{ + return *static_cast<const To*>(static_cast<const void*>(v)); +} + +extern "C" { + +#pragma mark - JSC::JSValue + +JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0) { + auto value = JSC::JSValue::decode(JSValue0); + return value.asCell(); +} +double JSC__JSValue__asNumber(JSC__JSValue JSValue0) { + auto value = JSC::JSValue::decode(JSValue0); + return value.asNumber(); +}; +bJSC__JSObject JSC__JSValue__asObject(JSC__JSValue JSValue0) { + auto value = JSC::JSValue::decode(JSValue0); + auto obj = JSC::asObject(value); + return cast<bJSC__JSObject>(&obj); +}; +JSC__JSString* JSC__JSValue__asString(JSC__JSValue JSValue0) { + auto value = JSC::JSValue::decode(JSValue0); + return JSC::asString(value); +}; +// uint64_t JSC__JSValue__encode(JSC__JSValue JSValue0) { // } +bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell* arg1) { + return JSC::JSValue::decode(JSValue0) == arg1; +}; +bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1) { + return JSC::JSValue::decode(JSValue0) == JSC::JSValue::decode(JSValue1); +}; +JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { + auto value = JSC::JSValue::decode(JSValue0); + return JSC::JSValue::encode(value.getPrototype(arg1)); +} +bool JSC__JSValue__isAnyInt(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isAnyInt(); } +bool JSC__JSValue__isBigInt(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isBigInt(); } +bool JSC__JSValue__isBigInt32(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isBigInt32(); } +bool JSC__JSValue__isBoolean(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isBoolean(); } +bool JSC__JSValue__isCell(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isCell(); } +bool JSC__JSValue__isCustomGetterSetter(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isCustomGetterSetter(); } +// bool JSC__JSValue__isError(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).getPrototype() } +bool JSC__JSValue__isGetterSetter(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isGetterSetter(); } +bool JSC__JSValue__isHeapBigInt(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isHeapBigInt(); } +bool JSC__JSValue__isInt32AsAnyInt(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isInt32AsAnyInt(); } +bool JSC__JSValue__isNull(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isNull(); } +bool JSC__JSValue__isNumber(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isNumber(); } +bool JSC__JSValue__isObject(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isObject(); } +bool JSC__JSValue__isPrimitive(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isPrimitive(); } +bool JSC__JSValue__isString(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isString(); } +bool JSC__JSValue__isSymbol(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isSymbol(); } +bool JSC__JSValue__isUInt32AsAnyInt(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isUInt32AsAnyInt(); } +bool JSC__JSValue__isUndefined(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isUndefined(); } +bool JSC__JSValue__isUndefinedOrNull(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isUndefinedOrNull(); } +JSC__JSValue JSC__JSValue__jsBoolean(bool arg0) { return JSC::JSValue::encode(JSC::jsBoolean(arg0)); }; +JSC__JSValue JSC__JSValue__jsDoubleNumber(double arg0) {return JSC::JSValue::encode(JSC::jsNumber(arg0)); } +JSC__JSValue JSC__JSValue__jsNull() { return JSC::JSValue::encode(JSC::jsNull()); }; +JSC__JSValue JSC__JSValue__jsNumberFromChar(char arg0) { return JSC::JSValue::encode(JSC::jsNumber(arg0));}; +JSC__JSValue JSC__JSValue__jsNumberFromDouble(double arg0) { return JSC::JSValue::encode(JSC::jsNumber(arg0));}; +JSC__JSValue JSC__JSValue__jsNumberFromInt32(int32_t arg0) { return JSC::JSValue::encode(JSC::jsNumber(arg0));}; +JSC__JSValue JSC__JSValue__jsNumberFromInt64(int64_t arg0) { return JSC::JSValue::encode(JSC::jsNumber(arg0));}; +JSC__JSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0) { return JSC::JSValue::encode(JSC::jsNumber(arg0));}; +JSC__JSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0) { return JSC::JSValue::encode(JSC::jsNumber(arg0));}; +JSC__JSValue JSC__JSValue__jsTDZValue() { return JSC::JSValue::encode(JSC::jsTDZValue()); }; +JSC__JSValue JSC__JSValue__jsUndefined() { return JSC::JSValue::encode(JSC::jsUndefined()); }; +JSC__JSObject* JSC__JSValue__toObject(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { + JSC::JSValue value = JSC::JSValue::decode(JSValue0); + return value.toObject(arg1); +} + +bJSC__Identifier JSC__JSValue__toPropertyKey(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { + JSC::JSValue value = JSC::JSValue::decode(JSValue0); + auto ident = value.toPropertyKey(arg1); + return cast<bJSC__Identifier>(&ident); +} +JSC__JSValue JSC__JSValue__toPropertyKeyValue(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { + JSC::JSValue value = JSC::JSValue::decode(JSValue0); + return JSC::JSValue::encode(value.toPropertyKeyValue(arg1)); +} +JSC__JSString* JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { + JSC::JSValue value = JSC::JSValue::decode(JSValue0); + return value.toString(arg1); +}; +JSC__JSString* JSC__JSValue__toStringOrNull(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { + JSC::JSValue value = JSC::JSValue::decode(JSValue0); + return value.toStringOrNull(arg1); +} + + +#pragma mark - JSC::PropertyName + +bool JSC__PropertyName__eqlToIdentifier(JSC__PropertyName* arg0, const JSC__Identifier* arg1) { + return (*arg0) == (*arg1); +}; +bool JSC__PropertyName__eqlToPropertyName(JSC__PropertyName* arg0, const JSC__PropertyName* arg1) { + return (*arg0) == (*arg1); +}; +const WTF__StringImpl* JSC__PropertyName__publicName(JSC__PropertyName* arg0) { + return arg0->publicName(); +}; +const WTF__StringImpl* JSC__PropertyName__uid(JSC__PropertyName* arg0) { + return arg0->uid(); +}; + + +#pragma mark - JSC::VM + +JSC__JSLock* JSC__VM__apiLock(JSC__VM* arg0) { + return makeRefPtr((*arg0).apiLock()).leakRef(); +} +JSC__VM* JSC__VM__create(char HeapType0) { + JSC::VM* vm = &JSC::VM::create(HeapType0 == JSC::SmallHeap ? JSC::SmallHeap : JSC::LargeHeap).leakRef(); + #if ENABLE(WEBASSEMBLY) + JSC::Wasm::enableFastMemory(); + #endif + + return vm; +} +void JSC__VM__deinit(JSC__VM* arg1, JSC__JSGlobalObject* globalObject) { + JSC::VM& vm = reinterpret_cast<JSC::VM&>(arg1); + bool protectCountIsZero = vm.heap.unprotect(globalObject); + + if (protectCountIsZero) + vm.heap.reportAbandonedObjectGraph(); + + vm.deref(); +} +void JSC__VM__drainMicrotasks(JSC__VM* arg0) { + arg0->drainMicrotasks(); +} + +bool JSC__VM__executionForbidden(JSC__VM* arg0) { + return (*arg0).executionForbidden(); +} + +bool JSC__VM__isEntered(JSC__VM* arg0) { + return (*arg0).isEntered(); +} + +void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1) { + (*arg0).setExecutionForbidden(); +} + +bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const char* arg3, size_t arg4) { + auto scope = arg2; + auto global = arg1; + const String& message = WTF::String(arg3, arg4); + return JSC::throwException(global, (*scope), createError(global, message)); +} + +#pragma mark - JSC::ThrowScope + +void JSC__ThrowScope__clearException(JSC__ThrowScope* arg0) { + arg0->clearException(); +}; +bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, char* arg1, char* arg2, size_t arg3) { + JSC::ThrowScope scope = JSC::ThrowScope(reinterpret_cast<JSC::VM&>(arg0)); + return cast<bJSC__ThrowScope>(&scope); +}; +JSC__Exception* JSC__ThrowScope__exception(JSC__ThrowScope* arg0) { + return arg0->exception(); +} +void JSC__ThrowScope__release(JSC__ThrowScope* arg0) { + arg0->release(); +} + +#pragma mark - JSC::CatchScope + +void JSC__CatchScope__clearException(JSC__CatchScope* arg0) { + arg0->clearException(); +} +bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, char* arg1, char* arg2, size_t arg3) { + JSC::CatchScope scope = JSC::CatchScope(reinterpret_cast<JSC::VM&>(arg0)); + return cast<bJSC__CatchScope>(&scope); +} +JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0) { + return arg0->exception(); +} + + +#pragma mark - JSC::CallFrame + +JSC__JSValue JSC__CallFrame__argument(const JSC__CallFrame* arg0, uint16_t arg1) { + return JSC::JSValue::encode(arg0->argument(arg1)); +}; +size_t JSC__CallFrame__argumentsCount(const JSC__CallFrame* arg0) { + return arg0->argumentCount(); +} +JSC__JSObject* JSC__CallFrame__jsCallee(const JSC__CallFrame* arg0) { + return arg0->jsCallee(); +} +JSC__JSValue JSC__CallFrame__newTarget(const JSC__CallFrame* arg0) { + return JSC::JSValue::encode(arg0->newTarget()); +}; +JSC__JSValue JSC__CallFrame__thisValue(const JSC__CallFrame* arg0) { + return JSC::JSValue::encode(arg0->thisValue()); +} +JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame* arg0, uint16_t arg1) { + return JSC::JSValue::encode(arg0->uncheckedArgument(arg1)); +} + +#pragma mark - JSC::Identifier + +bool JSC__Identifier__eqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1) { + return arg0 == arg1; +}; +bool JSC__Identifier__eqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1) { + return JSC::Identifier::equal(arg0->string().impl(), arg1); +}; +bool JSC__Identifier__eqlUTF8(const JSC__Identifier* arg0, const char* arg1, size_t arg2) { + return JSC::Identifier::equal(arg0->string().impl(), reinterpret_cast<const LChar*>(arg1), arg2); +}; +bool JSC__Identifier__neqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1) { + return arg0 != arg1; +} +bool JSC__Identifier__neqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1) { + return !JSC::Identifier::equal(arg0->string().impl(), arg1); +}; + +bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM* arg0, const char* arg1, size_t arg2) { + JSC::Identifier ident = JSC::Identifier::fromString(reinterpret_cast<JSC__VM&>(arg0), reinterpret_cast<const LChar*>(arg1), static_cast<int>(arg2)); + return cast<bJSC__Identifier>(&ident); +}; +bJSC__Identifier JSC__Identifier__fromString(JSC__VM* arg0, const WTF__String* arg1) { + JSC::Identifier ident = JSC::Identifier::fromString(reinterpret_cast<JSC__VM&>(arg0), reinterpret_cast<const WTF__String&>(arg1)); + return cast<bJSC__Identifier>(&ident); +}; +// bJSC__Identifier JSC__Identifier__fromUid(JSC__VM* arg0, const WTF__StringImpl* arg1) { +// auto ident = JSC::Identifier::fromUid(&arg0, &arg1); +// return *cast<bJSC__Identifier>(&ident); +// }; +bool JSC__Identifier__isEmpty(const JSC__Identifier* arg0) { + return arg0->isEmpty(); +}; +bool JSC__Identifier__isNull(const JSC__Identifier* arg0) { + return arg0->isNull(); +}; +bool JSC__Identifier__isPrivateName(const JSC__Identifier* arg0) { + return arg0->isPrivateName(); +}; +bool JSC__Identifier__isSymbol(const JSC__Identifier* arg0) { + return arg0->isSymbol(); +}; +size_t JSC__Identifier__length(const JSC__Identifier* arg0) { + return arg0->length(); +}; + +bWTF__String JSC__Identifier__toString(const JSC__Identifier* arg0) { + auto string = arg0->string(); + return cast<bWTF__String>(&string); +}; + + +#pragma mark - WTF::StringView + +const uint16_t* WTF__StringView__characters16(const WTF__StringView* arg0) { + WTF::StringView* view = (WTF::StringView*)arg0; + return reinterpret_cast<const uint16_t*>(view->characters16()); +} +const char* WTF__StringView__characters8(const WTF__StringView* arg0) { + return reinterpret_cast<const char*>(arg0->characters8()); +}; + +bool WTF__StringView__is16Bit(const WTF__StringView* arg0) {return !arg0->is8Bit(); }; +bool WTF__StringView__is8Bit(const WTF__StringView* arg0) {return arg0->is8Bit(); }; +bool WTF__StringView__isEmpty(const WTF__StringView* arg0) {return arg0->isEmpty(); }; +size_t WTF__StringView__length(const WTF__StringView* arg0) {return arg0->length(); }; + +#pragma mark - WTF::StringImpl + +const uint16_t* WTF__StringImpl__characters16(const WTF__StringImpl* arg0) { + return reinterpret_cast<const uint16_t*>(arg0->characters16()); +} +const char* WTF__StringImpl__characters8(const WTF__StringImpl* arg0) { + return reinterpret_cast<const char*>(arg0->characters8()); +} + +bWTF__StringView WTF__StringView__from8Bit(const char* arg0, size_t arg1) { + WTF::StringView view = WTF::StringView(arg0, arg1); + return cast<bWTF__StringView>(&view); +} + +bool WTF__StringImpl__is16Bit(const WTF__StringImpl* arg0) { + return !arg0->is8Bit(); +} +bool WTF__StringImpl__is8Bit(const WTF__StringImpl* arg0) { + return arg0->is8Bit(); +} +bool WTF__StringImpl__isEmpty(const WTF__StringImpl* arg0) { + return arg0->isEmpty(); +} +bool WTF__StringImpl__isExternal(const WTF__StringImpl* arg0) { + return arg0->isExternal(); +} +bool WTF__StringImpl__isStatic(const WTF__StringImpl* arg0) { + return arg0->isStatic(); +} +size_t WTF__StringImpl__length(const WTF__StringImpl* arg0) { + return arg0->length(); +} + + +#pragma mark - WTF::ExternalStringImpl + +const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0) { + return reinterpret_cast<const uint16_t*>(arg0->characters16()); +} +const char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0) { + return reinterpret_cast<const char*>(arg0->characters8()); +} + + + +bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl* arg0) { + return !arg0->is8Bit(); +} +bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl* arg0) { + return arg0->is8Bit(); +} +bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl* arg0) { + return arg0->isEmpty(); +} +bool WTF__ExternalStringImpl__isExternal(const WTF__ExternalStringImpl* arg0) { + return arg0->isExternal(); +} +bool WTF__ExternalStringImpl__isStatic(const WTF__ExternalStringImpl* arg0) { + return arg0->isStatic(); +} +size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl* arg0) { + return arg0->length(); +} + +#pragma mark - WTF::String + +const uint16_t* WTF__String__characters16(WTF__String* arg0) { + return reinterpret_cast<const uint16_t*>(arg0->characters16()); +}; + const char* WTF__String__characters8(WTF__String* arg0) { + return reinterpret_cast<const char*>(arg0->characters8()); +}; + + bool WTF__String__eqlSlice(WTF__String* arg0, const char* arg1, size_t arg2) { + return WTF::equal(arg0->impl(), reinterpret_cast<const LChar*>(arg1), arg2); +} + bool WTF__String__eqlString(WTF__String* arg0, const WTF__String* arg1) { + return arg0 == arg1; +} + const WTF__StringImpl* WTF__String__impl(WTF__String* arg0) { + return arg0->impl(); + } + +bool WTF__String__is16Bit(WTF__String* arg0) {return !arg0->is8Bit();} +bool WTF__String__is8Bit(WTF__String* arg0) {return arg0->is8Bit();} +bool WTF__String__isEmpty(WTF__String* arg0) {return arg0->isEmpty();} +bool WTF__String__isExternal(WTF__String* arg0) {return arg0->impl()->isExternal();} +bool WTF__String__isStatic(WTF__String* arg0) {return arg0->impl()->isStatic();} +size_t WTF__String__length(WTF__String* arg0) {return arg0->length();} + +bWTF__String WTF__String__createFromExternalString(bWTF__ExternalStringImpl arg0) { + WTF::ExternalStringImpl* external = cast<WTF::ExternalStringImpl*>(&arg0); + WTF::String string = WTF::String(external); + return ccast<bWTF__String>(&string); +}; +bWTF__String WTF__String__createWithoutCopyingFromPtr(const char* arg0, size_t arg1) { + const WTF::String string = WTF::String(WTF::StringImpl::createWithoutCopying(reinterpret_cast<const LChar*>(arg0), arg1)); + return ccast<bWTF__String>(&string); +} + +#pragma mark - WTF::URL + +bWTF__StringView WTF__URL__encodedPassword(WTF__URL* arg0) { + auto result = arg0->encodedPassword(); + return cast<bWTF__StringView>(&result); +}; +bWTF__StringView WTF__URL__encodedUser(WTF__URL* arg0) { + auto result = arg0->encodedUser(); + return cast<bWTF__StringView>(&result); +}; +bWTF__String WTF__URL__fileSystemPath(WTF__URL* arg0) { + auto result = arg0->fileSystemPath(); + return cast<bWTF__String>(&result); +}; +bWTF__StringView WTF__URL__fragmentIdentifier(WTF__URL* arg0) { + auto result = arg0->fragmentIdentifier(); + return cast<bWTF__StringView>(&result); +}; +bWTF__StringView WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF__URL* arg0) { + auto result = arg0->fragmentIdentifierWithLeadingNumberSign(); + return cast<bWTF__StringView>(&result); +}; +bWTF__URL WTF__URL__fromFileSystemPath(bWTF__StringView arg0) { + auto url = WTF::URL::fileURLWithFileSystemPath(cast<WTF::StringView>(&arg0)); + return cast<bWTF__URL>(&url); +}; +bWTF__URL WTF__URL__fromString(bWTF__String arg0, bWTF__String arg1) { + WTF::URL url= WTF::URL(WTF::URL(), cast<WTF::String>(&arg1)); + return cast<bWTF__URL>(&url); +}; +bWTF__StringView WTF__URL__host(WTF__URL* arg0) { + auto result = arg0->host(); + return cast<bWTF__StringView>(&result); +}; +bWTF__String WTF__URL__hostAndPort(WTF__URL* arg0) { + auto result = arg0->hostAndPort(); + return cast<bWTF__String>(&result); +}; +bool WTF__URL__isEmpty(const WTF__URL* arg0) { + return arg0->isEmpty(); +}; +bool WTF__URL__isValid(const WTF__URL* arg0) { + return arg0->isValid(); +}; +bWTF__StringView WTF__URL__lastPathComponent(WTF__URL* arg0) { + auto result = arg0->lastPathComponent(); + return cast<bWTF__StringView>(&result); +}; +bWTF__String WTF__URL__password(WTF__URL* arg0) { + auto result = arg0->password(); + return cast<bWTF__String>(&result); +}; +bWTF__StringView WTF__URL__path(WTF__URL* arg0) { + auto result = arg0->path(); + return cast<bWTF__StringView>(&result); +}; +bWTF__StringView WTF__URL__protocol(WTF__URL* arg0) { + auto result = arg0->protocol(); + return cast<bWTF__StringView>(&result); +}; +bWTF__String WTF__URL__protocolHostAndPort(WTF__URL* arg0) { + auto result = arg0->protocolHostAndPort(); + return cast<bWTF__String>(&result); +}; +bWTF__StringView WTF__URL__query(WTF__URL* arg0) { + auto result = arg0->query(); + return cast<bWTF__StringView>(&result); +}; +bWTF__StringView WTF__URL__queryWithLeadingQuestionMark(WTF__URL* arg0) { + auto result = arg0->queryWithLeadingQuestionMark(); + return cast<bWTF__StringView>(&result); +}; +bWTF__String WTF__URL__stringWithoutFragmentIdentifier(WTF__URL* arg0) { + auto result = arg0->stringWithoutFragmentIdentifier(); + return cast<bWTF__String>(&result); +}; +bWTF__StringView WTF__URL__stringWithoutQueryOrFragmentIdentifier(WTF__URL* arg0) { + auto result = arg0->stringWithoutQueryOrFragmentIdentifier(); + return cast<bWTF__StringView>(&result); +}; +bWTF__URL WTF__URL__truncatedForUseAsBase(WTF__URL* arg0) { + auto result = arg0->truncatedForUseAsBase(); + return cast<bWTF__URL>(&result); +}; +bWTF__String WTF__URL__user(WTF__URL* arg0) { + auto result = arg0->user(); + return cast<bWTF__String>(&result); +}; + +void WTF__URL__setHost(WTF__URL* arg0, bWTF__StringView arg1) { + arg0->setHost(cast<WTF::StringView>(&arg1)); +}; +void WTF__URL__setHostAndPort(WTF__URL* arg0, bWTF__StringView arg1) { + arg0->setHostAndPort(cast<WTF::StringView>(&arg1)); +}; +void WTF__URL__setPassword(WTF__URL* arg0, bWTF__StringView arg1) { + arg0->setPassword(cast<WTF::StringView>(&arg1)); +}; +void WTF__URL__setPath(WTF__URL* arg0, bWTF__StringView arg1) { + arg0->setPath(cast<WTF::StringView>(&arg1)); +}; +void WTF__URL__setProtocol(WTF__URL* arg0, bWTF__StringView arg1) { + arg0->setProtocol(cast<WTF::StringView>(&arg1)); +}; +void WTF__URL__setQuery(WTF__URL* arg0, bWTF__StringView arg1) { + arg0->setQuery(cast<WTF::StringView>(&arg1)); +}; +void WTF__URL__setUser(WTF__URL* arg0, bWTF__StringView arg1) { + arg0->setUser(cast<WTF::StringView>(&arg1)); +}; + +} + + + diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index 016de2ab9..aaba05ea2 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -1,2 +1,1854 @@ -pub usingnamespace @import("./JSValue.zig"); -pub usingnamespace @import("./DefaultGlobal.zig"); +usingnamespace @import("./imports.zig"); + +const std = @import("std"); +const main = @import("root"); +const is_bindgen = std.meta.trait.hasDecls(main, .{"bindgen"}); +const hasRef = std.meta.trait.hasField("ref"); +const StaticExport = @import("./static_export.zig"); +const Sizes = @import("./sizes.zig"); + +pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comptime Parent: type) type { + return struct { + pub const namespace = _namespace; + pub const name = _name; + + fn toCppType(comptime FromType: ?type) ?type { + return comptime brk: { + var NewReturnType = FromType orelse c_void; + + if (NewReturnType == c_void) { + break :brk FromType; + } + + var ReturnTypeInfo: std.builtin.TypeInfo = @typeInfo(FromType orelse c_void); + + if (ReturnTypeInfo == .Pointer and NewReturnType != *c_void) { + NewReturnType = ReturnTypeInfo.Pointer.child; + ReturnTypeInfo = @typeInfo(NewReturnType); + } + + switch (ReturnTypeInfo) { + .Union, + .Struct, + .Enum, + => { + if (@hasDecl(ReturnTypeInfo, "Type")) { + break :brk NewReturnType; + } + }, + else => {}, + } + + break :brk FromType; + }; + } + + pub const size_of_symbol = std.fmt.comptimePrint("{s}__{s}_object_size_", .{ namespace, name }); + pub const byte_size = brk: { + const identifier = std.fmt.comptimePrint("{s}__{s}", .{ namespace, name }); + if (@hasDecl(Sizes, identifier)) { + break :brk @field(Sizes, identifier); + } else { + break :brk 0; + } + }; + pub const Bytes = [byte_size]u8; + + pub inline fn getConvertibleType(comptime ZigType: type) type { + if (@typeInfo(ZigType) == .Struct) { + const Struct: std.builtin.TypeInfo.Struct = ChildType.Struct; + for (Struct.fields) |field| { + if (std.mem.eql(u8, field.name, "ref")) { + return field.field_type; + } + } + } + + return ZigType; + } + + fn pointerChild(comptime Type: type) type { + if (@typeInfo(Type) == .Pointer) { + return @typeInfo(Type).Pointer.child_type; + } + + return Type; + } + + pub inline fn toZigType(comptime ZigType: type, comptime CppType: type, value: CppType) *ZigType { + if (comptime hasRef(ZigType)) { + // *WTF::String => Wtf.String{ = value}, via casting instead of copying + if (comptime @typeInfo(CppType) == .Pointer and @typeInfo(ZigType) != .Pointer) { + return @bitCast(ZigType, @ptrToInt(value)); + } + } + + return @as(ZigType, value); + } + + pub fn symbolName(comptime typeName: []const u8) []const u8 { + return comptime std.fmt.comptimePrint("{s}__{s}__{s}", .{ namespace, name, typeName }); + } + + pub fn exportFunctions(comptime Functions: anytype) [std.meta.fieldNames(@TypeOf(Functions)).len]StaticExport { + const FunctionsType = @TypeOf(Functions); + return comptime brk: { + var functions: [std.meta.fieldNames(FunctionsType).len]StaticExport = undefined; + for (std.meta.fieldNames(FunctionsType)) |fn_name, i| { + const Function = @TypeOf(@field(Functions, fn_name)); + if (@typeInfo(Function) != .Fn) { + @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to be a function but received " ++ @tagName(@typeInfo(Function))); + } + var Fn: std.builtin.TypeInfo.Fn = @typeInfo(Function).Fn; + if (Fn.calling_convention != .C) { + @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to have a C Calling Convention."); + } + + const export_name = symbolName(fn_name); + functions[i] = StaticExport{ + .Type = Function, + .symbol_name = export_name, + .local_name = fn_name, + .Parent = Parent, + }; + } + + break :brk functions; + }; + } + + pub inline fn zigFn(comptime typeName: []const u8, args: anytype) (@typeInfo(@TypeOf(@field(Parent, typeName))).Fn.return_type orelse void) { + const identifier = symbolName(typeName); + const func = comptime @typeInfo(Parent).Struct.fields[std.meta.fieldIndex(Parent, typeName)].field_type; + const ReturnType = comptime @typeInfo(func).Fn.return_type orelse c_void; + + const Func: type = comptime brk: { + var FuncType: std.builtin.TypeInfo = @typeInfo(@TypeOf(func)); + var Fn: std.builtin.TypeInfo.Fn = FuncType.Fn; + + Fn.calling_convention = std.builtin.CallingConvention.C; + Fn.return_type = toCppType(Fn.return_type); + + const ArgsType = @TypeOf(args); + for (std.meta.fieldNames(args)) |field, i| { + Fn.args[i] = std.builtin.TypeInfo.FnArg{ + .is_generic = false, + .is_noalias = false, + .arg_type = @typeInfo(ArgsType).fields[i].field_type, + }; + } + FuncType.Fn = Fn; + break :brk @Type(FuncType); + }; + + comptime @export(Func, .{ .name = identifier }); + unreachable; + } + + pub inline fn cppFn(comptime typeName: []const u8, args: anytype) (ret: { + if (!@hasDecl(Parent, typeName)) { + @compileError(@typeName(Parent) ++ " is missing cppFn: " ++ typeName); + } + break :ret std.meta.declarationInfo(Parent, typeName).data.Fn.return_type; + }) { + if (comptime is_bindgen) { + unreachable; + } else { + const identifier = comptime std.fmt.comptimePrint("{s}__{s}__{s}", .{ namespace, name, typeName }); + const func = comptime @typeInfo(Parent).Struct.fields[std.meta.fieldIndex(Parent, typeName)].field_type; + const ReturnType = comptime @typeInfo(func).Fn.return_type orelse c_void; + + const Func: type = comptime brk: { + var FuncType: std.builtin.TypeInfo = @typeInfo(@TypeOf(func)); + var Fn: std.builtin.TypeInfo.Fn = FuncType.Fn; + + Fn.calling_convention = std.builtin.CallingConvention.C; + Fn.return_type = toCppType(Fn.return_type); + + const ArgsType = @TypeOf(args); + for (std.meta.fieldNames(args)) |field, i| { + Fn.args[i] = std.builtin.TypeInfo.FnArg{ + .is_generic = false, + .is_noalias = false, + .arg_type = @typeInfo(ArgsType).fields[i].field_type, + }; + } + FuncType.Fn = Fn; + break :brk @Type(FuncType); + }; + const Outgoing = comptime @extern(Func, std.builtin.ExternOptions{ .name = identifier }); + + return toZigType( + ReturnType, + @typeInfo(Func).Fn.return_type orelse void, + @call(.{}, Outgoing, args), + ); + } + } + }; +} + +pub const JSObject = packed struct { + pub const shim = Shimmer("JSC", "JSObject", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/JSObject.h>"; + pub const name = "JSC::JSObject"; + pub const namespace = "JSC"; + + pub fn putAtIndex(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName, i: u32) bool { + return cppFn("putAtIndex", .{ + this, + property_name, + i, + }); + } + + pub fn getArrayLength(this: *JSObject) usize { + return cppFn("getArrayLength", .{ + this, + }); + } + + pub fn getAtIndex(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName, i: u32) JSValue { + return cppFn("getAtIndex", .{ + this, + property_name, + i, + }); + } + + pub const Extern = [_][]const u8{ + "getArrayLength", + "getAtIndex", + "putAtIndex", + }; +}; + +pub const PropertyNameArray = packed struct { + pub const shim = Shimmer("JSC", "PropertyNameArray", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/PropertyNameArray.h>"; + pub const name = "JSC::PropertyNameArray"; + pub const namespace = "JSC"; + + pub fn length(this: *PropertyNameArray) usize { + return cppFn("length", .{this}); + } + + pub fn next(this: *PropertyNameArray, i: usize) ?*const PropertyName { + return cppFn("next", .{ this, i }); + } + + pub fn release(this: *PropertyNameArray) void { + return cppFn("release", .{this}); + } + + pub const Extern = [_][]const u8{ "length", "release", "next" }; +}; + +pub const JSCell = packed struct { + pub const shim = Shimmer("JSC", "JSCell", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/JSCell.h>"; + pub const name = "JSC::JSCell"; + pub const namespace = "JSC"; + + const CellType = enum(u8) { _ }; + + pub fn getObject(this: *JSCell) *JSObject { + return shim.cppFn("getObject", .{this}); + } + + pub fn getString(this: *JSCell, globalObject: *JSGlobalObject) *String { + return shim.cppFn("getString", .{ this, globalObject }); + } + + pub fn getType(this: *JSCell) u8 { + return shim.cppFn("getType", .{ + this, + }); + } + + pub const Extern = [_][]const u8{ "getObject", "getString", "getType" }; +}; + +pub const JSString = packed struct { + pub const shim = Shimmer("JSC", "JSString", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/JSString.h>"; + pub const name = "JSC::JSString"; + pub const namespace = "JSC"; + + pub fn getObject(this: *JSString) *JSObject { + return shim.cppFn("getObject", .{this}); + } + + pub fn eql(this: *const JSString, other: *const JSString) bool { + return shim.cppFn("eql", .{ this, other }); + } + + pub fn value(this: *JSString, globalObject: *JSGlobalObject) *String { + return shim.cppFn("value", .{ this, globalObject }); + } + + pub fn length(this: *const JSString) usize { + return shim.cppFn("length", .{ + this, + }); + } + + pub fn is8Bit(this: *const JSString) bool { + return shim.cppFn("is8Bit", .{ + this, + }); + } + + pub fn createFromOwnedString(vm: *VM, str: *const StringImpl) bool { + return shim.cppFn("createFromOwnedString", .{ + vm, str, + }); + } + + pub fn createFromString(vm: *VM, str: *const StringImpl) bool { + return shim.cppFn("createFromString", .{ + vm, str, + }); + } + + pub const Extern = [_][]const u8{ "getObject", "eql", "value", "length", "is8Bit", "createFromOwnedString", "createFromString" }; +}; + +pub const JSPromiseRejectionOperation = enum(u32) { + Reject = 0, + Handle = 1, +}; + +pub const ZigGlobalObject = packed struct { + pub const shim = Shimmer("Zig", "GlobalObject", @This()); + bytes: shim.Bytes, + pub const Type = *c_void; + pub const name = "Zig::GlobalObject"; + pub const include = "\"ZigGlobalObject.h\""; + pub const namespace = shim.namespace; + + pub fn import(global: *JSGlobalObject, loader: *JSModuleLoader, string: *JSString, value: JSValue, origin: *const SourceOrigin) callconv(.C) *JSInternalPromise { + if (comptime is_bindgen) { + unreachable; + } + } + pub fn resolve(global: *JSGlobalObject, loader: *JSModuleLoader, string: *JSString, value: JSValue, origin: *const SourceOrigin) callconv(.C) *const Identifier { + if (comptime is_bindgen) { + unreachable; + } + } + pub fn fetch(global: *JSGlobalObject, loader: *JSModuleLoader, value1: JSValue, value2: JSValue, value3: JSValue) callconv(.C) *JSInternalPromise { + if (comptime is_bindgen) { + unreachable; + } + } + pub fn eval(global: *JSGlobalObject, loader: *JSModuleLoader, key: JSValue, moduleRecordValue: JSValue, scriptFetcher: JSValue, awaitedValue: JSValue, resumeMode: JSValue) callconv(.C) JSValue { + if (comptime is_bindgen) { + unreachable; + } + } + pub fn reportUncaughtException(global: *JSGlobalObject, promise: *JSPromise, rejection: JSPromiseRejectionOperation) callconv(.C) JSValue { + if (comptime is_bindgen) { + unreachable; + } + } + + pub const Export = shim.exportFunctions(.{ + .@"import" = import, + .@"resolve" = resolve, + .@"fetch" = fetch, + .@"eval" = eval, + .@"reportUncaughtException" = reportUncaughtException, + }); + + comptime { + @export(import, .{ .name = Export[0].symbol_name }); + @export(resolve, .{ .name = Export[1].symbol_name }); + @export(fetch, .{ .name = Export[2].symbol_name }); + @export(eval, .{ .name = Export[3].symbol_name }); + @export(reportUncaughtException, .{ .name = Export[4].symbol_name }); + } +}; + +pub const DefaultGlobal = packed struct { + pub const shim = Shimmer("Wundle", "DefaultGlobal", @This()); + bytes: shim.Bytes, + pub const include = "\"DefaultGlobal.h\""; + pub const name = "Wundle::DefaultGlobal"; + pub const namespace = "Wundle"; + + pub fn getWrapper(this: *DefaultGlobal) *c_void { + return shim.cppFn("getWrapper", .{this}); + } + + pub fn create(this: *DefaultGlobal, wrapper_ptr: *c_void) *DefaultGlobal { + return shim.cppFn("create", .{ this, wrapper_ptr }); + } + + pub const Extern = [_][]const u8{ "getWrapper", "create" }; +}; + +pub const JSModuleLoader = packed struct { + pub const shim = Shimmer("JSC", "JSModuleLoader", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/JSModuleLoader.h>"; + pub const name = "JSC::JSModuleLoader"; + pub const namespace = "JSC"; + + pub fn dependencyKeysIfEvaluated(this: *JSModuleLoader, globalObject: *JSGlobalObject, moduleRecord: *JSModuleRecord) *JSValue { + return shim.cppFn("dependencyKeysIfEvaluated", .{ this, globalObject, moduleRecord }); + } + + pub const Extern = [_][]const u8{ + "dependencyKeysIfEvaluated", + }; +}; + +pub const JSModuleRecord = packed struct { + pub const shim = Shimmer("JSC", "JSModuleRecord", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/JSModuleRecord.h>"; + pub const name = "JSC::JSModuleRecord"; + pub const namespace = "JSC"; + + pub fn sourceCode(this: *JSModuleRecord) *const SourceCode { + return shim.cppFn("sourceCode", .{ + this, + }); + } + + pub const Extern = [_][]const u8{ + "sourceCode", + }; +}; + +pub const JSPromise = packed struct { + pub const shim = Shimmer("JSC", "JSPromise", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/JSPromise.h>"; + pub const name = "JSC::JSPromise"; + pub const namespace = "JSC"; + + pub const Status = enum(u32) { + Pending = 0, // Making this as 0, so that, we can change the status from Pending to others without masking. + Fulfilled = 1, + Rejected = 2, + }; + + pub fn status(this: *const JSPromise, vm: *VM) Status { + return shim.cppFn("status", .{ this, vm }); + } + pub fn result(this: *const JSPromise, vm: *VM) JSValue { + return cppFn("result", .{ this, vm }); + } + pub fn isHandled(this: *const JSPromise, vm: *VM) bool { + return cppFn("isHandled", .{ this, vm }); + } + + pub fn rejectWithCaughtException(this: *JSPromise, globalObject: *JSGlobalObject, scope: ThrowScope) void { + return cppFn("rejectWithCaughtException", .{ this, globalObject, scope }); + } + + pub fn resolvedPromise(globalThis: *JSGlobalObject, value: JSValue) *JSPromise { + return cppFn("resolvedPromise", .{ .globalThis = globalThis, .value = value }); + } + pub fn rejectedPromise(globalThis: *JSGlobalObject, value: JSValue) *JSPromise { + return cppFn("rejectedPromise", .{ .globalThis = globalThis, .value = value }); + } + + pub fn resolve(globalThis: *JSGlobalObject, value: JSValue) void { + cppFn("resolve", .{ .globalThis = globalThis, .value = value }); + } + pub fn reject(this: *JSPromise, globalThis: *JSGlobalObject, value: JSValue) void { + cppFn("reject", .{ .this = this, .globalThis = globalThis, .value = value }); + } + pub fn rejectAsHandled(this: *JSPromise, globalThis: *JSGlobalObject, value: JSValue) void { + cppFn("rejectAsHandled", .{ .this = this, .globalThis = globalThis, .value = value }); + } + pub fn rejectException(this: *JSPromise, globalThis: *JSGlobalObject, value: *Exception) void { + cppFn("rejectException", .{ .this = this, .globalThis = globalThis, .value = value }); + } + pub fn rejectAsHandledException(this: *JSPromise, globalThis: *JSGlobalObject, value: *Exception) void { + cppFn("rejectAsHandledException", .{ .this = this, .globalThis = globalThis, .value = value }); + } + + pub fn isInternal(this: *JSPromise, vm: *VM) bool { + return cppFn("isInternal", .{ this, vm }); + } + + pub fn createDeferred(globalThis: *JSGlobalObject, resolved: *JSFunction, rejected: *JSFunction, exception: *Exception) *JSPromise { + return cppFn("createDeferred", .{ + .globalThis = globalThis, + .resolve = resolved, + .reject = rejected, + .exception = exception, + }); + } + + pub const Extern = [_][]const u8{ "rejectWithCaughtException", "status", "result", "isHandled", "resolvedPromise", "rejectedPromise", "resolve", "reject", "rejectAsHandled", "rejectException", "rejectAsHandledException", "isInternal", "createDeferred" }; +}; + +pub const JSInternalPromise = JSPromise; + +// SourceProvider.h +pub const SourceType = enum(u8) { + Program = 0, + Module = 1, + WebAssembly = 2, +}; + +pub const SourceOrigin = packed struct { + pub const shim = Shimmer("JSC", "SourceOrigin", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/SourceOrigin.h>"; + pub const name = "JSC::SourceOrigin"; + pub const namespace = "JSC"; + + pub fn fromURL(url: *const URL) *const SourceOrigin { + return cppFn("fromURL", .{url}); + } + + pub const Extern = [_][]const u8{ + "fromURL", + }; +}; + +pub const SourceCode = packed struct { + pub const shim = Shimmer("JSC", "SourceCode", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/SourceProvider.h>"; + pub const name = "JSC::SourceCode"; + pub const namespace = "JSC"; + + pub fn fromString(source: *const String, origin: *const SourceOrigin, filename: *String, source_type: SourceType) *const SourceCode { + return cppFn("fromString", .{ source, origin, filename, source_type }); + } + + pub const Extern = [_][]const u8{ + "fromString", + }; +}; + +pub const JSFunction = packed struct { + pub const shim = Shimmer("JSC", "JSFunction", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/JSFunction.h>"; + pub const name = "JSC::JSFunction"; + pub const namespace = "JSC"; + + pub fn createFromSourceCode(source: *SourceCode, origin: *SourceOrigin, exception: ?*Exception) *JSFunction { + return cppFn("createFromSourceCode", .{ source, origin, exception }); + } + pub fn createFromNative( + vm: *VM, + globalthis: *JSGlobalObject, + argument_count: u32, + name_: *String, + func: *c_void, + ) *JSFunction { + return cppFn("createFromNative", .{ vm, globalthis, argument_count, name_, func }); + } + pub fn getName(this: *JSFunction, vm: *VM) *String { + return cppFn("getName", .{ this, vm }); + } + pub fn displayName(this: *JSFunction, vm: *VM) *String { + return cppFn("displayName", .{ this, vm }); + } + pub fn calculatedDisplayName(this: *JSFunction, vm: *VM) *String { + return cppFn("calculatedDisplayName", .{ this, vm }); + } + pub fn toString(this: *JSFunction, globalThis: *JSGlobalObject) *const JSString { + return cppFn("toString", .{ this, globalThis }); + } + + pub fn callWithArgumentsAndThis( + function: *JSFunction, + thisValue: JSValue, + globalThis: *JSGlobalObject, + arguments_ptr: [*]JSValue, + arguments_len: usize, + exception: *?*Exception, + error_message: ?*const u8, + ) JSValue { + return cppFn("callWithArgumentsAndThis", .{ + function, + globalThis, + thisValue, + arguments_ptr, + arguments_len, + exception, + error_message, + }); + } + + pub fn callWithArguments( + function: *JSFunction, + globalThis: *JSGlobalObject, + arguments_ptr: [*]JSValue, + arguments_len: usize, + exception: *?*Exception, + error_message: ?*const u8, + ) JSValue { + return cppFn("callWithArguments", .{ function, globalThis, arguments_ptr, arguments_len, exception, exception, error_message }); + } + + pub fn callWithThis( + function: *JSFunction, + globalThis: *JSGlobalObject, + thisValue: JSValue, + exception: *?*Exception, + error_message: ?*const u8, + ) JSValue { + return cppFn("callWithArguments", .{ + function, + globalThis, + thisValue, + exception, + error_message, + }); + } + + pub fn callWithoutAnyArgumentsOrThis( + function: *JSFunction, + globalThis: *JSGlobalObject, + exception: *?*Exception, + error_message: ?*const u8, + ) JSValue { + return cppFn("callWithoutAnyArgumentsOrThis", .{ function, globalThis, exception, exception, error_message }); + } + + pub fn constructWithArgumentsAndNewTarget( + function: *JSFunction, + newTarget: JSValue, + globalThis: *JSGlobalObject, + arguments_ptr: [*]JSValue, + arguments_len: usize, + exception: *?*Exception, + error_message: ?*const u8, + ) JSValue { + return cppFn("constructWithArgumentsAndNewTarget", .{ + function, + globalThis, + newTarget, + arguments_ptr, + arguments_len, + exception, + error_message, + }); + } + + pub fn constructWithArguments( + function: *JSFunction, + globalThis: *JSGlobalObject, + arguments_ptr: [*]JSValue, + arguments_len: usize, + exception: *?*Exception, + error_message: ?*const u8, + ) JSValue { + return cppFn("constructWithArguments", .{ function, globalThis, arguments_ptr, arguments_len, exception, exception, error_message }); + } + + pub fn constructWithNewTarget( + function: *JSFunction, + globalThis: *JSGlobalObject, + newTarget: JSValue, + exception: *?*Exception, + error_message: ?*const u8, + ) JSValue { + return cppFn("constructWithArguments", .{ + function, + globalThis, + newTarget, + exception, + error_message, + }); + } + + pub fn constructWithoutAnyArgumentsOrNewTarget( + function: *JSFunction, + globalThis: *JSGlobalObject, + exception: *?*Exception, + error_message: ?*const u8, + ) JSValue { + return cppFn("constructWithoutAnyArgumentsOrNewTarget", .{ function, globalThis, exception, exception, error_message }); + } + + pub const Extern = [_][]const u8{ + "fromString", + "createFromSourceCode", + "createFromNative", + "getName", + "displayName", + "calculatedDisplayName", + "callWithArgumentsAndThis", + "callWithArguments", + "callWithThis", + "callWithoutAnyArgumentsOrThis", + "constructWithArgumentsAndNewTarget", + "constructWithArguments", + "constructWithNewTarget", + "constructWithoutAnyArgumentsOrNewTarget", + }; +}; + +pub const JSGlobalObject = packed struct { + pub const shim = Shimmer("JSC", "JSGlobalObject", @This()); + bytes: shim.Bytes, + + pub const include = "<JavaScriptCore/JSGlobalObject.h>"; + pub const name = "JSC::JSGlobalObject"; + pub const namespace = "JSC"; + + pub const ErrorType = enum(u8) { + Error = 0, + EvalError = 1, + RangeError = 2, + ReferenceError = 3, + SyntaxError = 4, + TypeError = 5, + URIError = 6, + AggregateError = 7, + OutOfMemoryError = 8, + }; + + pub fn createError(globalObject: *JSGlobalObject, error_type: ErrorType, message: *String) *JSObject { + return cppFn("createError", .{ globalObject, @enumToInt(error_type), message }); + } + + pub fn throwError( + globalObject: *JSGlobalObject, + err: *JSObject, + ) *JSObject { + return cppFn("throwError", .{ + globalObject, + err, + }); + } + + const cppFn = shim.cppFn; + + pub fn objectPrototype(this: *JSGlobalObject) *ObjectPrototype { + return cppFn("objectPrototype", .{this}); + } + pub fn functionPrototype(this: *JSGlobalObject) *FunctionPrototype { + return cppFn("functionPrototype", .{this}); + } + pub fn arrayPrototype(this: *JSGlobalObject) *ArrayPrototype { + return cppFn("arrayPrototype", .{this}); + } + pub fn booleanPrototype(this: *JSGlobalObject) *JSObject { + return cppFn("booleanPrototype", .{this}); + } + pub fn stringPrototype(this: *JSGlobalObject) *StringPrototype { + return cppFn("stringPrototype", .{this}); + } + pub fn numberPrototype(this: *JSGlobalObject) *JSObject { + return cppFn("numberPrototype", .{this}); + } + pub fn bigIntPrototype(this: *JSGlobalObject) *BigIntPrototype { + return cppFn("bigIntPrototype", .{this}); + } + pub fn datePrototype(this: *JSGlobalObject) *JSObject { + return cppFn("datePrototype", .{this}); + } + pub fn symbolPrototype(this: *JSGlobalObject) *JSObject { + return cppFn("symbolPrototype", .{this}); + } + pub fn regExpPrototype(this: *JSGlobalObject) *RegExpPrototype { + return cppFn("regExpPrototype", .{this}); + } + pub fn errorPrototype(this: *JSGlobalObject) *JSObject { + return cppFn("errorPrototype", .{this}); + } + pub fn iteratorPrototype(this: *JSGlobalObject) *IteratorPrototype { + return cppFn("iteratorPrototype", .{this}); + } + pub fn asyncIteratorPrototype(this: *JSGlobalObject) *AsyncIteratorPrototype { + return cppFn("asyncIteratorPrototype", .{this}); + } + pub fn generatorFunctionPrototype(this: *JSGlobalObject) *GeneratorFunctionPrototype { + return cppFn("generatorFunctionPrototype", .{this}); + } + pub fn generatorPrototype(this: *JSGlobalObject) *GeneratorPrototype { + return cppFn("generatorPrototype", .{this}); + } + pub fn asyncFunctionPrototype(this: *JSGlobalObject) *AsyncFunctionPrototype { + return cppFn("asyncFunctionPrototype", .{this}); + } + pub fn arrayIteratorPrototype(this: *JSGlobalObject) *ArrayIteratorPrototype { + return cppFn("arrayIteratorPrototype", .{this}); + } + pub fn mapIteratorPrototype(this: *JSGlobalObject) *MapIteratorPrototype { + return cppFn("mapIteratorPrototype", .{this}); + } + pub fn setIteratorPrototype(this: *JSGlobalObject) *SetIteratorPrototype { + return cppFn("setIteratorPrototype", .{this}); + } + pub fn mapPrototype(this: *JSGlobalObject) *JSObject { + return cppFn("mapPrototype", .{this}); + } + pub fn jsSetPrototype(this: *JSGlobalObject) *JSObject { + return cppFn("jsSetPrototype", .{this}); + } + pub fn promisePrototype(this: *JSGlobalObject) *JSPromisePrototype { + return cppFn("promisePrototype", .{this}); + } + pub fn asyncGeneratorPrototype(this: *JSGlobalObject) *AsyncGeneratorPrototype { + return cppFn("asyncGeneratorPrototype", .{this}); + } + pub fn asyncGeneratorFunctionPrototype(this: *JSGlobalObject) *AsyncGeneratorFunctionPrototype { + return cppFn("asyncGeneratorFunctionPrototype", .{this}); + } + + pub fn vm(this: *JSGlobalObject) *VM { + return cppFn("vm", .{this}); + } + + pub const Extern = [_][]const u8{ + "objectPrototype", + "functionPrototype", + "arrayPrototype", + "booleanPrototype", + "stringPrototype", + "numberPrototype", + "bigIntPrototype", + "datePrototype", + "symbolPrototype", + "regExpPrototype", + "errorPrototype", + "iteratorPrototype", + "asyncIteratorPrototype", + "generatorFunctionPrototype", + "generatorPrototype", + "asyncFunctionPrototype", + "arrayIteratorPrototype", + "mapIteratorPrototype", + "setIteratorPrototype", + "mapPrototype", + "jsSetPrototype", + "promisePrototype", + "asyncGeneratorPrototype", + "asyncGeneratorFunctionPrototype", + "vm", + "createError", + "throwError", + }; +}; + +fn _JSCellStub(comptime str: []const u8) type { + if (is_bindgen) { + return opaque { + pub const name = "JSC::" ++ str ++ ""; + }; + } else { + return struct {}; + } +} + +fn _Wundle(comptime str: []const u8) type { + if (is_bindgen) { + return opaque { + pub const name = "Wundle::" ++ str ++ ""; + }; + } else { + return struct {}; + } +} + +fn _WTF(comptime str: []const u8) type { + if (is_bindgen) { + return opaque { + pub const name = "WTF::" ++ str ++ ""; + }; + } else { + return struct {}; + } +} + +pub const URL = packed struct { + pub const shim = Shimmer("WTF", "URL", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<wtf/URL.h>"; + pub const name = "WTF::URL"; + pub const namespace = "WTF"; + + pub fn fromString(base: String, relative: String) URL { + return cppFn("fromString", .{ base, relative }); + } + + pub fn fromFileSystemPath(file_system_path: StringView) URL { + return cppFn("fromFileSystemPath", .{file_system_path}); + } + + pub fn isEmpty(this: *const URL) bool { + return cppFn("isEmpty", .{this}); + } + pub fn isValid(this: *const URL) bool { + return cppFn("isValid", .{this}); + } + + pub fn protocol(this: *URL) StringView { + return cppFn("protocol", .{this}); + } + pub fn encodedUser(this: *URL) StringView { + return cppFn("encodedUser", .{this}); + } + pub fn encodedPassword(this: *URL) StringView { + return cppFn("encodedPassword", .{this}); + } + pub fn host(this: *URL) StringView { + return cppFn("host", .{this}); + } + pub fn path(this: *URL) StringView { + return cppFn("path", .{this}); + } + pub fn lastPathComponent(this: *URL) StringView { + return cppFn("lastPathComponent", .{this}); + } + pub fn query(this: *URL) StringView { + return cppFn("query", .{this}); + } + pub fn fragmentIdentifier(this: *URL) StringView { + return cppFn("fragmentIdentifier", .{this}); + } + pub fn queryWithLeadingQuestionMark(this: *URL) StringView { + return cppFn("queryWithLeadingQuestionMark", .{this}); + } + pub fn fragmentIdentifierWithLeadingNumberSign(this: *URL) StringView { + return cppFn("fragmentIdentifierWithLeadingNumberSign", .{this}); + } + pub fn stringWithoutQueryOrFragmentIdentifier(this: *URL) StringView { + return cppFn("stringWithoutQueryOrFragmentIdentifier", .{this}); + } + pub fn stringWithoutFragmentIdentifier(this: *URL) String { + return cppFn("stringWithoutFragmentIdentifier", .{this}); + } + pub fn protocolHostAndPort(this: *URL) String { + return cppFn("protocolHostAndPort", .{this}); + } + pub fn hostAndPort(this: *URL) String { + return cppFn("hostAndPort", .{this}); + } + pub fn user(this: *URL) String { + return cppFn("user", .{this}); + } + pub fn password(this: *URL) String { + return cppFn("password", .{this}); + } + pub fn fileSystemPath(this: *URL) String { + return cppFn("fileSystemPath", .{this}); + } + + pub fn setProtocol(this: *URL, protocol_value: StringView) void { + return cppFn("setProtocol", .{ this, protocol_value }); + } + pub fn setHost(this: *URL, host_value: StringView) void { + return cppFn("setHost", .{ this, host_value }); + } + pub fn setHostAndPort(this: *URL, host_and_port_value: StringView) void { + return cppFn("setHostAndPort", .{ this, host_and_port_value }); + } + pub fn setUser(this: *URL, user_value: StringView) void { + return cppFn("setUser", .{ this, user_value }); + } + pub fn setPassword(this: *URL, password_value: StringView) void { + return cppFn("setPassword", .{ this, password_value }); + } + pub fn setPath(this: *URL, path_value: StringView) void { + return cppFn("setPath", .{ this, path_value }); + } + pub fn setQuery(this: *URL, query_value: StringView) void { + return cppFn("setQuery", .{ this, query_value }); + } + + pub fn truncatedForUseAsBase( + this: *URL, + ) URL { + return cppFn("truncatedForUseAsBase", .{ + this, + }); + } + pub const Extern = [_][]const u8{ "fromFileSystemPath", "fromString", "isEmpty", "isValid", "protocol", "encodedUser", "encodedPassword", "host", "path", "lastPathComponent", "query", "fragmentIdentifier", "queryWithLeadingQuestionMark", "fragmentIdentifierWithLeadingNumberSign", "stringWithoutQueryOrFragmentIdentifier", "stringWithoutFragmentIdentifier", "protocolHostAndPort", "hostAndPort", "user", "password", "fileSystemPath", "setProtocol", "setHost", "setHostAndPort", "setUser", "setPassword", "setPath", "setQuery", "truncatedForUseAsBase" }; +}; + +pub const String = packed struct { + pub const shim = Shimmer("WTF", "String", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<wtf/text/WTFString.h>"; + pub const name = "WTF::String"; + pub const namespace = "WTF"; + + pub fn createWithoutCopyingFromPtr(str: [*]const u8, len: usize) String { + return cppFn("createWithoutCopyingFromPtr", .{ str, len }); + } + + pub fn createFromExternalString(str: ExternalStringImpl) String { + return cppFn("createFromExternalString", .{str}); + } + + pub fn createWithoutCopying(str: []const u8) String { + return @call(.{ .modifier = .always_inline }, createWithoutCopyingFromPtr, .{ str.ptr, str.len }); + } + + pub fn is8Bit(this: *String) bool { + return cppFn("is8Bit", .{this}); + } + pub fn is16Bit(this: *String) bool { + return cppFn("is16Bit", .{this}); + } + pub fn isExternal(this: *String) bool { + return cppFn("isExternal", .{this}); + } + pub fn isStatic(this: *String) bool { + return cppFn("isStatic", .{this}); + } + pub fn isEmpty(this: *String) bool { + return cppFn("isEmpty", .{this}); + } + pub fn length(this: *String) usize { + return cppFn("length", .{this}); + } + pub fn characters8(this: *String) [*]const u8 { + return cppFn("characters8", .{this}); + } + pub fn characters16(this: *String) [*]const u16 { + return cppFn("characters16", .{this}); + } + + pub fn eqlString(this: *String, other: *const String) bool { + return cppFn("eqlString", .{ this, other }); + } + + pub fn eqlSlice(this: *String, other: [*]const u8, other_len: usize) bool { + return cppFn("eqlSlice", .{ this, other, other_len }); + } + + pub fn impl( + this: *String, + ) *const StringImpl { + return cppFn("impl", .{ + this, + }); + } + + pub const slice = SliceFn(@This()); + + pub const Extern = [_][]const u8{ + "is8Bit", + "is16Bit", + "isExternal", + "isStatic", + "isEmpty", + "length", + "characters8", + "characters16", + "createWithoutCopyingFromPtr", + "eqlString", + "eqlSlice", + "impl", + "createFromExternalString", + }; +}; + +pub const JSValue = enum(i64) { + _, + + pub const shim = Shimmer("JSC", "JSValue", @This()); + pub const is_pointer = false; + pub const Type = i64; + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/JSValue.h>"; + pub const name = "JSC::JSValue"; + pub const namespace = "JSC"; + + pub fn jsNumber(number: anytype) JSValue { + return switch (@TypeOf(number)) { + f64 => @call(.{ .modifier = .always_inline }, jsNumberFromDouble, .{number}), + u8 => @call(.{ .modifier = .always_inline }, jsNumberFromChar, .{number}), + u16 => @call(.{ .modifier = .always_inline }, jsNumberFromU16, .{number}), + i32 => @call(.{ .modifier = .always_inline }, jsNumberFromInt32, .{number}), + i64 => @call(.{ .modifier = .always_inline }, jsNumberFromInt64, .{number}), + u64 => @call(.{ .modifier = .always_inline }, jsNumberFromUint64, .{number}), + else => @compileError("Type transformation missing for number of type: " ++ @typeName(@TypeOf(number))), + }; + } + + pub fn jsNull() JSValue { + return cppFn("jsNull", .{}); + } + pub fn jsUndefined() JSValue { + return cppFn("jsUndefined", .{}); + } + pub fn jsTDZValue() JSValue { + return cppFn("jsTDZValue", .{}); + } + pub fn jsBoolean(i: bool) JSValue { + return cppFn("jsBoolean", .{i}); + } + pub fn jsDoubleNumber(i: f64) JSValue { + return cppFn("jsDoubleNumber", .{i}); + } + + pub fn jsNumberFromDouble(i: f64) JSValue { + return cppFn("jsNumberFromDouble", .{i}); + } + pub fn jsNumberFromChar(i: u8) JSValue { + return cppFn("jsNumberFromChar", .{i}); + } + pub fn jsNumberFromU16(i: u16) JSValue { + return cppFn("jsNumberFromU16", .{i}); + } + pub fn jsNumberFromInt32(i: i32) JSValue { + return cppFn("jsNumberFromInt32", .{i}); + } + pub fn jsNumberFromInt64(i: i64) JSValue { + return cppFn("jsNumberFromInt64", .{i}); + } + pub fn jsNumberFromUint64(i: u64) JSValue { + return cppFn("jsNumberFromUint64", .{i}); + } + + pub fn isUndefined(this: JSValue) bool { + return cppFn("isUndefined", .{this}); + } + pub fn isNull(this: JSValue) bool { + return cppFn("isNull", .{this}); + } + pub fn isUndefinedOrNull(this: JSValue) bool { + return cppFn("isUndefinedOrNull", .{this}); + } + pub fn isBoolean(this: JSValue) bool { + return cppFn("isBoolean", .{this}); + } + pub fn isAnyInt(this: JSValue) bool { + return cppFn("isAnyInt", .{this}); + } + pub fn isUInt32AsAnyInt(this: JSValue) bool { + return cppFn("isUInt32AsAnyInt", .{this}); + } + pub fn isInt32AsAnyInt(this: JSValue) bool { + return cppFn("isInt32AsAnyInt", .{this}); + } + pub fn isNumber(this: JSValue) bool { + return cppFn("isNumber", .{this}); + } + pub fn isError(this: JSValue) bool { + return cppFn("isError", .{this}); + } + pub fn isString(this: JSValue) bool { + return cppFn("isString", .{this}); + } + pub fn isBigInt(this: JSValue) bool { + return cppFn("isBigInt", .{this}); + } + pub fn isHeapBigInt(this: JSValue) bool { + return cppFn("isHeapBigInt", .{this}); + } + pub fn isBigInt32(this: JSValue) bool { + return cppFn("isBigInt32", .{this}); + } + pub fn isSymbol(this: JSValue) bool { + return cppFn("isSymbol", .{this}); + } + pub fn isPrimitive(this: JSValue) bool { + return cppFn("isPrimitive", .{this}); + } + pub fn isGetterSetter(this: JSValue) bool { + return cppFn("isGetterSetter", .{this}); + } + pub fn isCustomGetterSetter(this: JSValue) bool { + return cppFn("isCustomGetterSetter", .{this}); + } + pub fn isObject(this: JSValue) bool { + return cppFn("isObject", .{this}); + } + + pub fn isCell(this: JSValue) bool { + return cppFn("isCell", .{this}); + } + + pub fn asCell(this: JSValue) *JSCell { + return cppFn("asCell", .{this}); + } + + pub fn isCallable(this: JSValue) bool { + return cppFn("isCallable", .{this}); + } + + // On exception, this returns the empty string. + pub fn toString(this: JSValue, globalThis: *JSGlobalObject) *JSString { + return cppFn("toString", .{ this, globalThis }); + } + + // On exception, this returns null, to make exception checks faster. + pub fn toStringOrNull(this: JSValue, globalThis: *JSGlobalObject) *JSString { + return cppFn("toStringOrNull", .{ this, globalThis }); + } + pub fn toPropertyKey(this: JSValue, globalThis: *JSGlobalObject) Identifier { + return cppFn("toPropertyKey", .{ this, globalThis }); + } + pub fn toPropertyKeyValue(this: JSValue, globalThis: *JSGlobalObject) JSValue { + return cppFn("toPropertyKeyValue", .{ this, globalThis }); + } + pub fn toObject(this: JSValue, globalThis: *JSGlobalObject) *JSObject { + return cppFn("toObject", .{ this, globalThis }); + } + + pub fn getPrototype(this: JSValue, globalObject: *JSGlobalObject) JSValue { + return cppFn("getPrototype", .{ this, globalObject }); + } + + pub fn eqlValue(this: JSValue, other: JSValue) bool { + return cppFn("eqlValue", .{ this, other }); + } + + pub fn eqlCell(this: JSValue, other: *JSCell) bool { + return cppFn("eqlCell", .{ this, other }); + } + + pub fn asString(this: JSValue) *JSString { + return cppFn("asString", .{ + this, + }); + } + + pub fn asObject(this: JSValue) JSObject { + return cppFn("asObject", .{ + this, + }); + } + + pub fn asNumber(this: JSValue) f64 { + return cppFn("asNumber", .{ + this, + }); + } + + pub fn encode(this: JSValue) u64 { + return cppFn("encode", .{ + this, + }); + } + + pub const Extern = [_][]const u8{ "hasProperty", "getPropertyNames", "getDirect", "putDirect", "get", "getIfExists", "encode", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isUndefined", "isNull", "isUndefinedOrNull", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell" }; +}; + +pub const PropertyName = packed struct { + pub const shim = Shimmer("JSC", "PropertyName", @This()); + bytes: shim.Bytes, + + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/PropertyName.h>"; + pub const name = "JSC::PropertyName"; + pub const namespace = "JSC"; + + pub fn eqlToPropertyName(property_name: *PropertyName, other: *const PropertyName) bool { + return cppFn("eqlToPropertyName", .{ property_name, other }); + } + + pub fn eqlToIdentifier(property_name: *PropertyName, other: *const Identifier) bool { + return cppFn("eqlToIdentifier", .{ property_name, other }); + } + + pub fn publicName(property_name: *PropertyName) ?*const StringImpl { + return cppFn("publicName", .{ + property_name, + }); + } + + pub fn uid(property_name: *PropertyName) ?*const StringImpl { + return cppFn("uid", .{ + property_name, + }); + } + + pub const Extern = [_][]const u8{ "eqlToPropertyName", "eqlToIdentifier", "publicName", "uid" }; +}; + +pub const Exception = packed struct { + pub const shim = Shimmer("JSC", "Exception", @This()); + bytes: shim.Bytes, + pub const Type = JSObject; + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/Exception.h>"; + pub const name = "JSC::Exception"; + pub const namespace = "JSC"; + + pub const StackCaptureAction = enum(u8) { + CaptureStack = 0, + DoNotCaptureStack = 1, + }; + + pub fn create(globalObject: *JSGlobalObject, object: *JSObject, stack_capture: StackCaptureAction) *Exception { + return cppFn( + "create", + .{ globalObject, object, @enumToInt(stack_capture) }, + ); + } + + pub const Extern = [_][]const u8{ + "create", + }; +}; + +pub const JSLock = packed struct { + pub const shim = Shimmer("JSC", "Exception", @This()); + bytes: shim.Bytes, + + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/JSLock.h>"; + pub const name = "JSC::JSLock"; + pub const namespace = "JSC"; + + pub fn lock(this: *JSLock) void { + return cppFn("lock", .{this}); + } + pub fn unlock(this: *JSLock) void { + return cppFn("unlock", .{this}); + } + + pub const Extern = [_][]const u8{ "lock", "unlock" }; +}; + +pub const VM = packed struct { + pub const shim = Shimmer("JSC", "VM", @This()); + bytes: shim.Bytes, + + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/VM.h>"; + pub const name = "JSC::VM"; + pub const namespace = "JSC"; + + pub const HeapType = enum(u8) { + SmallHeap = 0, + LargeHeap = 1, + }; + pub fn create(heap_type: HeapType) *VM { + return cppFn("create", .{@enumToInt(heap_type)}); + } + + pub fn deinit(vm: *VM, global_object: *JSGlobalObject) void { + return cppFn("deinit", .{ vm, global_object }); + } + + pub fn setExecutionForbidden(vm: *VM, forbidden: bool) void { + cppFn("setExecutionForbidden", .{ vm, forbidden }); + } + + pub fn executionForbidden(vm: *VM) bool { + return cppFn("executionForbidden", .{ + vm, + }); + } + + pub fn isEntered(vm: *VM) bool { + return cppFn("isEntered", .{ + vm, + }); + } + + pub fn throwError(vm: *VM, global_object: *JSGlobalObject, scope: *ThrowScope, message: [*]const u8, len: usize) bool { + return cppFn("throwError", .{ + vm, + scope, + global_object, + + message, + len, + }); + } + + pub fn apiLock(vm: *VM) *JSLock { + return cppFn("apiLock", .{ + vm, + }); + } + + pub fn drainMicrotasks( + vm: *VM, + ) void { + return cppFn("drainMicrotasks", .{ + vm, + }); + } + + pub const Extern = [_][]const u8{ "apiLock", "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError", "drainMicrotasks" }; +}; + +pub const ThrowScope = packed struct { + pub const shim = Shimmer("JSC", "ThrowScope", @This()); + bytes: shim.Bytes, + + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/ThrowScope.h>"; + pub const name = "JSC::ThrowScope"; + pub const namespace = "JSC"; + + pub fn declare( + vm: *VM, + function_name: [*]u8, + file: [*]u8, + line: usize, + ) ThrowScope { + return cppFn("declare", .{ vm, file, line }); + } + + pub fn release(this: *ThrowScope) void { + return cppFn("release", .{this}); + } + + pub fn exception(this: *ThrowScope) ?*Exception { + return cppFn("exception", .{this}); + } + + pub fn clearException(this: *ThrowScope) void { + return cppFn("clearException", .{this}); + } + + pub const Extern = [_][]const u8{ + "declare", + "release", + "exception", + "clearException", + }; +}; + +pub const CatchScope = packed struct { + pub const shim = Shimmer("JSC", "CatchScope", @This()); + bytes: shim.Bytes, + + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/CatchScope.h>"; + pub const name = "JSC::CatchScope"; + pub const namespace = "JSC"; + + pub fn declare( + vm: *VM, + function_name: [*]u8, + file: [*]u8, + line: usize, + ) CatchScope { + return cppFn("declare", .{ vm, file, line }); + } + + pub fn exception(this: *CatchScope) ?*Exception { + return cppFn("exception", .{this}); + } + + pub fn clearException(this: *CatchScope) void { + return cppFn("clearException", .{this}); + } + + pub const Extern = [_][]const u8{ + "declare", + "exception", + "clearException", + }; +}; + +pub const CallFrame = packed struct { + pub const shim = Shimmer("JSC", "CallFrame", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/CallFrame.h>"; + pub const name = "JSC::CallFrame"; + pub const namespace = "JSC"; + + pub inline fn argumentsCount(call_frame: *const CallFrame) usize { + return cppFn("argumentsCount", .{ + call_frame, + }); + } + pub inline fn uncheckedArgument(call_frame: *const CallFrame, i: u16) JSValue { + return cppFn("uncheckedArgument", .{ call_frame, i }); + } + pub inline fn argument(call_frame: *const CallFrame, i: u16) JSValue { + return cppFn("argument", .{ + call_frame, + }); + } + pub inline fn thisValue(call_frame: *const CallFrame) ?JSValue { + return cppFn("thisValue", .{ + call_frame, + }); + } + pub inline fn newTarget(call_frame: *const CallFrame) ?JSValue { + return cppFn("newTarget", .{ + call_frame, + }); + } + pub inline fn jsCallee(call_frame: *const CallFrame) *JSObject { + return cppFn("jsCallee", .{ + call_frame, + }); + } + pub const Extern = [_][]const u8{ "argumentsCount", "uncheckedArgument", "argument", "thisValue", "newTarget", "jsCallee" }; +}; + +// pub const WellKnownSymbols = packed struct { +// pub const shim = Shimmer("JSC", "CommonIdentifiers", @This()); + +// +// + +// pub const include = "<JavaScriptCore/CommonIdentifiers.h>"; +// pub const name = "JSC::CommonIdentifiers"; +// pub const namespace = "JSC"; + +// pub var hasthis: *const Identifier = shim.cppConst(Identifier, "hasInstance"); +// pub var isConcatSpreadable: Identifier = shim.cppConst(Identifier, "isConcatSpreadable"); +// pub var asyncIterator: Identifier = shim.cppConst(Identifier, "asyncIterator"); +// pub var iterator: Identifier = shim.cppConst(Identifier, "iterator"); +// pub var match: Identifier = shim.cppConst(Identifier, "match"); +// pub var matchAll: Identifier = shim.cppConst(Identifier, "matchAll"); +// pub var replace: Identifier = shim.cppConst(Identifier, "replace"); +// pub var search: Identifier = shim.cppConst(Identifier, "search"); +// pub var species: Identifier = shim.cppConst(Identifier, "species"); +// pub var split: Identifier = shim.cppConst(Identifier, "split"); +// pub var toPrimitive: Identifier = shim.cppConst(Identifier, "toPrimitive"); +// pub var toStringTag: Identifier = shim.cppConst(Identifier, "toStringTag"); +// pub var unscopable: Identifier = shim.cppConst(Identifier, "unscopabl"); + +// }; + +pub const EncodedJSValue = enum(i64) { + _, + + pub const shim = Shimmer("JSC", "EncodedJSValue", @This()); + + pub const Type = u64; + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/EncodedJSValue.h>"; + pub const name = "JSC::EncodedJSValue"; + pub const namespace = "JSC"; +}; + +pub const Identifier = packed struct { + pub const shim = Shimmer("JSC", "Identifier", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + + pub const include = "<JavaScriptCore/Identifier.h>"; + pub const name = "JSC::Identifier"; + pub const namespace = "JSC"; + + pub fn fromString(vm: *VM, other: *const String) Identifier { + return cppFn("fromString", .{ vm, other }); + } + + pub fn fromSlice(vm: *VM, ptr: [*]const u8, len: usize) Identifier { + return cppFn("fromSlice", .{ vm, ptr, len }); + } + + pub fn fromUid(vm: *VM, other: *const StringImpl) Identifier { + return cppFn("fromString", .{ vm, other }); + } + + pub fn deinit(this: *const Identifier) void { + return cppFn("deinit", .{this}); + } + + pub fn toString(identifier: *const Identifier) String { + return cppFn("toString", .{identifier}); + } + + pub fn length(identifier: *const Identifier) usize { + return cppFn("length", .{identifier}); + } + + pub fn isNull(this: *const Identifier) bool { + return cppFn("isNull", .{this}); + } + pub fn isEmpty(this: *const Identifier) bool { + return cppFn("isEmpty", .{this}); + } + pub fn isSymbol(this: *const Identifier) bool { + return cppFn("isSymbol", .{this}); + } + pub fn isPrivateName(this: *const Identifier) bool { + return cppFn("isPrivateName", .{this}); + } + + pub fn eqlIdent(this: *const Identifier, other: *const Identifier) bool { + return cppFn("eqlIdent", .{ this, other }); + } + + pub fn neqlIdent(this: *const Identifier, other: *const Identifier) bool { + return cppFn("neqlIdent", .{ this, other }); + } + + pub fn eqlStringImpl(this: *const Identifier, other: *const StringImpl) bool { + return cppFn("eqlStringImpl", .{ this, other }); + } + + pub fn neqlStringImpl(this: *const Identifier, other: *const StringImpl) bool { + return cppFn("neqlStringImpl", .{ this, other }); + } + + pub fn eqlUTF8(this: *const Identifier, other: [*]const u8, other_len: usize) bool { + return cppFn("eqlUTF8", .{ this, other, other_len }); + } + + pub const Extern = [_][]const u8{ + "fromString", + "fromSlice", + "fromUid", + "deinit", + "toString", + "length", + "isNull", + "isEmpty", + "isSymbol", + "isPrivateName", + "eqlIdent", + "neqlIdent", + "eqlStringImpl", + "neqlStringImpl", + "eqlUTF8", + }; +}; + +const DeinitFunction = fn (ctx: *c_void, buffer: [*]u8, len: usize) callconv(.C) void; + +pub const StringImpl = packed struct { + pub const shim = Shimmer("WTF", "StringImpl", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + + pub const include = "<wtf/text/StringImpl.h>"; + pub const name = "WTF::StringImpl"; + pub const namespace = "WTF"; + + pub fn is8Bit(this: *const StringImpl) bool { + return cppFn("is8Bit", .{this}); + } + pub fn is16Bit(this: *const StringImpl) bool { + return cppFn("is16Bit", .{this}); + } + pub fn isExternal(this: *const StringImpl) bool { + return cppFn("isExternal", .{this}); + } + pub fn isStatic(this: *const StringImpl) bool { + return cppFn("isStatic", .{this}); + } + pub fn isEmpty(this: *const StringImpl) bool { + return cppFn("isEmpty", .{this}); + } + pub fn length(this: *const StringImpl) usize { + return cppFn("length", .{this}); + } + pub fn characters8(this: *const StringImpl) [*]const u8 { + return cppFn("characters8", .{this}); + } + pub fn characters16(this: *const StringImpl) [*]const u16 { + return cppFn("characters16", .{this}); + } + + pub const slice = SliceFn(@This()); + + pub const Extern = [_][]const u8{ + "is8Bit", + "is16Bit", + "isExternal", + "isStatic", + "isEmpty", + "length", + "characters8", + "characters16", + }; +}; + +pub const ExternalStringImpl = packed struct { + pub const shim = Shimmer("WTF", "ExternalStringImpl", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + + pub const include = "<wtf/text/ExternalStringImpl.h>"; + pub const name = "WTF::ExternalStringImpl"; + pub const namespace = "WTF"; + + pub fn create(ptr: [*]const u8, len: usize, deinit: DeinitFunction) ExternalStringImpl { + return cppFn("create", .{ ptr, len, deinit }); + } + + pub fn is8Bit(this: *const ExternalStringImpl) bool { + return cppFn("is8Bit", .{this}); + } + pub fn is16Bit(this: *const ExternalStringImpl) bool { + return cppFn("is16Bit", .{this}); + } + pub fn isEmpty(this: *const ExternalStringImpl) bool { + return cppFn("isEmpty", .{this}); + } + pub fn length(this: *const ExternalStringImpl) usize { + return cppFn("length", .{this}); + } + pub fn characters8(this: *const ExternalStringImpl) [*]const u8 { + return cppFn("characters8", .{this}); + } + pub fn characters16(this: *const ExternalStringImpl) [*]const u16 { + return cppFn("characters16", .{this}); + } + + pub const Extern = [_][]const u8{ + "create", + "is8Bit", + "is16Bit", + "isEmpty", + "length", + "characters8", + "characters16", + }; +}; + +pub const StringView = packed struct { + pub const shim = Shimmer("WTF", "StringView", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + + pub const include = "<wtf/text/StringView.h>"; + pub const name = "WTF::StringView"; + pub const namespace = "WTF"; + + pub fn from8Bit(ptr: [*]const u8, len: usize) StringView { + return cppFn("from8Bit", .{ ptr, len }); + } + + pub fn fromSlice(value: []const u8) StringView { + return from8Bit(value.ptr, value.len); + } + + pub fn is8Bit(this: *const StringView) bool { + return cppFn("is8Bit", .{this}); + } + pub fn is16Bit(this: *const StringView) bool { + return cppFn("is16Bit", .{this}); + } + pub fn isEmpty(this: *const StringView) bool { + return cppFn("isEmpty", .{this}); + } + pub fn length(this: *const StringView) usize { + return cppFn("length", .{this}); + } + pub fn characters8(this: *const StringView) [*]const u8 { + return cppFn("characters8", .{this}); + } + pub fn characters16(this: *const StringView) [*]const u16 { + return cppFn("characters16", .{this}); + } + + pub const slice = SliceFn(@This()); + + pub const Extern = [_][]const u8{ + "from8Bit", + "is8Bit", + "is16Bit", + "isEmpty", + "length", + "characters8", + "characters16", + }; +}; + +pub const Cpp = struct { + pub const Function = fn ( + globalObject: *JSGlobalObject, + callframe: *CallFrame, + ) *EncodedJSValue; + pub const Getter = fn ( + globalObject: *JSGlobalObject, + this: *EncodedJSValue, + propertyName: *PropertyName, + ) *EncodedJSValue; + pub const Setter = fn ( + globalObject: *JSGlobalObject, + this: *EncodedJSValue, + value: EncodedJSValue, + propertyName: *PropertyName, + ) bool; + + pub const Tag = enum { + Callback, + Constructor, + Getter, + Setter, + }; + + pub const LUTAttribute = enum { + Function, + Accessor, + CellProperty, + ClassStructure, + PropertyCallback, + }; + + pub const ClassDefinition = struct { name: []const u8, hostFunctions: []Host }; + + pub const ZigValue = union(Tag) { + Callback: Function, + Constructor: Function, + Getter: Getter, + Setter: Setter, + }; +}; +pub const Callback = struct { + // zig: Value, +}; + +const _JSGlobalObject = _Wundle("JSGlobalObject"); +const ObjectPrototype = _JSCellStub("ObjectPrototype"); +const FunctionPrototype = _JSCellStub("FunctionPrototype"); +const ArrayPrototype = _JSCellStub("ArrayPrototype"); +const StringPrototype = _JSCellStub("StringPrototype"); +const BigIntPrototype = _JSCellStub("BigIntPrototype"); +const RegExpPrototype = _JSCellStub("RegExpPrototype"); +const IteratorPrototype = _JSCellStub("IteratorPrototype"); +const AsyncIteratorPrototype = _JSCellStub("AsyncIteratorPrototype"); +const GeneratorFunctionPrototype = _JSCellStub("GeneratorFunctionPrototype"); +const GeneratorPrototype = _JSCellStub("GeneratorPrototype"); +const AsyncFunctionPrototype = _JSCellStub("AsyncFunctionPrototype"); +const ArrayIteratorPrototype = _JSCellStub("ArrayIteratorPrototype"); +const MapIteratorPrototype = _JSCellStub("MapIteratorPrototype"); +const SetIteratorPrototype = _JSCellStub("SetIteratorPrototype"); +const JSPromisePrototype = _JSCellStub("JSPromisePrototype"); +const AsyncGeneratorPrototype = _JSCellStub("AsyncGeneratorPrototype"); +const AsyncGeneratorFunctionPrototype = _JSCellStub("AsyncGeneratorFunctionPrototype"); + +pub fn SliceFn(comptime Type: type) type { + const SliceStruct = struct { + pub fn slice(this: *Type) []const u8 { + if (this.isEmpty()) { + return ""; + } + + return this.characters8()[0..this.length()]; + } + }; + + return @TypeOf(SliceStruct.slice); +} diff --git a/src/javascript/jsc/bindings/header-gen.zig b/src/javascript/jsc/bindings/header-gen.zig index 6155c5d1a..7b664785d 100644 --- a/src/javascript/jsc/bindings/header-gen.zig +++ b/src/javascript/jsc/bindings/header-gen.zig @@ -6,16 +6,71 @@ const StructMeta = std.builtin.TypeInfo.Struct; const EnumMeta = std.builtin.TypeInfo.Enum; const UnionMeta = std.builtin.TypeInfo.Union; const warn = std.debug.warn; +const StaticExport = @import("./static_export.zig"); + +const TypeNameMap = std.StringHashMap([]const u8); fn isCppObject(comptime Type: type) bool { return switch (@typeInfo(Type)) { .Struct, .Union, .Opaque => true, + .Enum => |Enum| @hasDecl(Type, "Type"), else => false, }; } +pub fn cTypeLabel(comptime Type: type) ?[]const u8 { + return switch (comptime Type) { + void => "void", + bool => "bool", + usize => "size_t", + isize => "int", + u8 => "char", + u16 => "uint16_t", + u32 => "uint32_t", + u64 => "uint64_t", + i8 => "int8_t", + i16 => "int16_t", + i24 => "int24_t", + i32 => "int32_t", + i64 => "int64_t", + f64 => "double", + f32 => "float", + *c_void => "void*", + [*]bool => "bool*", + [*]usize => "size_t*", + [*]isize => "int*", + [*]u8 => "char*", + [*]u16 => "uint16_t*", + [*]u32 => "uint32_t*", + [*]u64 => "uint64_t*", + [*]i8 => "int8_t*", + [*]i16 => "int16_t*", + [*]i32 => "int32_t*", + [*]i64 => "int64_t*", + [*]const bool => "const bool*", + [*]const usize => "const size_t*", + [*]const isize => "const int*", + [*]const u8 => "const char*", + [*]const u16 => "const uint16_t*", + [*]const u32 => "const uint32_t*", + [*]const u64 => "const uint64_t*", + [*]const i8 => "const int8_t*", + [*]const i16 => "const int16_t*", + [*]const i32 => "const int32_t*", + [*]const i64 => "const int64_t*", + else => null, + }; +} + +var buffer = std.ArrayList(u8).init(std.heap.c_allocator); +var writer = buffer.writer(); +var impl_buffer = std.ArrayList(u8).init(std.heap.c_allocator); +var impl_writer = impl_buffer.writer(); +var bufset = std.BufSet.init(std.heap.c_allocator); +var type_names = TypeNameMap.init(std.heap.c_allocator); +var size_map = std.StringHashMap(u32).init(std.heap.c_allocator); + pub const C_Generator = struct { - file: std.fs.File, filebase: []const u8, direction: Direction = .export_cpp, @@ -26,8 +81,8 @@ pub const C_Generator = struct { export_zig, }; - pub fn init(comptime src_file: []const u8, file: std.fs.File) Self { - var res = Self{ .file = file, .filebase = src_file }; + pub fn init(comptime src_file: []const u8, comptime Writer: type, file: Writer) Self { + var res = Self{ .filebase = src_file }; return res; } @@ -38,7 +93,13 @@ pub const C_Generator = struct { // self.file.writeAll("> ****/\n\n") catch unreachable; } - pub fn gen_func(self: *Self, comptime name: []const u8, comptime func: FnDecl, comptime meta: FnMeta, comptime arg_names: []const []const u8) void { + pub fn gen_func( + self: *Self, + comptime name: []const u8, + comptime func: FnDecl, + comptime meta: FnMeta, + comptime arg_names: []const []const u8, + ) void { switch (meta.calling_convention) { .Naked => self.write("__attribute__((naked)) "), .Stdcall => self.write("__attribute__((stdcall)) "), @@ -48,26 +109,38 @@ pub const C_Generator = struct { } switch (self.direction) { - .export_cpp => self.write("CPP_DECL \"C\" "), - .export_zig => self.write("ZIG_DECL \"C\" "), + .export_cpp => self.write("CPP_DECL "), + .export_zig => self.write("ZIG_DECL "), } self.writeType(func.return_type); self.write(" " ++ name ++ "("); inline for (meta.args) |arg, i| { - self.writeType(arg.arg_type.?); - if (func.arg_names.len > i) { - self.write(comptime arg_names[i]); - } else { - const ArgType = arg.arg_type.?; - if (@typeInfo(ArgType) == .Enum) { - self.write(comptime std.fmt.comptimePrint(" {s}{d}", .{ @typeName(ArgType), i })); - } else { - self.write(comptime std.fmt.comptimePrint(" arg{d}", .{i})); - } + const ArgType = arg.arg_type.?; + + switch (@typeInfo(ArgType)) { + .Fn => { + self.gen_closure(comptime arg.arg_type.?, comptime std.fmt.comptimePrint(" ArgFn{d}", .{i})); + }, + else => { + self.writeType(arg.arg_type.?); + switch (@typeInfo(ArgType)) { + .Enum => { + self.write(comptime std.fmt.comptimePrint(" {s}{d}", .{ @typeName(ArgType), i })); + }, + + else => { + self.write(comptime std.fmt.comptimePrint(" arg{d}", .{i})); + }, + } + }, } + // if (comptime func.arg_names.len > 0 and func.arg_names.len > i) { + // self.write(comptime arg_names[i]); + // } else { + //TODO: Figure out how to get arg names; for now just do arg0..argN if (i != meta.args.len - 1) self.write(", "); @@ -85,6 +158,43 @@ pub const C_Generator = struct { // } } + pub fn gen_closure( + self: *Self, + comptime Function: type, + comptime name: []const u8, + ) void { + const func: std.builtin.TypeInfo.Fn = @typeInfo(Function).Fn; + self.writeType(func.return_type orelse void); + self.write(" (*" ++ name ++ ")("); + inline for (func.args) |arg, i| { + self.writeType(arg.arg_type.?); + // if (comptime func.arg_names.len > 0 and func.arg_names.len > i) { + // self.write(comptime arg_names[i]); + // } else { + const ArgType = arg.arg_type.?; + if (@typeInfo(ArgType) == .Enum) { + self.write(comptime std.fmt.comptimePrint(" {s}{d}", .{ @typeName(ArgType), i })); + } else { + self.write(comptime std.fmt.comptimePrint(" arg{d}", .{i})); + } + // } + + //TODO: Figure out how to get arg names; for now just do arg0..argN + if (i != func.args.len - 1) + self.write(", "); + } + + self.write(")"); + // const ReturnTypeInfo: std.builtin.TypeInfo = comptime @typeInfo(func.return_type); + // switch (comptime ReturnTypeInfo) { + // .Pointer => |Pointer| { + // self.write(" __attribute__((returns_nonnull))"); + // }, + // .Optional => |Optional| {}, + // else => {}, + // } + } + pub fn gen_struct(self: *Self, comptime name: []const u8, comptime meta: StructMeta) void { self.write("typedef struct "); @@ -107,7 +217,7 @@ pub const C_Generator = struct { self.write(" " ++ field.name); if (info == .Array) { - _ = self.file.writer().print("[{}]", .{info.Array.len}) catch unreachable; + writer.print("[{}]", .{info.Array.len}) catch unreachable; } self.write(";\n"); @@ -115,7 +225,11 @@ pub const C_Generator = struct { self.write("} " ++ name ++ "_t;\n\n"); } - pub fn gen_enum(self: *Self, comptime name: []const u8, comptime meta: EnumMeta) void { + pub fn gen_enum( + self: *Self, + comptime name: []const u8, + comptime meta: EnumMeta, + ) void { self.write("enum " ++ name ++ " {\n"); comptime var last = 0; @@ -124,7 +238,7 @@ pub const C_Generator = struct { // if field value is unexpected/custom, manually define it if ((i == 0 and field.value != 0) or (i > 0 and field.value > last + 1)) { - _ = self.file.writer().print(" = {}", .{field.value}) catch unreachable; + writer.print(" = {}", .{field.value}) catch unreachable; } self.write(",\n"); @@ -135,7 +249,11 @@ pub const C_Generator = struct { self.write("};\n\n"); } - pub fn gen_union(self: *Self, comptime name: []const u8, comptime meta: UnionMeta) void { + pub fn gen_union( + self: *Self, + comptime name: []const u8, + comptime meta: UnionMeta, + ) void { self.write("typedef union "); self.write(name ++ " {\n"); @@ -148,7 +266,10 @@ pub const C_Generator = struct { self.write("} " ++ name ++ "_t;\n\n"); } - fn writeType(self: *Self, comptime T: type) void { + fn writeType( + self: *Self, + comptime T: type, + ) void { const TT = comptime if (@typeInfo(T) == .Pointer) @typeInfo(T).Pointer.child else T; if (comptime (isCppObject(TT)) and @hasDecl(TT, "name")) { @@ -158,7 +279,38 @@ pub const C_Generator = struct { } } - self.write(comptime TT.name); + const _formatted_name = comptime brk: { + var original: [TT.name.len]u8 = undefined; + _ = std.mem.replace(u8, TT.name, ":", "_", &original); + break :brk original; + }; + const formatted_name = comptime std.mem.span(&_formatted_name); + + if (@hasDecl(TT, "is_pointer") and !TT.is_pointer) { + if (cTypeLabel(TT.Type)) |label| { + type_names.put(comptime label, formatted_name) catch unreachable; + if (@typeInfo(TT) == .Struct and @hasField(TT, "bytes")) { + size_map.put(comptime formatted_name, @as(u32, TT.shim.byte_size)) catch unreachable; + } + } else { + type_names.put(comptime TT.name, formatted_name) catch unreachable; + if (@typeInfo(TT) == .Struct and @hasField(TT, "bytes")) { + size_map.put(comptime formatted_name, @as(u32, TT.shim.byte_size)) catch unreachable; + } + } + } else { + type_names.put(comptime TT.name, formatted_name) catch unreachable; + if (@typeInfo(TT) == .Struct and @hasField(TT, "bytes")) { + size_map.put(comptime formatted_name, @as(u32, TT.shim.byte_size)) catch unreachable; + } + } + + if (TT == T and @hasField(T, "bytes")) { + write(self, comptime "b" ++ formatted_name); + } else { + write(self, comptime formatted_name); + } + if (@typeInfo(T) == .Pointer or @hasDecl(TT, "Type") and @typeInfo(TT.Type) == .Pointer) { if (@hasDecl(TT, "is_pointer") and !TT.is_pointer) {} else { write(self, "*"); @@ -167,73 +319,35 @@ pub const C_Generator = struct { return; } - switch (T) { - void => self.write("void"), - bool => self.write("bool"), - usize => self.write("size_t"), - isize => self.write("int"), - u8 => self.write("char"), - u16 => self.write("uint16_t"), - u32 => self.write("uint32_t"), - u64 => self.write("uint64_t"), - i8 => self.write("int8_t"), - i16 => self.write("int16_t"), - i24 => self.write("int24_t"), - i32 => self.write("int32_t"), - i64 => self.write("int64_t"), - f64 => self.write("double"), - f32 => self.write("float"), - *c_void => self.write("void*"), - [*]bool => self.write("bool*"), - [*]usize => self.write("size_t*"), - [*]isize => self.write("int*"), - [*]u8 => self.write("char*"), - [*]u16 => self.write("uint16_t*"), - [*]u32 => self.write("uint32_t*"), - [*]u64 => self.write("uint64_t*"), - [*]i8 => self.write("int8_t*"), - [*]i16 => self.write("int16_t*"), - [*]i32 => self.write("int32_t*"), - [*]i64 => self.write("int64_t*"), - [*]const bool => self.write("const bool*"), - [*]const usize => self.write("const size_t*"), - [*]const isize => self.write("const int*"), - [*]const u8 => self.write("const char*"), - [*]const u16 => self.write("const uint16_t*"), - [*]const u32 => self.write("const uint32_t*"), - [*]const u64 => self.write("const uint64_t*"), - [*]const i8 => self.write("const int8_t*"), - [*]const i16 => self.write("const int16_t*"), - [*]const i32 => self.write("const int32_t*"), - [*]const i64 => self.write("const int64_t*"), - else => { - const meta = @typeInfo(T); - switch (meta) { - .Pointer => |Pointer| { - const child = Pointer.child; - const childmeta = @typeInfo(child); - // if (childmeta == .Struct and childmeta.Struct.layout != .Extern) { - // self.write("void"); - // } else { - self.writeType(child); - // } - self.write("*"); - }, - .Optional => self.writeType(meta.Optional.child), - .Array => @compileError("Handle goofy looking C Arrays in the calling function"), - .Enum => |Enum| { - self.writeType(Enum.tag_type); - }, - else => { - return self.write(@typeName(T)); - }, - } - }, + if (comptime cTypeLabel(T)) |label| { + self.write(comptime label); + } else { + const meta = @typeInfo(T); + switch (meta) { + .Pointer => |Pointer| { + const child = Pointer.child; + const childmeta = @typeInfo(child); + // if (childmeta == .Struct and childmeta.Struct.layout != .Extern) { + // self.write("void"); + // } else { + self.writeType(child); + // } + self.write("*"); + }, + .Optional => self.writeType(meta.Optional.child), + .Array => @compileError("Handle goofy looking C Arrays in the calling function"), + .Enum => |Enum| { + self.writeType(Enum.tag_type); + }, + else => { + return self.write(@typeName(T)); + }, + } } } fn write(self: *Self, comptime str: []const u8) void { - _ = self.file.writeAll(str) catch {}; + _ = writer.write(str) catch {}; } }; @@ -295,32 +409,62 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { return struct { source_file: []const u8 = fname, gen: C_Generator = undefined, + const Self = @This(); pub fn init() Self { return Self{}; } - pub fn startFile(comptime self: Self, comptime Type: type, comptime prefix: []const u8, file: std.fs.File) void { + pub fn startFile( + comptime self: Self, + comptime Type: type, + comptime prefix: []const u8, + file: anytype, + other: std.fs.File, + ) void { if (comptime std.meta.trait.hasDecls(Type, .{"include"})) { comptime var new_name = std.mem.zeroes([Type.include.len]u8); comptime { _ = std.mem.replace(u8, Type.include, "/", "_", std.mem.span(&new_name)); _ = std.mem.replace(u8, &new_name, ".", "_", std.mem.span(&new_name)); + _ = std.mem.replace(u8, &new_name, "<", "_", std.mem.span(&new_name)); + _ = std.mem.replace(u8, &new_name, ">", "_", std.mem.span(&new_name)); + _ = std.mem.replace(u8, &new_name, "\"", "_", std.mem.span(&new_name)); + } + file.writeAll("\n#pragma mark - " ++ Type.name ++ "\n\n") catch unreachable; + + if (@hasDecl(Type, "include")) { + other.writer().print( + \\ + \\#ifndef INCLUDED_{s} + \\#define INCLUDED_{s} + \\#include {s} + \\#endif + \\ + \\extern "C" const size_t {s} = sizeof({s}); + \\ + , + .{ new_name, new_name, Type.include, Type.shim.size_of_symbol, Type.name }, + ) catch unreachable; } - const inner_name = comptime std.mem.trim(u8, &new_name, "<>\""); - file.writeAll("\n#pragma mark - " ++ Type.name ++ "\n") catch unreachable; - file.writeAll("\n#ifndef BINDINGS__decls__" ++ inner_name ++ "\n") catch {}; - file.writeAll("#define BINDINGS__decls__" ++ inner_name ++ "\n") catch {}; - file.writeAll("#include " ++ Type.include ++ "\n") catch {}; - file.writeAll("namespace " ++ Type.namespace ++ " {\n class " ++ prefix ++ ";\n}\n") catch {}; - file.writeAll("#endif\n\n") catch {}; } } + + pub fn processStaticExport(comptime self: Self, file: anytype, gen: *C_Generator, comptime static_export: StaticExport) void { + const fn_meta = comptime @typeInfo(static_export.Type).Fn; + gen.gen_func( + comptime static_export.symbol_name, + comptime static_export.Decl().data.Fn, + comptime fn_meta, + comptime std.mem.zeroes([]const []const u8), + ); + } + pub fn processDecl( comptime self: Self, - file: std.fs.File, + file: anytype, gen: *C_Generator, comptime Container: type, comptime Decl: std.builtin.TypeInfo.Declaration, @@ -332,14 +476,20 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { switch (@typeInfo(Type)) { .Enum => |Enum| { const layout = Enum.layout; - gen.gen_enum(prefix ++ "__" ++ name, Enum); + gen.gen_enum( + prefix ++ "__" ++ name, + Enum, + ); }, .Struct => |Struct| { - gen.gen_struct(decl.name, Struct); + gen.gen_struct(decl.name, Struct, file); }, .Union => |Union| { const layout = Union.layout; - gen.gen_union(prefix ++ "__" ++ name, Union); + gen.gen_union( + prefix ++ "__" ++ name, + Union, + ); }, .Fn => |func| { // if (func.) { @@ -370,41 +520,136 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { } } - pub fn exec(comptime self: Self, file: std.fs.File) void { + pub fn exec(comptime self: Self, file: std.fs.File, impl: std.fs.File) void { const Generator = C_Generator; validateGenerator(Generator); - - file.writeAll("#pragma once\n#include <stddef.h>\n#include <stdint.h>\n#include <stdbool.h>\n#define ZIG_DECL extern\n#define CPP_DECL extern \n\n") catch {}; - var bufset = std.BufSet.init(std.heap.c_allocator); + var file_writer = file.writer(); + file_writer.print("//-- AUTOGENERATED FILE -- {d}\n", .{std.time.timestamp()}) catch unreachable; + file.writeAll( + \\#pragma once + \\ + \\#include <stddef.h> + \\#include <stdint.h> + \\#include <stdbool.h> + \\ + \\#ifdef __cplusplus + \\ #define AUTO_EXTERN_C extern "C" + \\#else + \\ #define AUTO_EXTERN_C + \\#endif + \\#define ZIG_DECL AUTO_EXTERN_C + \\#define CPP_DECL AUTO_EXTERN_C + \\#define CPP_SIZE AUTO_EXTERN_C + \\ + \\ + ) catch {}; + + impl.writer().print("//-- AUTOGENERATED FILE -- {d}\n", .{std.time.timestamp()}) catch unreachable; + impl.writer().writeAll( + \\#pragma once + \\ + \\#include <stddef.h> + \\#include <stdint.h> + \\#include <stdbool.h> + \\ + \\#include "root.h" + \\ + ) catch {}; + + var impl_second_buffer = std.ArrayList(u8).init(std.heap.c_allocator); + var impl_second_writer = impl_second_buffer.writer(); + + var impl_third_buffer = std.ArrayList(u8).init(std.heap.c_allocator); + var impl_third_writer = impl_third_buffer.writer(); + + var to_get_sizes: usize = 0; inline for (all_decls) |_decls| { if (comptime _decls.is_pub) { switch (_decls.data) { .Type => |Type| { @setEvalBranchQuota(99999); - if (@hasDecl(Type, "Extern")) { + + if (@hasDecl(Type, "Extern") or @hasDecl(Type, "Export")) { const identifier = comptime std.fmt.comptimePrint("{s}_{s}", .{ Type.shim.name, Type.shim.namespace }); if (!bufset.contains(identifier)) { - self.startFile(Type, Type.shim.name, file); + self.startFile( + Type, + Type.shim.name, + writer, + impl, + ); + bufset.insert(identifier) catch unreachable; - var gen = C_Generator.init(Type.name, file); + var gen = C_Generator.init(Type.name, @TypeOf(writer), writer); defer gen.deinit(); - inline for (Type.Extern) |extern_decl| { - if (@hasDecl(Type, extern_decl)) { - const normalized_name = comptime brk: { - var _normalized_name: [Type.name.len]u8 = undefined; - _ = std.mem.replace(u8, Type.name, ":", "_", std.mem.span(&_normalized_name)); - break :brk _normalized_name; + + if (@hasDecl(Type, "Extern")) { + if (to_get_sizes > 0) { + impl_second_writer.writeAll(", ") catch unreachable; + impl_third_writer.writeAll(", ") catch unreachable; + } + + const formatted_name = comptime brk: { + var original: [Type.name.len]u8 = undefined; + _ = std.mem.replace(u8, Type.name, ":", "_", &original); + break :brk original; + }; + + impl_third_writer.print("sizeof({s})", .{comptime Type.name}) catch unreachable; + impl_second_writer.print("\"{s}\"", .{formatted_name}) catch unreachable; + to_get_sizes += 1; + const ExternList = comptime brk: { + const Sorder = struct { + pub fn lessThan(context: @This(), lhs: []const u8, rhs: []const u8) bool { + return std.ascii.orderIgnoreCase(lhs, rhs) == std.math.Order.lt; + } }; + var extern_list = Type.Extern; + std.sort.sort([]const u8, &extern_list, Sorder{}, Sorder.lessThan); + break :brk extern_list; + }; + // impl_writer.print(" #include {s}\n", .{Type.include}) catch unreachable; + inline for (&ExternList) |extern_decl| { + if (@hasDecl(Type, extern_decl)) { + const normalized_name = comptime brk: { + var _normalized_name: [Type.name.len]u8 = undefined; + _ = std.mem.replace(u8, Type.name, ":", "_", std.mem.span(&_normalized_name)); + break :brk _normalized_name; + }; + + processDecl( + self, + writer, + &gen, + Type, + comptime std.meta.declarationInfo(Type, extern_decl), + comptime extern_decl, + comptime std.mem.span(&normalized_name), + ); + } + } + } - processDecl( + if (@hasDecl(Type, "Export")) { + const ExportLIst = comptime brk: { + const Sorder = struct { + pub fn lessThan(context: @This(), comptime lhs: StaticExport, comptime rhs: StaticExport) bool { + return std.ascii.orderIgnoreCase(lhs.symbol_name, rhs.symbol_name) == std.math.Order.lt; + } + }; + var extern_list = Type.Export; + std.sort.sort(StaticExport, &extern_list, Sorder{}, Sorder.lessThan); + break :brk extern_list; + }; + + gen.direction = C_Generator.Direction.export_zig; + inline for (ExportLIst) |static_export| { + processStaticExport( self, file, &gen, - Type, - comptime std.meta.declarationInfo(Type, extern_decl), - comptime extern_decl, - comptime std.mem.span(&normalized_name), + comptime static_export, ); } } @@ -415,6 +660,90 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { } } } + impl.writer().print("\nconst size_t sizes[{d}] = {{", .{to_get_sizes}) catch unreachable; + impl.writeAll(impl_third_buffer.items) catch unreachable; + impl.writeAll("};\n") catch unreachable; + impl.writer().print("\nconst char* names[{d}] = {{", .{to_get_sizes}) catch unreachable; + impl.writeAll(impl_second_buffer.items) catch unreachable; + impl.writeAll("};\n") catch unreachable; + + var iter = type_names.iterator(); + + const NamespaceMap = std.StringArrayHashMap(std.BufMap); + var namespaces = NamespaceMap.init(std.heap.c_allocator); + + file_writer.writeAll("\n#ifndef __cplusplus\n") catch unreachable; + while (iter.next()) |entry| { + const key = entry.key_ptr.*; + const value = entry.value_ptr.*; + if (std.mem.indexOfScalar(u8, entry.key_ptr.*, ':')) |namespace_start| { + const namespace = entry.key_ptr.*[0..namespace_start]; + file_writer.print(" typedef struct {s} {s}; // {s}\n", .{ + value, + value, + key, + }) catch unreachable; + if (!namespaces.contains(namespace)) { + namespaces.put(namespace, std.BufMap.init(std.heap.c_allocator)) catch unreachable; + } + const class = key[namespace_start + 2 ..]; + namespaces.getPtr(namespace).?.put(class, value) catch unreachable; + } else { + file_writer.print(" typedef {s} {s};\n", .{ + key, + value, + }) catch unreachable; + + impl_writer.print(" typedef {s} {s};\n", .{ + key, + value, + }) catch unreachable; + } + } + + file_writer.writeAll("\n#endif\n") catch unreachable; + var size_iter = size_map.iterator(); + while (size_iter.next()) |size| { + file_writer.print(" typedef struct b{s} {{ char bytes[{d}]; }} b{s};\n", .{ + size.key_ptr.*, + size.value_ptr.*, + size.key_ptr.*, + }) catch unreachable; + } + + file_writer.writeAll("\n#ifdef __cplusplus\n") catch unreachable; + + iter = type_names.iterator(); + var namespace_iter = namespaces.iterator(); + while (namespace_iter.next()) |map| { + file_writer.print(" namespace {s} {{\n", .{map.key_ptr.*}) catch unreachable; + var classes = map.value_ptr.iterator(); + while (classes.next()) |class| { + file_writer.print(" class {s};\n", .{class.key_ptr.*}) catch unreachable; + } + file_writer.writeAll(" }\n") catch unreachable; + } + + file_writer.writeAll("\n") catch unreachable; + + file_writer.writeAll(impl_buffer.items) catch unreachable; + + iter = type_names.iterator(); + namespace_iter = namespaces.iterator(); + while (namespace_iter.next()) |map| { + var classes = map.value_ptr.iterator(); + while (classes.next()) |class| { + file_writer.print(" using {s} = {s}::{s};\n", .{ + class.value_ptr.*, + map.key_ptr.*, + class.key_ptr.*, + }) catch unreachable; + } + } + + file_writer.writeAll("\n#endif\n\n") catch unreachable; + + file.writeAll(buffer.items) catch unreachable; // processDecls( // self, diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h new file mode 100644 index 000000000..57c7bb4f9 --- /dev/null +++ b/src/javascript/jsc/bindings/headers-cpp.h @@ -0,0 +1,194 @@ +//-- AUTOGENERATED FILE -- 1626855517 +#pragma once + +#include <stddef.h> +#include <stdint.h> +#include <stdbool.h> + +#include "root.h" + +#ifndef INCLUDED__JavaScriptCore_JSObject_h_ +#define INCLUDED__JavaScriptCore_JSObject_h_ +#include <JavaScriptCore/JSObject.h> +#endif + +extern "C" const size_t JSC__JSObject_object_size_ = sizeof(JSC::JSObject); + +#ifndef INCLUDED__JavaScriptCore_PropertyNameArray_h_ +#define INCLUDED__JavaScriptCore_PropertyNameArray_h_ +#include <JavaScriptCore/PropertyNameArray.h> +#endif + +extern "C" const size_t JSC__PropertyNameArray_object_size_ = sizeof(JSC::PropertyNameArray); + +#ifndef INCLUDED__JavaScriptCore_JSCell_h_ +#define INCLUDED__JavaScriptCore_JSCell_h_ +#include <JavaScriptCore/JSCell.h> +#endif + +extern "C" const size_t JSC__JSCell_object_size_ = sizeof(JSC::JSCell); + +#ifndef INCLUDED__JavaScriptCore_JSString_h_ +#define INCLUDED__JavaScriptCore_JSString_h_ +#include <JavaScriptCore/JSString.h> +#endif + +extern "C" const size_t JSC__JSString_object_size_ = sizeof(JSC::JSString); + +#ifndef INCLUDED__ZigGlobalObject_h_ +#define INCLUDED__ZigGlobalObject_h_ +#include "ZigGlobalObject.h" +#endif + +extern "C" const size_t Zig__GlobalObject_object_size_ = sizeof(Zig::GlobalObject); + +#ifndef INCLUDED__DefaultGlobal_h_ +#define INCLUDED__DefaultGlobal_h_ +#include "DefaultGlobal.h" +#endif + +extern "C" const size_t Wundle__DefaultGlobal_object_size_ = sizeof(Wundle::DefaultGlobal); + +#ifndef INCLUDED__JavaScriptCore_JSModuleLoader_h_ +#define INCLUDED__JavaScriptCore_JSModuleLoader_h_ +#include <JavaScriptCore/JSModuleLoader.h> +#endif + +extern "C" const size_t JSC__JSModuleLoader_object_size_ = sizeof(JSC::JSModuleLoader); + +#ifndef INCLUDED__JavaScriptCore_JSModuleRecord_h_ +#define INCLUDED__JavaScriptCore_JSModuleRecord_h_ +#include <JavaScriptCore/JSModuleRecord.h> +#endif + +extern "C" const size_t JSC__JSModuleRecord_object_size_ = sizeof(JSC::JSModuleRecord); + +#ifndef INCLUDED__JavaScriptCore_JSPromise_h_ +#define INCLUDED__JavaScriptCore_JSPromise_h_ +#include <JavaScriptCore/JSPromise.h> +#endif + +extern "C" const size_t JSC__JSPromise_object_size_ = sizeof(JSC::JSPromise); + +#ifndef INCLUDED__JavaScriptCore_SourceOrigin_h_ +#define INCLUDED__JavaScriptCore_SourceOrigin_h_ +#include <JavaScriptCore/SourceOrigin.h> +#endif + +extern "C" const size_t JSC__SourceOrigin_object_size_ = sizeof(JSC::SourceOrigin); + +#ifndef INCLUDED__JavaScriptCore_SourceProvider_h_ +#define INCLUDED__JavaScriptCore_SourceProvider_h_ +#include <JavaScriptCore/SourceProvider.h> +#endif + +extern "C" const size_t JSC__SourceCode_object_size_ = sizeof(JSC::SourceCode); + +#ifndef INCLUDED__JavaScriptCore_JSFunction_h_ +#define INCLUDED__JavaScriptCore_JSFunction_h_ +#include <JavaScriptCore/JSFunction.h> +#endif + +extern "C" const size_t JSC__JSFunction_object_size_ = sizeof(JSC::JSFunction); + +#ifndef INCLUDED__JavaScriptCore_JSGlobalObject_h_ +#define INCLUDED__JavaScriptCore_JSGlobalObject_h_ +#include <JavaScriptCore/JSGlobalObject.h> +#endif + +extern "C" const size_t JSC__JSGlobalObject_object_size_ = sizeof(JSC::JSGlobalObject); + +#ifndef INCLUDED__wtf_URL_h_ +#define INCLUDED__wtf_URL_h_ +#include <wtf/URL.h> +#endif + +extern "C" const size_t WTF__URL_object_size_ = sizeof(WTF::URL); + +#ifndef INCLUDED__wtf_text_WTFString_h_ +#define INCLUDED__wtf_text_WTFString_h_ +#include <wtf/text/WTFString.h> +#endif + +extern "C" const size_t WTF__String_object_size_ = sizeof(WTF::String); + +#ifndef INCLUDED__JavaScriptCore_JSValue_h_ +#define INCLUDED__JavaScriptCore_JSValue_h_ +#include <JavaScriptCore/JSValue.h> +#endif + +extern "C" const size_t JSC__JSValue_object_size_ = sizeof(JSC::JSValue); + +#ifndef INCLUDED__JavaScriptCore_PropertyName_h_ +#define INCLUDED__JavaScriptCore_PropertyName_h_ +#include <JavaScriptCore/PropertyName.h> +#endif + +extern "C" const size_t JSC__PropertyName_object_size_ = sizeof(JSC::PropertyName); + +#ifndef INCLUDED__JavaScriptCore_Exception_h_ +#define INCLUDED__JavaScriptCore_Exception_h_ +#include <JavaScriptCore/Exception.h> +#endif + +extern "C" const size_t JSC__Exception_object_size_ = sizeof(JSC::Exception); + +#ifndef INCLUDED__JavaScriptCore_VM_h_ +#define INCLUDED__JavaScriptCore_VM_h_ +#include <JavaScriptCore/VM.h> +#endif + +extern "C" const size_t JSC__VM_object_size_ = sizeof(JSC::VM); + +#ifndef INCLUDED__JavaScriptCore_ThrowScope_h_ +#define INCLUDED__JavaScriptCore_ThrowScope_h_ +#include <JavaScriptCore/ThrowScope.h> +#endif + +extern "C" const size_t JSC__ThrowScope_object_size_ = sizeof(JSC::ThrowScope); + +#ifndef INCLUDED__JavaScriptCore_CatchScope_h_ +#define INCLUDED__JavaScriptCore_CatchScope_h_ +#include <JavaScriptCore/CatchScope.h> +#endif + +extern "C" const size_t JSC__CatchScope_object_size_ = sizeof(JSC::CatchScope); + +#ifndef INCLUDED__JavaScriptCore_CallFrame_h_ +#define INCLUDED__JavaScriptCore_CallFrame_h_ +#include <JavaScriptCore/CallFrame.h> +#endif + +extern "C" const size_t JSC__CallFrame_object_size_ = sizeof(JSC::CallFrame); + +#ifndef INCLUDED__JavaScriptCore_Identifier_h_ +#define INCLUDED__JavaScriptCore_Identifier_h_ +#include <JavaScriptCore/Identifier.h> +#endif + +extern "C" const size_t JSC__Identifier_object_size_ = sizeof(JSC::Identifier); + +#ifndef INCLUDED__wtf_text_StringImpl_h_ +#define INCLUDED__wtf_text_StringImpl_h_ +#include <wtf/text/StringImpl.h> +#endif + +extern "C" const size_t WTF__StringImpl_object_size_ = sizeof(WTF::StringImpl); + +#ifndef INCLUDED__wtf_text_ExternalStringImpl_h_ +#define INCLUDED__wtf_text_ExternalStringImpl_h_ +#include <wtf/text/ExternalStringImpl.h> +#endif + +extern "C" const size_t WTF__ExternalStringImpl_object_size_ = sizeof(WTF::ExternalStringImpl); + +#ifndef INCLUDED__wtf_text_StringView_h_ +#define INCLUDED__wtf_text_StringView_h_ +#include <wtf/text/StringView.h> +#endif + +extern "C" const size_t WTF__StringView_object_size_ = sizeof(WTF::StringView); + +const size_t sizes[25] = {sizeof(JSC::JSObject), sizeof(JSC::PropertyNameArray), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Wundle::DefaultGlobal), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::SourceOrigin), sizeof(JSC::SourceCode), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(WTF::URL), sizeof(WTF::String), sizeof(JSC::JSValue), sizeof(JSC::PropertyName), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(JSC::CallFrame), sizeof(JSC::Identifier), sizeof(WTF::StringImpl), sizeof(WTF::ExternalStringImpl), sizeof(WTF::StringView)}; + +const char* names[25] = {"JSC__JSObject", "JSC__PropertyNameArray", "JSC__JSCell", "JSC__JSString", "Wundle__DefaultGlobal", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__SourceOrigin", "JSC__SourceCode", "JSC__JSFunction", "JSC__JSGlobalObject", "WTF__URL", "WTF__String", "JSC__JSValue", "JSC__PropertyName", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "JSC__CallFrame", "JSC__Identifier", "WTF__StringImpl", "WTF__ExternalStringImpl", "WTF__StringView"}; diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h index 112b3a11f..53281a7eb 100644 --- a/src/javascript/jsc/bindings/headers.h +++ b/src/javascript/jsc/bindings/headers.h @@ -1,440 +1,492 @@ +//-- AUTOGENERATED FILE -- 1626855517 #pragma once + #include <stddef.h> #include <stdint.h> #include <stdbool.h> -#define ZIG_DECL extern -#define CPP_DECL extern +#ifdef __cplusplus + #define AUTO_EXTERN_C extern "C" +#else + #define AUTO_EXTERN_C +#endif +#define ZIG_DECL AUTO_EXTERN_C +#define CPP_DECL AUTO_EXTERN_C +#define CPP_SIZE AUTO_EXTERN_C + + +#ifndef __cplusplus + typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype + typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype + typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype + typedef struct JSC__CatchScope JSC__CatchScope; // JSC::CatchScope + typedef struct WTF__StringView WTF__StringView; // WTF::StringView + typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype + typedef struct JSC__CallFrame JSC__CallFrame; // JSC::CallFrame + typedef struct JSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope + typedef struct JSC__PropertyName JSC__PropertyName; // JSC::PropertyName + typedef struct JSC__JSObject JSC__JSObject; // JSC::JSObject + typedef struct WTF__StringImpl WTF__StringImpl; // WTF::StringImpl + typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype + typedef struct WTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl + typedef struct JSC__JSLock JSC__JSLock; // JSC::JSLock + typedef struct JSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader + typedef struct JSC__VM JSC__VM; // JSC::VM + typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype + typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype + typedef struct JSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject + typedef struct Wundle__DefaultGlobal Wundle__DefaultGlobal; // Wundle::DefaultGlobal + typedef struct JSC__JSFunction JSC__JSFunction; // JSC::JSFunction + typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype + typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype + typedef struct JSC__JSPromise JSC__JSPromise; // JSC::JSPromise + typedef struct JSC__Identifier JSC__Identifier; // JSC::Identifier + typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype + typedef struct JSC__SourceCode JSC__SourceCode; // JSC::SourceCode + typedef struct JSC__JSCell JSC__JSCell; // JSC::JSCell + typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype + typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype + typedef struct JSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin + typedef struct JSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord + typedef struct WTF__String WTF__String; // WTF::String + typedef struct WTF__URL WTF__URL; // WTF::URL + typedef int64_t JSC__JSValue; + typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype + typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype + typedef struct JSC__Exception JSC__Exception; // JSC::Exception + typedef struct JSC__JSString JSC__JSString; // JSC::JSString + typedef struct JSC__PropertyNameArray JSC__PropertyNameArray; // JSC::PropertyNameArray + typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype + typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype + typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype -#pragma mark - JSC::JSObject +#endif + typedef struct bJSC__JSModuleRecord { char bytes[344]; } bJSC__JSModuleRecord; + typedef struct bJSC__PropertyNameArray { char bytes[48]; } bJSC__PropertyNameArray; + typedef struct bJSC__PropertyName { char bytes[8]; } bJSC__PropertyName; + typedef struct bJSC__ThrowScope { char bytes[8]; } bJSC__ThrowScope; + typedef struct bJSC__CallFrame { char bytes[8]; } bJSC__CallFrame; + typedef struct bJSC__CatchScope { char bytes[8]; } bJSC__CatchScope; + typedef struct bWTF__String { char bytes[8]; } bWTF__String; + typedef struct bWTF__StringView { char bytes[24]; } bWTF__StringView; + typedef struct bJSC__JSModuleLoader { char bytes[16]; } bJSC__JSModuleLoader; + typedef struct bJSC__SourceOrigin { char bytes[48]; } bJSC__SourceOrigin; + typedef struct bJSC__VM { char bytes[49080]; } bJSC__VM; + typedef struct bJSC__JSString { char bytes[16]; } bJSC__JSString; + typedef struct bJSC__Exception { char bytes[40]; } bJSC__Exception; + typedef struct bWTF__ExternalStringImpl { char bytes[32]; } bWTF__ExternalStringImpl; + typedef struct bWTF__StringImpl { char bytes[24]; } bWTF__StringImpl; + typedef struct bJSC__SourceCode { char bytes[24]; } bJSC__SourceCode; + typedef struct bJSC__JSPromise { char bytes[32]; } bJSC__JSPromise; + typedef struct bWTF__URL { char bytes[40]; } bWTF__URL; + typedef struct bJSC__JSFunction { char bytes[32]; } bJSC__JSFunction; + typedef struct bJSC__JSGlobalObject { char bytes[2464]; } bJSC__JSGlobalObject; + typedef struct bJSC__JSCell { char bytes[8]; } bJSC__JSCell; + typedef struct bJSC__JSLock { char bytes[40]; } bJSC__JSLock; + typedef struct bWundle__DefaultGlobal { char bytes[2464]; } bWundle__DefaultGlobal; + typedef struct bJSC__JSObject { char bytes[16]; } bJSC__JSObject; + typedef struct bJSC__Identifier { char bytes[8]; } bJSC__Identifier; + +#ifdef __cplusplus + namespace JSC { + class JSCell; + class Exception; + class StringPrototype; + class JSPromisePrototype; + class GeneratorFunctionPrototype; + class ArrayPrototype; + class JSString; + class JSObject; + class AsyncIteratorPrototype; + class AsyncGeneratorFunctionPrototype; + class JSPromise; + class Identifier; + class RegExpPrototype; + class AsyncFunctionPrototype; + class CatchScope; + class VM; + class BigIntPrototype; + class SetIteratorPrototype; + class ThrowScope; + class SourceOrigin; + class PropertyNameArray; + class AsyncGeneratorPrototype; + class PropertyName; + class MapIteratorPrototype; + class JSModuleRecord; + class ArrayIteratorPrototype; + class JSFunction; + class JSModuleLoader; + class GeneratorPrototype; + class JSGlobalObject; + class SourceCode; + class JSLock; + class FunctionPrototype; + class IteratorPrototype; + class CallFrame; + class ObjectPrototype; + } + namespace WTF { + class URL; + class StringImpl; + class String; + class StringView; + class ExternalStringImpl; + } + namespace Wundle { + class DefaultGlobal; + } + + typedef int64_t JSC__JSValue; + using JSC__JSCell = JSC::JSCell; + using JSC__Exception = JSC::Exception; + using JSC__StringPrototype = JSC::StringPrototype; + using JSC__JSPromisePrototype = JSC::JSPromisePrototype; + 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__JSPromise = JSC::JSPromise; + using JSC__Identifier = JSC::Identifier; + 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__SetIteratorPrototype = JSC::SetIteratorPrototype; + using JSC__ThrowScope = JSC::ThrowScope; + using JSC__SourceOrigin = JSC::SourceOrigin; + using JSC__PropertyNameArray = JSC::PropertyNameArray; + using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype; + using JSC__PropertyName = JSC::PropertyName; + using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype; + using JSC__JSModuleRecord = JSC::JSModuleRecord; + 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__JSLock = JSC::JSLock; + 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 Wundle__DefaultGlobal = Wundle::DefaultGlobal; -#ifndef BINDINGS__decls__JavaScriptCore_JSObject_h -#define BINDINGS__decls__JavaScriptCore_JSObject_h -#include <JavaScriptCore/JSObject.h> -namespace JSC { - class JSObject; -} #endif -CPP_DECL "C" bool JSC__JSObject__hasProperty(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, JSC::PropertyName* arg2); -CPP_DECL "C" JSC::PropertyNameArray* JSC__JSObject__getPropertyNames(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" size_t JSC__JSObject__getArrayLength(JSC::JSObject* arg0); -CPP_DECL "C" JSC::JSValue JSC__JSObject__getDirect(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, JSC::PropertyName* arg2); -CPP_DECL "C" bool JSC__JSObject__putDirect(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, JSC::PropertyName* arg2, JSC::JSValue arg3); -CPP_DECL "C" JSC::JSValue JSC__JSObject__get(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, JSC::PropertyName* arg2); -CPP_DECL "C" JSC::JSValue JSC__JSObject__getAtIndex(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, JSC::PropertyName* arg2, uint32_t arg3); -CPP_DECL "C" bool JSC__JSObject__putAtIndex(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, JSC::PropertyName* arg2, uint32_t arg3); -CPP_DECL "C" JSC::JSValue JSC__JSObject__getIfExists(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, JSC::PropertyName* arg2); -#pragma mark - JSC::PropertyNameArray +#pragma mark - JSC::JSObject -#ifndef BINDINGS__decls__JavaScriptCore_PropertyNameArray_h -#define BINDINGS__decls__JavaScriptCore_PropertyNameArray_h -#include <JavaScriptCore/PropertyNameArray.h> -namespace JSC { - class PropertyNameArray; -} -#endif +CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0); +CPP_DECL JSC__JSValue JSC__JSObject__getAtIndex(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, JSC__PropertyName* arg2, uint32_t arg3); +CPP_DECL bool JSC__JSObject__putAtIndex(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, JSC__PropertyName* arg2, uint32_t arg3); -CPP_DECL "C" size_t JSC__PropertyNameArray__length(JSC::PropertyNameArray* arg0); -CPP_DECL "C" void JSC__PropertyNameArray__release(JSC::PropertyNameArray* arg0); -CPP_DECL "C" const JSC::PropertyName* JSC__PropertyNameArray__next(JSC::PropertyNameArray* arg0, size_t arg1); +#pragma mark - JSC::PropertyNameArray -#pragma mark - JSC::JSCell +CPP_DECL size_t JSC__PropertyNameArray__length(JSC__PropertyNameArray* arg0); +CPP_DECL const JSC__PropertyName* JSC__PropertyNameArray__next(JSC__PropertyNameArray* arg0, size_t arg1); +CPP_DECL void JSC__PropertyNameArray__release(JSC__PropertyNameArray* arg0); -#ifndef BINDINGS__decls__JavaScriptCore_JSCell_h -#define BINDINGS__decls__JavaScriptCore_JSCell_h -#include <JavaScriptCore/JSCell.h> -namespace JSC { - class JSCell; -} -#endif +#pragma mark - JSC::JSCell -CPP_DECL "C" JSC::JSObject* JSC__JSCell__getObject(JSC::JSCell* arg0); -CPP_DECL "C" WTF::WTFString* JSC__JSCell__getString(JSC::JSCell* arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" char JSC__JSCell__getType(JSC::JSCell* arg0); +CPP_DECL JSC__JSObject* JSC__JSCell__getObject(JSC__JSCell* arg0); +CPP_DECL WTF__String* JSC__JSCell__getString(JSC__JSCell* arg0, JSC__JSGlobalObject* arg1); +CPP_DECL char JSC__JSCell__getType(JSC__JSCell* arg0); #pragma mark - JSC::JSString -#ifndef BINDINGS__decls__JavaScriptCore_JSString_h -#define BINDINGS__decls__JavaScriptCore_JSString_h -#include <JavaScriptCore/JSString.h> -namespace JSC { - class JSString; -} -#endif +CPP_DECL bool JSC__JSString__createFromOwnedString(JSC__VM* arg0, const WTF__StringImpl* arg1); +CPP_DECL bool JSC__JSString__createFromString(JSC__VM* arg0, const WTF__StringImpl* arg1); +CPP_DECL bool JSC__JSString__eql(const JSC__JSString* arg0, const JSC__JSString* arg1); +CPP_DECL JSC__JSObject* JSC__JSString__getObject(JSC__JSString* arg0); +CPP_DECL bool JSC__JSString__is8Bit(const JSC__JSString* arg0); +CPP_DECL size_t JSC__JSString__length(const JSC__JSString* arg0); +CPP_DECL WTF__String* JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1); -CPP_DECL "C" JSC::JSObject* JSC__JSString__getObject(JSC::JSString* arg0); -CPP_DECL "C" bool JSC__JSString__eql(const JSC::JSString* arg0, const JSC::JSString* arg1); -CPP_DECL "C" WTF::WTFString* JSC__JSString__value(JSC::JSString* arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" size_t JSC__JSString__length(const JSC::JSString* arg0); -CPP_DECL "C" bool JSC__JSString__is8Bit(const JSC::JSString* arg0); -CPP_DECL "C" bool JSC__JSString__createFromOwnedString(JSC::VM* arg0, WTF::StringImpl* arg1); -CPP_DECL "C" bool JSC__JSString__createFromString(JSC::VM* arg0, WTF::StringImpl* arg1); +#pragma mark - Zig::GlobalObject -#pragma mark - JSC::JSPromise +ZIG_DECL JSC__JSValue Zig__GlobalObject__eval(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, JSC__JSValue JSValue4, JSC__JSValue JSValue5, JSC__JSValue JSValue6); +ZIG_DECL JSC__JSPromise* Zig__GlobalObject__fetch(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, JSC__JSValue JSValue4); +ZIG_DECL JSC__JSPromise* Zig__GlobalObject__import(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSString* arg2, JSC__JSValue JSValue3, const JSC__SourceOrigin* arg4); +ZIG_DECL JSC__JSValue Zig__GlobalObject__reportUncaughtException(JSC__JSGlobalObject* arg0, JSC__JSPromise* arg1, uint32_t JSPromiseRejectionOperation2); +ZIG_DECL const JSC__Identifier* Zig__GlobalObject__resolve(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSString* arg2, JSC__JSValue JSValue3, const JSC__SourceOrigin* arg4); -#ifndef BINDINGS__decls__JavaScriptCore_JSPromise_h -#define BINDINGS__decls__JavaScriptCore_JSPromise_h -#include <JavaScriptCore/JSPromise.h> -namespace JSC { - class JSPromise; -} -#endif +#pragma mark - Wundle::DefaultGlobal -CPP_DECL "C" uint32_t JSC__JSPromise__status(JSC::JSPromise* arg0, JSC::VM* arg1); -CPP_DECL "C" JSC::JSValue JSC__JSPromise__result(JSC::JSPromise* arg0, JSC::VM* arg1); -CPP_DECL "C" bool JSC__JSPromise__isHandled(JSC::JSPromise* arg0, JSC::VM* arg1); -CPP_DECL "C" JSC::JSPromise* JSC__JSPromise__resolvedPromise(JSC::JSGlobalObject* arg0, JSC::JSValue arg1); -CPP_DECL "C" JSC::JSPromise* JSC__JSPromise__rejectedPromise(JSC::JSGlobalObject* arg0, JSC::JSValue arg1); -CPP_DECL "C" void JSC__JSPromise__resolve(JSC::JSGlobalObject* arg0, JSC::JSValue arg1); -CPP_DECL "C" void JSC__JSPromise__reject(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::JSValue arg2); -CPP_DECL "C" void JSC__JSPromise__rejectAsHandled(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::JSValue arg2); -CPP_DECL "C" void JSC__JSPromise__rejectException(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::Exception* arg2); -CPP_DECL "C" void JSC__JSPromise__rejectAsHandledException(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::Exception* arg2); -CPP_DECL "C" bool JSC__JSPromise__isInternal(JSC::JSPromise* arg0, JSC::VM* arg1); -CPP_DECL "C" JSC::JSPromise* JSC__JSPromise__createDeferred(JSC::JSGlobalObject* arg0, JSC::JSFunction* arg1, JSC::JSFunction* arg2, JSC::Exception* arg3); +CPP_DECL Wundle__DefaultGlobal* Wundle__DefaultGlobal__create(Wundle__DefaultGlobal* arg0, void* arg1); +CPP_DECL void* Wundle__DefaultGlobal__getWrapper(Wundle__DefaultGlobal* arg0); -#pragma mark - JSC::SourceOrigin +#pragma mark - JSC::JSModuleLoader -#ifndef BINDINGS__decls__JavaScriptCore_SourceOrigin_h -#define BINDINGS__decls__JavaScriptCore_SourceOrigin_h -#include <JavaScriptCore/SourceOrigin.h> -namespace JSC { - class SourceOrigin; -} -#endif +CPP_DECL JSC__JSValue JSC__JSModuleLoader__dependencyKeysIfEvaluated(JSC__JSModuleLoader* arg0, JSC__JSGlobalObject* arg1, JSC__JSModuleRecord* arg2); -CPP_DECL "C" const JSC::SourceOrigin* JSC__SourceOrigin__fromURL(const WTF::URL* arg0); +#pragma mark - JSC::JSModuleRecord -#pragma mark - JSC::SourceCode +CPP_DECL const JSC__SourceCode* JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord* arg0); -#ifndef BINDINGS__decls__JavaScriptCore_SourceProvider_h -#define BINDINGS__decls__JavaScriptCore_SourceProvider_h -#include <JavaScriptCore/SourceProvider.h> -namespace JSC { - class SourceCode; -} -#endif +#pragma mark - JSC::JSPromise -CPP_DECL "C" const JSC::SourceCode* JSC__SourceCode__fromString(const WTF::WTFString* arg0, const JSC::SourceOrigin* arg1, WTF::WTFString* arg2, char SourceType3); +CPP_DECL JSC__JSPromise* JSC__JSPromise__createDeferred(JSC__JSGlobalObject* arg0, JSC__JSFunction* arg1, JSC__JSFunction* arg2, JSC__Exception* arg3); +CPP_DECL bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1); +CPP_DECL bool JSC__JSPromise__isInternal(JSC__JSPromise* arg0, JSC__VM* arg1); +CPP_DECL void JSC__JSPromise__reject(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); +CPP_DECL void JSC__JSPromise__rejectAsHandled(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); +CPP_DECL void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2); +CPP_DECL JSC__JSPromise* JSC__JSPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); +CPP_DECL void JSC__JSPromise__rejectException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2); +CPP_DECL void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2); +CPP_DECL void JSC__JSPromise__resolve(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); +CPP_DECL JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); +CPP_DECL JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise* arg0, JSC__VM* arg1); +CPP_DECL uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1); -#pragma mark - JSC::JSFunction +#pragma mark - JSC::SourceOrigin -#ifndef BINDINGS__decls__JavaScriptCore_JSFunction_h -#define BINDINGS__decls__JavaScriptCore_JSFunction_h -#include <JavaScriptCore/JSFunction.h> -namespace JSC { - class JSFunction; -} -#endif +CPP_DECL const JSC__SourceOrigin* JSC__SourceOrigin__fromURL(const WTF__URL* arg0); -CPP_DECL "C" JSC::JSFunction* JSC__JSFunction__createFromSourceCode(JSC::SourceCode* arg0, JSC::SourceOrigin* arg1, JSC::Exception* arg2); -CPP_DECL "C" JSC::JSFunction* JSC__JSFunction__createFromNative(JSC::VM* arg0, JSC::JSGlobalObject* arg1, uint32_t arg2, WTF::WTFString* arg3, void* arg4); -CPP_DECL "C" WTF::WTFString* JSC__JSFunction__getName(JSC::JSFunction* arg0, JSC::VM* arg1); -CPP_DECL "C" WTF::WTFString* JSC__JSFunction__displayName(JSC::JSFunction* arg0, JSC::VM* arg1); -CPP_DECL "C" WTF::WTFString* JSC__JSFunction__calculatedDisplayName(JSC::JSFunction* arg0, JSC::VM* arg1); -CPP_DECL "C" JSC::JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC::JSFunction* arg0, JSC::JSValue arg1, JSC::JSGlobalObject* arg2, JSC::JSValue* arg3, size_t arg4, JSC::Exception** arg5, char* arg6); -CPP_DECL "C" JSC::JSValue JSC__JSFunction__callWithArguments(JSC::JSFunction* arg0, JSC::JSGlobalObject* arg1, JSC::JSValue* arg2, size_t arg3, JSC::Exception** arg4, char* arg5); -CPP_DECL "C" JSC::JSValue JSC__JSFunction__callWithThis(JSC::JSFunction* arg0, JSC::JSGlobalObject* arg1, JSC::JSValue arg2, JSC::Exception** arg3, char* arg4); -CPP_DECL "C" JSC::JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC::JSFunction* arg0, JSC::JSGlobalObject* arg1, JSC::Exception** arg2, char* arg3); -CPP_DECL "C" JSC::JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC::JSFunction* arg0, JSC::JSValue arg1, JSC::JSGlobalObject* arg2, JSC::JSValue* arg3, size_t arg4, JSC::Exception** arg5, char* arg6); -CPP_DECL "C" JSC::JSValue JSC__JSFunction__constructWithArguments(JSC::JSFunction* arg0, JSC::JSGlobalObject* arg1, JSC::JSValue* arg2, size_t arg3, JSC::Exception** arg4, char* arg5); -CPP_DECL "C" JSC::JSValue JSC__JSFunction__constructWithNewTarget(JSC::JSFunction* arg0, JSC::JSGlobalObject* arg1, JSC::JSValue arg2, JSC::Exception** arg3, char* arg4); -CPP_DECL "C" JSC::JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC::JSFunction* arg0, JSC::JSGlobalObject* arg1, JSC::Exception** arg2, char* arg3); +#pragma mark - JSC::SourceCode -#pragma mark - JSC::JSGlobalObject +CPP_DECL const JSC__SourceCode* JSC__SourceCode__fromString(const WTF__String* arg0, const JSC__SourceOrigin* arg1, WTF__String* arg2, char SourceType3); -#ifndef BINDINGS__decls__JavaScriptCore_JSGlobalObject_h -#define BINDINGS__decls__JavaScriptCore_JSGlobalObject_h -#include <JavaScriptCore/JSGlobalObject.h> -namespace JSC { - class JSGlobalObject; -} -#endif +#pragma mark - JSC::JSFunction -CPP_DECL "C" JSC::ObjectPrototype* JSC__JSGlobalObject__objectPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::FunctionPrototype* JSC__JSGlobalObject__functionPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::ArrayPrototype* JSC__JSGlobalObject__arrayPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__booleanPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::StringPrototype* JSC__JSGlobalObject__stringPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__numberPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::BigIntPrototype* JSC__JSGlobalObject__bigIntPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__datePrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__symbolPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::RegExpPrototype* JSC__JSGlobalObject__regExpPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__errorPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::IteratorPrototype* JSC__JSGlobalObject__iteratorPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::AsyncIteratorPrototype* JSC__JSGlobalObject__asyncIteratorPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::GeneratorFunctionPrototype* JSC__JSGlobalObject__generatorFunctionPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::GeneratorPrototype* JSC__JSGlobalObject__generatorPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::AsyncFunctionPrototype* JSC__JSGlobalObject__asyncFunctionPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::ArrayIteratorPrototype* JSC__JSGlobalObject__arrayIteratorPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::MapIteratorPrototype* JSC__JSGlobalObject__mapIteratorPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::SetIteratorPrototype* JSC__JSGlobalObject__setIteratorPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__mapPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::JSObject* JSC__JSGlobalObject__jsSetPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::JSPromisePrototype* JSC__JSGlobalObject__promisePrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::AsyncGeneratorPrototype* JSC__JSGlobalObject__asyncGeneratorPrototype(JSC::JSGlobalObject* arg0); -CPP_DECL "C" JSC::AsyncGeneratorFunctionPrototype* JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC::JSGlobalObject* arg0); +CPP_DECL WTF__String* JSC__JSFunction__calculatedDisplayName(JSC__JSFunction* arg0, JSC__VM* arg1); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue arg2, size_t arg3, JSC__Exception** arg4, char* arg5); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSFunction* arg0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue arg3, size_t arg4, JSC__Exception** arg5, char* arg6); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, char* arg3); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, char* arg4); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue arg2, size_t arg3, JSC__Exception** arg4, char* arg5); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSFunction* arg0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue arg3, size_t arg4, JSC__Exception** arg5, char* arg6); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, char* arg4); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, char* arg3); +CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__VM* arg0, JSC__JSGlobalObject* arg1, uint32_t arg2, WTF__String* arg3, void* arg4); +CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromSourceCode(JSC__SourceCode* arg0, JSC__SourceOrigin* arg1, JSC__Exception* arg2); +CPP_DECL WTF__String* JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1); +CPP_DECL WTF__String* JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1); -#pragma mark - WTF::URL +#pragma mark - JSC::JSGlobalObject -#ifndef BINDINGS__decls__wtf_URL_h -#define BINDINGS__decls__wtf_URL_h -#include <wtf/URL.h> -namespace WTF { - class URL; -} -#endif +CPP_DECL JSC__ArrayIteratorPrototype* JSC__JSGlobalObject__arrayIteratorPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__ArrayPrototype* JSC__JSGlobalObject__arrayPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__AsyncFunctionPrototype* JSC__JSGlobalObject__asyncFunctionPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__AsyncGeneratorFunctionPrototype* JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__AsyncGeneratorPrototype* JSC__JSGlobalObject__asyncGeneratorPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__AsyncIteratorPrototype* JSC__JSGlobalObject__asyncIteratorPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__BigIntPrototype* JSC__JSGlobalObject__bigIntPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__booleanPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__createError(JSC__JSGlobalObject* arg0, char ErrorType1, WTF__String* arg2); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__datePrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__errorPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__FunctionPrototype* JSC__JSGlobalObject__functionPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__GeneratorFunctionPrototype* JSC__JSGlobalObject__generatorFunctionPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__GeneratorPrototype* JSC__JSGlobalObject__generatorPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__IteratorPrototype* JSC__JSGlobalObject__iteratorPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__jsSetPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__MapIteratorPrototype* JSC__JSGlobalObject__mapIteratorPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__mapPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__numberPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__ObjectPrototype* JSC__JSGlobalObject__objectPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSPromisePrototype* JSC__JSGlobalObject__promisePrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__RegExpPrototype* JSC__JSGlobalObject__regExpPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__SetIteratorPrototype* JSC__JSGlobalObject__setIteratorPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__StringPrototype* JSC__JSGlobalObject__stringPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__symbolPrototype(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__JSObject* JSC__JSGlobalObject__throwError(JSC__JSGlobalObject* arg0, JSC__JSObject* arg1); +CPP_DECL JSC__VM* JSC__JSGlobalObject__vm(JSC__JSGlobalObject* arg0); -CPP_DECL "C" WTF::URL* WTF__URL__fromFileSystemPath(const WTF::StringView* arg0); -CPP_DECL "C" WTF::URL* WTF__URL__fromString(const WTF::WTFString* arg0, const WTF::WTFString* arg1); -CPP_DECL "C" bool WTF__URL__isEmpty(const WTF::URL* arg0); -CPP_DECL "C" bool WTF__URL__isValid(const WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__protocol(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__encodedUser(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__encodedPassword(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__host(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__path(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__lastPathComponent(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__query(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__fragmentIdentifier(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__queryWithLeadingQuestionMark(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__stringWithoutQueryOrFragmentIdentifier(WTF::URL* arg0); -CPP_DECL "C" const WTF::StringView* WTF__URL__stringWithoutFragmentIdentifier(WTF::URL* arg0); -CPP_DECL "C" const WTF::WTFString* WTF__URL__protocolHostAndPort(WTF::URL* arg0); -CPP_DECL "C" const WTF::WTFString* WTF__URL__hostAndPort(WTF::URL* arg0); -CPP_DECL "C" const WTF::WTFString* WTF__URL__user(WTF::URL* arg0); -CPP_DECL "C" const WTF::WTFString* WTF__URL__password(WTF::URL* arg0); -CPP_DECL "C" const WTF::WTFString* WTF__URL__fileSystemPath(WTF::URL* arg0); -CPP_DECL "C" void WTF__URL__setProtocol(WTF::URL* arg0, const WTF::StringView* arg1); -CPP_DECL "C" void WTF__URL__setHost(WTF::URL* arg0, const WTF::StringView* arg1); -CPP_DECL "C" void WTF__URL__setHostAndPort(WTF::URL* arg0, const WTF::StringView* arg1); -CPP_DECL "C" void WTF__URL__setUser(WTF::URL* arg0, const WTF::StringView* arg1); -CPP_DECL "C" void WTF__URL__setPassword(WTF::URL* arg0, const WTF::StringView* arg1); -CPP_DECL "C" void WTF__URL__setPath(WTF::URL* arg0, const WTF::StringView* arg1); -CPP_DECL "C" void WTF__URL__setQuery(WTF::URL* arg0, const WTF::StringView* arg1); -CPP_DECL "C" WTF::URL* WTF__URL__truncatedForUseAsBase(WTF::URL* arg0); - -#pragma mark - WTF::WTFString - -#ifndef BINDINGS__decls__wtf_text_WTFString_h -#define BINDINGS__decls__wtf_text_WTFString_h -#include <wtf/text/WTFString.h> -namespace WTF { - class WTFString; -} -#endif +#pragma mark - WTF::URL -CPP_DECL "C" bool WTF__WTFString__is8Bit(WTF::WTFString* arg0); -CPP_DECL "C" bool WTF__WTFString__is16Bit(WTF::WTFString* arg0); -CPP_DECL "C" bool WTF__WTFString__isExternal(WTF::WTFString* arg0); -CPP_DECL "C" bool WTF__WTFString__isStatic(WTF::WTFString* arg0); -CPP_DECL "C" bool WTF__WTFString__isEmpty(WTF::WTFString* arg0); -CPP_DECL "C" size_t WTF__WTFString__length(WTF::WTFString* arg0); -CPP_DECL "C" char* WTF__WTFString__characters8(WTF::WTFString* arg0); -CPP_DECL "C" char* WTF__WTFString__characters16(WTF::WTFString* arg0); -CPP_DECL "C" WTF::WTFString* WTF__WTFString__createWithoutCopyingFromPtr(const char* arg0, size_t arg1); -CPP_DECL "C" bool WTF__WTFString__eqlString(WTF::WTFString* arg0, WTF::WTFString* arg1); -CPP_DECL "C" bool WTF__WTFString__eqlSlice(WTF::WTFString* arg0, char* arg1, size_t arg2); -CPP_DECL "C" WTF::StringImpl* WTF__WTFString__impl(WTF::WTFString* arg0); -CPP_DECL "C" WTF::WTFString* WTF__WTFString__createFromExternalString(WTF::StringImpl* arg0); +CPP_DECL bWTF__StringView WTF__URL__encodedPassword(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__encodedUser(WTF__URL* arg0); +CPP_DECL bWTF__String WTF__URL__fileSystemPath(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__fragmentIdentifier(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF__URL* arg0); +CPP_DECL bWTF__URL WTF__URL__fromFileSystemPath(bWTF__StringView arg0); +CPP_DECL bWTF__URL WTF__URL__fromString(bWTF__String arg0, bWTF__String arg1); +CPP_DECL bWTF__StringView WTF__URL__host(WTF__URL* arg0); +CPP_DECL bWTF__String WTF__URL__hostAndPort(WTF__URL* arg0); +CPP_DECL bool WTF__URL__isEmpty(const WTF__URL* arg0); +CPP_DECL bool WTF__URL__isValid(const WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__lastPathComponent(WTF__URL* arg0); +CPP_DECL bWTF__String WTF__URL__password(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__path(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__protocol(WTF__URL* arg0); +CPP_DECL bWTF__String WTF__URL__protocolHostAndPort(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__query(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__queryWithLeadingQuestionMark(WTF__URL* arg0); +CPP_DECL void WTF__URL__setHost(WTF__URL* arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setHostAndPort(WTF__URL* arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setPassword(WTF__URL* arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setPath(WTF__URL* arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setProtocol(WTF__URL* arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setQuery(WTF__URL* arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setUser(WTF__URL* arg0, bWTF__StringView arg1); +CPP_DECL bWTF__String WTF__URL__stringWithoutFragmentIdentifier(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__stringWithoutQueryOrFragmentIdentifier(WTF__URL* arg0); +CPP_DECL bWTF__URL WTF__URL__truncatedForUseAsBase(WTF__URL* arg0); +CPP_DECL bWTF__String WTF__URL__user(WTF__URL* arg0); + +#pragma mark - WTF::String + +CPP_DECL const uint16_t* WTF__String__characters16(WTF__String* arg0); +CPP_DECL const char* WTF__String__characters8(WTF__String* arg0); +CPP_DECL bWTF__String WTF__String__createFromExternalString(bWTF__ExternalStringImpl arg0); +CPP_DECL bWTF__String WTF__String__createWithoutCopyingFromPtr(const char* arg0, size_t arg1); +CPP_DECL bool WTF__String__eqlSlice(WTF__String* arg0, const char* arg1, size_t arg2); +CPP_DECL bool WTF__String__eqlString(WTF__String* arg0, const WTF__String* arg1); +CPP_DECL const WTF__StringImpl* WTF__String__impl(WTF__String* arg0); +CPP_DECL bool WTF__String__is16Bit(WTF__String* arg0); +CPP_DECL bool WTF__String__is8Bit(WTF__String* arg0); +CPP_DECL bool WTF__String__isEmpty(WTF__String* arg0); +CPP_DECL bool WTF__String__isExternal(WTF__String* arg0); +CPP_DECL bool WTF__String__isStatic(WTF__String* arg0); +CPP_DECL size_t WTF__String__length(WTF__String* arg0); #pragma mark - JSC::JSValue -#ifndef BINDINGS__decls__JavaScriptCore_JSValue_h -#define BINDINGS__decls__JavaScriptCore_JSValue_h -#include <JavaScriptCore/JSValue.h> -namespace JSC { - class JSValue; -} -#endif - -CPP_DECL "C" uint64_t JSC__JSValue__encode(JSC::JSValue arg0); -CPP_DECL "C" JSC::JSString* JSC__JSValue__asString(JSC::JSValue arg0); -CPP_DECL "C" JSC::JSString* JSC__JSValue__asObject(JSC::JSValue arg0); -CPP_DECL "C" JSC::JSString* JSC__JSValue__asNumber(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isError(JSC::JSValue arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsNull(); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsUndefined(); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsTDZValue(); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsBoolean(bool arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsDoubleNumber(double arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsNumberFromDouble(double arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsNumberFromChar(char arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsNumberFromInt32(int32_t arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsNumberFromInt64(int64_t arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0); -CPP_DECL "C" bool JSC__JSValue__isUndefined(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isNull(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isUndefinedOrNull(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isBoolean(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isAnyInt(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isUInt32AsAnyInt(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isInt32AsAnyInt(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isNumber(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isString(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isBigInt(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isHeapBigInt(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isBigInt32(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isSymbol(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isPrimitive(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isGetterSetter(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isCustomGetterSetter(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isObject(JSC::JSValue arg0); -CPP_DECL "C" bool JSC__JSValue__isCell(JSC::JSValue arg0); -CPP_DECL "C" JSC::JSCell* JSC__JSValue__asCell(JSC::JSValue arg0); -CPP_DECL "C" JSC::JSString* JSC__JSValue__toString(JSC::JSValue arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" JSC::JSString* JSC__JSValue__toStringOrNull(JSC::JSValue arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" JSC::Identifier* JSC__JSValue__toPropertyKey(JSC::JSValue arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" JSC::JSValue JSC__JSValue__toPropertyKeyValue(JSC::JSValue arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" JSC::JSObject* JSC__JSValue__toObject(JSC::JSValue arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" WTF::WTFString* JSC__JSValue__toWTFString(JSC::JSValue arg0); -CPP_DECL "C" JSC::JSValue JSC__JSValue__getPrototype(JSC::JSValue arg0, JSC::JSGlobalObject* arg1); -CPP_DECL "C" JSC::JSValue JSC__JSValue__getPropertyByPropertyName(JSC::JSValue arg0, JSC::PropertyName* arg1, JSC::JSGlobalObject* arg2); -CPP_DECL "C" bool JSC__JSValue__eqlValue(JSC::JSValue arg0, JSC::JSValue arg1); -CPP_DECL "C" bool JSC__JSValue__eqlCell(JSC::JSValue arg0, JSC::JSCell* arg1); +CPP_DECL JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0); +CPP_DECL double JSC__JSValue__asNumber(JSC__JSValue JSValue0); +CPP_DECL bJSC__JSObject JSC__JSValue__asObject(JSC__JSValue JSValue0); +CPP_DECL JSC__JSString* JSC__JSValue__asString(JSC__JSValue JSValue0); +CPP_DECL uint64_t JSC__JSValue__encode(JSC__JSValue JSValue0); +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 JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); +CPP_DECL bool JSC__JSValue__isAnyInt(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isBigInt(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isBigInt32(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isBoolean(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isCell(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isCustomGetterSetter(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isError(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isGetterSetter(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isHeapBigInt(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isInt32AsAnyInt(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isNull(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isNumber(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isObject(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isPrimitive(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isString(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isSymbol(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isUInt32AsAnyInt(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isUndefined(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isUndefinedOrNull(JSC__JSValue JSValue0); +CPP_DECL JSC__JSValue JSC__JSValue__jsBoolean(bool arg0); +CPP_DECL JSC__JSValue JSC__JSValue__jsDoubleNumber(double arg0); +CPP_DECL JSC__JSValue JSC__JSValue__jsNull(); +CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromChar(char arg0); +CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromDouble(double arg0); +CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromInt32(int32_t arg0); +CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromInt64(int64_t arg0); +CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0); +CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0); +CPP_DECL JSC__JSValue JSC__JSValue__jsTDZValue(); +CPP_DECL JSC__JSValue JSC__JSValue__jsUndefined(); +CPP_DECL JSC__JSObject* JSC__JSValue__toObject(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); +CPP_DECL bJSC__Identifier JSC__JSValue__toPropertyKey(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); +CPP_DECL JSC__JSValue JSC__JSValue__toPropertyKeyValue(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); +CPP_DECL JSC__JSString* JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); +CPP_DECL JSC__JSString* JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); +CPP_DECL JSC__JSString* JSC__JSValue__toStringOrNull(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); #pragma mark - JSC::PropertyName -#ifndef BINDINGS__decls__JavaScriptCore_PropertyName_h -#define BINDINGS__decls__JavaScriptCore_PropertyName_h -#include <JavaScriptCore/PropertyName.h> -namespace JSC { - class PropertyName; -} -#endif - -CPP_DECL "C" bool JSC__PropertyName__eqlToPropertyName(JSC::PropertyName* arg0, const JSC::PropertyName* arg1); -CPP_DECL "C" bool JSC__PropertyName__eqlToIdentifier(JSC::PropertyName* arg0, const JSC::Identifier* arg1); -CPP_DECL "C" WTF::StringImpl* JSC__PropertyName__publicName(JSC::PropertyName* arg0); -CPP_DECL "C" WTF::StringImpl* JSC__PropertyName__uid(JSC::PropertyName* arg0); +CPP_DECL bool JSC__PropertyName__eqlToIdentifier(JSC__PropertyName* arg0, const JSC__Identifier* arg1); +CPP_DECL bool JSC__PropertyName__eqlToPropertyName(JSC__PropertyName* arg0, const JSC__PropertyName* arg1); +CPP_DECL const WTF__StringImpl* JSC__PropertyName__publicName(JSC__PropertyName* arg0); +CPP_DECL const WTF__StringImpl* JSC__PropertyName__uid(JSC__PropertyName* arg0); #pragma mark - JSC::Exception -#ifndef BINDINGS__decls__JavaScriptCore_Exception_h -#define BINDINGS__decls__JavaScriptCore_Exception_h -#include <JavaScriptCore/Exception.h> -namespace JSC { - class Exception; -} -#endif - -CPP_DECL "C" JSC::Exception* JSC__Exception__create(JSC::JSGlobalObject* arg0, JSC::JSObject* arg1, char StackCaptureAction2); +CPP_DECL JSC__Exception* JSC__Exception__create(JSC__JSGlobalObject* arg0, JSC__JSObject* arg1, char StackCaptureAction2); #pragma mark - JSC::VM -#ifndef BINDINGS__decls__JavaScriptCore_VM_h -#define BINDINGS__decls__JavaScriptCore_VM_h -#include <JavaScriptCore/VM.h> -namespace JSC { - class VM; -} -#endif +CPP_DECL JSC__JSLock* JSC__VM__apiLock(JSC__VM* arg0); +CPP_DECL JSC__VM* JSC__VM__create(char HeapType0); +CPP_DECL void JSC__VM__deinit(JSC__VM* arg0, JSC__JSGlobalObject* arg1); +CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM* arg0); +CPP_DECL bool JSC__VM__executionForbidden(JSC__VM* arg0); +CPP_DECL bool JSC__VM__isEntered(JSC__VM* arg0); +CPP_DECL void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1); +CPP_DECL bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const char* arg3, size_t arg4); -CPP_DECL "C" JSC::VM* JSC__VM__create(char HeapType0); -CPP_DECL "C" void JSC__VM__deinit(JSC::VM* arg0); -CPP_DECL "C" void JSC__VM__setExecutionForbidden(JSC::VM* arg0, bool arg1); -CPP_DECL "C" bool JSC__VM__executionForbidden(JSC::VM* arg0); -CPP_DECL "C" bool JSC__VM__isEntered(JSC::VM* arg0); -CPP_DECL "C" bool JSC__VM__throwError(JSC::VM* arg0, JSC::ExceptionScope* arg1, const char* arg2, size_t arg3); - -#pragma mark - JSC::ExceptionScope - -#ifndef BINDINGS__decls__JavaScriptCore_ExceptionScope_h -#define BINDINGS__decls__JavaScriptCore_ExceptionScope_h -#include <JavaScriptCore/ExceptionScope.h> -namespace JSC { - class ExceptionScope; -} -#endif +#pragma mark - JSC::ThrowScope -CPP_DECL "C" void JSC__ExceptionScope__release(JSC::ExceptionScope* arg0); -CPP_DECL "C" JSC::ExceptionScope* JSC__ExceptionScope__declareThrowScope(JSC::VM* arg0, char* arg1, char* arg2, size_t arg3); -CPP_DECL "C" JSC::ExceptionScope* JSC__ExceptionScope__declareCatchScope(JSC::VM* arg0, char* arg1, char* arg2, size_t arg3); -CPP_DECL "C" void JSC__ExceptionScope__release(JSC::ExceptionScope* arg0); -CPP_DECL "C" JSC::Exception* JSC__ExceptionScope__exception(JSC::ExceptionScope* arg0); -CPP_DECL "C" void JSC__ExceptionScope__clearException(JSC::ExceptionScope* arg0); +CPP_DECL void JSC__ThrowScope__clearException(JSC__ThrowScope* arg0); +CPP_DECL bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, char* arg1, char* arg2, size_t arg3); +CPP_DECL JSC__Exception* JSC__ThrowScope__exception(JSC__ThrowScope* arg0); +CPP_DECL void JSC__ThrowScope__release(JSC__ThrowScope* arg0); -#pragma mark - JSC::CallFrame +#pragma mark - JSC::CatchScope -#ifndef BINDINGS__decls__JavaScriptCore_CallFrame_h -#define BINDINGS__decls__JavaScriptCore_CallFrame_h -#include <JavaScriptCore/CallFrame.h> -namespace JSC { - class CallFrame; -} -#endif +CPP_DECL void JSC__CatchScope__clearException(JSC__CatchScope* arg0); +CPP_DECL bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, char* arg1, char* arg2, size_t arg3); +CPP_DECL JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0); -CPP_DECL "C" size_t JSC__CallFrame__argumentsCount(const JSC::CallFrame* arg0); -CPP_DECL "C" JSC::JSValue JSC__CallFrame__uncheckedArgument(const JSC::CallFrame* arg0, uint16_t arg1); -CPP_DECL "C" JSC::JSValue JSC__CallFrame__argument(const JSC::CallFrame* arg0, uint16_t arg1); -CPP_DECL "C" JSC::JSValue JSC__CallFrame__thisValue(const JSC::CallFrame* arg0); -CPP_DECL "C" JSC::JSValue JSC__CallFrame__newTarget(const JSC::CallFrame* arg0); -CPP_DECL "C" JSC::JSObject* JSC__CallFrame__jsCallee(const JSC::CallFrame* arg0); +#pragma mark - JSC::CallFrame -#pragma mark - JSC::Identifier +CPP_DECL JSC__JSValue JSC__CallFrame__argument(const JSC__CallFrame* arg0, uint16_t arg1); +CPP_DECL size_t JSC__CallFrame__argumentsCount(const JSC__CallFrame* arg0); +CPP_DECL JSC__JSObject* JSC__CallFrame__jsCallee(const JSC__CallFrame* arg0); +CPP_DECL JSC__JSValue JSC__CallFrame__newTarget(const JSC__CallFrame* arg0); +CPP_DECL JSC__JSValue JSC__CallFrame__thisValue(const JSC__CallFrame* arg0); +CPP_DECL JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame* arg0, uint16_t arg1); -#ifndef BINDINGS__decls__JavaScriptCore_Identifier_h -#define BINDINGS__decls__JavaScriptCore_Identifier_h -#include <JavaScriptCore/Identifier.h> -namespace JSC { - class Identifier; -} -#endif +#pragma mark - JSC::Identifier -CPP_DECL "C" JSC::Identifier* JSC__Identifier__fromString(JSC::VM* arg0, WTF::WTFString* arg1); -CPP_DECL "C" JSC::Identifier* JSC__Identifier__fromSlice(JSC::VM* arg0, char* arg1, size_t arg2); -CPP_DECL "C" JSC::Identifier* JSC__Identifier__fromUid(JSC::VM* arg0, WTF::StringImpl* arg1); -CPP_DECL "C" void JSC__Identifier__deinit(JSC::VM* arg0); -CPP_DECL "C" WTF::WTFString* JSC__Identifier__toString(JSC::Identifier* arg0); -CPP_DECL "C" size_t JSC__Identifier__length(JSC::Identifier* arg0); -CPP_DECL "C" bool JSC__Identifier__isNull(JSC::Identifier* arg0); -CPP_DECL "C" bool JSC__Identifier__isEmpty(JSC::Identifier* arg0); -CPP_DECL "C" bool JSC__Identifier__isSymbol(JSC::Identifier* arg0); -CPP_DECL "C" bool JSC__Identifier__isPrivateName(JSC::Identifier* arg0); -CPP_DECL "C" bool JSC__Identifier__eqlIdent(JSC::Identifier* arg0, JSC::Identifier* arg1); -CPP_DECL "C" bool JSC__Identifier__neqlIdent(JSC::Identifier* arg0, JSC::Identifier* arg1); -CPP_DECL "C" bool JSC__Identifier__eqlStringImpl(JSC::Identifier* arg0, WTF::StringImpl* arg1); -CPP_DECL "C" bool JSC__Identifier__neqlStringImpl(JSC::Identifier* arg0, WTF::StringImpl* arg1); -CPP_DECL "C" bool JSC__Identifier__eqlUTF8(JSC::Identifier* arg0, char* arg1, size_t arg2); +CPP_DECL void JSC__Identifier__deinit(const JSC__Identifier* arg0); +CPP_DECL bool JSC__Identifier__eqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1); +CPP_DECL bool JSC__Identifier__eqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1); +CPP_DECL bool JSC__Identifier__eqlUTF8(const JSC__Identifier* arg0, const char* arg1, size_t arg2); +CPP_DECL bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM* arg0, const char* arg1, size_t arg2); +CPP_DECL bJSC__Identifier JSC__Identifier__fromString(JSC__VM* arg0, const WTF__String* arg1); +CPP_DECL bJSC__Identifier JSC__Identifier__fromUid(JSC__VM* arg0, const WTF__StringImpl* arg1); +CPP_DECL bool JSC__Identifier__isEmpty(const JSC__Identifier* arg0); +CPP_DECL bool JSC__Identifier__isNull(const JSC__Identifier* arg0); +CPP_DECL bool JSC__Identifier__isPrivateName(const JSC__Identifier* arg0); +CPP_DECL bool JSC__Identifier__isSymbol(const JSC__Identifier* arg0); +CPP_DECL size_t JSC__Identifier__length(const JSC__Identifier* arg0); +CPP_DECL bool JSC__Identifier__neqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1); +CPP_DECL bool JSC__Identifier__neqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1); +CPP_DECL bWTF__String JSC__Identifier__toString(const JSC__Identifier* arg0); #pragma mark - WTF::StringImpl -#ifndef BINDINGS__decls__WTF_text_StringImpl_h -#define BINDINGS__decls__WTF_text_StringImpl_h -#include <WTF/text/StringImpl.h> -namespace WTF { - class StringImpl; -} -#endif - -CPP_DECL "C" bool WTF__StringImpl__is8Bit(WTF::StringImpl* arg0); -CPP_DECL "C" bool WTF__StringImpl__is16Bit(WTF::StringImpl* arg0); -CPP_DECL "C" bool WTF__StringImpl__isExternal(WTF::StringImpl* arg0); -CPP_DECL "C" bool WTF__StringImpl__isStatic(WTF::StringImpl* arg0); -CPP_DECL "C" bool WTF__StringImpl__isEmpty(WTF::StringImpl* arg0); -CPP_DECL "C" size_t WTF__StringImpl__length(WTF::StringImpl* arg0); -CPP_DECL "C" char* WTF__StringImpl__characters8(WTF::StringImpl* arg0); -CPP_DECL "C" uint16_t* WTF__StringImpl__characters16(WTF::StringImpl* arg0); +CPP_DECL const uint16_t* WTF__StringImpl__characters16(const WTF__StringImpl* arg0); +CPP_DECL const char* WTF__StringImpl__characters8(const WTF__StringImpl* arg0); +CPP_DECL bool WTF__StringImpl__is16Bit(const WTF__StringImpl* arg0); +CPP_DECL bool WTF__StringImpl__is8Bit(const WTF__StringImpl* arg0); +CPP_DECL bool WTF__StringImpl__isEmpty(const WTF__StringImpl* arg0); +CPP_DECL bool WTF__StringImpl__isExternal(const WTF__StringImpl* arg0); +CPP_DECL bool WTF__StringImpl__isStatic(const WTF__StringImpl* arg0); +CPP_DECL size_t WTF__StringImpl__length(const WTF__StringImpl* arg0); + +#pragma mark - WTF::ExternalStringImpl + +CPP_DECL const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0); +CPP_DECL const char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0); +CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const char* arg0, size_t arg1, void (* ArgFn2)(void* arg0, 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); +CPP_DECL size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl* arg0); #pragma mark - WTF::StringView -#ifndef BINDINGS__decls__WTF_text_StringView_h -#define BINDINGS__decls__WTF_text_StringView_h -#include <WTF/text/StringView.h> -namespace WTF { - class StringView; -} -#endif - -CPP_DECL "C" WTF::StringView* WTF__StringView__from8Bit(const char* arg0, size_t arg1); -CPP_DECL "C" bool WTF__StringView__is8Bit(WTF::StringView* arg0); -CPP_DECL "C" bool WTF__StringView__is16Bit(WTF::StringView* arg0); -CPP_DECL "C" bool WTF__StringView__isEmpty(WTF::StringView* arg0); -CPP_DECL "C" size_t WTF__StringView__length(WTF::StringView* arg0); -CPP_DECL "C" char* WTF__StringView__characters8(WTF::StringView* arg0); -CPP_DECL "C" uint16_t* WTF__StringView__characters16(WTF::StringView* arg0); +CPP_DECL const uint16_t* WTF__StringView__characters16(const WTF__StringView* arg0); +CPP_DECL const char* WTF__StringView__characters8(const WTF__StringView* arg0); +CPP_DECL bWTF__StringView WTF__StringView__from8Bit(const char* arg0, size_t arg1); +CPP_DECL bool WTF__StringView__is16Bit(const WTF__StringView* arg0); +CPP_DECL bool WTF__StringView__is8Bit(const WTF__StringView* arg0); +CPP_DECL bool WTF__StringView__isEmpty(const WTF__StringView* arg0); +CPP_DECL size_t WTF__StringView__length(const WTF__StringView* arg0); diff --git a/src/javascript/jsc/bindings/sizes.zig b/src/javascript/jsc/bindings/sizes.zig new file mode 100644 index 000000000..a48ac9f16 --- /dev/null +++ b/src/javascript/jsc/bindings/sizes.zig @@ -0,0 +1,38 @@ +// Auto-generated by src/javascript/jsc/headergen/sizegen.cpp at 2021-07-21 02:02:1626858148. +// These are the byte sizes for the different object types with bindings in JavaScriptCore. +// This allows us to safely return stack allocated C++ types to Zig. +// It is only safe to do this when these sizes are correct. +// That means: +// 1. We can't dynamically link JavaScriptCore +// 2. It's important that this is run whenever JavaScriptCore is updated or the bindings on the Zig side change. +// Failure to do so will lead to undefined behavior and probably some frustrated people. +// --- To renegerate: --- +// 1. "make jsc-bindings-headers" +// 2. "make sizegen" +// 3. "make jsc-bindings-headers" +// You can verify the numbers written in this file at runtime via the `extern`d types +pub const JSC__JSObject = 16; +pub const JSC__PropertyNameArray = 48; +pub const JSC__JSCell = 8; +pub const JSC__JSString = 16; +pub const Wundle__DefaultGlobal = 2464; +pub const JSC__JSModuleLoader = 16; +pub const JSC__JSModuleRecord = 344; +pub const JSC__JSPromise = 32; +pub const JSC__SourceOrigin = 48; +pub const JSC__SourceCode = 24; +pub const JSC__JSFunction = 32; +pub const JSC__JSGlobalObject = 2464; +pub const WTF__URL = 40; +pub const WTF__String = 8; +pub const JSC__JSValue = 8; +pub const JSC__PropertyName = 8; +pub const JSC__Exception = 40; +pub const JSC__VM = 49080; +pub const JSC__ThrowScope = 8; +pub const JSC__CatchScope = 8; +pub const JSC__CallFrame = 8; +pub const JSC__Identifier = 8; +pub const WTF__StringImpl = 24; +pub const WTF__ExternalStringImpl = 32; +pub const WTF__StringView = 24; diff --git a/src/javascript/jsc/bindings/static_export.zig b/src/javascript/jsc/bindings/static_export.zig new file mode 100644 index 000000000..91342fad8 --- /dev/null +++ b/src/javascript/jsc/bindings/static_export.zig @@ -0,0 +1,8 @@ +const std = @import("std"); +Type: type, +symbol_name: []const u8, +local_name: []const u8, +Parent: type, +pub fn Decl(comptime this: *const @This()) std.builtin.TypeInfo.Declaration { + return comptime std.meta.declarationInfo(this.Parent, this.local_name); +} diff --git a/src/javascript/jsc/headergen/sizegen.cpp b/src/javascript/jsc/headergen/sizegen.cpp new file mode 100644 index 000000000..6999fcda0 --- /dev/null +++ b/src/javascript/jsc/headergen/sizegen.cpp @@ -0,0 +1,40 @@ +#include <iostream> +#include <fstream> +#include <ctime> +using namespace std; + +#include "headers-cpp.h" + +int main() { + time_t rawtime; + struct tm * timeinfo; + char buf [80]; + + time (&rawtime); + timeinfo = localtime (&rawtime); + + strftime (buf,80,"%Y-%m-%d %H:%M:%s",timeinfo); + + cout << "// Auto-generated by src/javascript/jsc/headergen/sizegen.cpp at " << buf << ".\n"; + cout << "// These are the byte sizes for the different object types with bindings in JavaScriptCore.\n"; + cout << "// This allows us to safely return stack allocated C++ types to Zig.\n"; + cout << "// It is only safe to do this when these sizes are correct.\n"; + cout << "// That means:\n"; + cout << "// 1. We can't dynamically link JavaScriptCore\n"; + cout << "// 2. It's important that this is run whenever JavaScriptCore is updated or the bindings on the Zig side change.\n"; + cout << "// Failure to do so will lead to undefined behavior and probably some frustrated people.\n"; + cout << "// --- Regenerate this: --- \n"; + cout << "// 1. \"make jsc-bindings-headers\"\n"; + cout << "// 2. \"make sizegen\"\n"; + cout << "// 3. \"make jsc-bindings-headers\"\n"; + cout << "// You can verify the numbers written in this file at runtime via the `extern`d types\n"; + cout << "// Run \"jsc-bindings-headers\" twice because it uses these values in the output. That's how all the bJSC__.* types are created - from these values. \n"; + cout << "// The data for this file is generated in headers-cpp.h \n"; + int i = 0; + int len = sizeof(sizes)/sizeof(sizes[0]); + for (i = 0; i < len ; i++) { + cout << "pub const " << names[i] << " = " << sizes[i] << ";\n"; + } + + return 0; +}
\ No newline at end of file |