diff options
author | 2021-07-26 16:39:40 -0700 | |
---|---|---|
committer | 2021-07-26 16:39:40 -0700 | |
commit | a7214ab61c42f1454a8e17c633085f12ed6bef5a (patch) | |
tree | 7da3047f2d6cbf2b1e19fd670d0d40edce5e7192 | |
parent | 796a9854b4a698b309a6e7a4c040047558858da6 (diff) | |
download | bun-a7214ab61c42f1454a8e17c633085f12ed6bef5a.tar.gz bun-a7214ab61c42f1454a8e17c633085f12ed6bef5a.tar.zst bun-a7214ab61c42f1454a8e17c633085f12ed6bef5a.zip |
cool
26 files changed, 1713 insertions, 839 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index 1b1f98485..341370c0e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -40,6 +40,14 @@ "__mutex_base": "cpp", "__string": "cpp", "string": "cpp", - "string_view": "cpp" + "string_view": "cpp", + "typeinfo": "cpp", + "__config": "cpp", + "__nullptr": "cpp", + "exception": "cpp", + "__bit_reference": "cpp", + "atomic": "cpp", + "utility": "cpp", + "sstream": "cpp" } } @@ -29,14 +29,18 @@ CLANG_FLAGS = -Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/Pri -DSTATICALLY_LINKED_WITH_JavaScriptCore=1 \ -DSTATICALLY_LINKED_WITH_WTF=1 \ -DBUILDING_WITH_CMAKE=1 \ + -DNDEBUG=1 \ -DNOMINMAX \ + -DIS_BUILD \ + -O3 \ + -g \ -DENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0 \ -DBUILDING_JSCONLY__ \ -DASSERT_ENABLED=0\ -Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/ \ -Isrc/JavaScript/jsc/bindings/ \ -Isrc/javascript/jsc/WebKit/Source/bmalloc \ - -std=gnu++17 \ + -std=gnu++1z \ -stdlib=libc++ \ -DDU_DISABLE_RENAMING=1 \ -Wall @@ -16,6 +16,20 @@ pub fn addPicoHTTP(step: *std.build.LibExeObjStep) void { // homebrew-provided icu4c } +pub var original_make_fn: ?fn (step: *std.build.Step) anyerror!void = null; +pub var headers_zig_file: ?[]const u8 = null; +const HeadersMaker = struct { + pub fn make(self: *std.build.Step) anyerror!void { + try original_make_fn.?(self); + var headers_zig: std.fs.File = try std.fs.openFileAbsolute(headers_zig_file.?, .{ .write = true }); + const contents = try headers_zig.readToEndAlloc(std.heap.page_allocator, 99999); + const last_extern_i = std.mem.lastIndexOf(u8, contents, "pub extern fn") orelse @panic("Expected contents"); + const last_newline = std.mem.indexOf(u8, contents[last_extern_i..], "\n") orelse @panic("Expected newline"); + try headers_zig.seekTo(0); + try headers_zig.setEndPos(last_newline + last_extern_i); + } +}; + pub fn build(b: *std.build.Builder) void { // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which @@ -171,10 +185,18 @@ pub fn build(b: *std.build.Builder) void { var headers_runner = headers_exec.run(); headers_exec.setMainPkgPath(javascript.main_pkg_path.?); headers_step.dependOn(&headers_runner.step); + var translate_c: *std.build.TranslateCStep = b.addTranslateC(.{ .path = b.pathFromRoot("src/javascript/jsc/bindings/headers.h") }); + translate_c.out_basename = "headers"; + translate_c.output_dir = b.pathFromRoot("src/javascript/jsc/bindings/"); + headers_step.dependOn(&translate_c.step); + headers_zig_file = b.pathFromRoot("src/javascript/jsc/bindings/headers.zig"); + + original_make_fn = headers_step.makeFn; + headers_step.makeFn = HeadersMaker.make; b.default_step.dependOn(&exe.step); - var steps = [_]*std.build.LibExeObjStep{ javascript, typings_exe }; + var steps = [_]*std.build.LibExeObjStep{ exe, javascript, typings_exe }; for (steps) |step| { step.linkLibC(); @@ -199,11 +221,11 @@ pub fn build(b: *std.build.Builder) void { step.addIncludeDir("/usr/local/opt/icu4c/include"); } - for (bindings_files.items) |binding| { - step.addObjectFile( - binding, - ); - } + // for (bindings_files.items) |binding| { + // step.addObjectFile( + // binding, + // ); + // } } } else { b.default_step.dependOn(&exe.step); diff --git a/src/global.zig b/src/global.zig index 16a515086..14a919872 100644 --- a/src/global.zig +++ b/src/global.zig @@ -9,16 +9,16 @@ pub const FeatureFlags = @import("feature_flags.zig"); pub const Output = struct { threadlocal var source: Source = undefined; pub const Source = struct { - const StreamType = { + pub const StreamType: type = brk: { if (isWasm) { - return std.io.FixedBufferStream([]u8); + break :brk std.io.FixedBufferStream([]u8); } else { - return std.fs.File; + break :brk std.fs.File; // var stdout = std.io.getStdOut(); // return @TypeOf(std.io.bufferedWriter(stdout.writer())); } }; - const BufferedStream = std.io.BufferedWriter(4096, @typeInfo(@TypeOf(Source.StreamType.writer)).Fn.return_type.?); + pub const BufferedStream: type = std.io.BufferedWriter(4096, @typeInfo(std.meta.declarationInfo(StreamType, "writer").data.Fn.fn_type).Fn.return_type.?); buffered_stream: BufferedStream, buffered_error_stream: BufferedStream, @@ -56,11 +56,13 @@ pub const Output = struct { enable_buffering = false; } - pub fn errorWriter() @typeInfo(@TypeOf(Source.StreamType.writer)).Fn.return_type.? { + pub const WriterType: type = @typeInfo(std.meta.declarationInfo(Source.StreamType, "writer").data.Fn.fn_type).Fn.return_type.?; + + pub fn errorWriter() WriterType { return source.error_stream.writer(); } - pub fn writer() @typeInfo(@TypeOf(Source.StreamType.writer)).Fn.return_type.? { + pub fn writer() WriterType { return source.stream.writer(); } diff --git a/src/javascript/jsc/WebKit b/src/javascript/jsc/WebKit -Subproject 7d494581249d31ff34d65436f077e76ea2516b9 +Subproject 4eb8a5a13ba6f023d9dddf975996052a6f8b5fe diff --git a/src/javascript/jsc/bindings/SourceProvider.cpp b/src/javascript/jsc/bindings/SourceProvider.cpp new file mode 100644 index 000000000..ceea95ab9 --- /dev/null +++ b/src/javascript/jsc/bindings/SourceProvider.cpp @@ -0,0 +1,38 @@ +#include "root.h" +#include <JavaScriptCore/SourceProvider.h> + +#include <wtf/Lock.h> + +namespace JSC { + +// SourceProvider::SourceProvider(const SourceOrigin&, String&& sourceURL, const TextPosition& startPosition, SourceProviderSourceType) { + +// } + + +// SourceProvider::SourceProvider(const SourceOrigin& sourceOrigin, String&& sourceURL, const TextPosition& startPosition, SourceProviderSourceType sourceType) +// : m_sourceType(sourceType) +// , m_sourceOrigin(sourceOrigin) +// , m_sourceURL(WTFMove(sourceURL)) +// , m_startPosition(startPosition) +// { +// } + +// SourceProvider::~SourceProvider() +// { +// } + +// static Lock providerIdLock; + +// void SourceProvider::getID() +// { +// Locker locker { providerIdLock }; +// if (!m_id) { +// static intptr_t nextProviderID = 0; +// m_id = ++nextProviderID; +// RELEASE_ASSERT(m_id); +// } +// } + +} // namespace JSC + diff --git a/src/javascript/jsc/bindings/ZigConsoleClient.cpp b/src/javascript/jsc/bindings/ZigConsoleClient.cpp index c8e3ec37d..241bf451d 100644 --- a/src/javascript/jsc/bindings/ZigConsoleClient.cpp +++ b/src/javascript/jsc/bindings/ZigConsoleClient.cpp @@ -13,6 +13,7 @@ using JSGlobalObject = JSC__JSGlobalObject; using String = WTF::String; +extern "C" { JSC__JSValue Inspector__ScriptArguments__argumentAt(const Inspector__ScriptArguments* arg0, size_t i) { return JSC::JSValue::encode(arg0->argumentAt(i)); } @@ -29,57 +30,60 @@ bWTF__String Inspector__ScriptArguments__getFirstArgumentAsString(const Inspecto bool Inspector__ScriptArguments__isEqual(const Inspector__ScriptArguments* arg0, const Inspector__ScriptArguments* arg1) { return arg0->isEqual(*arg1); } + void Inspector__ScriptArguments__release(Inspector__ScriptArguments* arg0) { arg0->deref(); } +} + void Zig::ConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::JSGlobalObject* globalObject, Ref<ScriptArguments>&& arguments) { - Zig__ConsoleClient__messageWithTypeAndLevel(static_cast<uint32_t>(type), static_cast<uint32_t>(level), globalObject, arguments.ptr()); + Zig__ConsoleClient__messageWithTypeAndLevel(this->m_client, static_cast<uint32_t>(type), static_cast<uint32_t>(level), globalObject, arguments.ptr()); } void Zig::ConsoleClient::count(JSGlobalObject* globalObject, const String& label) { - const char* ptr = reinterpret_cast<const char*>(label.characters8()); - Zig__ConsoleClient__count(globalObject, ptr, label.length()); + auto ptr = label.characters8(); + Zig__ConsoleClient__count(this->m_client, globalObject, ptr, label.length()); } void Zig::ConsoleClient::countReset(JSGlobalObject* globalObject, const String& label) { - const char* ptr = reinterpret_cast<const char*>(label.characters8()); - Zig__ConsoleClient__countReset(globalObject, ptr, label.length()); + auto ptr = label.characters8(); + Zig__ConsoleClient__countReset(this->m_client, globalObject, ptr, label.length()); } void Zig::ConsoleClient::profile(JSC::JSGlobalObject* globalObject, const String& label) { - const char* ptr = reinterpret_cast<const char*>(label.characters8()); - Zig__ConsoleClient__profile(globalObject, ptr, label.length()); + auto ptr = label.characters8(); + Zig__ConsoleClient__profile(this->m_client, globalObject, ptr, label.length()); } void Zig::ConsoleClient::profileEnd(JSC::JSGlobalObject* globalObject, const String& label) { - const char* ptr = reinterpret_cast<const char*>(label.characters8()); - Zig__ConsoleClient__profileEnd(globalObject, ptr, label.length()); + auto ptr = label.characters8(); + Zig__ConsoleClient__profileEnd(this->m_client, globalObject, ptr, label.length()); } void Zig::ConsoleClient::takeHeapSnapshot(JSC::JSGlobalObject* globalObject, const String& label) { - const char* ptr = reinterpret_cast<const char*>(label.characters8()); - Zig__ConsoleClient__takeHeapSnapshot(globalObject, ptr, label.length()); + auto ptr = label.characters8(); + Zig__ConsoleClient__takeHeapSnapshot(this->m_client, globalObject, ptr, label.length()); } void Zig::ConsoleClient::time(JSGlobalObject* globalObject, const String& label) { - const char* ptr = reinterpret_cast<const char*>(label.characters8()); - Zig__ConsoleClient__time(globalObject, ptr, label.length()); + auto ptr = label.characters8(); + Zig__ConsoleClient__time(this->m_client, globalObject, ptr, label.length()); } void Zig::ConsoleClient::timeLog(JSGlobalObject* globalObject, const String& label, Ref<ScriptArguments>&& arguments) { - const char* ptr = reinterpret_cast<const char*>(label.characters8()); - Zig__ConsoleClient__timeLog(globalObject, ptr, label.length(), arguments.ptr()); + auto ptr = label.characters8(); + Zig__ConsoleClient__timeLog(this->m_client, globalObject, ptr, label.length(), arguments.ptr()); } void Zig::ConsoleClient::timeEnd(JSGlobalObject* globalObject, const String& label) { - const char* ptr = reinterpret_cast<const char*>(label.characters8()); - Zig__ConsoleClient__timeEnd(globalObject, ptr, label.length()); + auto ptr = label.characters8(); + Zig__ConsoleClient__timeEnd(this->m_client, globalObject, ptr, label.length()); } void Zig::ConsoleClient::timeStamp(JSGlobalObject* globalObject, Ref<ScriptArguments>&& args) { - Zig__ConsoleClient__timeStamp(globalObject, args.ptr()); + Zig__ConsoleClient__timeStamp(this->m_client, globalObject, args.ptr()); } void Zig::ConsoleClient::record(JSGlobalObject*, Ref<ScriptArguments>&&) { diff --git a/src/javascript/jsc/bindings/ZigConsoleClient.h b/src/javascript/jsc/bindings/ZigConsoleClient.h index 11b4c6758..ee230234d 100644 --- a/src/javascript/jsc/bindings/ZigConsoleClient.h +++ b/src/javascript/jsc/bindings/ZigConsoleClient.h @@ -18,8 +18,11 @@ namespace Zig { class ConsoleClient final : public JSC::ConsoleClient { WTF_MAKE_FAST_ALLOCATED; public: - explicit ConsoleClient(InspectorConsoleAgent*); ~ConsoleClient() final { } + ConsoleClient(void* client) : JSC::ConsoleClient() { + m_client = client; + } + static bool logToSystemConsole(); static void setLogToSystemConsole(bool); @@ -27,20 +30,22 @@ public: void setDebuggerAgent(InspectorDebuggerAgent* agent) { m_debuggerAgent = agent; } void setPersistentScriptProfilerAgent(InspectorScriptProfilerAgent* agent) { m_scriptProfilerAgent = agent; } + void* m_client; private: - void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&) final; - void count(JSC::JSGlobalObject*, const String& label) final; - void countReset(JSC::JSGlobalObject*, const String& label) final; - void profile(JSC::JSGlobalObject*, const String& title) final; - void profileEnd(JSC::JSGlobalObject*, const String& title) final; - void takeHeapSnapshot(JSC::JSGlobalObject*, const String& title) final; - void time(JSC::JSGlobalObject*, const String& label) final; - void timeLog(JSC::JSGlobalObject*, const String& label, Ref<Inspector::ScriptArguments>&&) final; - void timeEnd(JSC::JSGlobalObject*, const String& label) final; - void timeStamp(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&) final; - void record(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&) final; - void recordEnd(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&) final; - void screenshot(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&) final; + + void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); + void count(JSC::JSGlobalObject*, const String& label); + void countReset(JSC::JSGlobalObject*, const String& label); + void profile(JSC::JSGlobalObject*, const String& title); + void profileEnd(JSC::JSGlobalObject*, const String& title); + void takeHeapSnapshot(JSC::JSGlobalObject*, const String& title); + void time(JSC::JSGlobalObject*, const String& label); + void timeLog(JSC::JSGlobalObject*, const String& label, Ref<Inspector::ScriptArguments>&&); + void timeEnd(JSC::JSGlobalObject*, const String& label); + void timeStamp(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); + void record(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); + void recordEnd(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); + void screenshot(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); void warnUnimplemented(const String& method); void internalAddMessage(MessageType, MessageLevel, JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index e17e3aeba..c8a2cbcde 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -25,6 +25,7 @@ #include <JavaScriptCore/WasmFaultSignalHandler.h> #include <JavaScriptCore/JSCast.h> #include <JavaScriptCore/InitializeThreading.h> +#include "ZigConsoleClient.h" #include <JavaScriptCore/JSLock.h> @@ -39,29 +40,31 @@ using SourceOrigin = JSC::SourceOrigin; namespace JSCastingHelpers = JSC::JSCastingHelpers; -JSC__JSGlobalObject* Zig__GlobalObject__create(JSC__VM* arg0) { +extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSC__VM* arg0, void* console_client) { + auto client = makeUnique<Zig::ConsoleClient>(console_client); + // There are assertions that the apiLock is set while the JSGlobalObject is initialized. if (arg0 != nullptr) { - JSC::VM& vm = reinterpret_cast<JSC__VM&>(arg0); - vm.apiLock().lock(); - Zig::GlobalObject* globalObject = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::jsNull())); - vm.apiLock().unlock(); + Zig::GlobalObject* globalObject = Zig::GlobalObject::create(*arg0, Zig::GlobalObject::createStructure(*arg0, JSC::jsNull())); + JSC::JSLockHolder holder(globalObject); + globalObject->setConsoleClient(makeWeakPtr(*client)); + return static_cast<JSC__JSGlobalObject*>(globalObject); } JSC::initialize(); - - JSC::VM& vm = JSC::VM::create(JSC::LargeHeap, nullptr); - vm.apiLock().lock(); + JSC::VM& vm = JSC::VM::create(JSC::LargeHeap).leakRef(); #if ENABLE(WEBASSEMBLY) JSC::Wasm::enableFastMemory(); #endif + JSC::JSLockHolder locker(vm); + auto globalObject = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::jsNull())); + globalObject->setConsoleClient(makeWeakPtr(*client)); + - Zig::GlobalObject* globalObject = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::jsNull())); - vm.apiLock().unlock(); - return static_cast<JSC__JSGlobalObject*>(globalObject); + return globalObject; } namespace Zig { diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h index b7bf7e00b..588379577 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.h +++ b/src/javascript/jsc/bindings/ZigGlobalObject.h @@ -13,9 +13,13 @@ namespace JSC { #include <JavaScriptCore/JSGlobalObject.h> #include <JavaScriptCore/JSTypeInfo.h> +#include "ZigConsoleClient.h" + + namespace Zig { + class GlobalObject final : public JSC::JSGlobalObject { using Base = JSC::JSGlobalObject; @@ -28,7 +32,7 @@ public: template<typename CellType, JSC::SubspaceAccess mode> static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) { - return vm.apiGlobalObjectSpace<mode>(); + return vm.globalObjectSpace<mode>(); } static GlobalObject* create(JSC::VM& vm, JSC::Structure* structure) @@ -53,6 +57,8 @@ public: static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSModuleRecord*, JSC::JSValue); static JSC::JSValue moduleLoaderEvaluate(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue); static void promiseRejectionTracker(JSGlobalObject*, JSC::JSPromise*, JSC::JSPromiseRejectionOperation); + + private: GlobalObject(JSC::VM& vm, JSC::Structure* structure) diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp index 45d22f59d..0942cb617 100644 --- a/src/javascript/jsc/bindings/bindings.cpp +++ b/src/javascript/jsc/bindings/bindings.cpp @@ -2,7 +2,7 @@ #include "headers.h" #include "root.h" - +#include "helpers.h" #include <JavaScriptCore/ExceptionScope.h> #include <JavaScriptCore/JSObject.h> @@ -23,8 +23,8 @@ #include <JavaScriptCore/JSString.h> #include <JavaScriptCore/JSMap.h> #include <JavaScriptCore/JSSet.h> +#include <JavaScriptCore/JSInternalPromise.h> -#include "helpers.h" extern "C" { @@ -42,7 +42,7 @@ JSC__JSObject* JSC__JSCell__getObject(JSC__JSCell* arg0) { bWTF__String JSC__JSCell__getString(JSC__JSCell* arg0, JSC__JSGlobalObject* arg1) { return Wrap<WTF__String, bWTF__String>::wrap(arg0->getString(arg1)); } -char JSC__JSCell__getType(JSC__JSCell* arg0) { +unsigned char JSC__JSCell__getType(JSC__JSCell* arg0) { return arg0->type(); } @@ -72,7 +72,9 @@ bWTF__String JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1 #pragma mark - JSC::JSModuleLoader -// JSC__JSValue JSC__JSModuleLoader__dependencyKeysIfEvaluated(JSC__JSModuleLoader* arg0, JSC__JSGlobalObject* arg1, JSC__JSModuleRecord* arg2); +// JSC__JSValue JSC__JSModuleLoader__dependencyKeysIfEvaluated(JSC__JSModuleLoader* arg0, JSC__JSGlobalObject* arg1, JSC__JSModuleRecord* arg2) { +// arg2->depen +// } bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1, bool arg2) { JSC::ParserError error; @@ -88,10 +90,11 @@ bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__Sour } JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3) { WTF::NakedPtr<JSC::Exception> returnedException; - - auto val = JSC::JSValue::encode(JSC::evaluate(arg0, reinterpret_cast<const JSC__SourceCode&>(arg1), JSC::JSValue::decode(JSValue2), returnedException)); + auto str2 = arg1->provider()->source(); + auto val = JSC::evaluate(arg0, *arg1, JSC::JSValue::decode(JSValue2), returnedException); + auto str = val.toWTFString(arg0); *arg3 = returnedException.get(); - return val; + return JSC::JSValue::encode(val); } JSC__JSInternalPromise* JSC__JSModuleLoader__importModule(JSC__JSGlobalObject* arg0, const JSC__Identifier* arg1) { return JSC::importModule(arg0, reinterpret_cast<JSC::Identifier&>(arg1), JSC::JSValue{}, JSC::JSValue{}); @@ -128,9 +131,7 @@ void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise* arg0, JSC__JSGloba JSC__JSPromise* JSC__JSPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1) { return JSC::JSPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1)); } -// void JSC__JSPromise__rejectException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2) { -// JSC::JSPromise::rejec -// } + void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2) { Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>(arg2); @@ -158,6 +159,57 @@ bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1) { return arg0->isHandled(reinterpret_cast<JSC::VM&>(arg1)); } +#pragma mark - JSC::JSInternalPromise + +JSC__JSInternalPromise* JSC__JSInternalPromise__create(JSC__JSGlobalObject* globalObject) { + JSC::VM& vm = globalObject->vm(); + return JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure()); +} + +void JSC__JSInternalPromise__reject(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2) { + arg0->reject(arg1, JSC::JSValue::decode(JSValue2)); +} +void JSC__JSInternalPromise__rejectAsHandled(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2) { + arg0->rejectAsHandled(arg1, JSC::JSValue::decode(JSValue2)); +} +void JSC__JSInternalPromise__rejectAsHandledException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2) { + arg0->rejectAsHandled(arg1,arg2); +} +JSC__JSInternalPromise* JSC__JSInternalPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1) { + return reinterpret_cast<JSC::JSInternalPromise*>(JSC::JSInternalPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1))); +} + +void JSC__JSInternalPromise__rejectWithCaughtException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2) { + Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>(arg2); + + arg0->rejectWithCaughtException(arg1, *wrapped.cpp); +} +void JSC__JSInternalPromise__resolve(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2) { + arg0->resolve(arg1, JSC::JSValue::decode(JSValue2)); +} +JSC__JSInternalPromise* JSC__JSInternalPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1) { + return reinterpret_cast<JSC::JSInternalPromise*>(JSC::JSInternalPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1))); +} + +JSC__JSValue JSC__JSInternalPromise__result(const JSC__JSInternalPromise* arg0, JSC__VM* arg1) { + return JSC::JSValue::encode(arg0->result(reinterpret_cast<JSC::VM&>(arg1))); +} +uint32_t JSC__JSInternalPromise__status(const JSC__JSInternalPromise* arg0, JSC__VM* arg1) { + switch (arg0->status(reinterpret_cast<JSC::VM&>(arg1))) { + case JSC::JSInternalPromise::Status::Pending: return 0; + case JSC::JSInternalPromise::Status::Fulfilled: return 1; + case JSC::JSInternalPromise::Status::Rejected: return 2; + default: return 255; + } +} +bool JSC__JSInternalPromise__isHandled(const JSC__JSInternalPromise* arg0, JSC__VM* arg1) { + return arg0->isHandled(reinterpret_cast<JSC::VM&>(arg1)); +} + +JSC__JSInternalPromise* JSC__JSInternalPromise__then(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSFunction* arg2, JSC__JSFunction* arg3) { + return arg0->then(arg1, arg2, arg3); +} + // bool JSC__JSPromise__isInternal(JSC__JSPromise* arg0, JSC__VM* arg1) { // return arg0->inf @@ -168,55 +220,89 @@ bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1) { bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL* arg0) { - auto wrap = Wrap<JSC::SourceOrigin, bJSC__SourceOrigin>(JSC::SourceOrigin(reinterpret_cast<const WTF::URL&>(arg0))); + auto wrap = Wrap<JSC::SourceOrigin, bJSC__SourceOrigin>(JSC::SourceOrigin(*arg0)); return wrap.result; } #pragma mark - JSC::SourceCode -bJSC__SourceCode JSC__SourceCode__fromString(const WTF__String* arg0, const JSC__SourceOrigin* arg1, WTF__String* arg2, char SourceType3) { - auto wrap = Wrap<JSC::SourceCode, bJSC__SourceCode>( - JSC::makeSource( - reinterpret_cast<const WTF::String&>(arg0), - reinterpret_cast<const JSC::SourceOrigin&>(arg1), - arg2 == nullptr ? WTF::String() : *arg2, - WTF::TextPosition(), - SourceType3 == 0 ? JSC::SourceProviderSourceType::Program : JSC::SourceProviderSourceType::Module - )); +// class StringSourceProvider : public JSC::SourceProvider { +// public: +// unsigned hash() const override +// { +// return m_source->hash(); +// } + +// StringView source() const override +// { +// return WTF::StringView(m_source); +// } + +// ~StringSourceProvider() { + +// } +// WTF::StringImpl *m_source; + +// StringSourceProvider(const WTF::String& source, const JSC::SourceOrigin& sourceOrigin, WTF::String&& sourceURL, const WTF::TextPosition& startPosition, JSC::SourceProviderSourceType sourceType) +// : JSC::SourceProvider(sourceOrigin, WTFMove(sourceURL), startPosition, sourceType) +// , m_source(source.isNull() ? WTF::StringImpl::empty() : source.impl()) +// { +// } +// }; - return wrap.result; +class CustomStringProvider : public JSC::StringSourceProvider { + public: JS_EXPORT_PRIVATE CustomStringProvider(const WTF::String& source, const JSC::SourceOrigin& sourceOrigin, WTF::String&& sourceURL, const TextPosition& startPosition, JSC::SourceProviderSourceType sourceType) + : JSC::StringSourceProvider(source, sourceOrigin, WTFMove(sourceURL), startPosition, sourceType) { + + } + + +}; + +void JSC__SourceCode__fromString(JSC__SourceCode* arg0, const WTF__String* arg1, const JSC__SourceOrigin* arg2, WTF__String* arg3, unsigned char SourceType4) { + arg1->impl()->ref(); + + auto source = CustomStringProvider( + *arg1, + JSC::SourceOrigin(WTF::URL()), + arg3 == nullptr ? WTF::String() : *arg3, + WTF::TextPosition(), + SourceType4 == 0 ? JSC::SourceProviderSourceType::Program : JSC::SourceProviderSourceType::Module + ); + *arg0 = JSC::SourceCode(source, 1,0); + } #pragma mark - JSC::JSFunction -JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, char* arg5) { +JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, const char* arg5) { auto args = makeArgs(arg2, arg3); return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0), JSC::JSValue::decode(JSValue0), args, arg5)); } -JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, char* arg6) { +JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const char* arg6) { auto args = makeArgs(arg3, arg4); return JSC::JSValue::encode(JSC::call(arg2, JSC::JSValue::decode(JSValue0), JSC::JSValue::decode(JSValue1), args, arg6)); } -JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, char* arg3) { +JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const char* arg3) { return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0), JSC::JSValue::decode(JSValue0), JSC::ArgList(), arg3)); } -JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, char* arg4) { +JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const char* arg4) { return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0), JSC::JSValue::decode(JSValue2), JSC::ArgList(), arg4)); } -JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, char* arg5) { +JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, const char* arg5) { auto args = makeArgs(arg2, arg3); return JSC::JSValue::encode(JSC::construct(arg1, JSC::JSValue::decode(JSValue0), args, arg5)); } -JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, char* arg6) { +JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const char* arg6) { auto args = makeArgs(arg3, arg4); return JSC::JSValue::encode(JSC::construct(arg2, JSC::JSValue::decode(JSValue0), JSC::JSValue::decode(JSValue0), args, arg6)); } -JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, char* arg4) { +JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const char* arg4) { return JSC::JSValue::encode(JSC::construct(arg1, JSC::JSValue::decode(JSValue0), JSC::JSValue::decode(JSValue2), JSC::ArgList(), arg4)); } -JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, char* arg3) { +JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const char* arg3) { return JSC::JSValue::encode(JSC::construct(arg1, JSC::JSValue::decode(JSValue0), JSC::ArgList(), arg3)); } @@ -233,7 +319,7 @@ JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, ui } // JSC__JSFunction* JSC__JSFunction__createFromSourceCode( // JSC__JSGlobalObject* arg0, -// const char* arg1, +// const unsigned char* arg1, // uint16_t arg2, // JSC__JSValue arg3, // uint16_t arg4, @@ -262,7 +348,7 @@ bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1) return wrap.result; }; bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1) { - auto wrap = Wrap<WTF::String, bWTF__String>(arg0->name(reinterpret_cast<JSC::VM&>(arg1))); + auto wrap = Wrap<WTF::String, bWTF__String>(arg0->name(reinterpret_cast<JSC::VM&>(arg1))); return wrap.result; }; bWTF__String JSC__JSFunction__calculatedDisplayName(JSC__JSFunction* arg0, JSC__VM* arg1) { @@ -299,7 +385,7 @@ JSC__JSObject* JSC__JSGlobalObject__symbolPrototype(JSC__JSGlobalObject* arg0) { JSC__VM* JSC__JSGlobalObject__vm(JSC__JSGlobalObject* arg0) { return &arg0->vm(); }; -// JSC__JSObject* JSC__JSGlobalObject__createError(JSC__JSGlobalObject* arg0, char ErrorType1, WTF__String* arg2) {}; +// JSC__JSObject* JSC__JSGlobalObject__createError(JSC__JSGlobalObject* arg0, unsigned char ErrorType1, WTF__String* arg2) {}; // JSC__JSObject* JSC__JSGlobalObject__throwError(JSC__JSGlobalObject* arg0, JSC__JSObject* arg1) {}; @@ -341,7 +427,14 @@ bool JSC__JSValue__isBigInt32(JSC__JSValue JSValue0) { return JSC::JSValue::deco 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__isError(JSC__JSValue JSValue0) { + JSC::JSObject* obj = JSC::JSValue::decode(JSValue0).getObject(); + return obj != nullptr && obj->isErrorInstance(); +} +bool JSC__JSValue__isCallable(JSC__JSValue JSValue0, JSC__VM* arg1) { + return JSC::JSValue::decode(JSValue0).isCallable(reinterpret_cast<JSC::VM&>(arg1)); + +} 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(); } @@ -357,7 +450,7 @@ bool JSC__JSValue__isUndefinedOrNull(JSC__JSValue JSValue0) { return JSC::JSValu 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__jsNumberFromChar(unsigned 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));}; @@ -389,7 +482,7 @@ JSC__JSString* JSC__JSValue__toStringOrNull(JSC__JSValue JSValue0, JSC__JSGlobal } bWTF__String JSC__JSValue__toWTFString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1) { JSC::JSValue value = JSC::JSValue::decode(JSValue0); - return Wrap<WTF::String, bWTF__String>(value.toWTFString(arg1)); + return Wrap<WTF::String, bWTF__String>::wrap(value.toWTFString(arg1)); }; #pragma mark - JSC::PropertyName @@ -413,7 +506,7 @@ const WTF__StringImpl* JSC__PropertyName__uid(JSC__PropertyName* arg0) { JSC__JSLock* JSC__VM__apiLock(JSC__VM* arg0) { return makeRefPtr((*arg0).apiLock()).leakRef(); } -JSC__VM* JSC__VM__create(char HeapType0) { +JSC__VM* JSC__VM__create(unsigned char HeapType0) { JSC::VM* vm = &JSC::VM::create(HeapType0 == JSC::SmallHeap ? JSC::SmallHeap : JSC::LargeHeap).leakRef(); #if ENABLE(WEBASSEMBLY) JSC::Wasm::enableFastMemory(); @@ -446,7 +539,7 @@ 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) { +bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const unsigned char* arg3, size_t arg4) { auto scope = arg2; auto global = arg1; const String& message = WTF::String(arg3, arg4); @@ -458,7 +551,7 @@ bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowSco void JSC__ThrowScope__clearException(JSC__ThrowScope* arg0) { arg0->clearException(); }; -bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, char* arg1, char* arg2, size_t arg3) { +bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, size_t arg3) { Wrap<JSC::ThrowScope, bJSC__ThrowScope> wrapped = Wrap<JSC::ThrowScope, bJSC__ThrowScope>(); wrapped.cpp = new (wrapped.alignedBuffer()) JSC::ThrowScope(reinterpret_cast<JSC::VM&>(arg0)); return wrapped.result; @@ -475,7 +568,7 @@ void JSC__ThrowScope__release(JSC__ThrowScope* arg0) { void JSC__CatchScope__clearException(JSC__CatchScope* arg0) { arg0->clearException(); } -bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, char* arg1, char* arg2, size_t arg3) { +bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, size_t arg3) { JSC::CatchScope scope = JSC::CatchScope(reinterpret_cast<JSC::VM&>(arg0)); return cast<bJSC__CatchScope>(&scope); } @@ -507,13 +600,17 @@ JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame* arg0, uint1 #pragma mark - JSC::Identifier +void JSC__Identifier__deinit(const JSC__Identifier* arg0) { + +} + 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) { +bool JSC__Identifier__eqlUTF8(const JSC__Identifier* arg0, const unsigned 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) { @@ -523,7 +620,7 @@ bool JSC__Identifier__neqlStringImpl(const JSC__Identifier* arg0, const WTF__Str return !JSC::Identifier::equal(arg0->string().impl(), arg1); }; -bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM* arg0, const char* arg1, size_t arg2) { +bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM* arg0, const unsigned 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); }; @@ -563,8 +660,8 @@ 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()); +const unsigned char* WTF__StringView__characters8(const WTF__StringView* arg0) { + return reinterpret_cast<const unsigned char*>(arg0->characters8()); }; bool WTF__StringView__is16Bit(const WTF__StringView* arg0) {return !arg0->is8Bit(); }; @@ -577,13 +674,12 @@ size_t WTF__StringView__length(const WTF__StringView* arg0) {return arg0->length 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()); +const unsigned char* WTF__StringImpl__characters8(const WTF__StringImpl* arg0) { + return reinterpret_cast<const unsigned 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); +void WTF__StringView__from8Bit(WTF__StringView* arg0, const unsigned char* arg1, size_t arg2) { + *arg0 = WTF::StringView(arg1, arg2); } bool WTF__StringImpl__is16Bit(const WTF__StringImpl* arg0) { @@ -611,8 +707,8 @@ size_t WTF__StringImpl__length(const WTF__StringImpl* arg0) { 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()); +const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0) { + return reinterpret_cast<const unsigned char*>(arg0->characters8()); } @@ -641,11 +737,11 @@ size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl* arg0) { 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()); + const unsigned char* WTF__String__characters8(WTF__String* arg0) { + return reinterpret_cast<const unsigned char*>(arg0->characters8()); }; - bool WTF__String__eqlSlice(WTF__String* arg0, const char* arg1, size_t arg2) { + bool WTF__String__eqlSlice(WTF__String* arg0, const unsigned 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) { @@ -663,13 +759,12 @@ 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); + auto external = Wrap<WTF::ExternalStringImpl, bWTF__ExternalStringImpl>(arg0); + return Wrap<WTF::String, bWTF__String>(WTF::String(external.cpp)).result; }; -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); + +void WTF__String__createWithoutCopyingFromPtr(WTF__String* str, unsigned char* arg0, size_t arg1) { + *str = WTF::String(arg0, arg1); } #pragma mark - WTF::URL @@ -694,9 +789,10 @@ bWTF__StringView WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF__URL* arg 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); +void WTF__URL__fromFileSystemPath(WTF::URL* result, bWTF__StringView arg0) { + Wrap<WTF::StringView, bWTF__StringView> fsPath = Wrap<WTF::StringView, bWTF__StringView>(&arg0); + *result = WTF::URL::fileURLWithFileSystemPath(*fsPath.cpp); + result->string().impl()->ref(); }; bWTF__URL WTF__URL__fromString(bWTF__String arg0, bWTF__String arg1) { WTF::URL url= WTF::URL(WTF::URL(), cast<WTF::String>(&arg1)); @@ -762,25 +858,25 @@ bWTF__String WTF__URL__user(WTF__URL* arg0) { }; void WTF__URL__setHost(WTF__URL* arg0, bWTF__StringView arg1) { - arg0->setHost(cast<WTF::StringView>(&arg1)); + arg0->setHost(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1)); }; void WTF__URL__setHostAndPort(WTF__URL* arg0, bWTF__StringView arg1) { - arg0->setHostAndPort(cast<WTF::StringView>(&arg1)); + arg0->setHostAndPort(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1)); }; void WTF__URL__setPassword(WTF__URL* arg0, bWTF__StringView arg1) { - arg0->setPassword(cast<WTF::StringView>(&arg1)); + arg0->setPassword(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1)); }; void WTF__URL__setPath(WTF__URL* arg0, bWTF__StringView arg1) { - arg0->setPath(cast<WTF::StringView>(&arg1)); + arg0->setPath(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1)); }; void WTF__URL__setProtocol(WTF__URL* arg0, bWTF__StringView arg1) { - arg0->setProtocol(cast<WTF::StringView>(&arg1)); + arg0->setProtocol(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1)); }; void WTF__URL__setQuery(WTF__URL* arg0, bWTF__StringView arg1) { - arg0->setQuery(cast<WTF::StringView>(&arg1)); + arg0->setQuery(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1)); }; void WTF__URL__setUser(WTF__URL* arg0, bWTF__StringView arg1) { - arg0->setUser(cast<WTF::StringView>(&arg1)); + arg0->setUser(*Wrap<WTF::StringView, bWTF__StringView>::unwrap(&arg1)); }; } diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index c7b69a23d..c84058095 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -1,12 +1,9 @@ -usingnamespace @import("../../../global.zig"); - -const std = @import("std"); -const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false; +usingnamespace @import("./shared.zig"); +usingnamespace @import("./headers.zig"); +pub const Shimmer = @import("./shimmer.zig").Shimmer; const hasRef = std.meta.trait.hasField("ref"); -const StaticExport = @import("./static_export.zig"); -const Shimmer = @import("./shimmer.zig").Shimmer; -pub const JSObject = packed struct { +pub const JSObject = extern struct { pub const shim = Shimmer("JSC", "JSObject", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -14,13 +11,7 @@ pub const JSObject = packed struct { 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 extern "c" fn putAtIndex(this: *JSObject, globalThis: *JSGlobalObject, property_name: *PropertyName, i: u32) bool; pub fn getArrayLength(this: *JSObject) usize { return cppFn("getArrayLength", .{ @@ -43,7 +34,7 @@ pub const JSObject = packed struct { }; }; -// pub const JSMap = packed struct { +// pub const JSMap = extern struct { // pub const shim = Shimmer("JSC", "JSMap", @This()); // bytes: shim.Bytes, // const cppFn = shim.cppFn; @@ -53,53 +44,53 @@ pub const JSObject = packed struct { // pub const EntryIteratorCallback = fn (ctx: ?*c_void, container: JSValue, key: JSValue, value: JSValue) callconv(.C) bool; -// pub fn get(this: *JSMap, globalThis: *JSGlobalObject) JSValue { -// return cppFn("get", .{ this, globalThis }); +// pub fn get(this: *JSMap,globalThis: *JSGlobalObject) JSValue { +// return cppFn("get", .{ this,globalThis }); // } -// pub fn set(this: *JSMap, globalThis: *JSGlobalObject, key: JSValue, value: JSValue) bool { -// return cppFn("set", .{ this, globalThis, key, value }); +// pub fn set(this: *JSMap,globalThis: *JSGlobalObject, key: JSValue, value: JSValue) bool { +// return cppFn("set", .{ this,globalThis, key, value }); // } -// pub fn clear(this: *JSMap, globalThis: *JSGlobalObject) void { +// pub fn clear(this: *JSMap,globalThis: *JSGlobalObject) void { // return cppFn("clear", .{ // this, -// globalThis, +// globalThis, // }); // } // // This is a JSValue so that we can use the same callback for iterating over different JSCell types. -// pub fn forEach(this: JSValue, globalThis: *JSGlobalObject, ctx: ?*c_void, iterator: EntryIteratorCallback) void { +// pub fn forEach(this: JSValue,globalThis: *JSGlobalObject, ctx: ?*c_void, iterator: EntryIteratorCallback) void { // return cppFn("forEach", .{ // this, -// globalThis, +// globalThis, // ctx, // iterator, // }); // } -// // pub fn iterator(this: *JSMap, globalThis: *JSGlobalObject) *JSMapIterator {} -// pub fn delete(this: *JSMap, globalThis: *JSGlobalObject) bool { -// return cppFn("delete", .{ this, globalThis }); +// // pub fn iterator(this: *JSMap,globalThis: *JSGlobalObject) *JSMapIterator {} +// pub fn delete(this: *JSMap,globalThis: *JSGlobalObject) bool { +// return cppFn("delete", .{ this,globalThis }); // } -// pub fn has(this: *JSMap, globalThis: *JSGlobalObject) JSValue { -// return cppFn("has", .{ this, globalThis }); +// pub fn has(this: *JSMap,globalThis: *JSGlobalObject) JSValue { +// return cppFn("has", .{ this,globalThis }); // } -// pub fn size(this: *JSMap, globalThis: *JSGlobalObject) u32 { -// return cppFn("size", .{ this, globalThis }); +// pub fn size(this: *JSMap,globalThis: *JSGlobalObject) u32 { +// return cppFn("size", .{ this,globalThis }); // } -// pub fn create(globalThis: *JSGlobalObject, size_hint: u32) *JSMap { -// return cppFn("create", .{ globalThis, size_hint }); +// pub fn createglobalThis: *JSGlobalObject, size_hint: u32) *JSMap { +// return cppFn("create", .{globalThis, size_hint }); // } -// pub fn clone(this: *JSMap, globalThis: *JSGlobalObject) *JSMap { -// return cppFn("clone", .{ this, globalThis }); +// pub fn clone(this: *JSMap,globalThis: *JSGlobalObject) *JSMap { +// return cppFn("clone", .{ this,globalThis }); // } // pub const Extern = [_][]const u8{ "get", "set", "clear", "delete", "has", "create", "size", "forEach", "clone" }; // }; -pub const JSCell = packed struct { +pub const JSCell = extern struct { pub const shim = Shimmer("JSC", "JSCell", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -126,7 +117,7 @@ pub const JSCell = packed struct { pub const Extern = [_][]const u8{ "getObject", "getString", "getType" }; }; -pub const JSString = packed struct { +pub const JSString = extern struct { pub const shim = Shimmer("JSC", "JSString", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -142,9 +133,7 @@ pub const JSString = packed struct { return shim.cppFn("eql", .{ this, global, other }); } - pub fn value(this: *JSString, globalObject: *JSGlobalObject) String { - return shim.cppFn("value", .{ this, globalObject }); - } + pub extern fn value(ret_value: String, this: *JSString, globalObject: *JSGlobalObject) void; pub fn length(this: *const JSString) usize { return shim.cppFn("length", .{ @@ -178,7 +167,7 @@ pub const JSPromiseRejectionOperation = enum(u32) { Handle = 1, }; -pub const ScriptArguments = packed struct { +pub const ScriptArguments = extern struct { pub const shim = Shimmer("Inspector", "ScriptArguments", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -220,240 +209,57 @@ pub const ScriptArguments = packed struct { }; }; -const EmptyGlobalInterface = struct { - pub fn import(global: *JSGlobalObject, loader: *JSModuleLoader, specifier: *JSString, referrer: JSValue, origin: *const SourceOrigin) callconv(.C) *JSInternalPromise { - return JSInternalPromise.rejectedPromise(global, JSValue.jsUndefined()); - } - const slice = "hello.js"; - pub fn resolve(global: *JSGlobalObject, loader: *JSModuleLoader, specifier: JSValue, value: JSValue, origin: *const SourceOrigin) callconv(.C) Identifier { - return Identifier.fromSlice(global.vm(), &slice, slice.len); - } - pub fn fetch(global: *JSGlobalObject, loader: *JSModuleLoader, value1: JSValue, value2: JSValue, value3: JSValue) callconv(.C) *JSInternalPromise { - return JSInternalPromise.rejectedPromise(global, JSValue.jsUndefined()); - } - pub fn eval(global: *JSGlobalObject, loader: *JSModuleLoader, key: JSValue, moduleRecordValue: JSValue, scriptFetcher: JSValue, awaitedValue: JSValue, resumeMode: JSValue) callconv(.C) JSValue { - return JSValue.jsUndefined(); - } - pub fn promiseRejectionTracker(global: *JSGlobalObject, promise: *JSPromise, rejection: JSPromiseRejectionOperation) callconv(.C) JSValue { - return JSValue.jsUndefined(); - } - - pub fn reportUncaughtException(global: *JSGlobalObject, exception: *Exception) callconv(.C) JSValue { - return JSValue.jsUndefined(); - } - - pub fn createImportMetaProperties(global: *JSGlobalObject, loader: *JSModuleLoader, obj: JSValue, record: *JSModuleRecord, specifier: JSValue) callconv(.C) JSValue { - return JSValue.jsUndefined(); - } -}; - -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 const Interface: type = std.meta.globalOption("JSGlobalObject", type) orelse EmptyGlobalInterface; - - pub fn create(vm: ?*VM, console: *ZigConsoleClient) *JSGlobalObject { - return shim.cppFn("create", .{ vm, console }); - } - - pub fn import(global: *JSGlobalObject, loader: *JSModuleLoader, specifier: *JSString, referrer: JSValue, origin: *const SourceOrigin) callconv(.C) *JSInternalPromise { - // if (comptime is_bindgen) { - // unreachable; - // } - - return @call(.{ .modifier = .always_inline }, Interface.import, .{ global, loader, specifier, referrer, origin }); - } - pub fn resolve(global: *JSGlobalObject, loader: *JSModuleLoader, specifier: JSValue, value: JSValue, origin: *const SourceOrigin) callconv(.C) Identifier { - if (comptime is_bindgen) { - unreachable; +pub fn NewGlobalObject(comptime Type: type) type { + return struct { + pub fn import(global: *JSGlobalObject, loader: *JSModuleLoader, specifier: *JSString, referrer: JSValue, origin: *const SourceOrigin) callconv(.C) *JSInternalPromise { + if (comptime @hasDecl(Type, "import")) { + return @call(.{ .modifier = .always_inline }, Interface.import, .{ global, loader, specifier, referrer, origin }); + } + return JSInternalPromise.rejectedPromise(global, JSValue.jsUndefined()); } - return @call(.{ .modifier = .always_inline }, Interface.resolve, .{ global, loader, specifier, value, origin }); - } - pub fn fetch(global: *JSGlobalObject, loader: *JSModuleLoader, value1: JSValue, value2: JSValue, value3: JSValue) callconv(.C) *JSInternalPromise { - if (comptime is_bindgen) { - unreachable; + const slice: []const u8 = "hello.js"; + pub fn resolve(global: *JSGlobalObject, loader: *JSModuleLoader, specifier: JSValue, value: JSValue, origin: *const SourceOrigin) callconv(.C) Identifier { + if (comptime @hasDecl(Type, "resolve")) { + return @call(.{ .modifier = .always_inline }, Interface.resolve, .{ global, loader, specifier, value, origin }); + } + return Identifier.fromSlice(global.vm(), slice.ptr, slice.len); } - return @call(.{ .modifier = .always_inline }, Interface.fetch, .{ global, loader, value1, value2, value3 }); - } - 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 fetch(global: *JSGlobalObject, loader: *JSModuleLoader, value1: JSValue, value2: JSValue, value3: JSValue) callconv(.C) *JSInternalPromise { + if (comptime @hasDecl(Type, "fetch")) { + return @call(.{ .modifier = .always_inline }, Interface.fetch, .{ global, loader, value1, value2, value3 }); + } + return JSInternalPromise.rejectedPromise(global, JSValue.jsUndefined()); } - @call(.{ .modifier = .always_inline }, Interface.eval, .{ global, loader, key, moduleRecordValue, scriptFetcher, awaitedValue, resumeMode }); - } - pub fn promiseRejectionTracker(global: *JSGlobalObject, promise: *JSPromise, rejection: JSPromiseRejectionOperation) callconv(.C) JSValue { - 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 @hasDecl(Type, "eval")) { + return @call(.{ .modifier = .always_inline }, Interface.eval, .{ global, loader, key, moduleRecordValue, scriptFetcher, awaitedValue, resumeMode }); + } + return JSValue.jsUndefined(); } - return @call(.{ .modifier = .always_inline }, Interface.promiseRejectionTracker, .{ global, promise, rejection }); - } - - pub fn reportUncaughtException(global: *JSGlobalObject, exception: *Exception) callconv(.C) JSValue { - if (comptime is_bindgen) { - unreachable; + pub fn promiseRejectionTracker(global: *JSGlobalObject, promise: *JSPromise, rejection: JSPromiseRejectionOperation) callconv(.C) JSValue { + if (comptime @hasDecl(Type, "promiseRejectionTracker")) { + return @call(.{ .modifier = .always_inline }, Interface.promiseRejectionTracker, .{ global, promise, rejection }); + } + return JSValue.jsUndefined(); } - return @call(.{ .modifier = .always_inline }, Interface.reportUncaughtException, .{ global, exception }); - } - pub fn createImportMetaProperties(global: *JSGlobalObject, loader: *JSModuleLoader, obj: JSValue, record: *JSModuleRecord, specifier: JSValue) callconv(.C) JSValue { - if (comptime is_bindgen) { - unreachable; + pub fn reportUncaughtException(global: *JSGlobalObject, exception: *Exception) callconv(.C) JSValue { + if (comptime @hasDecl(Type, "reportUncaughtException")) { + return @call(.{ .modifier = .always_inline }, Interface.reportUncaughtException, .{ global, exception }); + } + return JSValue.jsUndefined(); } - return @call(.{ .modifier = .always_inline }, Interface.createImportMetaProperties, .{ global, loader, obj, record, specifier }); - } - - pub const Export = shim.exportFunctions(.{ - .@"import" = import, - .@"resolve" = resolve, - .@"fetch" = fetch, - .@"eval" = eval, - .@"promiseRejectionTracker" = promiseRejectionTracker, - .@"reportUncaughtException" = reportUncaughtException, - .@"createImportMetaProperties" = createImportMetaProperties, - }); - - pub const Extern = [_][]const u8{"create"}; - - 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(promiseRejectionTracker, .{ .name = Export[4].symbol_name }); - @export(reportUncaughtException, .{ .name = Export[5].symbol_name }); - @export(createImportMetaProperties, .{ .name = Export[6].symbol_name }); - } -}; -pub const ZigConsoleClient = packed struct { - pub const shim = Shimmer("Zig", "ConsoleClient", @This()); - pub const Type = *c_void; - pub const name = "Zig::ConsoleClient"; - pub const include = "\"ZigConsoleClient.h\""; - pub const namespace = shim.namespace; - pub const Counter = struct { - // if it turns out a hash table is a better idea we'll do that later - pub const Entry = struct { - hash: u32, - count: u32, - - pub const List = std.MultiArrayList(Entry); - }; - counts: Entry.List, - allocator: *std.mem.Allocator, - }; - - pub fn messageWithTypeAndLevel( - message_type: u32, - message_level: u32, - global: *JSGlobalObject, - args: *ScriptArguments, - ) callconv(.C) void { - var i: usize = 0; - const len = args.argumentCount(); - defer args.release(); - defer Output.flush(); - var writer = Output.writer(); - while (i < len) : (i += 1) { - var str = args.argumentAt(i).toWTFString(global); - writer.writeAll(str.slice()) catch {}; + pub fn createImportMetaProperties(global: *JSGlobalObject, loader: *JSModuleLoader, obj: JSValue, record: *JSModuleRecord, specifier: JSValue) callconv(.C) JSValue { + if (comptime @hasDecl(Type, "createImportMetaProperties")) { + return @call(.{ .modifier = .always_inline }, Interface.createImportMetaProperties, .{ global, loader, obj, record, specifier }); + } + return JSValue.jsUndefined(); } - } - pub fn count(global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} - pub fn countReset(global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} - pub fn time(global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} - pub fn timeLog(global: *JSGlobalObject, chars: [*]const u8, len: usize, args: *ScriptArguments) callconv(.C) void {} - pub fn timeEnd(global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} - pub fn profile(global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} - pub fn profileEnd(global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} - pub fn takeHeapSnapshot(global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} - pub fn timeStamp(global: *JSGlobalObject, args: *ScriptArguments) callconv(.C) void {} - pub fn record(global: *JSGlobalObject, args: *ScriptArguments) callconv(.C) void {} - pub fn recordEnd(global: *JSGlobalObject, args: *ScriptArguments) callconv(.C) void {} - pub fn screenshot(global: *JSGlobalObject, args: *ScriptArguments) callconv(.C) void {} - - pub const Export = shim.exportFunctions(.{ - .@"messageWithTypeAndLevel" = messageWithTypeAndLevel, - .@"count" = count, - .@"countReset" = countReset, - .@"time" = time, - .@"timeLog" = timeLog, - .@"timeEnd" = timeEnd, - .@"profile" = profile, - .@"profileEnd" = profileEnd, - .@"takeHeapSnapshot" = takeHeapSnapshot, - .@"timeStamp" = timeStamp, - .@"record" = record, - .@"recordEnd" = recordEnd, - .@"screenshot" = screenshot, - }); - - comptime { - @export(messageWithTypeAndLevel, .{ - .name = Export[0].symbol_name, - }); - @export(count, .{ - .name = Export[1].symbol_name, - }); - @export(countReset, .{ - .name = Export[2].symbol_name, - }); - @export(time, .{ - .name = Export[3].symbol_name, - }); - @export(timeLog, .{ - .name = Export[4].symbol_name, - }); - @export(timeEnd, .{ - .name = Export[5].symbol_name, - }); - @export(profile, .{ - .name = Export[6].symbol_name, - }); - @export(profileEnd, .{ - .name = Export[7].symbol_name, - }); - @export(takeHeapSnapshot, .{ - .name = Export[8].symbol_name, - }); - @export(timeStamp, .{ - .name = Export[9].symbol_name, - }); - @export(record, .{ - .name = Export[10].symbol_name, - }); - @export(recordEnd, .{ - .name = Export[11].symbol_name, - }); - @export(screenshot, .{ - .name = Export[12].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 JSModuleLoader = extern struct { pub const shim = Shimmer("JSC", "JSModuleLoader", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -485,7 +291,7 @@ pub const JSModuleLoader = packed struct { } pub fn importModule(globalObject: *JSGlobalObject, key: *const Identifier) *JSInternalPromise { - return shim.cppFn("loadAndEvaluateModule", .{ + return shim.cppFn("importModule", .{ globalObject, key, }); @@ -506,12 +312,12 @@ pub const JSModuleLoader = packed struct { }); } - pub fn dependencyKeysIfEvaluated(this: *JSModuleLoader, globalObject: *JSGlobalObject, moduleRecord: *JSModuleRecord) *JSValue { - return shim.cppFn("dependencyKeysIfEvaluated", .{ this, globalObject, moduleRecord }); - } + // pub fn dependencyKeysIfEvaluated(this: *JSModuleLoader, globalObject: *JSGlobalObject, moduleRecord: *JSModuleRecord) *JSValue { + // return shim.cppFn("dependencyKeysIfEvaluated", .{ this, globalObject, moduleRecord }); + // } pub const Extern = [_][]const u8{ - "dependencyKeysIfEvaluated", + // "dependencyKeysIfEvaluated", "evaluate", "loadAndEvaluateModuleEntryPoint", "loadAndEvaluateModule", @@ -521,7 +327,7 @@ pub const JSModuleLoader = packed struct { }; }; -pub const JSModuleRecord = packed struct { +pub const JSModuleRecord = extern struct { pub const shim = Shimmer("JSC", "JSModuleRecord", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -540,7 +346,7 @@ pub const JSModuleRecord = packed struct { }; }; -pub const JSPromise = packed struct { +pub const JSPromise = extern struct { pub const shim = Shimmer("JSC", "JSPromise", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -569,26 +375,26 @@ pub const JSPromise = packed struct { } pub fn resolvedPromise(globalThis: *JSGlobalObject, value: JSValue) *JSPromise { - return cppFn("resolvedPromise", .{ .globalThis = globalThis, .value = value }); + return cppFn("resolvedPromise", .{ globalThis, value }); } pub fn rejectedPromise(globalThis: *JSGlobalObject, value: JSValue) *JSPromise { - return cppFn("rejectedPromise", .{ .globalThis = globalThis, .value = value }); + return cppFn("rejectedPromise", .{ globalThis, value }); } pub fn resolve(this: *JSPromise, globalThis: *JSGlobalObject, value: JSValue) void { - cppFn("resolve", .{ .this = this, .globalThis = globalThis, .value = value }); + cppFn("resolve", .{ this, globalThis, value }); } pub fn reject(this: *JSPromise, globalThis: *JSGlobalObject, value: JSValue) void { - cppFn("reject", .{ .this = this, .globalThis = globalThis, .value = value }); + cppFn("reject", .{ this, globalThis, 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 }); + cppFn("rejectAsHandled", .{ this, globalThis, value }); } + // pub fn rejectException(this: *JSPromise, globalThis: *JSGlobalObject, value: *Exception) void { + // cppFn("rejectException", .{ this, globalThis, value }); + // } pub fn rejectAsHandledException(this: *JSPromise, globalThis: *JSGlobalObject, value: *Exception) void { - cppFn("rejectAsHandledException", .{ .this = this, .globalThis = globalThis, .value = value }); + cppFn("rejectAsHandledException", .{ this, globalThis, value }); } pub const Extern = [_][]const u8{ @@ -601,12 +407,12 @@ pub const JSPromise = packed struct { "resolve", "reject", "rejectAsHandled", - "rejectException", + // "rejectException", "rejectAsHandledException", }; }; -pub const JSInternalPromise = packed struct { +pub const JSInternalPromise = extern struct { pub const shim = Shimmer("JSC", "JSInternalPromise", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -635,34 +441,34 @@ pub const JSInternalPromise = packed struct { } pub fn resolvedPromise(globalThis: *JSGlobalObject, value: JSValue) *JSInternalPromise { - return cppFn("resolvedPromise", .{ .globalThis = globalThis, .value = value }); + return cppFn("resolvedPromise", .{ globalThis, value }); } pub fn rejectedPromise(globalThis: *JSGlobalObject, value: JSValue) *JSInternalPromise { - return cppFn("rejectedPromise", .{ .globalThis = globalThis, .value = value }); + return cppFn("rejectedPromise", .{ globalThis, value }); } pub fn resolve(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: JSValue) void { - cppFn("resolve", .{ .this = this, .globalThis = globalThis, .value = value }); + cppFn("resolve", .{ this, globalThis, value }); } pub fn reject(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: JSValue) void { - cppFn("reject", .{ .this = this, .globalThis = globalThis, .value = value }); + cppFn("reject", .{ this, globalThis, value }); } pub fn rejectAsHandled(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: JSValue) void { - cppFn("rejectAsHandled", .{ .this = this, .globalThis = globalThis, .value = value }); - } - pub fn rejectException(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: *Exception) void { - cppFn("rejectException", .{ .this = this, .globalThis = globalThis, .value = value }); + cppFn("rejectAsHandled", .{ this, globalThis, value }); } + // pub fn rejectException(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: *Exception) void { + // cppFn("rejectException", .{ this, globalThis, value }); + // } pub fn rejectAsHandledException(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: *Exception) void { - cppFn("rejectAsHandledException", .{ .this = this, .globalThis = globalThis, .value = value }); + cppFn("rejectAsHandledException", .{ this, globalThis, value }); } pub fn then(this: *JSInternalPromise, globalThis: *JSGlobalObject, resolvefunc: ?*JSFunction, rejectfunc: ?*JSFunction) *JSInternalPromise { - return cppFn("then", .{ .this = this, .globalThis = globalThis, .resolvefunc = resolvefunc, .rejectfunc = rejectfunc }); + return cppFn("then", .{ this, globalThis, resolvefunc, rejectfunc }); } pub fn create(globalThis: *JSGlobalObject) *JSInternalPromise { - return cppFn("create", .{ .globalThis = globalThis }); + return cppFn("create", .{globalThis}); } pub const Extern = [_][]const u8{ @@ -677,7 +483,7 @@ pub const JSInternalPromise = packed struct { "resolve", "reject", "rejectAsHandled", - "rejectException", + // "rejectException", "rejectAsHandledException", }; }; @@ -689,7 +495,7 @@ pub const SourceType = enum(u8) { WebAssembly = 2, }; -pub const SourceOrigin = packed struct { +pub const SourceOrigin = extern struct { pub const shim = Shimmer("JSC", "SourceOrigin", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -706,7 +512,7 @@ pub const SourceOrigin = packed struct { }; }; -pub const SourceCode = packed struct { +pub const SourceCode = extern struct { pub const shim = Shimmer("JSC", "SourceCode", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -714,8 +520,8 @@ pub const SourceCode = packed struct { pub const name = "JSC::SourceCode"; pub const namespace = "JSC"; - pub fn fromString(source: *const String, origin: *const SourceOrigin, filename: *String, source_type: SourceType) SourceCode { - return cppFn("fromString", .{ source, origin, filename, source_type }); + pub fn fromString(result: *SourceCode, source: *const String, origin: ?*const SourceOrigin, filename: ?*String, source_type: SourceType) void { + cppFn("fromString", .{ result, source, origin, filename, source_type }); } pub const Extern = [_][]const u8{ @@ -723,7 +529,7 @@ pub const SourceCode = packed struct { }; }; -pub const JSFunction = packed struct { +pub const JSFunction = extern struct { pub const shim = Shimmer("JSC", "JSFunction", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -783,7 +589,7 @@ pub const JSFunction = packed struct { arguments_ptr: [*]JSValue, arguments_len: usize, exception: *?*Exception, - error_message: ?*const u8, + error_message: *const c_char, ) JSValue { return cppFn("callWithArgumentsAndThis", .{ function, @@ -802,7 +608,7 @@ pub const JSFunction = packed struct { arguments_ptr: [*]JSValue, arguments_len: usize, exception: *?*Exception, - error_message: ?*const u8, + error_message: *const c_char, ) JSValue { return cppFn("callWithArguments", .{ function, globalThis, arguments_ptr, arguments_len, exception, exception, error_message }); } @@ -812,7 +618,7 @@ pub const JSFunction = packed struct { globalThis: *JSGlobalObject, thisValue: JSValue, exception: *?*Exception, - error_message: ?*const u8, + error_message: *const c_char, ) JSValue { return cppFn("callWithArguments", .{ function, @@ -827,7 +633,7 @@ pub const JSFunction = packed struct { function: JSValue, globalThis: *JSGlobalObject, exception: *?*Exception, - error_message: ?*const u8, + error_message: *const c_char, ) JSValue { return cppFn("callWithoutAnyArgumentsOrThis", .{ function, globalThis, exception, exception, error_message }); } @@ -839,7 +645,7 @@ pub const JSFunction = packed struct { arguments_ptr: [*]JSValue, arguments_len: usize, exception: *?*Exception, - error_message: ?*const u8, + error_message: *const c_char, ) JSValue { return cppFn("constructWithArgumentsAndNewTarget", .{ function, @@ -858,7 +664,7 @@ pub const JSFunction = packed struct { arguments_ptr: [*]JSValue, arguments_len: usize, exception: *?*Exception, - error_message: ?*const u8, + error_message: *const c_char, ) JSValue { return cppFn("constructWithArguments", .{ function, globalThis, arguments_ptr, arguments_len, exception, exception, error_message }); } @@ -868,7 +674,7 @@ pub const JSFunction = packed struct { globalThis: *JSGlobalObject, newTarget: JSValue, exception: *?*Exception, - error_message: ?*const u8, + error_message: *const c_char, ) JSValue { return cppFn("constructWithArguments", .{ function, @@ -883,7 +689,7 @@ pub const JSFunction = packed struct { function: JSValue, globalThis: *JSGlobalObject, exception: *?*Exception, - error_message: ?*const u8, + error_message: *const c_char, ) JSValue { return cppFn("constructWithoutAnyArgumentsOrNewTarget", .{ function, globalThis, exception, exception, error_message }); } @@ -906,7 +712,7 @@ pub const JSFunction = packed struct { }; }; -pub const JSGlobalObject = packed struct { +pub const JSGlobalObject = extern struct { pub const shim = Shimmer("JSC", "JSGlobalObject", @This()); bytes: shim.Bytes, @@ -926,19 +732,19 @@ pub const JSGlobalObject = packed struct { OutOfMemoryError = 8, }; - pub fn createError(globalObject: *JSGlobalObject, error_type: ErrorType, message: *String) *JSObject { - return cppFn("createError", .{ globalObject, @enumToInt(error_type), message }); - } + // pub fn createError(globalObject: *JSGlobalObject, error_type: ErrorType, message: *String) *JSObject { + // return cppFn("createError", .{ globalObject, error_type, message }); + // } - pub fn throwError( - globalObject: *JSGlobalObject, - err: *JSObject, - ) *JSObject { - return cppFn("throwError", .{ - globalObject, - err, - }); - } + // pub fn throwError( + // globalObject: *JSGlobalObject, + // err: *JSObject, + // ) *JSObject { + // return cppFn("throwError", .{ + // globalObject, + // err, + // }); + // } const cppFn = shim.cppFn; @@ -1045,8 +851,8 @@ pub const JSGlobalObject = packed struct { "asyncGeneratorPrototype", "asyncGeneratorFunctionPrototype", "vm", - "createError", - "throwError", + // "createError", + // "throwError", }; }; @@ -1056,7 +862,7 @@ fn _JSCellStub(comptime str: []const u8) type { pub const name = "JSC::" ++ str ++ ""; }; } else { - return struct {}; + return opaque {}; } } @@ -1066,7 +872,7 @@ fn _Wundle(comptime str: []const u8) type { pub const name = "Wundle::" ++ str ++ ""; }; } else { - return struct {}; + return opaque {}; } } @@ -1076,11 +882,11 @@ fn _WTF(comptime str: []const u8) type { pub const name = "WTF::" ++ str ++ ""; }; } else { - return struct {}; + return opaque {}; } } -pub const URL = packed struct { +pub const URL = extern struct { pub const shim = Shimmer("WTF", "URL", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -1092,8 +898,8 @@ pub const URL = packed struct { return cppFn("fromString", .{ base, relative }); } - pub fn fromFileSystemPath(file_system_path: StringView) URL { - return cppFn("fromFileSystemPath", .{file_system_path}); + pub fn fromFileSystemPath(result: *URL, file_system_path: StringView) void { + cppFn("fromFileSystemPath", .{ result, file_system_path }); } pub fn isEmpty(this: *const URL) bool { @@ -1187,7 +993,7 @@ pub const URL = packed struct { 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 String = extern struct { pub const shim = Shimmer("WTF", "String", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -1195,16 +1001,20 @@ pub const String = packed struct { 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 createWithoutCopyingFromPtr(out: *String, str: [*c]const u8, len: usize) void { + return cppFn("createWithoutCopyingFromPtr", .{ out, str, len }); } pub fn createFromExternalString(str: ExternalStringImpl) String { - return cppFn("createFromExternalString", .{str}); + return cppFn("createFromExternalString", .{ + str, + }); } pub fn createWithoutCopying(str: []const u8) String { - return @call(.{ .modifier = .always_inline }, createWithoutCopyingFromPtr, .{ str.ptr, str.len }); + var bytes = String{ .bytes = undefined }; + @call(.{ .modifier = .always_inline }, createWithoutCopyingFromPtr, .{ &bytes, str.ptr, str.len }); + return bytes; } pub fn is8Bit(this: *String) bool { @@ -1392,8 +1202,8 @@ pub const JSValue = enum(i64) { return cppFn("asCell", .{this}); } - pub fn isCallable(this: JSValue) bool { - return cppFn("isCallable", .{this}); + pub fn isCallable(this: JSValue, vm: *VM) bool { + return cppFn("isCallable", .{ this, vm }); } // On exception, this returns the empty string. @@ -1449,16 +1259,10 @@ pub const JSValue = enum(i64) { }); } - pub fn encode(this: JSValue) u64 { - return cppFn("encode", .{ - this, - }); - } - - pub const Extern = [_][]const u8{ "toWTFString", "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 Extern = [_][]const u8{ "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "get", "getIfExists", "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", "isCallable" }; }; -pub const PropertyName = packed struct { +pub const PropertyName = extern struct { pub const shim = Shimmer("JSC", "PropertyName", @This()); bytes: shim.Bytes, @@ -1491,7 +1295,7 @@ pub const PropertyName = packed struct { pub const Extern = [_][]const u8{ "eqlToPropertyName", "eqlToIdentifier", "publicName", "uid" }; }; -pub const Exception = packed struct { +pub const Exception = extern struct { pub const shim = Shimmer("JSC", "Exception", @This()); bytes: shim.Bytes, pub const Type = JSObject; @@ -1518,7 +1322,7 @@ pub const Exception = packed struct { }; }; -pub const JSLock = packed struct { +pub const JSLock = extern struct { pub const shim = Shimmer("JSC", "Exception", @This()); bytes: shim.Bytes, @@ -1538,7 +1342,7 @@ pub const JSLock = packed struct { pub const Extern = [_][]const u8{ "lock", "unlock" }; }; -pub const VM = packed struct { +pub const VM = extern struct { pub const shim = Shimmer("JSC", "VM", @This()); bytes: shim.Bytes, @@ -1604,7 +1408,7 @@ pub const VM = packed struct { pub const Extern = [_][]const u8{ "apiLock", "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError", "drainMicrotasks" }; }; -pub const ThrowScope = packed struct { +pub const ThrowScope = extern struct { pub const shim = Shimmer("JSC", "ThrowScope", @This()); bytes: shim.Bytes, @@ -1643,7 +1447,7 @@ pub const ThrowScope = packed struct { }; }; -pub const CatchScope = packed struct { +pub const CatchScope = extern struct { pub const shim = Shimmer("JSC", "CatchScope", @This()); bytes: shim.Bytes, @@ -1677,7 +1481,7 @@ pub const CatchScope = packed struct { }; }; -pub const CallFrame = packed struct { +pub const CallFrame = extern struct { pub const shim = Shimmer("JSC", "CallFrame", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -1731,7 +1535,7 @@ pub const CallFrame = packed struct { pub const Extern = [_][]const u8{ "argumentsCount", "uncheckedArgument", "argument", "thisValue", "newTarget", "jsCallee", "setNewTarget", "setThisValue" }; }; -// pub const WellKnownSymbols = packed struct { +// pub const WellKnownSymbols = extern struct { // pub const shim = Shimmer("JSC", "CommonIdentifiers", @This()); // @@ -1770,7 +1574,7 @@ pub const EncodedJSValue = enum(i64) { pub const namespace = "JSC"; }; -pub const Identifier = packed struct { +pub const Identifier = extern struct { pub const shim = Shimmer("JSC", "Identifier", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -1787,9 +1591,9 @@ pub const Identifier = packed struct { return cppFn("fromSlice", .{ vm, ptr, len }); } - pub fn fromUid(vm: *VM, other: *const StringImpl) Identifier { - return cppFn("fromString", .{ vm, other }); - } + // pub fn fromUid(vm: *VM, other: *const StringImpl) Identifier { + // return cppFn("fromUid", .{ vm, other }); + // } pub fn deinit(this: *const Identifier) void { return cppFn("deinit", .{this}); @@ -1839,7 +1643,7 @@ pub const Identifier = packed struct { pub const Extern = [_][]const u8{ "fromString", "fromSlice", - "fromUid", + // "fromUid", "deinit", "toString", "length", @@ -1857,7 +1661,7 @@ pub const Identifier = packed struct { const DeinitFunction = fn (ctx: *c_void, buffer: [*]u8, len: usize) callconv(.C) void; -pub const StringImpl = packed struct { +pub const StringImpl = extern struct { pub const shim = Shimmer("WTF", "StringImpl", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -1905,7 +1709,7 @@ pub const StringImpl = packed struct { }; }; -pub const ExternalStringImpl = packed struct { +pub const ExternalStringImpl = extern struct { pub const shim = Shimmer("WTF", "ExternalStringImpl", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -1948,7 +1752,39 @@ pub const ExternalStringImpl = packed struct { }; }; -pub const StringView = packed struct { +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: *const Type) []const u8 { + if (this.isEmpty()) { + return ""; + } + + return this.characters8()[0..this.length()]; + } + }; + + return @TypeOf(SliceStruct.slice); +} + +pub const StringView = extern struct { pub const shim = Shimmer("WTF", "StringView", @This()); bytes: shim.Bytes, const cppFn = shim.cppFn; @@ -1957,12 +1793,14 @@ pub const StringView = packed struct { 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 from8Bit(view: *StringView, ptr: [*]const u8, len: usize) void { + return cppFn("from8Bit", .{ view, ptr, len }); } pub fn fromSlice(value: []const u8) StringView { - return from8Bit(value.ptr, value.len); + var view = std.mem.zeroes(StringView); + from8Bit(&view, value.ptr, value.len); + return view; } pub fn is8Bit(this: *const StringView) bool { @@ -2396,38 +2234,9 @@ pub const Cpp = struct { // } }; }; + +pub usingnamespace @import("exports.zig"); + 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: *const Type) []const u8 { - if (this.isEmpty()) { - return ""; - } - - return this.characters8()[0..this.length()]; - } - }; - - return @TypeOf(SliceStruct.slice); -} diff --git a/src/javascript/jsc/bindings/exports.zig b/src/javascript/jsc/bindings/exports.zig new file mode 100644 index 000000000..63e19beb0 --- /dev/null +++ b/src/javascript/jsc/bindings/exports.zig @@ -0,0 +1,212 @@ +usingnamespace @import("./bindings.zig"); +usingnamespace @import("./shared.zig"); + +pub const ZigGlobalObject = extern 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 const Interface: type = NewGlobalObject(std.meta.globalOption("JSGlobalObject", type) orelse struct {}); + + pub fn create(vm: ?*VM, console: *c_void) *JSGlobalObject { + return shim.cppFn("create", .{ vm, console }); + } + + pub fn import(global: *JSGlobalObject, loader: *JSModuleLoader, specifier: *JSString, referrer: JSValue, origin: *const SourceOrigin) callconv(.C) *JSInternalPromise { + // if (comptime is_bindgen) { + // unreachable; + // } + + return @call(.{ .modifier = .always_inline }, Interface.import, .{ global, loader, specifier, referrer, origin }); + } + pub fn resolve(global: *JSGlobalObject, loader: *JSModuleLoader, specifier: JSValue, value: JSValue, origin: *const SourceOrigin) callconv(.C) Identifier { + if (comptime is_bindgen) { + unreachable; + } + return @call(.{ .modifier = .always_inline }, Interface.resolve, .{ global, loader, specifier, value, origin }); + } + pub fn fetch(global: *JSGlobalObject, loader: *JSModuleLoader, value1: JSValue, value2: JSValue, value3: JSValue) callconv(.C) *JSInternalPromise { + if (comptime is_bindgen) { + unreachable; + } + return @call(.{ .modifier = .always_inline }, Interface.fetch, .{ global, loader, value1, value2, value3 }); + } + 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; + } + return @call(.{ .modifier = .always_inline }, Interface.eval, .{ global, loader, key, moduleRecordValue, scriptFetcher, awaitedValue, resumeMode }); + } + pub fn promiseRejectionTracker(global: *JSGlobalObject, promise: *JSPromise, rejection: JSPromiseRejectionOperation) callconv(.C) JSValue { + if (comptime is_bindgen) { + unreachable; + } + return @call(.{ .modifier = .always_inline }, Interface.promiseRejectionTracker, .{ global, promise, rejection }); + } + + pub fn reportUncaughtException(global: *JSGlobalObject, exception: *Exception) callconv(.C) JSValue { + if (comptime is_bindgen) { + unreachable; + } + return @call(.{ .modifier = .always_inline }, Interface.reportUncaughtException, .{ global, exception }); + } + + pub fn createImportMetaProperties(global: *JSGlobalObject, loader: *JSModuleLoader, obj: JSValue, record: *JSModuleRecord, specifier: JSValue) callconv(.C) JSValue { + if (comptime is_bindgen) { + unreachable; + } + return @call(.{ .modifier = .always_inline }, Interface.createImportMetaProperties, .{ global, loader, obj, record, specifier }); + } + + pub const Export = shim.exportFunctions(.{ + .@"import" = import, + .@"resolve" = resolve, + .@"fetch" = fetch, + .@"eval" = eval, + .@"promiseRejectionTracker" = promiseRejectionTracker, + .@"reportUncaughtException" = reportUncaughtException, + .@"createImportMetaProperties" = createImportMetaProperties, + }); + + pub const Extern = [_][]const u8{"create"}; + + 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(promiseRejectionTracker, .{ .name = Export[4].symbol_name }); + @export(reportUncaughtException, .{ .name = Export[5].symbol_name }); + @export(createImportMetaProperties, .{ .name = Export[6].symbol_name }); + } +}; + +pub const ZigConsoleClient = struct { + pub const shim = Shimmer("Zig", "ConsoleClient", @This()); + pub const Type = *c_void; + pub const name = "Zig::ConsoleClient"; + pub const include = "\"ZigConsoleClient.h\""; + pub const namespace = shim.namespace; + pub const Counter = struct { + // if it turns out a hash table is a better idea we'll do that later + pub const Entry = struct { + hash: u32, + count: u32, + + pub const List = std.MultiArrayList(Entry); + }; + counts: Entry.List, + allocator: *std.mem.Allocator, + }; + const BufferedWriter = std.io.BufferedWriter(4096, Output.WriterType); + error_writer: BufferedWriter, + writer: BufferedWriter, + + pub fn init(allocator: *std.mem.Allocator) !*ZigConsoleClient { + var console = try allocator.create(ZigConsoleClient); + console.* = ZigConsoleClient{ + .error_writer = BufferedWriter{ .unbuffered_writer = Output.errorWriter() }, + .writer = BufferedWriter{ .unbuffered_writer = Output.writer() }, + }; + return console; + } + + pub fn messageWithTypeAndLevel( + console_: ZigConsoleClient.Type, + message_type: u32, + message_level: u32, + global: *JSGlobalObject, + args: *ScriptArguments, + ) callconv(.C) void { + var console = zigCast(ZigConsoleClient, console_); + var i: usize = 0; + const len = args.argumentCount(); + defer args.release(); + var writer = console.writer; + + if (len == 1) { + var str = args.getFirstArgumentAsString(); + _ = writer.unbuffered_writer.write(str.slice()) catch 0; + return; + } + + defer writer.flush() catch {}; + + while (i < len) : (i += 1) { + var str = args.argumentAt(i).toWTFString(global); + _ = writer.write(str.slice()) catch 0; + } + } + pub fn count(console: ZigConsoleClient.Type, global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} + pub fn countReset(console: ZigConsoleClient.Type, global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} + pub fn time(console: ZigConsoleClient.Type, global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} + pub fn timeLog(console: ZigConsoleClient.Type, global: *JSGlobalObject, chars: [*]const u8, len: usize, args: *ScriptArguments) callconv(.C) void {} + pub fn timeEnd(console: ZigConsoleClient.Type, global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} + pub fn profile(console: ZigConsoleClient.Type, global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} + pub fn profileEnd(console: ZigConsoleClient.Type, global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} + pub fn takeHeapSnapshot(console: ZigConsoleClient.Type, global: *JSGlobalObject, chars: [*]const u8, len: usize) callconv(.C) void {} + pub fn timeStamp(console: ZigConsoleClient.Type, global: *JSGlobalObject, args: *ScriptArguments) callconv(.C) void {} + pub fn record(console: ZigConsoleClient.Type, global: *JSGlobalObject, args: *ScriptArguments) callconv(.C) void {} + pub fn recordEnd(console: ZigConsoleClient.Type, global: *JSGlobalObject, args: *ScriptArguments) callconv(.C) void {} + pub fn screenshot(console: ZigConsoleClient.Type, global: *JSGlobalObject, args: *ScriptArguments) callconv(.C) void {} + + pub const Export = shim.exportFunctions(.{ + .@"messageWithTypeAndLevel" = messageWithTypeAndLevel, + .@"count" = count, + .@"countReset" = countReset, + .@"time" = time, + .@"timeLog" = timeLog, + .@"timeEnd" = timeEnd, + .@"profile" = profile, + .@"profileEnd" = profileEnd, + .@"takeHeapSnapshot" = takeHeapSnapshot, + .@"timeStamp" = timeStamp, + .@"record" = record, + .@"recordEnd" = recordEnd, + .@"screenshot" = screenshot, + }); + + comptime { + @export(messageWithTypeAndLevel, .{ + .name = Export[0].symbol_name, + }); + @export(count, .{ + .name = Export[1].symbol_name, + }); + @export(countReset, .{ + .name = Export[2].symbol_name, + }); + @export(time, .{ + .name = Export[3].symbol_name, + }); + @export(timeLog, .{ + .name = Export[4].symbol_name, + }); + @export(timeEnd, .{ + .name = Export[5].symbol_name, + }); + @export(profile, .{ + .name = Export[6].symbol_name, + }); + @export(profileEnd, .{ + .name = Export[7].symbol_name, + }); + @export(takeHeapSnapshot, .{ + .name = Export[8].symbol_name, + }); + @export(timeStamp, .{ + .name = Export[9].symbol_name, + }); + @export(record, .{ + .name = Export[10].symbol_name, + }); + @export(recordEnd, .{ + .name = Export[11].symbol_name, + }); + @export(screenshot, .{ + .name = Export[12].symbol_name, + }); + } +}; diff --git a/src/javascript/jsc/bindings/header-gen.zig b/src/javascript/jsc/bindings/header-gen.zig index 15b13b4aa..319a18cae 100644 --- a/src/javascript/jsc/bindings/header-gen.zig +++ b/src/javascript/jsc/bindings/header-gen.zig @@ -18,13 +18,19 @@ fn isCppObject(comptime Type: type) bool { }; } +const ENABLE_REWRITE_RETURN = false; + pub fn cTypeLabel(comptime Type: type) ?[]const u8 { return switch (comptime Type) { - void => "void", + *StaticExport.c_char => "char*", + *const StaticExport.c_char => "const char*", + StaticExport.c_char => "char", + + *void => "void", bool => "bool", usize => "size_t", isize => "int", - u8 => "char", + u8 => "unsigned char", u16 => "uint16_t", u32 => "uint32_t", u64 => "uint64_t", @@ -39,7 +45,7 @@ pub fn cTypeLabel(comptime Type: type) ?[]const u8 { [*]bool => "bool*", [*]usize => "size_t*", [*]isize => "int*", - [*]u8 => "char*", + [*]u8 => "unsigned char*", [*]u16 => "uint16_t*", [*]u32 => "uint32_t*", [*]u64 => "uint64_t*", @@ -50,7 +56,7 @@ pub fn cTypeLabel(comptime Type: type) ?[]const u8 { [*]const bool => "const bool*", [*]const usize => "const size_t*", [*]const isize => "const int*", - [*]const u8 => "const char*", + [*]const u8 => "const unsigned char*", [*]const u16 => "const uint16_t*", [*]const u32 => "const uint32_t*", [*]const u64 => "const uint64_t*", @@ -68,7 +74,9 @@ 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 opaque_types = std.BufSet.init(std.heap.c_allocator); var size_map = std.StringHashMap(u32).init(std.heap.c_allocator); +var align_map = std.StringHashMap(u29).init(std.heap.c_allocator); pub const C_Generator = struct { filebase: []const u8, @@ -99,8 +107,9 @@ pub const C_Generator = struct { comptime func: FnDecl, comptime meta: FnMeta, comptime arg_names: []const []const u8, + comptime rewrite_return: bool, ) void { - switch (meta.calling_convention) { + switch (comptime meta.calling_convention) { .Naked => self.write("__attribute__((naked)) "), .Stdcall => self.write("__attribute__((stdcall)) "), .Fastcall => self.write("__attribute__((fastcall)) "), @@ -113,18 +122,33 @@ pub const C_Generator = struct { .export_zig => self.write("ZIG_DECL "), } - self.writeType(func.return_type); + if (comptime rewrite_return) { + self.writeType(void); + } else { + self.writeType(comptime func.return_type); + } + self.write(" " ++ name ++ "("); + if (comptime rewrite_return) { + self.writeType(comptime func.return_type); + self.write("_buf ret_value"); + + if (comptime meta.args.len > 0) { + self.write(", "); + } + } + inline for (meta.args) |arg, i| { - const ArgType = arg.arg_type.?; + const ArgType = comptime 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.?); + self.writeType(comptime arg.arg_type.?); + switch (@typeInfo(ArgType)) { .Enum => { self.write(comptime std.fmt.comptimePrint(" {s}{d}", .{ @typeName(ArgType), i })); @@ -291,17 +315,26 @@ pub const C_Generator = struct { 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; + align_map.put(comptime formatted_name, @as(u29, TT.shim.align_size)) catch unreachable; + } else if (@typeInfo(TT) == .Opaque) { + opaque_types.insert(comptime label) 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; + align_map.put(comptime formatted_name, @as(u29, TT.shim.align_size)) catch unreachable; + } else if (@typeInfo(TT) == .Opaque) { + opaque_types.insert(comptime label) 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; + align_map.put(comptime formatted_name, @as(u29, TT.shim.align_size)) catch unreachable; + } else if (@typeInfo(TT) == .Opaque) { + opaque_types.insert(comptime TT.name) catch unreachable; } } @@ -460,6 +493,7 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { comptime static_export.Decl().data.Fn, comptime fn_meta, comptime std.mem.zeroes([]const []const u8), + false, ); } @@ -494,13 +528,13 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { }, .Fn => |func| { // if (func.) { - const fn_meta = @typeInfo(func.name).Fn; // blocked by https://github.com/ziglang/zig/issues/8259 gen.gen_func( - prefix ++ "__" ++ name, - func, - fn_meta, - &.{}, + comptime prefix ++ "__" ++ name, + comptime func, + comptime func, + comptime &.{}, + comptime ENABLE_REWRITE_RETURN and @typeInfo(fn_meta.return_type) == .Struct, ); }, else => {}, @@ -508,13 +542,13 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { }, .Fn => |func| { // if (func.) { - const fn_meta = @typeInfo(func.fn_type).Fn; // blocked by https://github.com/ziglang/zig/issues/8259 gen.gen_func( - prefix ++ "__" ++ name, - func, - fn_meta, - &.{}, + comptime prefix ++ "__" ++ name, + comptime func, + comptime @typeInfo(func.fn_type).Fn, + comptime &.{}, + comptime ENABLE_REWRITE_RETURN and @typeInfo(func.return_type) == .Struct, ); }, else => {}, @@ -573,7 +607,7 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { .Type => |Type| { @setEvalBranchQuota(99999); const is_container_type = switch (@typeInfo(Type)) { - .Opaque, .Struct => true, + .Opaque, .Struct, .Enum => true, else => false, }; if (is_container_type and (@hasDecl(Type, "Extern") or @hasDecl(Type, "Export"))) { @@ -653,13 +687,17 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { }; gen.direction = C_Generator.Direction.export_zig; - inline for (ExportLIst) |static_export| { - processStaticExport( - self, - file, - &gen, - comptime static_export, - ); + if (ExportLIst.len > 0) { + gen.write("\n#ifdef __cplusplus\n\n"); + inline for (ExportLIst) |static_export| { + processStaticExport( + self, + file, + &gen, + comptime static_export, + ); + } + gen.write("\n#endif\n"); } } } @@ -683,17 +721,41 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { const NamespaceMap = std.StringArrayHashMap(std.BufMap); var namespaces = NamespaceMap.init(std.heap.c_allocator); + var size_iter = size_map.iterator(); + while (size_iter.next()) |size| { + file_writer.print(" typedef struct b{s} {{ unsigned char bytes[{d}]; }} b{s};\n", .{ + size.key_ptr.*, + // align_map.get(size.key_ptr.*).?, + size.value_ptr.*, + size.key_ptr.*, + }) catch unreachable; + + file_writer.print(" typedef char* b{s}_buf;\n", .{ + size.key_ptr.*, + }) catch unreachable; + } + 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 (opaque_types.contains(entry.key_ptr.*)) { + file_writer.print(" typedef struct {s} {s}; // {s}\n", .{ + value, + value, + key, + }) catch unreachable; + } else { + file_writer.print(" typedef b{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; } @@ -713,14 +775,6 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { } 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; diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h index c8c0e7b16..5edb7568c 100644 --- a/src/javascript/jsc/bindings/headers-cpp.h +++ b/src/javascript/jsc/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1627163531 +//-- AUTOGENERATED FILE -- 1627342675 #pragma once #include <stddef.h> @@ -39,30 +39,6 @@ extern "C" const size_t JSC__JSString_object_align_ = alignof(JSC::JSString); extern "C" const size_t Inspector__ScriptArguments_object_size_ = sizeof(Inspector::ScriptArguments); extern "C" const size_t Inspector__ScriptArguments_object_align_ = alignof(Inspector::ScriptArguments); -#ifndef INCLUDED__ZigGlobalObject_h_ -#define INCLUDED__ZigGlobalObject_h_ -#include "ZigGlobalObject.h" -#endif - -extern "C" const size_t Zig__GlobalObject_object_size_ = sizeof(Zig::GlobalObject); -extern "C" const size_t Zig__GlobalObject_object_align_ = alignof(Zig::GlobalObject); - -#ifndef INCLUDED__ZigConsoleClient_h_ -#define INCLUDED__ZigConsoleClient_h_ -#include "ZigConsoleClient.h" -#endif - -extern "C" const size_t Zig__ConsoleClient_object_size_ = sizeof(Zig::ConsoleClient); -extern "C" const size_t Zig__ConsoleClient_object_align_ = alignof(Zig::ConsoleClient); - -#ifndef INCLUDED__DefaultGlobal_h_ -#define INCLUDED__DefaultGlobal_h_ -#include "DefaultGlobal.h" -#endif - -extern "C" const size_t Wundle__DefaultGlobal_object_size_ = sizeof(Wundle::DefaultGlobal); -extern "C" const size_t Wundle__DefaultGlobal_object_align_ = alignof(Wundle::DefaultGlobal); - #ifndef INCLUDED__JavaScriptCore_JSModuleLoader_h_ #define INCLUDED__JavaScriptCore_JSModuleLoader_h_ #include <JavaScriptCore/JSModuleLoader.h> @@ -143,6 +119,14 @@ extern "C" const size_t WTF__URL_object_align_ = alignof(WTF::URL); extern "C" const size_t WTF__String_object_size_ = sizeof(WTF::String); extern "C" const size_t WTF__String_object_align_ = alignof(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); +extern "C" const size_t JSC__JSValue_object_align_ = alignof(JSC::JSValue); + #ifndef INCLUDED__JavaScriptCore_PropertyName_h_ #define INCLUDED__JavaScriptCore_PropertyName_h_ #include <JavaScriptCore/PropertyName.h> @@ -223,8 +207,24 @@ extern "C" const size_t WTF__ExternalStringImpl_object_align_ = alignof(WTF::Ext extern "C" const size_t WTF__StringView_object_size_ = sizeof(WTF::StringView); extern "C" const size_t WTF__StringView_object_align_ = alignof(WTF::StringView); -const size_t sizes[26] = {sizeof(JSC::JSObject), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Inspector::ScriptArguments), sizeof(Zig::GlobalObject), sizeof(Wundle::DefaultGlobal), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::SourceOrigin), sizeof(JSC::SourceCode), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(WTF::URL), sizeof(WTF::String), 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)}; +#ifndef INCLUDED__ZigGlobalObject_h_ +#define INCLUDED__ZigGlobalObject_h_ +#include "ZigGlobalObject.h" +#endif + +extern "C" const size_t Zig__GlobalObject_object_size_ = sizeof(Zig::GlobalObject); +extern "C" const size_t Zig__GlobalObject_object_align_ = alignof(Zig::GlobalObject); + +#ifndef INCLUDED__ZigConsoleClient_h_ +#define INCLUDED__ZigConsoleClient_h_ +#include "ZigConsoleClient.h" +#endif + +extern "C" const size_t Zig__ConsoleClient_object_size_ = sizeof(Zig::ConsoleClient); +extern "C" const size_t Zig__ConsoleClient_object_align_ = alignof(Zig::ConsoleClient); + +const size_t sizes[26] = {sizeof(JSC::JSObject), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Inspector::ScriptArguments), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), 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), sizeof(Zig::GlobalObject)}; -const char* names[26] = {"JSC__JSObject", "JSC__JSCell", "JSC__JSString", "Inspector__ScriptArguments", "Zig__GlobalObject", "Wundle__DefaultGlobal", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__SourceOrigin", "JSC__SourceCode", "JSC__JSFunction", "JSC__JSGlobalObject", "WTF__URL", "WTF__String", "JSC__PropertyName", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "JSC__CallFrame", "JSC__Identifier", "WTF__StringImpl", "WTF__ExternalStringImpl", "WTF__StringView"}; +const char* names[26] = {"JSC__JSObject", "JSC__JSCell", "JSC__JSString", "Inspector__ScriptArguments", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__JSInternalPromise", "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", "Zig__GlobalObject"}; -const size_t aligns[26] = {alignof(JSC::JSObject), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(Inspector::ScriptArguments), alignof(Zig::GlobalObject), alignof(Wundle::DefaultGlobal), alignof(JSC::JSModuleLoader), alignof(JSC::JSModuleRecord), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::SourceOrigin), alignof(JSC::SourceCode), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(WTF::URL), alignof(WTF::String), alignof(JSC::PropertyName), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(JSC::CallFrame), alignof(JSC::Identifier), alignof(WTF::StringImpl), alignof(WTF::ExternalStringImpl), alignof(WTF::StringView)}; +const size_t aligns[26] = {alignof(JSC::JSObject), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(Inspector::ScriptArguments), alignof(JSC::JSModuleLoader), alignof(JSC::JSModuleRecord), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::SourceOrigin), alignof(JSC::SourceCode), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(WTF::URL), alignof(WTF::String), alignof(JSC::JSValue), alignof(JSC::PropertyName), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(JSC::CallFrame), alignof(JSC::Identifier), alignof(WTF::StringImpl), alignof(WTF::ExternalStringImpl), alignof(WTF::StringView), alignof(Zig::GlobalObject)}; diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h index b5a96ec37..dd1db277e 100644 --- a/src/javascript/jsc/bindings/headers.h +++ b/src/javascript/jsc/bindings/headers.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1627163531 +//-- AUTOGENERATED FILE -- 1627342675 #pragma once #include <stddef.h> @@ -14,81 +14,103 @@ #define CPP_DECL AUTO_EXTERN_C #define CPP_SIZE AUTO_EXTERN_C + typedef struct bJSC__JSModuleRecord { unsigned char bytes[216]; } bJSC__JSModuleRecord; + typedef char* bJSC__JSModuleRecord_buf; + typedef struct bJSC__ThrowScope { unsigned char bytes[8]; } bJSC__ThrowScope; + typedef char* bJSC__ThrowScope_buf; + typedef struct bJSC__PropertyName { unsigned char bytes[8]; } bJSC__PropertyName; + typedef char* bJSC__PropertyName_buf; + typedef struct bJSC__CallFrame { unsigned char bytes[8]; } bJSC__CallFrame; + typedef char* bJSC__CallFrame_buf; + typedef struct bJSC__CatchScope { unsigned char bytes[8]; } bJSC__CatchScope; + typedef char* bJSC__CatchScope_buf; + typedef struct bWTF__String { unsigned char bytes[8]; } bWTF__String; + typedef char* bWTF__String_buf; + typedef struct bWTF__StringView { unsigned char bytes[16]; } bWTF__StringView; + typedef char* bWTF__StringView_buf; + typedef struct bJSC__JSModuleLoader { unsigned char bytes[16]; } bJSC__JSModuleLoader; + typedef char* bJSC__JSModuleLoader_buf; + typedef struct bJSC__Exception { unsigned char bytes[40]; } bJSC__Exception; + typedef char* bJSC__Exception_buf; + typedef struct bJSC__VM { unsigned char bytes[48824]; } bJSC__VM; + typedef char* bJSC__VM_buf; + typedef struct bJSC__JSString { unsigned char bytes[16]; } bJSC__JSString; + typedef char* bJSC__JSString_buf; + typedef struct bJSC__SourceOrigin { unsigned char bytes[48]; } bJSC__SourceOrigin; + typedef char* bJSC__SourceOrigin_buf; + typedef struct bWTF__ExternalStringImpl { unsigned char bytes[32]; } bWTF__ExternalStringImpl; + typedef char* bWTF__ExternalStringImpl_buf; + typedef struct bWTF__StringImpl { unsigned char bytes[24]; } bWTF__StringImpl; + typedef char* bWTF__StringImpl_buf; + typedef struct bJSC__JSPromise { unsigned char bytes[32]; } bJSC__JSPromise; + typedef char* bJSC__JSPromise_buf; + typedef struct bJSC__SourceCode { unsigned char bytes[24]; } bJSC__SourceCode; + typedef char* bJSC__SourceCode_buf; + typedef struct bWTF__URL { unsigned char bytes[40]; } bWTF__URL; + typedef char* bWTF__URL_buf; + typedef struct bJSC__JSFunction { unsigned char bytes[32]; } bJSC__JSFunction; + typedef char* bJSC__JSFunction_buf; + typedef struct bJSC__JSGlobalObject { unsigned char bytes[2400]; } bJSC__JSGlobalObject; + typedef char* bJSC__JSGlobalObject_buf; + typedef struct bJSC__JSCell { unsigned char bytes[8]; } bJSC__JSCell; + typedef char* bJSC__JSCell_buf; + typedef struct bJSC__JSLock { unsigned char bytes[40]; } bJSC__JSLock; + typedef char* bJSC__JSLock_buf; + typedef struct bInspector__ScriptArguments { unsigned char bytes[32]; } bInspector__ScriptArguments; + typedef char* bInspector__ScriptArguments_buf; + typedef struct bJSC__JSInternalPromise { unsigned char bytes[32]; } bJSC__JSInternalPromise; + typedef char* bJSC__JSInternalPromise_buf; + typedef struct bJSC__JSObject { unsigned char bytes[16]; } bJSC__JSObject; + typedef char* bJSC__JSObject_buf; + typedef struct bJSC__Identifier { unsigned char bytes[8]; } bJSC__Identifier; + typedef char* bJSC__Identifier_buf; #ifndef __cplusplus typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype - typedef struct WTF__StringView WTF__StringView; // WTF::StringView + typedef bWTF__StringView WTF__StringView; // WTF::StringView typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype - typedef struct JSC__CatchScope JSC__CatchScope; // JSC::CatchScope - 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__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl + typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope + typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope + typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName + typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject + typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype - typedef struct WTF__StringImpl WTF__StringImpl; // WTF::StringImpl - 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 bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl + typedef bJSC__JSLock JSC__JSLock; // JSC::JSLock + typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader + typedef bJSC__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 bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject + typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype - typedef struct JSC__Identifier JSC__Identifier; // JSC::Identifier - typedef struct JSC__JSPromise JSC__JSPromise; // JSC::JSPromise typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype + typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier + typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise 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 bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode + typedef bJSC__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 bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin + typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord + typedef bWTF__String WTF__String; // WTF::String + typedef bWTF__URL WTF__URL; // WTF::URL typedef int64_t JSC__JSValue; typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype - typedef struct JSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise + typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype - typedef struct Inspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments - typedef struct JSC__Exception JSC__Exception; // JSC::Exception - typedef struct JSC__JSString JSC__JSString; // JSC::JSString - typedef struct Zig__ConsoleClient Zig__ConsoleClient; // Zig::ConsoleClient + typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments + typedef bJSC__Exception JSC__Exception; // JSC::Exception + typedef bJSC__JSString JSC__JSString; // JSC::JSString typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype - typedef struct JSC__CallFrame JSC__CallFrame; // JSC::CallFrame + typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype #endif - typedef struct bJSC__JSModuleRecord { char bytes[344]; } bJSC__JSModuleRecord; - typedef struct bJSC__ThrowScope { char bytes[8]; } bJSC__ThrowScope; - typedef struct bJSC__PropertyName { char bytes[8]; } bJSC__PropertyName; - 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 bInspector__ScriptArguments { char bytes[32]; } bInspector__ScriptArguments; - typedef struct bWundle__DefaultGlobal { char bytes[2464]; } bWundle__DefaultGlobal; - typedef struct bJSC__JSInternalPromise { char bytes[32]; } bJSC__JSInternalPromise; - typedef struct bJSC__JSObject { char bytes[16]; } bJSC__JSObject; - typedef struct bJSC__Identifier { char bytes[8]; } bJSC__Identifier; #ifdef __cplusplus namespace JSC { @@ -136,15 +158,9 @@ class StringView; class ExternalStringImpl; } - namespace Wundle { - class DefaultGlobal; - } namespace Inspector { class ScriptArguments; } - namespace Zig { - class ConsoleClient; - } typedef int64_t JSC__JSValue; using JSC__JSCell = JSC::JSCell; @@ -188,9 +204,7 @@ using WTF__String = WTF::String; using WTF__StringView = WTF::StringView; using WTF__ExternalStringImpl = WTF::ExternalStringImpl; - using Wundle__DefaultGlobal = Wundle::DefaultGlobal; using Inspector__ScriptArguments = Inspector::ScriptArguments; - using Zig__ConsoleClient = Zig::ConsoleClient; #endif @@ -205,7 +219,7 @@ CPP_DECL bool JSC__JSObject__putAtIndex(JSC__JSObject* arg0, JSC__JSGlobalObject CPP_DECL JSC__JSObject* JSC__JSCell__getObject(JSC__JSCell* arg0); CPP_DECL bWTF__String JSC__JSCell__getString(JSC__JSCell* arg0, JSC__JSGlobalObject* arg1); -CPP_DECL char JSC__JSCell__getType(JSC__JSCell* arg0); +CPP_DECL unsigned char JSC__JSCell__getType(JSC__JSCell* arg0); #pragma mark - JSC::JSString @@ -215,7 +229,7 @@ CPP_DECL bool JSC__JSString__eql(const JSC__JSString* arg0, JSC__JSGlobalObject* CPP_DECL bool JSC__JSString__is8Bit(const JSC__JSString* arg0); CPP_DECL size_t JSC__JSString__length(const JSC__JSString* arg0); CPP_DECL JSC__JSObject* JSC__JSString__toObject(JSC__JSString* arg0, JSC__JSGlobalObject* arg1); -CPP_DECL bWTF__String JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1); +CPP_DECL void JSC__JSString__value(bWTF__String arg0, JSC__JSString* arg1, JSC__JSGlobalObject* arg2); #pragma mark - Inspector::ScriptArguments @@ -225,42 +239,9 @@ CPP_DECL bWTF__String Inspector__ScriptArguments__getFirstArgumentAsString(const CPP_DECL bool Inspector__ScriptArguments__isEqual(const Inspector__ScriptArguments* arg0, const Inspector__ScriptArguments* arg1); CPP_DECL void Inspector__ScriptArguments__release(Inspector__ScriptArguments* arg0); -#pragma mark - Zig::GlobalObject - -CPP_DECL JSC__JSGlobalObject* Zig__GlobalObject__create(JSC__VM* arg0, Zig__ConsoleClient* arg1); -ZIG_DECL JSC__JSValue Zig__GlobalObject__createImportMetaProperties(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSModuleRecord* arg3, JSC__JSValue JSValue4); -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__JSInternalPromise* Zig__GlobalObject__fetch(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, JSC__JSValue JSValue4); -ZIG_DECL JSC__JSInternalPromise* 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__promiseRejectionTracker(JSC__JSGlobalObject* arg0, JSC__JSPromise* arg1, uint32_t JSPromiseRejectionOperation2); -ZIG_DECL JSC__JSValue Zig__GlobalObject__reportUncaughtException(JSC__JSGlobalObject* arg0, JSC__Exception* arg1); -ZIG_DECL bJSC__Identifier Zig__GlobalObject__resolve(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, const JSC__SourceOrigin* arg4); - -#pragma mark - Zig::ConsoleClient - -ZIG_DECL void Zig__ConsoleClient__count(JSC__JSGlobalObject* arg0, const char* arg1, size_t arg2); -ZIG_DECL void Zig__ConsoleClient__countReset(JSC__JSGlobalObject* arg0, const char* arg1, size_t arg2); -ZIG_DECL void Zig__ConsoleClient__messageWithTypeAndLevel(uint32_t arg0, uint32_t arg1, JSC__JSGlobalObject* arg2, Inspector__ScriptArguments* arg3); -ZIG_DECL void Zig__ConsoleClient__profile(JSC__JSGlobalObject* arg0, const char* arg1, size_t arg2); -ZIG_DECL void Zig__ConsoleClient__profileEnd(JSC__JSGlobalObject* arg0, const char* arg1, size_t arg2); -ZIG_DECL void Zig__ConsoleClient__record(JSC__JSGlobalObject* arg0, Inspector__ScriptArguments* arg1); -ZIG_DECL void Zig__ConsoleClient__recordEnd(JSC__JSGlobalObject* arg0, Inspector__ScriptArguments* arg1); -ZIG_DECL void Zig__ConsoleClient__screenshot(JSC__JSGlobalObject* arg0, Inspector__ScriptArguments* arg1); -ZIG_DECL void Zig__ConsoleClient__takeHeapSnapshot(JSC__JSGlobalObject* arg0, const char* arg1, size_t arg2); -ZIG_DECL void Zig__ConsoleClient__time(JSC__JSGlobalObject* arg0, const char* arg1, size_t arg2); -ZIG_DECL void Zig__ConsoleClient__timeEnd(JSC__JSGlobalObject* arg0, const char* arg1, size_t arg2); -ZIG_DECL void Zig__ConsoleClient__timeLog(JSC__JSGlobalObject* arg0, const char* arg1, size_t arg2, Inspector__ScriptArguments* arg3); -ZIG_DECL void Zig__ConsoleClient__timeStamp(JSC__JSGlobalObject* arg0, Inspector__ScriptArguments* arg1); - -#pragma mark - Wundle::DefaultGlobal - -CPP_DECL Wundle__DefaultGlobal* Wundle__DefaultGlobal__create(Wundle__DefaultGlobal* arg0, void* arg1); -CPP_DECL void* Wundle__DefaultGlobal__getWrapper(Wundle__DefaultGlobal* arg0); - #pragma mark - JSC::JSModuleLoader CPP_DECL bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1, bool arg2); -CPP_DECL JSC__JSValue JSC__JSModuleLoader__dependencyKeysIfEvaluated(JSC__JSModuleLoader* arg0, JSC__JSGlobalObject* arg1, JSC__JSModuleRecord* arg2); CPP_DECL JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3); CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__importModule(JSC__JSGlobalObject* arg0, const JSC__Identifier* arg1); CPP_DECL JSC__JSValue JSC__JSModuleLoader__linkAndEvaluateModule(JSC__JSGlobalObject* arg0, const JSC__Identifier* arg1); @@ -278,7 +259,6 @@ CPP_DECL void JSC__JSPromise__reject(JSC__JSPromise* arg0, JSC__JSGlobalObject* 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__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); CPP_DECL JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); @@ -293,7 +273,6 @@ CPP_DECL void JSC__JSInternalPromise__reject(JSC__JSInternalPromise* arg0, JSC__ CPP_DECL void JSC__JSInternalPromise__rejectAsHandled(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); CPP_DECL void JSC__JSInternalPromise__rejectAsHandledException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2); CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); -CPP_DECL void JSC__JSInternalPromise__rejectException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2); CPP_DECL void JSC__JSInternalPromise__rejectWithCaughtException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2); CPP_DECL void JSC__JSInternalPromise__resolve(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); @@ -307,21 +286,21 @@ CPP_DECL bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL* arg0); #pragma mark - JSC::SourceCode -CPP_DECL bJSC__SourceCode JSC__SourceCode__fromString(const WTF__String* arg0, const JSC__SourceOrigin* arg1, WTF__String* arg2, char SourceType3); +CPP_DECL void JSC__SourceCode__fromString(JSC__SourceCode* arg0, const WTF__String* arg1, const JSC__SourceOrigin* arg2, WTF__String* arg3, unsigned char SourceType4); #pragma mark - JSC::JSFunction CPP_DECL bWTF__String JSC__JSFunction__calculatedDisplayName(JSC__JSFunction* arg0, JSC__VM* arg1); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, char* arg5); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSValue JSValue0, 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__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, char* arg3); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, char* arg4); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, char* arg5); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, char* arg6); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, char* arg4); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, char* arg3); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, const char* arg5); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const char* arg6); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const char* arg3); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const char* arg4); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, const char* arg5); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const char* arg6); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const char* arg4); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const char* arg3); CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* arg3, JSC__JSValue (* ArgFn4)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2)); -CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromSourceCode(JSC__JSGlobalObject* arg0, const char* arg1, uint16_t arg2, JSC__JSValue* arg3, uint16_t arg4, const JSC__SourceCode* arg5, JSC__SourceOrigin* arg6, JSC__JSObject** arg7); +CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromSourceCode(JSC__JSGlobalObject* arg0, const unsigned char* arg1, uint16_t arg2, JSC__JSValue* arg3, uint16_t arg4, const JSC__SourceCode* arg5, JSC__SourceOrigin* arg6, JSC__JSObject** arg7); CPP_DECL bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1); CPP_DECL bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1); @@ -335,7 +314,6 @@ CPP_DECL JSC__AsyncGeneratorPrototype* JSC__JSGlobalObject__asyncGeneratorProtot 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); @@ -352,7 +330,6 @@ CPP_DECL JSC__RegExpPrototype* JSC__JSGlobalObject__regExpPrototype(JSC__JSGloba 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); #pragma mark - WTF::URL @@ -362,7 +339,7 @@ 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 void WTF__URL__fromFileSystemPath(WTF__URL* arg0, bWTF__StringView arg1); 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); @@ -390,10 +367,10 @@ 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 const unsigned 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 void WTF__String__createWithoutCopyingFromPtr(WTF__String* arg0, unsigned char* arg1, size_t arg2); +CPP_DECL bool WTF__String__eqlSlice(WTF__String* arg0, const unsigned 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); @@ -403,6 +380,54 @@ 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 + +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 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__isCallable(JSC__JSValue JSValue0, JSC__VM* arg1); +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(unsigned 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); +CPP_DECL bWTF__String JSC__JSValue__toWTFString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); + #pragma mark - JSC::PropertyName CPP_DECL bool JSC__PropertyName__eqlToIdentifier(JSC__PropertyName* arg0, const JSC__Identifier* arg1); @@ -412,30 +437,30 @@ CPP_DECL const WTF__StringImpl* JSC__PropertyName__uid(JSC__PropertyName* arg0); #pragma mark - JSC::Exception -CPP_DECL 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, unsigned char StackCaptureAction2); #pragma mark - JSC::VM CPP_DECL JSC__JSLock* JSC__VM__apiLock(JSC__VM* arg0); -CPP_DECL JSC__VM* JSC__VM__create(char HeapType0); +CPP_DECL JSC__VM* JSC__VM__create(unsigned 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 bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const unsigned char* arg3, size_t arg4); #pragma mark - JSC::ThrowScope 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 bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned 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::CatchScope 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 bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, size_t arg3); CPP_DECL JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0); #pragma mark - JSC::CallFrame @@ -454,10 +479,9 @@ CPP_DECL JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame* ar 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 bool JSC__Identifier__eqlUTF8(const JSC__Identifier* arg0, const unsigned char* arg1, size_t arg2); +CPP_DECL bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM* arg0, const unsigned 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); @@ -470,7 +494,7 @@ CPP_DECL bWTF__String JSC__Identifier__toString(const JSC__Identifier* arg0); #pragma mark - WTF::StringImpl 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 const unsigned 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); @@ -481,8 +505,8 @@ 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 const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0); +CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (* ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2)); CPP_DECL 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); @@ -491,9 +515,46 @@ CPP_DECL size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl* a #pragma mark - WTF::StringView 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 const unsigned char* WTF__StringView__characters8(const WTF__StringView* arg0); +CPP_DECL void WTF__StringView__from8Bit(WTF__StringView* arg0, const unsigned char* arg1, size_t arg2); 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); + +#pragma mark - Zig::GlobalObject + +CPP_DECL JSC__JSGlobalObject* Zig__GlobalObject__create(JSC__VM* arg0, void* arg1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Zig__GlobalObject__createImportMetaProperties(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSModuleRecord* arg3, JSC__JSValue JSValue4); +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__JSInternalPromise* Zig__GlobalObject__fetch(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, JSC__JSValue JSValue4); +ZIG_DECL JSC__JSInternalPromise* 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__promiseRejectionTracker(JSC__JSGlobalObject* arg0, JSC__JSPromise* arg1, uint32_t JSPromiseRejectionOperation2); +ZIG_DECL JSC__JSValue Zig__GlobalObject__reportUncaughtException(JSC__JSGlobalObject* arg0, JSC__Exception* arg1); +ZIG_DECL bJSC__Identifier Zig__GlobalObject__resolve(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, const JSC__SourceOrigin* arg4); + +#endif + +#pragma mark - Zig::ConsoleClient + + +#ifdef __cplusplus + +ZIG_DECL void Zig__ConsoleClient__count(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__countReset(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__messageWithTypeAndLevel(void* arg0, uint32_t arg1, uint32_t arg2, JSC__JSGlobalObject* arg3, Inspector__ScriptArguments* arg4); +ZIG_DECL void Zig__ConsoleClient__profile(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__profileEnd(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__record(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2); +ZIG_DECL void Zig__ConsoleClient__recordEnd(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2); +ZIG_DECL void Zig__ConsoleClient__screenshot(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2); +ZIG_DECL void Zig__ConsoleClient__takeHeapSnapshot(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__time(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__timeEnd(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__timeLog(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3, Inspector__ScriptArguments* arg4); +ZIG_DECL void Zig__ConsoleClient__timeStamp(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2); + +#endif diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig new file mode 100644 index 000000000..9953c220c --- /dev/null +++ b/src/javascript/jsc/bindings/headers.zig @@ -0,0 +1,563 @@ +pub usingnamespace @import("std").zig.c_builtins; +pub const ptrdiff_t = c_long; +pub const wchar_t = c_int; +pub const max_align_t = c_longdouble; +pub const int_least8_t = i8; +pub const int_least16_t = i16; +pub const int_least32_t = i32; +pub const int_least64_t = i64; +pub const uint_least8_t = u8; +pub const uint_least16_t = u16; +pub const uint_least32_t = u32; +pub const uint_least64_t = u64; +pub const int_fast8_t = i8; +pub const int_fast16_t = i16; +pub const int_fast32_t = i32; +pub const int_fast64_t = i64; +pub const uint_fast8_t = u8; +pub const uint_fast16_t = u16; +pub const uint_fast32_t = u32; +pub const uint_fast64_t = u64; +pub const __int8_t = i8; +pub const __uint8_t = u8; +pub const __int16_t = c_short; +pub const __uint16_t = c_ushort; +pub const __int32_t = c_int; +pub const __uint32_t = c_uint; +pub const __int64_t = c_longlong; +pub const __uint64_t = c_ulonglong; +pub const __darwin_intptr_t = c_long; +pub const __darwin_natural_t = c_uint; +pub const __darwin_ct_rune_t = c_int; +pub const __mbstate_t = extern union { + __mbstate8: [128]u8, + _mbstateL: c_longlong, +}; +pub const __darwin_mbstate_t = __mbstate_t; +pub const __darwin_ptrdiff_t = c_long; +pub const __darwin_size_t = c_ulong; +pub const struct___va_list_tag = extern struct { + gp_offset: c_uint, + fp_offset: c_uint, + overflow_arg_area: ?*c_void, + reg_save_area: ?*c_void, +}; +pub const __builtin_va_list = [1]struct___va_list_tag; +pub const __darwin_va_list = __builtin_va_list; +pub const __darwin_wchar_t = c_int; +pub const __darwin_rune_t = __darwin_wchar_t; +pub const __darwin_wint_t = c_int; +pub const __darwin_clock_t = c_ulong; +pub const __darwin_socklen_t = __uint32_t; +pub const __darwin_ssize_t = c_long; +pub const __darwin_time_t = c_long; +pub const __darwin_blkcnt_t = __int64_t; +pub const __darwin_blksize_t = __int32_t; +pub const __darwin_dev_t = __int32_t; +pub const __darwin_fsblkcnt_t = c_uint; +pub const __darwin_fsfilcnt_t = c_uint; +pub const __darwin_gid_t = __uint32_t; +pub const __darwin_id_t = __uint32_t; +pub const __darwin_ino64_t = __uint64_t; +pub const __darwin_ino_t = __darwin_ino64_t; +pub const __darwin_mach_port_name_t = __darwin_natural_t; +pub const __darwin_mach_port_t = __darwin_mach_port_name_t; +pub const __darwin_mode_t = __uint16_t; +pub const __darwin_off_t = __int64_t; +pub const __darwin_pid_t = __int32_t; +pub const __darwin_sigset_t = __uint32_t; +pub const __darwin_suseconds_t = __int32_t; +pub const __darwin_uid_t = __uint32_t; +pub const __darwin_useconds_t = __uint32_t; +pub const __darwin_uuid_t = [16]u8; +pub const __darwin_uuid_string_t = [37]u8; +pub const struct___darwin_pthread_handler_rec = extern struct { + __routine: ?fn (?*c_void) callconv(.C) void, + __arg: ?*c_void, + __next: [*c]struct___darwin_pthread_handler_rec, +}; +pub const struct__opaque_pthread_attr_t = extern struct { + __sig: c_long, + __opaque: [56]u8, +}; +pub const struct__opaque_pthread_cond_t = extern struct { + __sig: c_long, + __opaque: [40]u8, +}; +pub const struct__opaque_pthread_condattr_t = extern struct { + __sig: c_long, + __opaque: [8]u8, +}; +pub const struct__opaque_pthread_mutex_t = extern struct { + __sig: c_long, + __opaque: [56]u8, +}; +pub const struct__opaque_pthread_mutexattr_t = extern struct { + __sig: c_long, + __opaque: [8]u8, +}; +pub const struct__opaque_pthread_once_t = extern struct { + __sig: c_long, + __opaque: [8]u8, +}; +pub const struct__opaque_pthread_rwlock_t = extern struct { + __sig: c_long, + __opaque: [192]u8, +}; +pub const struct__opaque_pthread_rwlockattr_t = extern struct { + __sig: c_long, + __opaque: [16]u8, +}; +pub const struct__opaque_pthread_t = extern struct { + __sig: c_long, + __cleanup_stack: [*c]struct___darwin_pthread_handler_rec, + __opaque: [8176]u8, +}; +pub const __darwin_pthread_attr_t = struct__opaque_pthread_attr_t; +pub const __darwin_pthread_cond_t = struct__opaque_pthread_cond_t; +pub const __darwin_pthread_condattr_t = struct__opaque_pthread_condattr_t; +pub const __darwin_pthread_key_t = c_ulong; +pub const __darwin_pthread_mutex_t = struct__opaque_pthread_mutex_t; +pub const __darwin_pthread_mutexattr_t = struct__opaque_pthread_mutexattr_t; +pub const __darwin_pthread_once_t = struct__opaque_pthread_once_t; +pub const __darwin_pthread_rwlock_t = struct__opaque_pthread_rwlock_t; +pub const __darwin_pthread_rwlockattr_t = struct__opaque_pthread_rwlockattr_t; +pub const __darwin_pthread_t = [*c]struct__opaque_pthread_t; +pub const u_int8_t = u8; +pub const u_int16_t = c_ushort; +pub const u_int32_t = c_uint; +pub const u_int64_t = c_ulonglong; +pub const register_t = i64; +pub const user_addr_t = u_int64_t; +pub const user_size_t = u_int64_t; +pub const user_ssize_t = i64; +pub const user_long_t = i64; +pub const user_ulong_t = u_int64_t; +pub const user_time_t = i64; +pub const user_off_t = i64; +pub const syscall_arg_t = u_int64_t; +pub const intmax_t = c_long; +pub const uintmax_t = c_ulong; +pub const struct_bJSC__JSModuleRecord = extern struct { + bytes: [216]u8, +}; +pub const bJSC__JSModuleRecord = struct_bJSC__JSModuleRecord; +pub const bJSC__JSModuleRecord_buf = [*c]u8; +pub const struct_bJSC__ThrowScope = extern struct { + bytes: [8]u8, +}; +pub const bJSC__ThrowScope = struct_bJSC__ThrowScope; +pub const bJSC__ThrowScope_buf = [*c]u8; +pub const struct_bJSC__PropertyName = extern struct { + bytes: [8]u8, +}; +pub const bJSC__PropertyName = struct_bJSC__PropertyName; +pub const bJSC__PropertyName_buf = [*c]u8; +pub const struct_bJSC__CallFrame = extern struct { + bytes: [8]u8, +}; +pub const bJSC__CallFrame = struct_bJSC__CallFrame; +pub const bJSC__CallFrame_buf = [*c]u8; +pub const struct_bJSC__CatchScope = extern struct { + bytes: [8]u8, +}; +pub const bJSC__CatchScope = struct_bJSC__CatchScope; +pub const bJSC__CatchScope_buf = [*c]u8; +pub const struct_bWTF__String = extern struct { + bytes: [8]u8, +}; +pub const bWTF__String = struct_bWTF__String; +pub const bWTF__String_buf = [*c]u8; +pub const struct_bWTF__StringView = extern struct { + bytes: [16]u8, +}; +pub const bWTF__StringView = struct_bWTF__StringView; +pub const bWTF__StringView_buf = [*c]u8; +pub const struct_bJSC__JSModuleLoader = extern struct { + bytes: [16]u8, +}; +pub const bJSC__JSModuleLoader = struct_bJSC__JSModuleLoader; +pub const bJSC__JSModuleLoader_buf = [*c]u8; +pub const struct_bJSC__Exception = extern struct { + bytes: [40]u8, +}; +pub const bJSC__Exception = struct_bJSC__Exception; +pub const bJSC__Exception_buf = [*c]u8; +pub const struct_bJSC__VM = extern struct { + bytes: [48824]u8, +}; +pub const bJSC__VM = struct_bJSC__VM; +pub const bJSC__VM_buf = [*c]u8; +pub const struct_bJSC__JSString = extern struct { + bytes: [16]u8, +}; +pub const bJSC__JSString = struct_bJSC__JSString; +pub const bJSC__JSString_buf = [*c]u8; +pub const struct_bJSC__SourceOrigin = extern struct { + bytes: [48]u8, +}; +pub const bJSC__SourceOrigin = struct_bJSC__SourceOrigin; +pub const bJSC__SourceOrigin_buf = [*c]u8; +pub const struct_bWTF__ExternalStringImpl = extern struct { + bytes: [32]u8, +}; +pub const bWTF__ExternalStringImpl = struct_bWTF__ExternalStringImpl; +pub const bWTF__ExternalStringImpl_buf = [*c]u8; +pub const struct_bWTF__StringImpl = extern struct { + bytes: [24]u8, +}; +pub const bWTF__StringImpl = struct_bWTF__StringImpl; +pub const bWTF__StringImpl_buf = [*c]u8; +pub const struct_bJSC__JSPromise = extern struct { + bytes: [32]u8, +}; +pub const bJSC__JSPromise = struct_bJSC__JSPromise; +pub const bJSC__JSPromise_buf = [*c]u8; +pub const struct_bJSC__SourceCode = extern struct { + bytes: [24]u8, +}; +pub const bJSC__SourceCode = struct_bJSC__SourceCode; +pub const bJSC__SourceCode_buf = [*c]u8; +pub const struct_bWTF__URL = extern struct { + bytes: [40]u8, +}; +pub const bWTF__URL = struct_bWTF__URL; +pub const bWTF__URL_buf = [*c]u8; +pub const struct_bJSC__JSFunction = extern struct { + bytes: [32]u8, +}; +pub const bJSC__JSFunction = struct_bJSC__JSFunction; +pub const bJSC__JSFunction_buf = [*c]u8; +pub const struct_bJSC__JSGlobalObject = extern struct { + bytes: [2400]u8, +}; +pub const bJSC__JSGlobalObject = struct_bJSC__JSGlobalObject; +pub const bJSC__JSGlobalObject_buf = [*c]u8; +pub const struct_bJSC__JSCell = extern struct { + bytes: [8]u8, +}; +pub const bJSC__JSCell = struct_bJSC__JSCell; +pub const bJSC__JSCell_buf = [*c]u8; +pub const struct_bJSC__JSLock = extern struct { + bytes: [40]u8, +}; +pub const bJSC__JSLock = struct_bJSC__JSLock; +pub const bJSC__JSLock_buf = [*c]u8; +pub const struct_bInspector__ScriptArguments = extern struct { + bytes: [32]u8, +}; +pub const bInspector__ScriptArguments = struct_bInspector__ScriptArguments; +pub const bInspector__ScriptArguments_buf = [*c]u8; +pub const struct_bJSC__JSInternalPromise = extern struct { + bytes: [32]u8, +}; +pub const bJSC__JSInternalPromise = struct_bJSC__JSInternalPromise; +pub const bJSC__JSInternalPromise_buf = [*c]u8; +pub const struct_bJSC__JSObject = extern struct { + bytes: [16]u8, +}; +pub const bJSC__JSObject = struct_bJSC__JSObject; +pub const bJSC__JSObject_buf = [*c]u8; +pub const struct_bJSC__Identifier = extern struct { + bytes: [8]u8, +}; +pub const bJSC__Identifier = struct_bJSC__Identifier; +pub const bJSC__Identifier_buf = [*c]u8; +pub const struct_JSC__RegExpPrototype = opaque {}; +pub const JSC__RegExpPrototype = struct_JSC__RegExpPrototype; +pub const struct_JSC__GeneratorPrototype = opaque {}; +pub const JSC__GeneratorPrototype = struct_JSC__GeneratorPrototype; +pub const struct_JSC__ArrayIteratorPrototype = opaque {}; +pub const JSC__ArrayIteratorPrototype = struct_JSC__ArrayIteratorPrototype; +pub const struct_JSC__StringPrototype = opaque {}; +pub const JSC__StringPrototype = struct_JSC__StringPrototype; +pub const WTF__StringView = bWTF__StringView; +pub const struct_JSC__JSPromisePrototype = opaque {}; +pub const JSC__JSPromisePrototype = struct_JSC__JSPromisePrototype; +pub const JSC__CatchScope = bJSC__CatchScope; +pub const JSC__ThrowScope = bJSC__ThrowScope; +pub const JSC__PropertyName = bJSC__PropertyName; +pub const JSC__JSObject = bJSC__JSObject; +pub const WTF__ExternalStringImpl = bWTF__ExternalStringImpl; +pub const struct_JSC__AsyncIteratorPrototype = opaque {}; +pub const JSC__AsyncIteratorPrototype = struct_JSC__AsyncIteratorPrototype; +pub const WTF__StringImpl = bWTF__StringImpl; +pub const JSC__JSLock = bJSC__JSLock; +pub const JSC__JSModuleLoader = bJSC__JSModuleLoader; +pub const JSC__VM = bJSC__VM; +pub const struct_JSC__AsyncGeneratorPrototype = opaque {}; +pub const JSC__AsyncGeneratorPrototype = struct_JSC__AsyncGeneratorPrototype; +pub const struct_JSC__AsyncGeneratorFunctionPrototype = opaque {}; +pub const JSC__AsyncGeneratorFunctionPrototype = struct_JSC__AsyncGeneratorFunctionPrototype; +pub const JSC__JSGlobalObject = bJSC__JSGlobalObject; +pub const JSC__JSFunction = bJSC__JSFunction; +pub const struct_JSC__ArrayPrototype = opaque {}; +pub const JSC__ArrayPrototype = struct_JSC__ArrayPrototype; +pub const struct_JSC__AsyncFunctionPrototype = opaque {}; +pub const JSC__AsyncFunctionPrototype = struct_JSC__AsyncFunctionPrototype; +pub const JSC__Identifier = bJSC__Identifier; +pub const JSC__JSPromise = bJSC__JSPromise; +pub const struct_JSC__SetIteratorPrototype = opaque {}; +pub const JSC__SetIteratorPrototype = struct_JSC__SetIteratorPrototype; +pub const JSC__SourceCode = bJSC__SourceCode; +pub const JSC__JSCell = bJSC__JSCell; +pub const struct_JSC__BigIntPrototype = opaque {}; +pub const JSC__BigIntPrototype = struct_JSC__BigIntPrototype; +pub const struct_JSC__GeneratorFunctionPrototype = opaque {}; +pub const JSC__GeneratorFunctionPrototype = struct_JSC__GeneratorFunctionPrototype; +pub const JSC__SourceOrigin = bJSC__SourceOrigin; +pub const JSC__JSModuleRecord = bJSC__JSModuleRecord; +pub const WTF__String = bWTF__String; +pub const WTF__URL = bWTF__URL; +pub const JSC__JSValue = i64; +pub const struct_JSC__IteratorPrototype = opaque {}; +pub const JSC__IteratorPrototype = struct_JSC__IteratorPrototype; +pub const JSC__JSInternalPromise = bJSC__JSInternalPromise; +pub const struct_JSC__FunctionPrototype = opaque {}; +pub const JSC__FunctionPrototype = struct_JSC__FunctionPrototype; +pub const Inspector__ScriptArguments = bInspector__ScriptArguments; +pub const JSC__Exception = bJSC__Exception; +pub const JSC__JSString = bJSC__JSString; +pub const struct_JSC__ObjectPrototype = opaque {}; +pub const JSC__ObjectPrototype = struct_JSC__ObjectPrototype; +pub const JSC__CallFrame = bJSC__CallFrame; +pub const struct_JSC__MapIteratorPrototype = opaque {}; +pub const JSC__MapIteratorPrototype = struct_JSC__MapIteratorPrototype; +pub extern fn JSC__JSObject__getArrayLength(arg0: [*c]JSC__JSObject) usize; +pub extern fn JSC__JSObject__getAtIndex(arg0: [*c]JSC__JSObject, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__PropertyName, arg3: u32) JSC__JSValue; +pub extern fn JSC__JSObject__putAtIndex(arg0: [*c]JSC__JSObject, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__PropertyName, arg3: u32) bool; +pub extern fn JSC__JSCell__getObject(arg0: [*c]JSC__JSCell) [*c]JSC__JSObject; +pub extern fn JSC__JSCell__getString(arg0: [*c]JSC__JSCell, arg1: [*c]JSC__JSGlobalObject) bWTF__String; +pub extern fn JSC__JSCell__getType(arg0: [*c]JSC__JSCell) u8; +pub extern fn JSC__JSString__createFromOwnedString(arg0: [*c]JSC__VM, arg1: [*c]const WTF__String) [*c]JSC__JSString; +pub extern fn JSC__JSString__createFromString(arg0: [*c]JSC__VM, arg1: [*c]const WTF__String) [*c]JSC__JSString; +pub extern fn JSC__JSString__eql(arg0: [*c]const JSC__JSString, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__JSString) bool; +pub extern fn JSC__JSString__is8Bit(arg0: [*c]const JSC__JSString) bool; +pub extern fn JSC__JSString__length(arg0: [*c]const JSC__JSString) usize; +pub extern fn JSC__JSString__toObject(arg0: [*c]JSC__JSString, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSString__value(arg0: bWTF__String, arg1: [*c]JSC__JSString, arg2: [*c]JSC__JSGlobalObject) void; +pub extern fn Inspector__ScriptArguments__argumentAt(arg0: [*c]const Inspector__ScriptArguments, arg1: usize) JSC__JSValue; +pub extern fn Inspector__ScriptArguments__argumentCount(arg0: [*c]const Inspector__ScriptArguments) usize; +pub extern fn Inspector__ScriptArguments__getFirstArgumentAsString(arg0: [*c]const Inspector__ScriptArguments) bWTF__String; +pub extern fn Inspector__ScriptArguments__isEqual(arg0: [*c]const Inspector__ScriptArguments, arg1: [*c]const Inspector__ScriptArguments) bool; +pub extern fn Inspector__ScriptArguments__release(arg0: [*c]Inspector__ScriptArguments) void; +pub extern fn JSC__JSModuleLoader__checkSyntax(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__SourceCode, arg2: bool) bool; +pub extern fn JSC__JSModuleLoader__evaluate(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__SourceCode, JSValue2: JSC__JSValue, arg3: [*c][*c]JSC__Exception) JSC__JSValue; +pub extern fn JSC__JSModuleLoader__importModule(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__Identifier) [*c]JSC__JSInternalPromise; +pub extern fn JSC__JSModuleLoader__linkAndEvaluateModule(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__Identifier) JSC__JSValue; +pub extern fn JSC__JSModuleLoader__loadAndEvaluateModule(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const WTF__String) [*c]JSC__JSInternalPromise; +pub extern fn JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__SourceCode) [*c]JSC__JSInternalPromise; +pub extern fn JSC__JSModuleRecord__sourceCode(arg0: [*c]JSC__JSModuleRecord) bJSC__SourceCode; +pub extern fn JSC__JSPromise__isHandled(arg0: [*c]const JSC__JSPromise, arg1: [*c]JSC__VM) bool; +pub extern fn JSC__JSPromise__reject(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void; +pub extern fn JSC__JSPromise__rejectAsHandled(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void; +pub extern fn JSC__JSPromise__rejectAsHandledException(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__Exception) void; +pub extern fn JSC__JSPromise__rejectedPromise(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSPromise; +pub extern fn JSC__JSPromise__rejectWithCaughtException(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, arg2: bJSC__ThrowScope) void; +pub extern fn JSC__JSPromise__resolve(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void; +pub extern fn JSC__JSPromise__resolvedPromise(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSPromise; +pub extern fn JSC__JSPromise__result(arg0: [*c]const JSC__JSPromise, arg1: [*c]JSC__VM) JSC__JSValue; +pub extern fn JSC__JSPromise__status(arg0: [*c]const JSC__JSPromise, arg1: [*c]JSC__VM) u32; +pub extern fn JSC__JSInternalPromise__create(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSInternalPromise; +pub extern fn JSC__JSInternalPromise__isHandled(arg0: [*c]const JSC__JSInternalPromise, arg1: [*c]JSC__VM) bool; +pub extern fn JSC__JSInternalPromise__reject(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void; +pub extern fn JSC__JSInternalPromise__rejectAsHandled(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void; +pub extern fn JSC__JSInternalPromise__rejectAsHandledException(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__Exception) void; +pub extern fn JSC__JSInternalPromise__rejectedPromise(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSInternalPromise; +pub extern fn JSC__JSInternalPromise__rejectWithCaughtException(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, arg2: bJSC__ThrowScope) void; +pub extern fn JSC__JSInternalPromise__resolve(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void; +pub extern fn JSC__JSInternalPromise__resolvedPromise(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSInternalPromise; +pub extern fn JSC__JSInternalPromise__result(arg0: [*c]const JSC__JSInternalPromise, arg1: [*c]JSC__VM) JSC__JSValue; +pub extern fn JSC__JSInternalPromise__status(arg0: [*c]const JSC__JSInternalPromise, arg1: [*c]JSC__VM) u32; +pub extern fn JSC__JSInternalPromise__then(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__JSFunction, arg3: [*c]JSC__JSFunction) [*c]JSC__JSInternalPromise; +pub extern fn JSC__SourceOrigin__fromURL(arg0: [*c]const WTF__URL) bJSC__SourceOrigin; +pub extern fn JSC__SourceCode__fromString(arg0: [*c]JSC__SourceCode, arg1: [*c]const WTF__String, arg2: [*c]const JSC__SourceOrigin, arg3: [*c]WTF__String, SourceType4: u8) void; +pub extern fn JSC__JSFunction__calculatedDisplayName(arg0: [*c]JSC__JSFunction, arg1: [*c]JSC__VM) bWTF__String; +pub extern fn JSC__JSFunction__callWithArguments(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__JSValue, arg3: usize, arg4: [*c][*c]JSC__Exception, arg5: [*c]const u8) JSC__JSValue; +pub extern fn JSC__JSFunction__callWithArgumentsAndThis(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: [*c]JSC__JSGlobalObject, arg3: [*c]JSC__JSValue, arg4: usize, arg5: [*c][*c]JSC__Exception, arg6: [*c]const u8) JSC__JSValue; +pub extern fn JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c][*c]JSC__Exception, arg3: [*c]const u8) JSC__JSValue; +pub extern fn JSC__JSFunction__callWithThis(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue, arg3: [*c][*c]JSC__Exception, arg4: [*c]const u8) JSC__JSValue; +pub extern fn JSC__JSFunction__constructWithArguments(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__JSValue, arg3: usize, arg4: [*c][*c]JSC__Exception, arg5: [*c]const u8) JSC__JSValue; +pub extern fn JSC__JSFunction__constructWithArgumentsAndNewTarget(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: [*c]JSC__JSGlobalObject, arg3: [*c]JSC__JSValue, arg4: usize, arg5: [*c][*c]JSC__Exception, arg6: [*c]const u8) JSC__JSValue; +pub extern fn JSC__JSFunction__constructWithNewTarget(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue, arg3: [*c][*c]JSC__Exception, arg4: [*c]const u8) JSC__JSValue; +pub extern fn JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c][*c]JSC__Exception, arg3: [*c]const u8) JSC__JSValue; +pub extern fn JSC__JSFunction__createFromNative(arg0: [*c]JSC__JSGlobalObject, arg1: u16, arg2: [*c]const WTF__String, arg3: ?*c_void, ArgFn4: ?fn (?*c_void, [*c]JSC__JSGlobalObject, [*c]JSC__CallFrame) callconv(.C) JSC__JSValue) [*c]JSC__JSFunction; +pub extern fn JSC__JSFunction__createFromSourceCode(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const u8, arg2: u16, arg3: [*c]JSC__JSValue, arg4: u16, arg5: [*c]const JSC__SourceCode, arg6: [*c]JSC__SourceOrigin, arg7: [*c][*c]JSC__JSObject) [*c]JSC__JSFunction; +pub extern fn JSC__JSFunction__displayName(arg0: [*c]JSC__JSFunction, arg1: [*c]JSC__VM) bWTF__String; +pub extern fn JSC__JSFunction__getName(arg0: [*c]JSC__JSFunction, arg1: [*c]JSC__VM) bWTF__String; +pub extern fn JSC__JSGlobalObject__arrayIteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__ArrayIteratorPrototype; +pub extern fn JSC__JSGlobalObject__arrayPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__ArrayPrototype; +pub extern fn JSC__JSGlobalObject__asyncFunctionPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__AsyncFunctionPrototype; +pub extern fn JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__AsyncGeneratorFunctionPrototype; +pub extern fn JSC__JSGlobalObject__asyncGeneratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__AsyncGeneratorPrototype; +pub extern fn JSC__JSGlobalObject__asyncIteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__AsyncIteratorPrototype; +pub extern fn JSC__JSGlobalObject__bigIntPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__BigIntPrototype; +pub extern fn JSC__JSGlobalObject__booleanPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSGlobalObject__datePrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSGlobalObject__errorPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSGlobalObject__functionPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__FunctionPrototype; +pub extern fn JSC__JSGlobalObject__generatorFunctionPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__GeneratorFunctionPrototype; +pub extern fn JSC__JSGlobalObject__generatorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__GeneratorPrototype; +pub extern fn JSC__JSGlobalObject__iteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__IteratorPrototype; +pub extern fn JSC__JSGlobalObject__jsSetPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSGlobalObject__mapIteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__MapIteratorPrototype; +pub extern fn JSC__JSGlobalObject__mapPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSGlobalObject__numberPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSGlobalObject__objectPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__ObjectPrototype; +pub extern fn JSC__JSGlobalObject__promisePrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__JSPromisePrototype; +pub extern fn JSC__JSGlobalObject__regExpPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__RegExpPrototype; +pub extern fn JSC__JSGlobalObject__setIteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__SetIteratorPrototype; +pub extern fn JSC__JSGlobalObject__stringPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__StringPrototype; +pub extern fn JSC__JSGlobalObject__symbolPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSGlobalObject__vm(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__VM; +pub extern fn WTF__URL__encodedPassword(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__encodedUser(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__fileSystemPath(arg0: [*c]WTF__URL) bWTF__String; +pub extern fn WTF__URL__fragmentIdentifier(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__fragmentIdentifierWithLeadingNumberSign(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__fromFileSystemPath(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void; +pub extern fn WTF__URL__fromString(arg0: bWTF__String, arg1: bWTF__String) bWTF__URL; +pub extern fn WTF__URL__host(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__hostAndPort(arg0: [*c]WTF__URL) bWTF__String; +pub extern fn WTF__URL__isEmpty(arg0: [*c]const WTF__URL) bool; +pub extern fn WTF__URL__isValid(arg0: [*c]const WTF__URL) bool; +pub extern fn WTF__URL__lastPathComponent(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__password(arg0: [*c]WTF__URL) bWTF__String; +pub extern fn WTF__URL__path(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__protocol(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__protocolHostAndPort(arg0: [*c]WTF__URL) bWTF__String; +pub extern fn WTF__URL__query(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__queryWithLeadingQuestionMark(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__setHost(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void; +pub extern fn WTF__URL__setHostAndPort(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void; +pub extern fn WTF__URL__setPassword(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void; +pub extern fn WTF__URL__setPath(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void; +pub extern fn WTF__URL__setProtocol(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void; +pub extern fn WTF__URL__setQuery(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void; +pub extern fn WTF__URL__setUser(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void; +pub extern fn WTF__URL__stringWithoutFragmentIdentifier(arg0: [*c]WTF__URL) bWTF__String; +pub extern fn WTF__URL__stringWithoutQueryOrFragmentIdentifier(arg0: [*c]WTF__URL) bWTF__StringView; +pub extern fn WTF__URL__truncatedForUseAsBase(arg0: [*c]WTF__URL) bWTF__URL; +pub extern fn WTF__URL__user(arg0: [*c]WTF__URL) bWTF__String; +pub extern fn WTF__String__characters16(arg0: [*c]WTF__String) [*c]const u16; +pub extern fn WTF__String__characters8(arg0: [*c]WTF__String) [*c]const u8; +pub extern fn WTF__String__createFromExternalString(arg0: bWTF__ExternalStringImpl) bWTF__String; +pub extern fn WTF__String__createWithoutCopyingFromPtr(arg0: [*c]WTF__String, arg1: [*c]u8, arg2: usize) void; +pub extern fn WTF__String__eqlSlice(arg0: [*c]WTF__String, arg1: [*c]const u8, arg2: usize) bool; +pub extern fn WTF__String__eqlString(arg0: [*c]WTF__String, arg1: [*c]const WTF__String) bool; +pub extern fn WTF__String__impl(arg0: [*c]WTF__String) [*c]const WTF__StringImpl; +pub extern fn WTF__String__is16Bit(arg0: [*c]WTF__String) bool; +pub extern fn WTF__String__is8Bit(arg0: [*c]WTF__String) bool; +pub extern fn WTF__String__isEmpty(arg0: [*c]WTF__String) bool; +pub extern fn WTF__String__isExternal(arg0: [*c]WTF__String) bool; +pub extern fn WTF__String__isStatic(arg0: [*c]WTF__String) bool; +pub extern fn WTF__String__length(arg0: [*c]WTF__String) usize; +pub extern fn JSC__JSValue__asCell(JSValue0: JSC__JSValue) [*c]JSC__JSCell; +pub extern fn JSC__JSValue__asNumber(JSValue0: JSC__JSValue) f64; +pub extern fn JSC__JSValue__asObject(JSValue0: JSC__JSValue) bJSC__JSObject; +pub extern fn JSC__JSValue__asString(JSValue0: JSC__JSValue) [*c]JSC__JSString; +pub extern fn JSC__JSValue__eqlCell(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSCell) bool; +pub extern fn JSC__JSValue__eqlValue(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) bool; +pub extern fn JSC__JSValue__getPrototype(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue; +pub extern fn JSC__JSValue__isAnyInt(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isBigInt(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isBigInt32(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isBoolean(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isCallable(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) bool; +pub extern fn JSC__JSValue__isCell(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isCustomGetterSetter(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isError(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isGetterSetter(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isHeapBigInt(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isInt32AsAnyInt(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isNull(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isNumber(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isObject(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isPrimitive(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isString(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isSymbol(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isUInt32AsAnyInt(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isUndefined(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isUndefinedOrNull(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__jsBoolean(arg0: bool) JSC__JSValue; +pub extern fn JSC__JSValue__jsDoubleNumber(arg0: f64) JSC__JSValue; +pub extern fn JSC__JSValue__jsNull(...) JSC__JSValue; +pub extern fn JSC__JSValue__jsNumberFromChar(arg0: u8) JSC__JSValue; +pub extern fn JSC__JSValue__jsNumberFromDouble(arg0: f64) JSC__JSValue; +pub extern fn JSC__JSValue__jsNumberFromInt32(arg0: i32) JSC__JSValue; +pub extern fn JSC__JSValue__jsNumberFromInt64(arg0: i64) JSC__JSValue; +pub extern fn JSC__JSValue__jsNumberFromU16(arg0: u16) JSC__JSValue; +pub extern fn JSC__JSValue__jsNumberFromUint64(arg0: u64) JSC__JSValue; +pub extern fn JSC__JSValue__jsTDZValue(...) JSC__JSValue; +pub extern fn JSC__JSValue__jsUndefined(...) JSC__JSValue; +pub extern fn JSC__JSValue__toObject(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject; +pub extern fn JSC__JSValue__toPropertyKey(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bJSC__Identifier; +pub extern fn JSC__JSValue__toPropertyKeyValue(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue; +pub extern fn JSC__JSValue__toString(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSString; +pub extern fn JSC__JSValue__toStringOrNull(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSString; +pub extern fn JSC__JSValue__toWTFString(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bWTF__String; +pub extern fn JSC__PropertyName__eqlToIdentifier(arg0: [*c]JSC__PropertyName, arg1: [*c]const JSC__Identifier) bool; +pub extern fn JSC__PropertyName__eqlToPropertyName(arg0: [*c]JSC__PropertyName, arg1: [*c]const JSC__PropertyName) bool; +pub extern fn JSC__PropertyName__publicName(arg0: [*c]JSC__PropertyName) [*c]const WTF__StringImpl; +pub extern fn JSC__PropertyName__uid(arg0: [*c]JSC__PropertyName) [*c]const WTF__StringImpl; +pub extern fn JSC__Exception__create(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]JSC__JSObject, StackCaptureAction2: u8) [*c]JSC__Exception; +pub extern fn JSC__VM__apiLock(arg0: [*c]JSC__VM) [*c]JSC__JSLock; +pub extern fn JSC__VM__create(HeapType0: u8) [*c]JSC__VM; +pub extern fn JSC__VM__deinit(arg0: [*c]JSC__VM, arg1: [*c]JSC__JSGlobalObject) void; +pub extern fn JSC__VM__drainMicrotasks(arg0: [*c]JSC__VM) void; +pub extern fn JSC__VM__executionForbidden(arg0: [*c]JSC__VM) bool; +pub extern fn JSC__VM__isEntered(arg0: [*c]JSC__VM) bool; +pub extern fn JSC__VM__setExecutionForbidden(arg0: [*c]JSC__VM, arg1: bool) void; +pub extern fn JSC__VM__throwError(arg0: [*c]JSC__VM, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__ThrowScope, arg3: [*c]const u8, arg4: usize) bool; +pub extern fn JSC__ThrowScope__clearException(arg0: [*c]JSC__ThrowScope) void; +pub extern fn JSC__ThrowScope__declare(arg0: [*c]JSC__VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__ThrowScope; +pub extern fn JSC__ThrowScope__exception(arg0: [*c]JSC__ThrowScope) [*c]JSC__Exception; +pub extern fn JSC__ThrowScope__release(arg0: [*c]JSC__ThrowScope) void; +pub extern fn JSC__CatchScope__clearException(arg0: [*c]JSC__CatchScope) void; +pub extern fn JSC__CatchScope__declare(arg0: [*c]JSC__VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__CatchScope; +pub extern fn JSC__CatchScope__exception(arg0: [*c]JSC__CatchScope) [*c]JSC__Exception; +pub extern fn JSC__CallFrame__argument(arg0: [*c]const JSC__CallFrame, arg1: u16) JSC__JSValue; +pub extern fn JSC__CallFrame__argumentsCount(arg0: [*c]const JSC__CallFrame) usize; +pub extern fn JSC__CallFrame__jsCallee(arg0: [*c]const JSC__CallFrame) [*c]JSC__JSObject; +pub extern fn JSC__CallFrame__newTarget(arg0: [*c]const JSC__CallFrame) JSC__JSValue; +pub extern fn JSC__CallFrame__setNewTarget(arg0: [*c]JSC__CallFrame, JSValue1: JSC__JSValue) JSC__JSValue; +pub extern fn JSC__CallFrame__setThisValue(arg0: [*c]JSC__CallFrame, JSValue1: JSC__JSValue) JSC__JSValue; +pub extern fn JSC__CallFrame__thisValue(arg0: [*c]const JSC__CallFrame) JSC__JSValue; +pub extern fn JSC__CallFrame__uncheckedArgument(arg0: [*c]const JSC__CallFrame, arg1: u16) JSC__JSValue; +pub extern fn JSC__Identifier__deinit(arg0: [*c]const JSC__Identifier) void; +pub extern fn JSC__Identifier__eqlIdent(arg0: [*c]const JSC__Identifier, arg1: [*c]const JSC__Identifier) bool; +pub extern fn JSC__Identifier__eqlStringImpl(arg0: [*c]const JSC__Identifier, arg1: [*c]const WTF__StringImpl) bool; +pub extern fn JSC__Identifier__eqlUTF8(arg0: [*c]const JSC__Identifier, arg1: [*c]const u8, arg2: usize) bool; +pub extern fn JSC__Identifier__fromSlice(arg0: [*c]JSC__VM, arg1: [*c]const u8, arg2: usize) bJSC__Identifier; +pub extern fn JSC__Identifier__fromString(arg0: [*c]JSC__VM, arg1: [*c]const WTF__String) bJSC__Identifier; +pub extern fn JSC__Identifier__isEmpty(arg0: [*c]const JSC__Identifier) bool; +pub extern fn JSC__Identifier__isNull(arg0: [*c]const JSC__Identifier) bool; +pub extern fn JSC__Identifier__isPrivateName(arg0: [*c]const JSC__Identifier) bool; +pub extern fn JSC__Identifier__isSymbol(arg0: [*c]const JSC__Identifier) bool; +pub extern fn JSC__Identifier__length(arg0: [*c]const JSC__Identifier) usize; +pub extern fn JSC__Identifier__neqlIdent(arg0: [*c]const JSC__Identifier, arg1: [*c]const JSC__Identifier) bool; +pub extern fn JSC__Identifier__neqlStringImpl(arg0: [*c]const JSC__Identifier, arg1: [*c]const WTF__StringImpl) bool; +pub extern fn JSC__Identifier__toString(arg0: [*c]const JSC__Identifier) bWTF__String; +pub extern fn WTF__StringImpl__characters16(arg0: [*c]const WTF__StringImpl) [*c]const u16; +pub extern fn WTF__StringImpl__characters8(arg0: [*c]const WTF__StringImpl) [*c]const u8; +pub extern fn WTF__StringImpl__is16Bit(arg0: [*c]const WTF__StringImpl) bool; +pub extern fn WTF__StringImpl__is8Bit(arg0: [*c]const WTF__StringImpl) bool; +pub extern fn WTF__StringImpl__isEmpty(arg0: [*c]const WTF__StringImpl) bool; +pub extern fn WTF__StringImpl__isExternal(arg0: [*c]const WTF__StringImpl) bool; +pub extern fn WTF__StringImpl__isStatic(arg0: [*c]const WTF__StringImpl) bool; +pub extern fn WTF__StringImpl__length(arg0: [*c]const WTF__StringImpl) usize; +pub extern fn WTF__ExternalStringImpl__characters16(arg0: [*c]const WTF__ExternalStringImpl) [*c]const u16; +pub extern fn WTF__ExternalStringImpl__characters8(arg0: [*c]const WTF__ExternalStringImpl) [*c]const u8; +pub extern fn WTF__ExternalStringImpl__create(arg0: [*c]const u8, arg1: usize, ArgFn2: ?fn (?*c_void, [*c]u8, usize) callconv(.C) void) bWTF__ExternalStringImpl; +pub extern fn WTF__ExternalStringImpl__is16Bit(arg0: [*c]const WTF__ExternalStringImpl) bool; +pub extern fn WTF__ExternalStringImpl__is8Bit(arg0: [*c]const WTF__ExternalStringImpl) bool; +pub extern fn WTF__ExternalStringImpl__isEmpty(arg0: [*c]const WTF__ExternalStringImpl) bool; +pub extern fn WTF__ExternalStringImpl__length(arg0: [*c]const WTF__ExternalStringImpl) usize; +pub extern fn WTF__StringView__characters16(arg0: [*c]const WTF__StringView) [*c]const u16; +pub extern fn WTF__StringView__characters8(arg0: [*c]const WTF__StringView) [*c]const u8; +pub extern fn WTF__StringView__from8Bit(arg0: [*c]WTF__StringView, arg1: [*c]const u8, arg2: usize) void; +pub extern fn WTF__StringView__is16Bit(arg0: [*c]const WTF__StringView) bool; +pub extern fn WTF__StringView__is8Bit(arg0: [*c]const WTF__StringView) bool; +pub extern fn WTF__StringView__isEmpty(arg0: [*c]const WTF__StringView) bool; +pub extern fn WTF__StringView__length(arg0: [*c]const WTF__StringView) usize; +pub extern fn Zig__GlobalObject__create(arg0: [*c]JSC__VM, arg1: ?*c_void) [*c]JSC__JSGlobalObject;
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/helpers.h b/src/javascript/jsc/bindings/helpers.h index c21f3fb3c..b1839d0b4 100644 --- a/src/javascript/jsc/bindings/helpers.h +++ b/src/javascript/jsc/bindings/helpers.h @@ -6,6 +6,7 @@ #include <JavaScriptCore/VM.h> + template<class CppType, typename ZigType> class Wrap { public: @@ -17,16 +18,20 @@ public: cpp = static_cast<CppType*>(static_cast<void*>(&zig)); }; + Wrap(ZigType* zig){ + cpp = static_cast<CppType*>(static_cast<void*>(&zig)); + }; + + Wrap(CppType _cpp){ - char* buffer = alignedBuffer(); - memcpy(buffer, std::move(reinterpret_cast<char*>(reinterpret_cast<void*>(&_cpp))), sizeof(CppType)); - cpp = reinterpret_cast<CppType*>(buffer); + auto buffer = alignedBuffer(); + cpp = new (buffer) CppType(_cpp); }; ~Wrap(){}; - char* alignedBuffer() { + unsigned char* alignedBuffer() { return result.bytes + alignof(CppType) - reinterpret_cast<intptr_t>(result.bytes) % alignof(CppType); } @@ -37,9 +42,17 @@ public: return *static_cast<ZigType*>(static_cast<void*>(&obj)); } - static ZigType wrap(CppType* obj) { - return *static_cast<ZigType*>(static_cast<void*>(obj)); + static CppType unwrap(ZigType obj) { + return *static_cast<CppType*>(static_cast<void*>(&obj)); } + + static CppType* unwrap(ZigType* obj) { + return static_cast<CppType*>(static_cast<void*>(obj)); + } + + + + }; diff --git a/src/javascript/jsc/bindings/jsc.zig b/src/javascript/jsc/bindings/jsc.zig new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/javascript/jsc/bindings/jsc.zig diff --git a/src/javascript/jsc/bindings/shared.zig b/src/javascript/jsc/bindings/shared.zig new file mode 100644 index 000000000..cb0a8a73f --- /dev/null +++ b/src/javascript/jsc/bindings/shared.zig @@ -0,0 +1,9 @@ +pub const std = @import("std"); +pub const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false; +pub const StaticExport = @import("./static_export.zig"); +pub const c_char = StaticExport.c_char; +pub usingnamespace @import("../../../global.zig"); + +pub fn zigCast(comptime Destination: type, value: anytype) *Destination { + return @ptrCast(*Destination, @alignCast(@alignOf(*Destination), value)); +} diff --git a/src/javascript/jsc/bindings/shimmer.zig b/src/javascript/jsc/bindings/shimmer.zig index 3f61dad96..558066884 100644 --- a/src/javascript/jsc/bindings/shimmer.zig +++ b/src/javascript/jsc/bindings/shimmer.zig @@ -1,56 +1,71 @@ const std = @import("std"); const StaticExport = @import("./static_export.zig"); const Sizes = @import("./sizes.zig"); -const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false; +pub const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false; pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comptime Parent: type) type { + const extern_count: usize = if (@hasDecl(Parent, "Extern")) Parent.Extern.len else 0; + 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; - }; - } + // fn toCppType(comptime FromType: type) type { + // var NewReturnType = FromType; + + // if (NewReturnType == c_void) { + // return FromType; + // } + + // var ReturnTypeInfo: std.builtin.TypeInfo = @typeInfo(FromType); + + // if (ReturnTypeInfo == .Pointer and NewReturnType != *c_void) { + // NewReturnType = ReturnTypeInfo.Pointer.child; + // ReturnTypeInfo = @typeInfo(NewReturnType); + // } + + // switch (ReturnTypeInfo) { + // .Union, + // .Struct, + // .Enum, + // => { + // if (@hasDecl(ReturnTypeInfo., "Type")) { + // return NewReturnType; + // } + // }, + // else => {}, + // } + + // return FromType; + // } pub const align_of_symbol = std.fmt.comptimePrint("{s}__{s}_object_align_", .{ namespace, name }); pub const size_of_symbol = std.fmt.comptimePrint("{s}__{s}_object_size_", .{ namespace, name }); + const align_symbol = std.fmt.comptimePrint("{s}__{s}_align", .{ namespace, name }); + pub const byte_size = brk: { const identifier = std.fmt.comptimePrint("{s}__{s}", .{ namespace, name }); - const align_symbol = std.fmt.comptimePrint("{s}__{s}_align", .{ namespace, name }); if (@hasDecl(Sizes, identifier)) { - break :brk @field(Sizes, identifier); //+ @field(Sizes, align_symbol); + break :brk @field(Sizes, identifier); + } else { + break :brk 0; + } + }; + + pub const align_size = brk: { + const identifier = std.fmt.comptimePrint("{s}__{s}_align", .{ namespace, name }); + if (@hasDecl(Sizes, identifier)) { + break :brk @field(Sizes, identifier); } else { break :brk 0; } }; pub const Bytes = [byte_size]u8; + pub const Return = struct { + pub const Type = Parent; + pub const is_return = true; + }; + pub inline fn getConvertibleType(comptime ZigType: type) type { if (@typeInfo(ZigType) == .Struct) { const Struct: std.builtin.TypeInfo.Struct = ChildType.Struct; @@ -72,17 +87,6 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp 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 }); } @@ -114,34 +118,6 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp }; } - 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); @@ -150,37 +126,7 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp }) { 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), - ); - } + } else {} } }; } diff --git a/src/javascript/jsc/bindings/sizes.zig b/src/javascript/jsc/bindings/sizes.zig index ddee597de..2b5c4d593 100644 --- a/src/javascript/jsc/bindings/sizes.zig +++ b/src/javascript/jsc/bindings/sizes.zig @@ -1,4 +1,4 @@ -// Auto-generated by src/javascript/jsc/headergen/sizegen.cpp at 2021-07-23 23:37:1627108668. +// Auto-generated by src/javascript/jsc/headergen/sizegen.cpp at 2021-07-26 01:37:1627288660. // 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. @@ -8,7 +8,7 @@ // Failure to do so will lead to undefined behavior and probably some frustrated people. // --- Regenerate this: --- // 1. "make jsc-bindings-headers" -// 2. "make sizegen" +// 2. "makpe sizegen" // 3. "make jsc-bindings-headers" // ------------------------ // You can verify the numbers written in this file at runtime via the `extern`d types @@ -21,13 +21,11 @@ pub const JSC__JSString = 16; pub const JSC__JSString_align = 8; pub const Inspector__ScriptArguments = 32; pub const Inspector__ScriptArguments_align = 8; -pub const Zig__GlobalObject = 2464; +pub const Zig__GlobalObject = 2400; pub const Zig__GlobalObject_align = 8; -pub const Wundle__DefaultGlobal = 2464; -pub const Wundle__DefaultGlobal_align = 8; pub const JSC__JSModuleLoader = 16; pub const JSC__JSModuleLoader_align = 8; -pub const JSC__JSModuleRecord = 344; +pub const JSC__JSModuleRecord = 216; pub const JSC__JSModuleRecord_align = 8; pub const JSC__JSPromise = 32; pub const JSC__JSPromise_align = 8; @@ -39,7 +37,7 @@ pub const JSC__SourceCode = 24; pub const JSC__SourceCode_align = 8; pub const JSC__JSFunction = 32; pub const JSC__JSFunction_align = 8; -pub const JSC__JSGlobalObject = 2464; +pub const JSC__JSGlobalObject = 2400; pub const JSC__JSGlobalObject_align = 8; pub const WTF__URL = 40; pub const WTF__URL_align = 8; @@ -51,7 +49,7 @@ pub const JSC__PropertyName = 8; pub const JSC__PropertyName_align = 8; pub const JSC__Exception = 40; pub const JSC__Exception_align = 8; -pub const JSC__VM = 49080; +pub const JSC__VM = 48824; pub const JSC__VM_align = 8; pub const JSC__ThrowScope = 8; pub const JSC__ThrowScope_align = 8; @@ -65,5 +63,5 @@ pub const WTF__StringImpl = 24; pub const WTF__StringImpl_align = 8; pub const WTF__ExternalStringImpl = 32; pub const WTF__ExternalStringImpl_align = 8; -pub const WTF__StringView = 24; +pub const WTF__StringView = 16; pub const WTF__StringView_align = 8; diff --git a/src/javascript/jsc/bindings/static_export.zig b/src/javascript/jsc/bindings/static_export.zig index 8c30587a0..83707b984 100644 --- a/src/javascript/jsc/bindings/static_export.zig +++ b/src/javascript/jsc/bindings/static_export.zig @@ -11,3 +11,5 @@ pub fn Decl(comptime this: *const @This()) std.builtin.TypeInfo.Declaration { pub fn wrappedName(comptime this: *const @This()) []const u8 { return comptime "wrap" ++ this.symbol_name; } + +pub const c_char = enum(u8) { _ }; diff --git a/src/javascript/jsc/bindings/wrapper.zig b/src/javascript/jsc/bindings/wrapper.zig new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/javascript/jsc/bindings/wrapper.zig diff --git a/src/main.zig b/src/main.zig index c54d2cf7f..8c19fb3f5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -33,10 +33,8 @@ pub fn main() anyerror!void { var stdout = std.io.getStdOut(); // var stdout = std.io.bufferedWriter(stdout_file.writer()); var stderr = std.io.getStdErr(); - // var stderr = std.io.bufferedWriter(stderr_file.writer()); var output_source = Output.Source.init(stdout, stderr); - // defer stdout.flush() catch {}; - // defer stderr.flush() catch {}; + Output.Source.set(&output_source); Output.enable_ansi_colors = stderr.isTty(); defer Output.flush(); diff --git a/src/main_javascript.zig b/src/main_javascript.zig index b6aa7da08..06b9c86ce 100644 --- a/src/main_javascript.zig +++ b/src/main_javascript.zig @@ -19,7 +19,7 @@ const clap = @import("clap"); const bundler = @import("bundler.zig"); const fs = @import("fs.zig"); const NodeModuleBundle = @import("./node_module_bundle.zig").NodeModuleBundle; -const js_bindings = @import("javascript/jsc/bindings/bindings.zig"); +const js = @import("javascript/jsc/bindings/bindings.zig"); const allocators = @import("allocators.zig"); pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { if (MainPanicHandler.Singleton) |singleton| { @@ -28,6 +28,9 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) nore panicky.default_panic(msg, error_return_trace); } } + +pub const JSGlobalObject = struct {}; + const constStrToU8 = allocators.constStrToU8; pub fn main() anyerror!void { // The memory allocator makes a massive difference. @@ -359,6 +362,25 @@ pub const Cli = struct { Output.printError("\nJSON printing took: {d}\n", .{std.time.nanoTimestamp() - print_start}); } pub fn startTransform(allocator: *std.mem.Allocator, args: Api.TransformOptions, log: *logger.Log) anyerror!void {} + const StringS = struct { + pub const src = "console.log('hi'); \"HELLO\";"; + }; + pub fn demo(allocator: *std.mem.Allocator) !void { + var console = try js.ZigConsoleClient.init(allocator); + + var global: *js.JSGlobalObject = js.ZigGlobalObject.create(null, console); + var exception: ?*js.Exception = null; + const source_string = js.String.createWithoutCopying(StringS.src); + const slice = js.StringView.fromSlice("/Users/jarredsumner/Desktop/hi.js"); + var url = std.mem.zeroes(js.URL); + js.URL.fromFileSystemPath(&url, slice); + // const origin = js.SourceOrigin.fromURL(&url); + var source_code = std.mem.zeroes(js.SourceCode); + js.SourceCode.fromString(&source_code, &source_string, null, null, js.SourceType.Module); + var result = js.JSModuleLoader.evaluate(global, &source_code, js.JSValue.jsUndefined(), &exception); + if (exception) |except| {} + } + pub fn start(allocator: *std.mem.Allocator, stdout: anytype, stderr: anytype) anyerror!void { const start_time = std.time.nanoTimestamp(); var log = logger.Log.init(allocator); @@ -379,7 +401,6 @@ pub const Cli = struct { // ); // var exception: js.JSValueRef = null; // var result = try js.Module.loadFromResolveResult(vm, vm.global.ctx, resolved_entry_point, &exception); -js_bindings.ZigConsoleClient - js_bindings.ZigGlobalObject.create(vm: ?*VM, console: *ZigConsoleClient) + try demo(allocator); } }; |