diff options
-rw-r--r-- | src/javascript/jsc/bindings/bindings.cpp | 346 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/bindings.zig | 315 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/header-gen.zig | 14 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers-cpp.h | 48 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers.h | 104 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/sizes.zig | 35 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/static_export.zig | 1 | ||||
-rw-r--r-- | src/javascript/jsc/headergen/sizegen.cpp | 3 | ||||
-rw-r--r-- | src/javascript/jsc/javascript.zig | 1 |
9 files changed, 732 insertions, 135 deletions
diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp index 1cf55cff8..7120285c1 100644 --- a/src/javascript/jsc/bindings/bindings.cpp +++ b/src/javascript/jsc/bindings/bindings.cpp @@ -16,6 +16,54 @@ #include <JavaScriptCore/VM.h> #include <JavaScriptCore/WasmFaultSignalHandler.h> #include <wtf/text/StringCommon.h> +#include <JavaScriptCore/FunctionConstructor.h> +#include <JavaScriptCore/JSNativeStdFunction.h> +#include <JavaScriptCore/Completion.h> +#include <JavaScriptCore/JSModuleRecord.h> +#include <JavaScriptCore/ParserError.h> +#include <JavaScriptCore/JSString.h> +#include <JavaScriptCore/JSMap.h> +#include <JavaScriptCore/JSSet.h> + +template<class CppType, typename ZigType> +class Wrap { +public: + Wrap(){ + }; + + Wrap(ZigType zig){ + result = 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); + }; + + + ~Wrap(){}; + + char* alignedBuffer() { + return result.bytes + alignof(CppType) - reinterpret_cast<intptr_t>(result.bytes) % alignof(CppType); + } + + ZigType result; + CppType* cpp; + + static ZigType wrap(CppType obj) { + return *static_cast<ZigType*>(static_cast<void*>(&obj)); + } + + static ZigType wrap(CppType* obj) { + return *static_cast<ZigType*>(static_cast<void*>(obj)); + } +}; + + + + template<class To, class From> To cast(From v) @@ -29,8 +77,297 @@ To ccast(From v) return *static_cast<const To*>(static_cast<const void*>(v)); } +typedef JSC__JSValue (* NativeCallbackFunction)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2); + +static const JSC::ArgList makeArgs(JSC__JSValue* v, size_t count) { + JSC::MarkedArgumentBuffer args = JSC::MarkedArgumentBuffer(); + args.ensureCapacity(count); + for (size_t i = 0; i < count; ++i) { + args.append(JSC::JSValue::decode(v[i])); + } + + return JSC::ArgList(args); +} + + extern "C" { +// #pragma mark - JSC::PropertyNameArray + +// CPP_DECL size_t JSC__PropertyNameArray__length(JSC__PropertyNameArray* arg0); +// CPP_DECL const JSC__PropertyName* JSC__PropertyNameArray__next(JSC__PropertyNameArray* arg0, size_t arg1); +// CPP_DECL void JSC__PropertyNameArray__release(JSC__PropertyNameArray* arg0); + +#pragma mark - JSC::JSCell + +JSC__JSObject* JSC__JSCell__getObject(JSC__JSCell* arg0) { + return arg0->getObject(); +} +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) { + return arg0->type(); +} + +#pragma mark - JSC::JSString + +JSC__JSString* JSC__JSString__createFromOwnedString(JSC__VM* arg0, const WTF__String* arg1) { + return JSC::jsOwnedString(reinterpret_cast<JSC__VM&>(arg0), reinterpret_cast<const WTF__String&>(arg1)); +} +JSC__JSString* JSC__JSString__createFromString(JSC__VM* arg0, const WTF__String* arg1) { + return JSC::jsString(reinterpret_cast<JSC__VM&>(arg0), reinterpret_cast<const WTF__String&>(arg1)); +} +bool JSC__JSString__eql(const JSC__JSString* arg0, JSC__JSGlobalObject* obj, JSC__JSString* arg2) { + return arg0->equal(obj, arg2); +} +bool JSC__JSString__is8Bit(const JSC__JSString* arg0) { + return arg0->is8Bit(); +}; +size_t JSC__JSString__length(const JSC__JSString* arg0) { + return arg0->length(); +} +JSC__JSObject* JSC__JSString__toObject(JSC__JSString* arg0, JSC__JSGlobalObject* arg1) { + return arg0->toObject(arg1); +} +bWTF__String JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1) { + auto wrap = Wrap<WTF__String, bWTF__String>::wrap(arg0->value(arg1)); + return wrap.result; +} + +#pragma mark - JSC::JSModuleLoader + +// JSC__JSValue JSC__JSModuleLoader__dependencyKeysIfEvaluated(JSC__JSModuleLoader* arg0, JSC__JSGlobalObject* arg1, JSC__JSModuleRecord* arg2); + +bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1, bool arg2) { + JSC::ParserError error; + bool result = false; + if (arg2) { + result = JSC::checkModuleSyntax(arg0, reinterpret_cast<const JSC::SourceCode&>(arg1), error); + } else { + result = JSC::checkSyntax(reinterpret_cast<JSC__VM&>(arg0->vm()), reinterpret_cast<const JSC::SourceCode&>(arg1), error); + } + + return result; + +} +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)); + *arg3 = returnedException.get(); + return 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{}); +} +JSC__JSValue JSC__JSModuleLoader__linkAndEvaluateModule(JSC__JSGlobalObject* arg0, const JSC__Identifier* arg1) { + return JSC::JSValue::encode(JSC::linkAndEvaluateModule(arg0, reinterpret_cast<const JSC::Identifier&>(arg1), JSC::JSValue{})); +} +JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModule(JSC__JSGlobalObject* arg0, const WTF__String* arg1) { + return JSC::loadAndEvaluateModule(arg0, reinterpret_cast<const WTF__String&>(arg1), JSC::JSValue{}, JSC::JSValue{}); +} +JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1) { + return JSC::loadAndEvaluateModule(arg0, reinterpret_cast<const JSC__SourceCode&>(arg1), JSC::JSValue{}); +} + +#pragma mark - JSC::JSModuleRecord + +bJSC__SourceCode JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord* arg0) { + Wrap<JSC::SourceCode, bJSC__SourceCode> wrapped = Wrap<JSC::SourceCode, bJSC__SourceCode>(arg0->sourceCode()); + return wrapped.result; +} + + +#pragma mark - JSC::JSPromise + +void JSC__JSPromise__reject(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2) { + arg0->reject(arg1, JSC::JSValue::decode(JSValue2)); +} +void JSC__JSPromise__rejectAsHandled(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2) { + arg0->rejectAsHandled(arg1, JSC::JSValue::decode(JSValue2)); +} +void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2) { + arg0->rejectAsHandled(arg1,arg2); +} +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); + + arg0->rejectWithCaughtException(arg1, *wrapped.cpp); +} +void JSC__JSPromise__resolve(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2) { + arg0->resolve(arg1, JSC::JSValue::decode(JSValue2)); +} +JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1) { + return JSC::JSPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1)); +} + +JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise* arg0, JSC__VM* arg1) { + return JSC::JSValue::encode(arg0->result(reinterpret_cast<JSC::VM&>(arg1))); +} +uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1) { + switch (arg0->status(reinterpret_cast<JSC::VM&>(arg1))) { + case JSC::JSPromise::Status::Pending: return 0; + case JSC::JSPromise::Status::Fulfilled: return 1; + case JSC::JSPromise::Status::Rejected: return 2; + default: return 255; + } +} +bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1) { + return arg0->isHandled(reinterpret_cast<JSC::VM&>(arg1)); +} + + +// bool JSC__JSPromise__isInternal(JSC__JSPromise* arg0, JSC__VM* arg1) { +// return arg0->inf +// } + + +#pragma mark - JSC::SourceOrigin + +bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL* arg0) { + + auto wrap = Wrap<JSC::SourceOrigin, bJSC__SourceOrigin>(JSC::SourceOrigin(reinterpret_cast<const WTF::URL&>(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 + )); + + return wrap.result; +} + + +#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) { + 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) { + 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) { + 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) { + 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) { + 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) { + 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) { + 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) { + return JSC::JSValue::encode(JSC::construct(arg1, JSC::JSValue::decode(JSValue0), JSC::ArgList(), arg3)); +} + +JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* ctx, NativeCallbackFunction callback) { + return JSC::JSNativeStdFunction::create( + reinterpret_cast<JSC::VM&>(arg0->vm()), + arg0, + arg1, + arg2 != nullptr ? *arg2 : WTF::String(), + [ctx, callback](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> JSC::EncodedJSValue { + return callback(ctx, globalObject, callFrame); + + }); +} +// JSC__JSFunction* JSC__JSFunction__createFromSourceCode( +// JSC__JSGlobalObject* arg0, +// const char* arg1, +// uint16_t arg2, +// JSC__JSValue arg3, +// uint16_t arg4, +// const JSC__SourceCode* source, +// JSC__SourceOrigin* origin, +// JSC__JSObject** exception +// ) { +// JSC::VM& vm = reinterpret_cast<JSC::VM&>(arg0->vm()); +// JSC::Identifier functionName = JSC::Identifier::fromString(vm, arg2 && arg1 != nullptr ? WTF::StringImpl(static_cast<const LChar*>(arg1), arg2) : vm->propertyNames->anonymous.impl()); + +// JSC::FunctionExecutable* function = JSC::FunctionExecutable::fromGlobalCode( +// functionName, +// arg0, +// source, +// exception, +// 0, +// nullptr, +// ); + + + +// } + +bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1) { + auto wrap = Wrap<WTF::String, bWTF__String>(arg0->displayName(reinterpret_cast<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))); + return wrap.result; +}; +bWTF__String JSC__JSFunction__calculatedDisplayName(JSC__JSFunction* arg0, JSC__VM* arg1) { + auto wrap = Wrap<WTF::String, bWTF__String>(arg0->calculatedDisplayName(reinterpret_cast<JSC::VM&>(arg1))); + return wrap.result; +}; +#pragma mark - JSC::JSGlobalObject + +JSC__ArrayIteratorPrototype* JSC__JSGlobalObject__arrayIteratorPrototype(JSC__JSGlobalObject* arg0) { return arg0->arrayIteratorPrototype(); }; +JSC__ArrayPrototype* JSC__JSGlobalObject__arrayPrototype(JSC__JSGlobalObject* arg0) { return arg0->arrayPrototype(); }; +JSC__AsyncFunctionPrototype* JSC__JSGlobalObject__asyncFunctionPrototype(JSC__JSGlobalObject* arg0) { return arg0->asyncFunctionPrototype(); }; +JSC__AsyncGeneratorFunctionPrototype* JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC__JSGlobalObject* arg0) { return arg0->asyncGeneratorFunctionPrototype(); }; +JSC__AsyncGeneratorPrototype* JSC__JSGlobalObject__asyncGeneratorPrototype(JSC__JSGlobalObject* arg0) { return arg0->asyncGeneratorPrototype(); }; +JSC__AsyncIteratorPrototype* JSC__JSGlobalObject__asyncIteratorPrototype(JSC__JSGlobalObject* arg0) { return arg0->asyncIteratorPrototype(); }; +JSC__BigIntPrototype* JSC__JSGlobalObject__bigIntPrototype(JSC__JSGlobalObject* arg0) { return arg0->bigIntPrototype(); }; +JSC__JSObject* JSC__JSGlobalObject__booleanPrototype(JSC__JSGlobalObject* arg0) { return arg0->booleanPrototype(); }; +JSC__JSObject* JSC__JSGlobalObject__datePrototype(JSC__JSGlobalObject* arg0) { return arg0->datePrototype(); }; +JSC__JSObject* JSC__JSGlobalObject__errorPrototype(JSC__JSGlobalObject* arg0) { return arg0->errorPrototype(); }; +JSC__FunctionPrototype* JSC__JSGlobalObject__functionPrototype(JSC__JSGlobalObject* arg0) { return arg0->functionPrototype(); }; +JSC__GeneratorFunctionPrototype* JSC__JSGlobalObject__generatorFunctionPrototype(JSC__JSGlobalObject* arg0) { return arg0->generatorFunctionPrototype(); }; +JSC__GeneratorPrototype* JSC__JSGlobalObject__generatorPrototype(JSC__JSGlobalObject* arg0) { return arg0->generatorPrototype(); }; +JSC__IteratorPrototype* JSC__JSGlobalObject__iteratorPrototype(JSC__JSGlobalObject* arg0) { return arg0->iteratorPrototype(); }; +JSC__JSObject* JSC__JSGlobalObject__jsSetPrototype(JSC__JSGlobalObject* arg0) { return arg0->jsSetPrototype(); }; +JSC__MapIteratorPrototype* JSC__JSGlobalObject__mapIteratorPrototype(JSC__JSGlobalObject* arg0) { return arg0->mapIteratorPrototype(); }; +JSC__JSObject* JSC__JSGlobalObject__mapPrototype(JSC__JSGlobalObject* arg0) { return arg0->mapPrototype(); }; +JSC__JSObject* JSC__JSGlobalObject__numberPrototype(JSC__JSGlobalObject* arg0) { return arg0->numberPrototype(); }; +JSC__ObjectPrototype* JSC__JSGlobalObject__objectPrototype(JSC__JSGlobalObject* arg0) { return arg0->objectPrototype(); }; +JSC__JSPromisePrototype* JSC__JSGlobalObject__promisePrototype(JSC__JSGlobalObject* arg0) { return arg0->promisePrototype(); }; +JSC__RegExpPrototype* JSC__JSGlobalObject__regExpPrototype(JSC__JSGlobalObject* arg0) { return arg0->regExpPrototype(); }; +JSC__SetIteratorPrototype* JSC__JSGlobalObject__setIteratorPrototype(JSC__JSGlobalObject* arg0) { return arg0->setIteratorPrototype(); }; +JSC__StringPrototype* JSC__JSGlobalObject__stringPrototype(JSC__JSGlobalObject* arg0) { return arg0->stringPrototype(); }; +JSC__JSObject* JSC__JSGlobalObject__symbolPrototype(JSC__JSGlobalObject* arg0) { return arg0->symbolPrototype(); }; + +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__throwError(JSC__JSGlobalObject* arg0, JSC__JSObject* arg1) {}; + + #pragma mark - JSC::JSValue JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0) { @@ -184,8 +521,9 @@ void JSC__ThrowScope__clearException(JSC__ThrowScope* arg0) { arg0->clearException(); }; bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, char* arg1, char* arg2, size_t arg3) { - JSC::ThrowScope scope = JSC::ThrowScope(reinterpret_cast<JSC::VM&>(arg0)); - return cast<bJSC__ThrowScope>(&scope); + 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; }; JSC__Exception* JSC__ThrowScope__exception(JSC__ThrowScope* arg0) { return arg0->exception(); @@ -449,8 +787,8 @@ bWTF__String WTF__URL__password(WTF__URL* arg0) { return cast<bWTF__String>(&result); }; bWTF__StringView WTF__URL__path(WTF__URL* arg0) { - auto result = arg0->path(); - return cast<bWTF__StringView>(&result); + auto wrap = Wrap<WTF::StringView, bWTF__StringView>(arg0->path()); + return wrap.result; }; bWTF__StringView WTF__URL__protocol(WTF__URL* arg0) { auto result = arg0->protocol(); diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index aaba05ea2..c9c0b100d 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -42,12 +42,13 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp break :brk 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 }); 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); + break :brk @field(Sizes, identifier); //+ @field(Sizes, align_symbol); } else { break :brk 0; } @@ -225,28 +226,61 @@ pub const JSObject = packed struct { }; }; -pub const PropertyNameArray = packed struct { - pub const shim = Shimmer("JSC", "PropertyNameArray", @This()); - bytes: shim.Bytes, - const cppFn = shim.cppFn; - pub const include = "<JavaScriptCore/PropertyNameArray.h>"; - pub const name = "JSC::PropertyNameArray"; - pub const namespace = "JSC"; - - pub fn length(this: *PropertyNameArray) usize { - return cppFn("length", .{this}); - } - - pub fn next(this: *PropertyNameArray, i: usize) ?*const PropertyName { - return cppFn("next", .{ this, i }); - } - - pub fn release(this: *PropertyNameArray) void { - return cppFn("release", .{this}); - } +// pub const JSMap = packed struct { +// pub const shim = Shimmer("JSC", "JSMap", @This()); +// bytes: shim.Bytes, +// const cppFn = shim.cppFn; +// pub const include = "<JavaScriptCore/JSMap.h>"; +// pub const name = "JSC::JSMap"; +// pub const namespace = "JSC"; - pub const Extern = [_][]const u8{ "length", "release", "next" }; -}; +// 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 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 { +// return cppFn("clear", .{ +// this, +// 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 { +// return cppFn("forEach", .{ +// this, +// 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 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 create(globalThis: *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 const Extern = [_][]const u8{ "get", "set", "clear", "delete", "has", "create", "size", "forEach", "clone" }; +// }; pub const JSCell = packed struct { pub const shim = Shimmer("JSC", "JSCell", @This()); @@ -262,7 +296,7 @@ pub const JSCell = packed struct { return shim.cppFn("getObject", .{this}); } - pub fn getString(this: *JSCell, globalObject: *JSGlobalObject) *String { + pub fn getString(this: *JSCell, globalObject: *JSGlobalObject) String { return shim.cppFn("getString", .{ this, globalObject }); } @@ -283,15 +317,15 @@ pub const JSString = packed struct { pub const name = "JSC::JSString"; pub const namespace = "JSC"; - pub fn getObject(this: *JSString) *JSObject { - return shim.cppFn("getObject", .{this}); + pub fn toObject(this: *JSString, global: *JSGlobalObject) ?*JSObject { + return shim.cppFn("toObject", .{ this, global }); } - pub fn eql(this: *const JSString, other: *const JSString) bool { - return shim.cppFn("eql", .{ this, other }); + pub fn eql(this: *const JSString, global: *JSGlobalObject, other: *JSString) bool { + return shim.cppFn("eql", .{ this, global, other }); } - pub fn value(this: *JSString, globalObject: *JSGlobalObject) *String { + pub fn value(this: *JSString, globalObject: *JSGlobalObject) String { return shim.cppFn("value", .{ this, globalObject }); } @@ -307,19 +341,19 @@ pub const JSString = packed struct { }); } - pub fn createFromOwnedString(vm: *VM, str: *const StringImpl) bool { + pub fn createFromOwnedString(vm: *VM, str: *const String) *JSString { return shim.cppFn("createFromOwnedString", .{ vm, str, }); } - pub fn createFromString(vm: *VM, str: *const StringImpl) bool { + pub fn createFromString(vm: *VM, str: *const String) *JSString { return shim.cppFn("createFromString", .{ vm, str, }); } - pub const Extern = [_][]const u8{ "getObject", "eql", "value", "length", "is8Bit", "createFromOwnedString", "createFromString" }; + pub const Extern = [_][]const u8{ "toObject", "eql", "value", "length", "is8Bit", "createFromOwnedString", "createFromString" }; }; pub const JSPromiseRejectionOperation = enum(u32) { @@ -404,12 +438,63 @@ pub const JSModuleLoader = packed struct { pub const name = "JSC::JSModuleLoader"; pub const namespace = "JSC"; + pub fn evaluate(globalObject: *JSGlobalObject, source_code: *const SourceCode, thisValue: JSValue, exception: *?*Exception) JSValue { + return shim.cppFn("evaluate", .{ + globalObject, + source_code, + thisValue, + exception, + }); + } + + pub fn loadAndEvaluateModuleEntryPoint(globalObject: *JSGlobalObject, source_code: *const SourceCode) *JSInternalPromise { + return shim.cppFn("loadAndEvaluateModuleEntryPoint", .{ + globalObject, + source_code, + }); + } + + pub fn loadAndEvaluateModule(globalObject: *JSGlobalObject, module_name: *const String) *JSInternalPromise { + return shim.cppFn("loadAndEvaluateModule", .{ + globalObject, + module_name, + }); + } + + pub fn importModule(globalObject: *JSGlobalObject, key: *const Identifier) *JSInternalPromise { + return shim.cppFn("loadAndEvaluateModule", .{ + globalObject, + key, + }); + } + + pub fn linkAndEvaluateModule(globalObject: *JSGlobalObject, key: *const Identifier) JSValue { + return shim.cppFn("linkAndEvaluateModule", .{ + globalObject, + key, + }); + } + + pub fn checkSyntax(globalObject: *JSGlobalObject, source_code: *const SourceCode, is_module: bool) bool { + return shim.cppFn("checkSyntax", .{ + globalObject, + source_code, + is_module, + }); + } + pub fn dependencyKeysIfEvaluated(this: *JSModuleLoader, globalObject: *JSGlobalObject, moduleRecord: *JSModuleRecord) *JSValue { return shim.cppFn("dependencyKeysIfEvaluated", .{ this, globalObject, moduleRecord }); } pub const Extern = [_][]const u8{ "dependencyKeysIfEvaluated", + "evaluate", + "loadAndEvaluateModuleEntryPoint", + "loadAndEvaluateModule", + "importModule", + "linkAndEvaluateModule", + "checkSyntax", }; }; @@ -421,7 +506,7 @@ pub const JSModuleRecord = packed struct { pub const name = "JSC::JSModuleRecord"; pub const namespace = "JSC"; - pub fn sourceCode(this: *JSModuleRecord) *const SourceCode { + pub fn sourceCode(this: *JSModuleRecord) SourceCode { return shim.cppFn("sourceCode", .{ this, }); @@ -467,8 +552,8 @@ pub const JSPromise = packed struct { return cppFn("rejectedPromise", .{ .globalThis = globalThis, .value = value }); } - pub fn resolve(globalThis: *JSGlobalObject, value: JSValue) void { - cppFn("resolve", .{ .globalThis = globalThis, .value = value }); + pub fn resolve(this: *JSPromise, globalThis: *JSGlobalObject, value: JSValue) void { + cppFn("resolve", .{ .this = this, .globalThis = globalThis, .value = value }); } pub fn reject(this: *JSPromise, globalThis: *JSGlobalObject, value: JSValue) void { cppFn("reject", .{ .this = this, .globalThis = globalThis, .value = value }); @@ -483,23 +568,96 @@ pub const JSPromise = packed struct { cppFn("rejectAsHandledException", .{ .this = this, .globalThis = globalThis, .value = value }); } - pub fn isInternal(this: *JSPromise, vm: *VM) bool { - return cppFn("isInternal", .{ this, vm }); + pub const Extern = [_][]const u8{ + "rejectWithCaughtException", + "status", + "result", + "isHandled", + "resolvedPromise", + "rejectedPromise", + "resolve", + "reject", + "rejectAsHandled", + "rejectException", + "rejectAsHandledException", + }; +}; + +pub const JSInternalPromise = packed struct { + pub const shim = Shimmer("JSC", "JSInternalPromise", @This()); + bytes: shim.Bytes, + const cppFn = shim.cppFn; + pub const include = "<JavaScriptCore/JSInternalPromise.h>"; + pub const name = "JSC::JSInternalPromise"; + pub const namespace = "JSC"; + + pub const Status = enum(u32) { + Pending = 0, // Making this as 0, so that, we can change the status from Pending to others without masking. + Fulfilled = 1, + Rejected = 2, + }; + + pub fn status(this: *const JSInternalPromise, vm: *VM) Status { + return shim.cppFn("status", .{ this, vm }); + } + pub fn result(this: *const JSInternalPromise, vm: *VM) JSValue { + return cppFn("result", .{ this, vm }); + } + pub fn isHandled(this: *const JSInternalPromise, vm: *VM) bool { + return cppFn("isHandled", .{ this, vm }); } - pub fn createDeferred(globalThis: *JSGlobalObject, resolved: *JSFunction, rejected: *JSFunction, exception: *Exception) *JSPromise { - return cppFn("createDeferred", .{ - .globalThis = globalThis, - .resolve = resolved, - .reject = rejected, - .exception = exception, - }); + pub fn rejectWithCaughtException(this: *JSInternalPromise, globalObject: *JSGlobalObject, scope: ThrowScope) void { + return cppFn("rejectWithCaughtException", .{ this, globalObject, scope }); } - pub const Extern = [_][]const u8{ "rejectWithCaughtException", "status", "result", "isHandled", "resolvedPromise", "rejectedPromise", "resolve", "reject", "rejectAsHandled", "rejectException", "rejectAsHandledException", "isInternal", "createDeferred" }; -}; + pub fn resolvedPromise(globalThis: *JSGlobalObject, value: JSValue) *JSInternalPromise { + return cppFn("resolvedPromise", .{ .globalThis = globalThis, .value = value }); + } + pub fn rejectedPromise(globalThis: *JSGlobalObject, value: JSValue) *JSInternalPromise { + return cppFn("rejectedPromise", .{ .globalThis = globalThis, .value = value }); + } -pub const JSInternalPromise = JSPromise; + pub fn resolve(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: JSValue) void { + cppFn("resolve", .{ .this = this, .globalThis = globalThis, .value = value }); + } + pub fn reject(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: JSValue) void { + cppFn("reject", .{ .this = this, .globalThis = globalThis, .value = 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 }); + } + pub fn rejectAsHandledException(this: *JSInternalPromise, globalThis: *JSGlobalObject, value: *Exception) void { + cppFn("rejectAsHandledException", .{ .this = this, .globalThis = globalThis, .value = value }); + } + + pub fn then(this: *JSInternalPromise, globalThis: *JSGlobalObject, resolvefunc: ?*JSFunction, rejectfunc: ?*JSFunction) *JSInternalPromise { + return cppFn("then", .{ .this = this, .globalThis = globalThis, .resolvefunc = resolvefunc, .rejectfunc = rejectfunc }); + } + + pub fn create(globalThis: *JSGlobalObject) *JSInternalPromise { + return cppFn("create", .{ .globalThis = globalThis }); + } + + pub const Extern = [_][]const u8{ + "create", + "then", + "rejectWithCaughtException", + "status", + "result", + "isHandled", + "resolvedPromise", + "rejectedPromise", + "resolve", + "reject", + "rejectAsHandled", + "rejectException", + "rejectAsHandledException", + }; +}; // SourceProvider.h pub const SourceType = enum(u8) { @@ -516,7 +674,7 @@ pub const SourceOrigin = packed struct { pub const name = "JSC::SourceOrigin"; pub const namespace = "JSC"; - pub fn fromURL(url: *const URL) *const SourceOrigin { + pub fn fromURL(url: *const URL) SourceOrigin { return cppFn("fromURL", .{url}); } @@ -533,7 +691,7 @@ 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) *const SourceCode { + pub fn fromString(source: *const String, origin: *const SourceOrigin, filename: *String, source_type: SourceType) SourceCode { return cppFn("fromString", .{ source, origin, filename, source_type }); } @@ -550,25 +708,45 @@ pub const JSFunction = packed struct { pub const name = "JSC::JSFunction"; pub const namespace = "JSC"; - pub fn createFromSourceCode(source: *SourceCode, origin: *SourceOrigin, exception: ?*Exception) *JSFunction { - return cppFn("createFromSourceCode", .{ source, origin, exception }); + pub const NativeFunctionCallback = fn (ctx: ?*c_void, global: *JSGlobalObject, call_frame: *CallFrame) callconv(.C) JSValue; + + pub fn createFromSourceCode( + global: *JSGlobalObject, + function_name: ?[*]const u8, + function_name_len: u16, + args: ?[*]JSValue, + args_len: u16, + source: *const SourceCode, + origin: *SourceOrigin, + exception: *?*JSObject, + ) *JSFunction { + return cppFn("createFromSourceCode", .{ + global, + function_name, + function_name_len, + args, + args_len, + source, + origin, + exception, + }); } pub fn createFromNative( - vm: *VM, - globalthis: *JSGlobalObject, - argument_count: u32, - name_: *String, - func: *c_void, + global: *JSGlobalObject, + argument_count: u16, + name_: ?*const String, + ctx: ?*c_void, + func: NativeFunctionCallback, ) *JSFunction { - return cppFn("createFromNative", .{ vm, globalthis, argument_count, name_, func }); + return cppFn("createFromNative", .{ global, argument_count, name_, ctx, func }); } - pub fn getName(this: *JSFunction, vm: *VM) *String { + pub fn getName(this: *JSFunction, vm: *VM) String { return cppFn("getName", .{ this, vm }); } - pub fn displayName(this: *JSFunction, vm: *VM) *String { + pub fn displayName(this: *JSFunction, vm: *VM) String { return cppFn("displayName", .{ this, vm }); } - pub fn calculatedDisplayName(this: *JSFunction, vm: *VM) *String { + pub fn calculatedDisplayName(this: *JSFunction, vm: *VM) String { return cppFn("calculatedDisplayName", .{ this, vm }); } pub fn toString(this: *JSFunction, globalThis: *JSGlobalObject) *const JSString { @@ -576,7 +754,7 @@ pub const JSFunction = packed struct { } pub fn callWithArgumentsAndThis( - function: *JSFunction, + function: JSValue, thisValue: JSValue, globalThis: *JSGlobalObject, arguments_ptr: [*]JSValue, @@ -596,7 +774,7 @@ pub const JSFunction = packed struct { } pub fn callWithArguments( - function: *JSFunction, + function: JSValue, globalThis: *JSGlobalObject, arguments_ptr: [*]JSValue, arguments_len: usize, @@ -607,7 +785,7 @@ pub const JSFunction = packed struct { } pub fn callWithThis( - function: *JSFunction, + function: JSValue, globalThis: *JSGlobalObject, thisValue: JSValue, exception: *?*Exception, @@ -623,7 +801,7 @@ pub const JSFunction = packed struct { } pub fn callWithoutAnyArgumentsOrThis( - function: *JSFunction, + function: JSValue, globalThis: *JSGlobalObject, exception: *?*Exception, error_message: ?*const u8, @@ -632,7 +810,7 @@ pub const JSFunction = packed struct { } pub fn constructWithArgumentsAndNewTarget( - function: *JSFunction, + function: JSValue, newTarget: JSValue, globalThis: *JSGlobalObject, arguments_ptr: [*]JSValue, @@ -652,7 +830,7 @@ pub const JSFunction = packed struct { } pub fn constructWithArguments( - function: *JSFunction, + function: JSValue, globalThis: *JSGlobalObject, arguments_ptr: [*]JSValue, arguments_len: usize, @@ -663,7 +841,7 @@ pub const JSFunction = packed struct { } pub fn constructWithNewTarget( - function: *JSFunction, + function: JSValue, globalThis: *JSGlobalObject, newTarget: JSValue, exception: *?*Exception, @@ -679,7 +857,7 @@ pub const JSFunction = packed struct { } pub fn constructWithoutAnyArgumentsOrNewTarget( - function: *JSFunction, + function: JSValue, globalThis: *JSGlobalObject, exception: *?*Exception, error_message: ?*const u8, @@ -1838,7 +2016,6 @@ const SetIteratorPrototype = _JSCellStub("SetIteratorPrototype"); const JSPromisePrototype = _JSCellStub("JSPromisePrototype"); const AsyncGeneratorPrototype = _JSCellStub("AsyncGeneratorPrototype"); const AsyncGeneratorFunctionPrototype = _JSCellStub("AsyncGeneratorFunctionPrototype"); - pub fn SliceFn(comptime Type: type) type { const SliceStruct = struct { pub fn slice(this: *Type) []const u8 { diff --git a/src/javascript/jsc/bindings/header-gen.zig b/src/javascript/jsc/bindings/header-gen.zig index 7b664785d..452c5d67c 100644 --- a/src/javascript/jsc/bindings/header-gen.zig +++ b/src/javascript/jsc/bindings/header-gen.zig @@ -270,7 +270,7 @@ pub const C_Generator = struct { self: *Self, comptime T: type, ) void { - const TT = comptime if (@typeInfo(T) == .Pointer) @typeInfo(T).Pointer.child else T; + const TT = comptime if (@typeInfo(T) == .Pointer and !std.meta.trait.isManyItemPtr(T)) @typeInfo(T).Pointer.child else T; if (comptime (isCppObject(TT)) and @hasDecl(TT, "name")) { if (@typeInfo(T) == .Pointer or @hasDecl(TT, "Type") and @typeInfo(TT.Type) == .Pointer) { @@ -444,9 +444,10 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { \\#endif \\ \\extern "C" const size_t {s} = sizeof({s}); + \\extern "C" const size_t {s} = alignof({s}); \\ , - .{ new_name, new_name, Type.include, Type.shim.size_of_symbol, Type.name }, + .{ new_name, new_name, Type.include, Type.shim.size_of_symbol, Type.name, Type.shim.align_of_symbol, Type.name }, ) catch unreachable; } } @@ -562,6 +563,9 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { var impl_third_buffer = std.ArrayList(u8).init(std.heap.c_allocator); var impl_third_writer = impl_third_buffer.writer(); + var impl_fourth_buffer = std.ArrayList(u8).init(std.heap.c_allocator); + var impl_fourth_writer = impl_fourth_buffer.writer(); + var to_get_sizes: usize = 0; inline for (all_decls) |_decls| { if (comptime _decls.is_pub) { @@ -588,6 +592,7 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { if (to_get_sizes > 0) { impl_second_writer.writeAll(", ") catch unreachable; impl_third_writer.writeAll(", ") catch unreachable; + impl_fourth_writer.writeAll(", ") catch unreachable; } const formatted_name = comptime brk: { @@ -597,6 +602,7 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { }; impl_third_writer.print("sizeof({s})", .{comptime Type.name}) catch unreachable; + impl_fourth_writer.print("alignof({s})", .{comptime Type.name}) catch unreachable; impl_second_writer.print("\"{s}\"", .{formatted_name}) catch unreachable; to_get_sizes += 1; const ExternList = comptime brk: { @@ -666,7 +672,9 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { impl.writer().print("\nconst char* names[{d}] = {{", .{to_get_sizes}) catch unreachable; impl.writeAll(impl_second_buffer.items) catch unreachable; impl.writeAll("};\n") catch unreachable; - + impl.writer().print("\nconst size_t aligns[{d}] = {{", .{to_get_sizes}) catch unreachable; + impl.writeAll(impl_fourth_buffer.items) catch unreachable; + impl.writeAll("};\n") catch unreachable; var iter = type_names.iterator(); const NamespaceMap = std.StringArrayHashMap(std.BufMap); diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h index 57c7bb4f9..61b4d2f87 100644 --- a/src/javascript/jsc/bindings/headers-cpp.h +++ b/src/javascript/jsc/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1626855517 +//-- AUTOGENERATED FILE -- 1626933952 #pragma once #include <stddef.h> @@ -13,13 +13,7 @@ #endif extern "C" const size_t JSC__JSObject_object_size_ = sizeof(JSC::JSObject); - -#ifndef INCLUDED__JavaScriptCore_PropertyNameArray_h_ -#define INCLUDED__JavaScriptCore_PropertyNameArray_h_ -#include <JavaScriptCore/PropertyNameArray.h> -#endif - -extern "C" const size_t JSC__PropertyNameArray_object_size_ = sizeof(JSC::PropertyNameArray); +extern "C" const size_t JSC__JSObject_object_align_ = alignof(JSC::JSObject); #ifndef INCLUDED__JavaScriptCore_JSCell_h_ #define INCLUDED__JavaScriptCore_JSCell_h_ @@ -27,6 +21,7 @@ extern "C" const size_t JSC__PropertyNameArray_object_size_ = sizeof(JSC::Proper #endif extern "C" const size_t JSC__JSCell_object_size_ = sizeof(JSC::JSCell); +extern "C" const size_t JSC__JSCell_object_align_ = alignof(JSC::JSCell); #ifndef INCLUDED__JavaScriptCore_JSString_h_ #define INCLUDED__JavaScriptCore_JSString_h_ @@ -34,6 +29,7 @@ extern "C" const size_t JSC__JSCell_object_size_ = sizeof(JSC::JSCell); #endif extern "C" const size_t JSC__JSString_object_size_ = sizeof(JSC::JSString); +extern "C" const size_t JSC__JSString_object_align_ = alignof(JSC::JSString); #ifndef INCLUDED__ZigGlobalObject_h_ #define INCLUDED__ZigGlobalObject_h_ @@ -41,6 +37,7 @@ extern "C" const size_t JSC__JSString_object_size_ = sizeof(JSC::JSString); #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__DefaultGlobal_h_ #define INCLUDED__DefaultGlobal_h_ @@ -48,6 +45,7 @@ extern "C" const size_t Zig__GlobalObject_object_size_ = sizeof(Zig::GlobalObjec #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_ @@ -55,6 +53,7 @@ extern "C" const size_t Wundle__DefaultGlobal_object_size_ = sizeof(Wundle::Defa #endif extern "C" const size_t JSC__JSModuleLoader_object_size_ = sizeof(JSC::JSModuleLoader); +extern "C" const size_t JSC__JSModuleLoader_object_align_ = alignof(JSC::JSModuleLoader); #ifndef INCLUDED__JavaScriptCore_JSModuleRecord_h_ #define INCLUDED__JavaScriptCore_JSModuleRecord_h_ @@ -62,6 +61,7 @@ extern "C" const size_t JSC__JSModuleLoader_object_size_ = sizeof(JSC::JSModuleL #endif extern "C" const size_t JSC__JSModuleRecord_object_size_ = sizeof(JSC::JSModuleRecord); +extern "C" const size_t JSC__JSModuleRecord_object_align_ = alignof(JSC::JSModuleRecord); #ifndef INCLUDED__JavaScriptCore_JSPromise_h_ #define INCLUDED__JavaScriptCore_JSPromise_h_ @@ -69,6 +69,15 @@ extern "C" const size_t JSC__JSModuleRecord_object_size_ = sizeof(JSC::JSModuleR #endif extern "C" const size_t JSC__JSPromise_object_size_ = sizeof(JSC::JSPromise); +extern "C" const size_t JSC__JSPromise_object_align_ = alignof(JSC::JSPromise); + +#ifndef INCLUDED__JavaScriptCore_JSInternalPromise_h_ +#define INCLUDED__JavaScriptCore_JSInternalPromise_h_ +#include <JavaScriptCore/JSInternalPromise.h> +#endif + +extern "C" const size_t JSC__JSInternalPromise_object_size_ = sizeof(JSC::JSInternalPromise); +extern "C" const size_t JSC__JSInternalPromise_object_align_ = alignof(JSC::JSInternalPromise); #ifndef INCLUDED__JavaScriptCore_SourceOrigin_h_ #define INCLUDED__JavaScriptCore_SourceOrigin_h_ @@ -76,6 +85,7 @@ extern "C" const size_t JSC__JSPromise_object_size_ = sizeof(JSC::JSPromise); #endif extern "C" const size_t JSC__SourceOrigin_object_size_ = sizeof(JSC::SourceOrigin); +extern "C" const size_t JSC__SourceOrigin_object_align_ = alignof(JSC::SourceOrigin); #ifndef INCLUDED__JavaScriptCore_SourceProvider_h_ #define INCLUDED__JavaScriptCore_SourceProvider_h_ @@ -83,6 +93,7 @@ extern "C" const size_t JSC__SourceOrigin_object_size_ = sizeof(JSC::SourceOrigi #endif extern "C" const size_t JSC__SourceCode_object_size_ = sizeof(JSC::SourceCode); +extern "C" const size_t JSC__SourceCode_object_align_ = alignof(JSC::SourceCode); #ifndef INCLUDED__JavaScriptCore_JSFunction_h_ #define INCLUDED__JavaScriptCore_JSFunction_h_ @@ -90,6 +101,7 @@ extern "C" const size_t JSC__SourceCode_object_size_ = sizeof(JSC::SourceCode); #endif extern "C" const size_t JSC__JSFunction_object_size_ = sizeof(JSC::JSFunction); +extern "C" const size_t JSC__JSFunction_object_align_ = alignof(JSC::JSFunction); #ifndef INCLUDED__JavaScriptCore_JSGlobalObject_h_ #define INCLUDED__JavaScriptCore_JSGlobalObject_h_ @@ -97,6 +109,7 @@ extern "C" const size_t JSC__JSFunction_object_size_ = sizeof(JSC::JSFunction); #endif extern "C" const size_t JSC__JSGlobalObject_object_size_ = sizeof(JSC::JSGlobalObject); +extern "C" const size_t JSC__JSGlobalObject_object_align_ = alignof(JSC::JSGlobalObject); #ifndef INCLUDED__wtf_URL_h_ #define INCLUDED__wtf_URL_h_ @@ -104,6 +117,7 @@ extern "C" const size_t JSC__JSGlobalObject_object_size_ = sizeof(JSC::JSGlobalO #endif extern "C" const size_t WTF__URL_object_size_ = sizeof(WTF::URL); +extern "C" const size_t WTF__URL_object_align_ = alignof(WTF::URL); #ifndef INCLUDED__wtf_text_WTFString_h_ #define INCLUDED__wtf_text_WTFString_h_ @@ -111,6 +125,7 @@ extern "C" const size_t WTF__URL_object_size_ = sizeof(WTF::URL); #endif 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_ @@ -118,6 +133,7 @@ extern "C" const size_t WTF__String_object_size_ = sizeof(WTF::String); #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_ @@ -125,6 +141,7 @@ extern "C" const size_t JSC__JSValue_object_size_ = sizeof(JSC::JSValue); #endif extern "C" const size_t JSC__PropertyName_object_size_ = sizeof(JSC::PropertyName); +extern "C" const size_t JSC__PropertyName_object_align_ = alignof(JSC::PropertyName); #ifndef INCLUDED__JavaScriptCore_Exception_h_ #define INCLUDED__JavaScriptCore_Exception_h_ @@ -132,6 +149,7 @@ extern "C" const size_t JSC__PropertyName_object_size_ = sizeof(JSC::PropertyNam #endif extern "C" const size_t JSC__Exception_object_size_ = sizeof(JSC::Exception); +extern "C" const size_t JSC__Exception_object_align_ = alignof(JSC::Exception); #ifndef INCLUDED__JavaScriptCore_VM_h_ #define INCLUDED__JavaScriptCore_VM_h_ @@ -139,6 +157,7 @@ extern "C" const size_t JSC__Exception_object_size_ = sizeof(JSC::Exception); #endif extern "C" const size_t JSC__VM_object_size_ = sizeof(JSC::VM); +extern "C" const size_t JSC__VM_object_align_ = alignof(JSC::VM); #ifndef INCLUDED__JavaScriptCore_ThrowScope_h_ #define INCLUDED__JavaScriptCore_ThrowScope_h_ @@ -146,6 +165,7 @@ extern "C" const size_t JSC__VM_object_size_ = sizeof(JSC::VM); #endif extern "C" const size_t JSC__ThrowScope_object_size_ = sizeof(JSC::ThrowScope); +extern "C" const size_t JSC__ThrowScope_object_align_ = alignof(JSC::ThrowScope); #ifndef INCLUDED__JavaScriptCore_CatchScope_h_ #define INCLUDED__JavaScriptCore_CatchScope_h_ @@ -153,6 +173,7 @@ extern "C" const size_t JSC__ThrowScope_object_size_ = sizeof(JSC::ThrowScope); #endif extern "C" const size_t JSC__CatchScope_object_size_ = sizeof(JSC::CatchScope); +extern "C" const size_t JSC__CatchScope_object_align_ = alignof(JSC::CatchScope); #ifndef INCLUDED__JavaScriptCore_CallFrame_h_ #define INCLUDED__JavaScriptCore_CallFrame_h_ @@ -160,6 +181,7 @@ extern "C" const size_t JSC__CatchScope_object_size_ = sizeof(JSC::CatchScope); #endif extern "C" const size_t JSC__CallFrame_object_size_ = sizeof(JSC::CallFrame); +extern "C" const size_t JSC__CallFrame_object_align_ = alignof(JSC::CallFrame); #ifndef INCLUDED__JavaScriptCore_Identifier_h_ #define INCLUDED__JavaScriptCore_Identifier_h_ @@ -167,6 +189,7 @@ extern "C" const size_t JSC__CallFrame_object_size_ = sizeof(JSC::CallFrame); #endif extern "C" const size_t JSC__Identifier_object_size_ = sizeof(JSC::Identifier); +extern "C" const size_t JSC__Identifier_object_align_ = alignof(JSC::Identifier); #ifndef INCLUDED__wtf_text_StringImpl_h_ #define INCLUDED__wtf_text_StringImpl_h_ @@ -174,6 +197,7 @@ extern "C" const size_t JSC__Identifier_object_size_ = sizeof(JSC::Identifier); #endif extern "C" const size_t WTF__StringImpl_object_size_ = sizeof(WTF::StringImpl); +extern "C" const size_t WTF__StringImpl_object_align_ = alignof(WTF::StringImpl); #ifndef INCLUDED__wtf_text_ExternalStringImpl_h_ #define INCLUDED__wtf_text_ExternalStringImpl_h_ @@ -181,6 +205,7 @@ extern "C" const size_t WTF__StringImpl_object_size_ = sizeof(WTF::StringImpl); #endif extern "C" const size_t WTF__ExternalStringImpl_object_size_ = sizeof(WTF::ExternalStringImpl); +extern "C" const size_t WTF__ExternalStringImpl_object_align_ = alignof(WTF::ExternalStringImpl); #ifndef INCLUDED__wtf_text_StringView_h_ #define INCLUDED__wtf_text_StringView_h_ @@ -188,7 +213,10 @@ extern "C" const size_t WTF__ExternalStringImpl_object_size_ = sizeof(WTF::Exter #endif 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[25] = {sizeof(JSC::JSObject), sizeof(JSC::JSCell), sizeof(JSC::JSString), 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::JSValue), sizeof(JSC::PropertyName), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(JSC::CallFrame), sizeof(JSC::Identifier), sizeof(WTF::StringImpl), sizeof(WTF::ExternalStringImpl), sizeof(WTF::StringView)}; -const size_t sizes[25] = {sizeof(JSC::JSObject), sizeof(JSC::PropertyNameArray), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Wundle::DefaultGlobal), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::SourceOrigin), sizeof(JSC::SourceCode), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(WTF::URL), sizeof(WTF::String), sizeof(JSC::JSValue), sizeof(JSC::PropertyName), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(JSC::CallFrame), sizeof(JSC::Identifier), sizeof(WTF::StringImpl), sizeof(WTF::ExternalStringImpl), sizeof(WTF::StringView)}; +const char* names[25] = {"JSC__JSObject", "JSC__JSCell", "JSC__JSString", "Wundle__DefaultGlobal", "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"}; -const char* names[25] = {"JSC__JSObject", "JSC__PropertyNameArray", "JSC__JSCell", "JSC__JSString", "Wundle__DefaultGlobal", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__SourceOrigin", "JSC__SourceCode", "JSC__JSFunction", "JSC__JSGlobalObject", "WTF__URL", "WTF__String", "JSC__JSValue", "JSC__PropertyName", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "JSC__CallFrame", "JSC__Identifier", "WTF__StringImpl", "WTF__ExternalStringImpl", "WTF__StringView"}; +const size_t aligns[25] = {alignof(JSC::JSObject), alignof(JSC::JSCell), alignof(JSC::JSString), 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::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)}; diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h index 53281a7eb..282a63333 100644 --- a/src/javascript/jsc/bindings/headers.h +++ b/src/javascript/jsc/bindings/headers.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1626855517 +//-- AUTOGENERATED FILE -- 1626933952 #pragma once #include <stddef.h> @@ -16,19 +16,19 @@ #ifndef __cplusplus - typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype + 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__CatchScope JSC__CatchScope; // JSC::CatchScope + typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype typedef struct WTF__StringView WTF__StringView; // WTF::StringView typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype - typedef struct JSC__CallFrame JSC__CallFrame; // JSC::CallFrame + typedef struct JSC__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__StringImpl WTF__StringImpl; // WTF::StringImpl - typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype typedef struct WTF__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 @@ -52,19 +52,18 @@ typedef struct WTF__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 struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype typedef struct JSC__Exception JSC__Exception; // JSC::Exception typedef struct JSC__JSString JSC__JSString; // JSC::JSString - typedef struct JSC__PropertyNameArray JSC__PropertyNameArray; // JSC::PropertyNameArray typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype + typedef struct JSC__CallFrame JSC__CallFrame; // JSC::CallFrame typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype - typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype #endif typedef struct bJSC__JSModuleRecord { char bytes[344]; } bJSC__JSModuleRecord; - typedef struct bJSC__PropertyNameArray { char bytes[48]; } bJSC__PropertyNameArray; - typedef struct bJSC__PropertyName { char bytes[8]; } bJSC__PropertyName; typedef struct bJSC__ThrowScope { char bytes[8]; } bJSC__ThrowScope; + typedef struct bJSC__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; @@ -84,6 +83,7 @@ typedef struct bJSC__JSCell { char bytes[8]; } bJSC__JSCell; typedef struct bJSC__JSLock { char bytes[40]; } bJSC__JSLock; typedef struct bWundle__DefaultGlobal { char bytes[2464]; } bWundle__DefaultGlobal; + typedef struct bJSC__JSInternalPromise { char bytes[32]; } bJSC__JSInternalPromise; typedef struct bJSC__JSObject { char bytes[16]; } bJSC__JSObject; typedef struct bJSC__Identifier { char bytes[8]; } bJSC__Identifier; @@ -109,11 +109,11 @@ class SetIteratorPrototype; class ThrowScope; class SourceOrigin; - class PropertyNameArray; class AsyncGeneratorPrototype; class PropertyName; class MapIteratorPrototype; class JSModuleRecord; + class JSInternalPromise; class ArrayIteratorPrototype; class JSFunction; class JSModuleLoader; @@ -158,11 +158,11 @@ using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype; using JSC__ThrowScope = JSC::ThrowScope; using JSC__SourceOrigin = JSC::SourceOrigin; - using JSC__PropertyNameArray = JSC::PropertyNameArray; using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype; using JSC__PropertyName = JSC::PropertyName; using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype; using JSC__JSModuleRecord = JSC::JSModuleRecord; + using JSC__JSInternalPromise = JSC::JSInternalPromise; using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype; using JSC__JSFunction = JSC::JSFunction; using JSC__JSModuleLoader = JSC::JSModuleLoader; @@ -190,33 +190,27 @@ CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0); CPP_DECL JSC__JSValue JSC__JSObject__getAtIndex(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, JSC__PropertyName* arg2, uint32_t arg3); CPP_DECL bool JSC__JSObject__putAtIndex(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, JSC__PropertyName* arg2, uint32_t arg3); -#pragma mark - JSC::PropertyNameArray - -CPP_DECL size_t JSC__PropertyNameArray__length(JSC__PropertyNameArray* arg0); -CPP_DECL const JSC__PropertyName* JSC__PropertyNameArray__next(JSC__PropertyNameArray* arg0, size_t arg1); -CPP_DECL void JSC__PropertyNameArray__release(JSC__PropertyNameArray* arg0); - #pragma mark - JSC::JSCell CPP_DECL JSC__JSObject* JSC__JSCell__getObject(JSC__JSCell* arg0); -CPP_DECL WTF__String* JSC__JSCell__getString(JSC__JSCell* arg0, JSC__JSGlobalObject* arg1); +CPP_DECL bWTF__String JSC__JSCell__getString(JSC__JSCell* arg0, JSC__JSGlobalObject* arg1); CPP_DECL char JSC__JSCell__getType(JSC__JSCell* arg0); #pragma mark - JSC::JSString -CPP_DECL bool JSC__JSString__createFromOwnedString(JSC__VM* arg0, const WTF__StringImpl* arg1); -CPP_DECL bool JSC__JSString__createFromString(JSC__VM* arg0, const WTF__StringImpl* arg1); -CPP_DECL bool JSC__JSString__eql(const JSC__JSString* arg0, const JSC__JSString* arg1); -CPP_DECL JSC__JSObject* JSC__JSString__getObject(JSC__JSString* arg0); +CPP_DECL JSC__JSString* JSC__JSString__createFromOwnedString(JSC__VM* arg0, const WTF__String* arg1); +CPP_DECL JSC__JSString* JSC__JSString__createFromString(JSC__VM* arg0, const WTF__String* arg1); +CPP_DECL bool JSC__JSString__eql(const JSC__JSString* arg0, JSC__JSGlobalObject* arg1, JSC__JSString* arg2); CPP_DECL bool JSC__JSString__is8Bit(const JSC__JSString* arg0); CPP_DECL size_t JSC__JSString__length(const JSC__JSString* arg0); -CPP_DECL WTF__String* JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1); +CPP_DECL JSC__JSObject* JSC__JSString__toObject(JSC__JSString* arg0, JSC__JSGlobalObject* arg1); +CPP_DECL bWTF__String JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1); #pragma mark - Zig::GlobalObject ZIG_DECL JSC__JSValue Zig__GlobalObject__eval(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, JSC__JSValue JSValue4, JSC__JSValue JSValue5, JSC__JSValue JSValue6); -ZIG_DECL JSC__JSPromise* Zig__GlobalObject__fetch(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, JSC__JSValue JSValue4); -ZIG_DECL JSC__JSPromise* Zig__GlobalObject__import(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSString* arg2, JSC__JSValue JSValue3, const JSC__SourceOrigin* arg4); +ZIG_DECL JSC__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__reportUncaughtException(JSC__JSGlobalObject* arg0, JSC__JSPromise* arg1, uint32_t JSPromiseRejectionOperation2); ZIG_DECL const JSC__Identifier* Zig__GlobalObject__resolve(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSString* arg2, JSC__JSValue JSValue3, const JSC__SourceOrigin* arg4); @@ -227,51 +221,71 @@ 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); +CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModule(JSC__JSGlobalObject* arg0, const WTF__String* arg1); +CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1); #pragma mark - JSC::JSModuleRecord -CPP_DECL const JSC__SourceCode* JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord* arg0); +CPP_DECL bJSC__SourceCode JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord* arg0); #pragma mark - JSC::JSPromise -CPP_DECL JSC__JSPromise* JSC__JSPromise__createDeferred(JSC__JSGlobalObject* arg0, JSC__JSFunction* arg1, JSC__JSFunction* arg2, JSC__Exception* arg3); CPP_DECL bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1); -CPP_DECL bool JSC__JSPromise__isInternal(JSC__JSPromise* arg0, JSC__VM* arg1); CPP_DECL void JSC__JSPromise__reject(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); CPP_DECL void JSC__JSPromise__rejectAsHandled(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); CPP_DECL void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2); CPP_DECL JSC__JSPromise* JSC__JSPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); CPP_DECL void JSC__JSPromise__rejectException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2); CPP_DECL void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2); -CPP_DECL void JSC__JSPromise__resolve(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); +CPP_DECL 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); CPP_DECL JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise* arg0, JSC__VM* arg1); CPP_DECL uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1); +#pragma mark - JSC::JSInternalPromise + +CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__create(JSC__JSGlobalObject* arg0); +CPP_DECL bool JSC__JSInternalPromise__isHandled(const JSC__JSInternalPromise* arg0, JSC__VM* arg1); +CPP_DECL void JSC__JSInternalPromise__reject(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); +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); +CPP_DECL JSC__JSValue JSC__JSInternalPromise__result(const JSC__JSInternalPromise* arg0, JSC__VM* arg1); +CPP_DECL uint32_t JSC__JSInternalPromise__status(const JSC__JSInternalPromise* arg0, JSC__VM* arg1); +CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__then(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSFunction* arg2, JSC__JSFunction* arg3); + #pragma mark - JSC::SourceOrigin -CPP_DECL const JSC__SourceOrigin* JSC__SourceOrigin__fromURL(const WTF__URL* arg0); +CPP_DECL bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL* arg0); #pragma mark - JSC::SourceCode -CPP_DECL const JSC__SourceCode* JSC__SourceCode__fromString(const WTF__String* arg0, const JSC__SourceOrigin* arg1, WTF__String* arg2, char SourceType3); +CPP_DECL bJSC__SourceCode JSC__SourceCode__fromString(const WTF__String* arg0, const JSC__SourceOrigin* arg1, WTF__String* arg2, char SourceType3); #pragma mark - JSC::JSFunction -CPP_DECL WTF__String* JSC__JSFunction__calculatedDisplayName(JSC__JSFunction* arg0, JSC__VM* arg1); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue arg2, size_t arg3, JSC__Exception** arg4, char* arg5); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSFunction* arg0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue arg3, size_t arg4, JSC__Exception** arg5, char* arg6); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, char* arg3); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, char* arg4); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue arg2, size_t arg3, JSC__Exception** arg4, char* arg5); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSFunction* arg0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue arg3, size_t arg4, JSC__Exception** arg5, char* arg6); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, char* arg4); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSFunction* arg0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, char* arg3); -CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__VM* arg0, JSC__JSGlobalObject* arg1, uint32_t arg2, WTF__String* arg3, void* arg4); -CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromSourceCode(JSC__SourceCode* arg0, JSC__SourceOrigin* arg1, JSC__Exception* arg2); -CPP_DECL WTF__String* JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1); -CPP_DECL WTF__String* JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1); +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__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 bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1); +CPP_DECL bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1); #pragma mark - JSC::JSGlobalObject diff --git a/src/javascript/jsc/bindings/sizes.zig b/src/javascript/jsc/bindings/sizes.zig index a48ac9f16..88cc96c12 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-21 02:02:1626858148. +// Auto-generated by src/javascript/jsc/headergen/sizegen.cpp at 2021-07-21 22:39:1626932365. // 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. @@ -6,33 +6,62 @@ // 1. We can't dynamically link JavaScriptCore // 2. It's important that this is run whenever JavaScriptCore is updated or the bindings on the Zig side change. // Failure to do so will lead to undefined behavior and probably some frustrated people. -// --- To renegerate: --- +// --- Regenerate this: --- // 1. "make jsc-bindings-headers" // 2. "make sizegen" // 3. "make jsc-bindings-headers" +// ------------------------ // You can verify the numbers written in this file at runtime via the `extern`d types +// Run "jsc-bindings-headers" twice because it uses these values in the output. That's how all the bJSC__.* types are created - from these values. pub const JSC__JSObject = 16; -pub const JSC__PropertyNameArray = 48; +pub const JSC__JSObject_align = 8; +pub const JSC__JSMap = 56; +pub const JSC__JSMap_align = 8; pub const JSC__JSCell = 8; +pub const JSC__JSCell_align = 4; pub const JSC__JSString = 16; +pub const JSC__JSString_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_align = 8; pub const JSC__JSPromise = 32; +pub const JSC__JSPromise_align = 8; +pub const JSC__JSInternalPromise = 32; +pub const JSC__JSInternalPromise_align = 8; pub const JSC__SourceOrigin = 48; +pub const JSC__SourceOrigin_align = 8; 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_align = 8; pub const WTF__URL = 40; +pub const WTF__URL_align = 8; pub const WTF__String = 8; +pub const WTF__String_align = 8; pub const JSC__JSValue = 8; +pub const JSC__JSValue_align = 8; 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_align = 8; pub const JSC__ThrowScope = 8; +pub const JSC__ThrowScope_align = 8; pub const JSC__CatchScope = 8; +pub const JSC__CatchScope_align = 8; pub const JSC__CallFrame = 8; +pub const JSC__CallFrame_align = 8; pub const JSC__Identifier = 8; +pub const JSC__Identifier_align = 8; 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_align = 8; diff --git a/src/javascript/jsc/bindings/static_export.zig b/src/javascript/jsc/bindings/static_export.zig index 91342fad8..a922ae96b 100644 --- a/src/javascript/jsc/bindings/static_export.zig +++ b/src/javascript/jsc/bindings/static_export.zig @@ -2,6 +2,7 @@ const std = @import("std"); Type: type, symbol_name: []const u8, local_name: []const u8, + Parent: type, pub fn Decl(comptime this: *const @This()) std.builtin.TypeInfo.Declaration { return comptime std.meta.declarationInfo(this.Parent, this.local_name); diff --git a/src/javascript/jsc/headergen/sizegen.cpp b/src/javascript/jsc/headergen/sizegen.cpp index 6999fcda0..ecad3f2f3 100644 --- a/src/javascript/jsc/headergen/sizegen.cpp +++ b/src/javascript/jsc/headergen/sizegen.cpp @@ -27,13 +27,14 @@ int main() { cout << "// 1. \"make jsc-bindings-headers\"\n"; cout << "// 2. \"make sizegen\"\n"; cout << "// 3. \"make jsc-bindings-headers\"\n"; + cout << "// ------------------------\n"; cout << "// You can verify the numbers written in this file at runtime via the `extern`d types\n"; cout << "// Run \"jsc-bindings-headers\" twice because it uses these values in the output. That's how all the bJSC__.* types are created - from these values. \n"; - cout << "// The data for this file is generated in headers-cpp.h \n"; int i = 0; int len = sizeof(sizes)/sizeof(sizes[0]); for (i = 0; i < len ; i++) { cout << "pub const " << names[i] << " = " << sizes[i] << ";\n"; + cout << "pub const " << names[i] << "_align = " << aligns[i] << ";\n"; } return 0; diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index e984ccbb1..04e7a9d80 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -988,6 +988,7 @@ pub const Module = struct { js.JSValueUnprotect(global_ctx, commonjs_wrapper); } + if (except != null) { var message = js.JSValueToStringCopy(function_ctx, except.?, null); defer js.JSStringRelease(message); |