console.log(<JSX>) support

This commit is contained in:
Jarred Sumner
2022-03-10 00:44:01 -08:00
parent 4204baabe6
commit 69eeff1f76
48 changed files with 2750 additions and 2355 deletions

View File

@@ -237,10 +237,10 @@ void JSC__JSValue__jsonStringify(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg
unsigned char JSC__JSValue__jsType(JSC__JSValue JSValue0)
{
JSC::JSValue jsValue = JSC::JSValue::decode(JSValue0);
if (!jsValue.isCell())
return 0;
if (JSC::JSCell* cell = jsValue.asCell())
return cell->type();
return jsValue.asCell()->type();
return 0;
}
void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC__JSGlobalObject* global, ZigString* arg1)
@@ -1541,6 +1541,46 @@ JSC__JSValue JSC__JSValue__getIfPropertyExistsImpl(JSC__JSValue JSValue0,
return JSC::JSValue::encode(object->getIfPropertyExists(globalObject, propertyName));
}
void JSC__JSValue__getSymbolDescription(JSC__JSValue symbolValue_, JSC__JSGlobalObject* arg1, ZigString* arg2)
{
JSC::JSValue symbolValue = JSC::JSValue::decode(symbolValue_);
if (!symbolValue.isSymbol())
return;
JSC::Symbol* symbol = JSC::asSymbol(symbolValue);
JSC::VM& vm = arg1->vm();
WTF::String string = symbol->description();
*arg2 = Zig::toZigString(string);
}
JSC__JSValue JSC__JSValue__symbolFor(JSC__JSGlobalObject* globalObject, ZigString* arg2)
{
JSC::VM& vm = globalObject->vm();
WTF::String string = Zig::toString(*arg2);
return JSC::JSValue::encode(JSC::Symbol::create(vm, vm.symbolRegistry().symbolForKey(string)));
}
bool JSC__JSValue__symbolKeyFor(JSC__JSValue symbolValue_, JSC__JSGlobalObject* arg1, ZigString* arg2)
{
JSC::JSValue symbolValue = JSC::JSValue::decode(symbolValue_);
JSC::VM& vm = arg1->vm();
if (!symbolValue.isSymbol())
return false;
JSC::PrivateName privateName = JSC::asSymbol(symbolValue)->privateName();
SymbolImpl& uid = privateName.uid();
if (!uid.symbolRegistry())
return false;
*arg2 = Zig::toZigString(JSC::jsString(vm, &uid), arg1);
return true;
}
bool JSC__JSValue__toBoolean(JSC__JSValue JSValue0)
{
return JSC::JSValue::decode(JSValue0).asBoolean();

View File

@@ -1701,6 +1701,13 @@ pub const JSValue = enum(i64) {
};
}
pub fn isFunction(this: JSType) bool {
return switch (this) {
.FunctionExecutable, .InternalFunction => true,
else => false,
};
}
pub fn toC(this: JSType) C_API.JSTypedArrayType {
return switch (this) {
.Int8Array => .kJSTypedArrayTypeInt8Array,
@@ -2089,6 +2096,24 @@ pub const JSValue = enum(i64) {
return cppFn("getIfPropertyExistsImpl", .{ this, global, ptr, len });
}
pub fn getSymbolDescription(this: JSValue, global: *JSGlobalObject, str: *ZigString) void {
cppFn("getSymbolDescription", .{ this, global, str });
}
pub fn symbolFor(global: *JSGlobalObject, str: *ZigString) JSValue {
return cppFn("symbolFor", .{ global, str });
}
pub fn symbolKeyFor(this: JSValue, global: *JSGlobalObject, str: *ZigString) bool {
return cppFn("symbolKeyFor", .{ this, global, str });
}
pub fn getDescription(this: JSValue, global: *JSGlobalObject) ZigString {
var zig_str = ZigString.init("");
getSymbolDescription(this, global, &zig_str);
return zig_str;
}
pub fn get(this: JSValue, global: *JSGlobalObject, property: []const u8) ?JSValue {
const value = getIfPropertyExistsImpl(this, global, property.ptr, @intCast(u32, property.len));
return if (@enumToInt(value) != 0) value else return null;
@@ -2211,7 +2236,7 @@ pub const JSValue = enum(i64) {
return @intToPtr(*anyopaque, @bitCast(u64, @enumToInt(this)));
}
pub const Extern = [_][]const u8{ "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "getReadableStreamState", "getWritableStreamState", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "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 Extern = [_][]const u8{ "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "getReadableStreamState", "getWritableStreamState", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "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" };
};
extern "c" fn Microtask__run(*Microtask, *JSGlobalObject) void;

View File

@@ -28,6 +28,7 @@ const Microtask = JSC.Microtask;
const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
const Backtrace = @import("../../../deps/backtrace.zig");
const JSPrinter = @import("../../../js_printer.zig");
const JSLexer = @import("../../../js_lexer.zig");
pub const ZigGlobalObject = extern struct {
pub const shim = Shimmer("Zig", "GlobalObject", @This());
bytes: shim.Bytes,
@@ -641,7 +642,7 @@ pub const ZigException = extern struct {
pub const Holder = extern struct {
const frame_count = 24;
const source_lines_count = 6;
pub const source_lines_count = 6;
source_line_numbers: [source_lines_count]i32,
source_lines: [source_lines_count]ZigString,
frames: [frame_count]ZigStackFrame,
@@ -1073,6 +1074,8 @@ pub const ZigConsoleClient = struct {
NativeCode,
ArrayBuffer,
JSX,
pub inline fn canHaveCircularReferences(tag: Tag) bool {
return tag == .Array or tag == .Object or tag == .Map or tag == .Set;
}
@@ -1103,15 +1106,24 @@ pub const ZigConsoleClient = struct {
return .{
.tag = .Boolean,
};
} else if (value.isSymbol()) {
return .{
.tag = .Symbol,
.cell = .Symbol,
};
}
const js_type = value.jsType();
if (js_type.isHidden()) return .{ .tag = .NativeCode };
if (js_type.isHidden()) return .{
.tag = .NativeCode,
.cell = js_type,
};
if (CAPI.JSObjectGetPrivate(value.asObjectRef()) != null)
return .{
.tag = .Private,
.cell = js_type,
};
// If we check an Object has a method table and it does not
@@ -1125,19 +1137,34 @@ pub const ZigConsoleClient = struct {
if (CAPI.JSValueIsObjectOfClass(globalThis.ref(), value.asObjectRef(), JSC.Bun.EnvironmentVariables.Class.get().?[0])) {
return .{
.tag = .Object,
.cell = js_type,
};
}
return .{
.tag = .Class,
.cell = js_type,
};
}
if (callable) {
return .{
.tag = .Function,
.cell = js_type,
};
}
// Is this a react element?
if (js_type.isObject()) {
if (value.get(globalThis, "$$typeof")) |typeof_symbol| {
var reactElement = ZigString.init("react.element");
var react_fragment = ZigString.init("react.fragment");
if (JSValue.isSameValue(typeof_symbol, JSValue.symbolFor(globalThis, &reactElement), globalThis) or JSValue.isSameValue(typeof_symbol, JSValue.symbolFor(globalThis, &react_fragment), globalThis)) {
return .{ .tag = .JSX, .cell = js_type };
}
}
}
return .{
.tag = switch (js_type) {
JSValue.JSType.ErrorInstance => .Error,
@@ -1311,9 +1338,7 @@ pub const ZigConsoleClient = struct {
const value = JSC.JSObject.getIndex(nextValue, globalObject, 1);
this.formatter.writeIndent(Writer, this.writer) catch unreachable;
const key_tag = Tag.get(key, globalObject);
if (key_tag.tag == Tag.String) {
this.writer.writeAll("\"") catch unreachable;
}
this.formatter.format(
key_tag,
Writer,
@@ -1322,15 +1347,8 @@ pub const ZigConsoleClient = struct {
this.formatter.globalThis,
enable_ansi_colors,
);
if (key_tag.tag == Tag.String) {
this.writer.writeAll("\": ") catch unreachable;
} else {
this.writer.writeAll(": ") catch unreachable;
}
this.writer.writeAll(": ") catch unreachable;
const value_tag = Tag.get(value, globalObject);
if (value_tag.tag == Tag.String) {
this.writer.writeAll("\"") catch unreachable;
}
this.formatter.format(
value_tag,
Writer,
@@ -1339,9 +1357,6 @@ pub const ZigConsoleClient = struct {
this.formatter.globalThis,
enable_ansi_colors,
);
if (value_tag.tag == Tag.String) {
this.writer.writeAll("\"") catch unreachable;
}
this.formatter.printComma(Writer, this.writer, enable_ansi_colors) catch unreachable;
this.writer.writeAll("\n") catch unreachable;
}
@@ -1458,6 +1473,19 @@ pub const ZigConsoleClient = struct {
.Null => {
writer.print(comptime Output.prettyFmt("<r><yellow>null<r>", enable_ansi_colors), .{});
},
.Symbol => {
var description = value.getDescription(this.globalThis);
if (description.len > 0) {
var slice = description.toSlice(default_allocator);
defer if (slice.allocated) slice.deinit();
writer.print(comptime Output.prettyFmt("<r><cyan>Symbol<r><d>(<green>{}<r><d>)<r>", enable_ansi_colors), .{
JSPrinter.formatJSONString(slice.slice()),
});
} else {
writer.print(comptime Output.prettyFmt("<r><cyan>Symbol<r>", enable_ansi_colors), .{});
}
},
.Error => {
JS.VirtualMachine.vm.printErrorlikeObject(
value,
@@ -1598,6 +1626,7 @@ pub const ZigConsoleClient = struct {
if (length == 0) {
return writer.writeAll("Map {}");
}
writer.print("Map({d}) {{\n", .{length});
{
this.indent += 1;
@@ -1654,63 +1683,299 @@ pub const ZigConsoleClient = struct {
writer.print("{}", .{str});
},
.JSX => {
writer.writeAll(comptime Output.prettyFmt("<r>", enable_ansi_colors));
writer.writeAll("<");
var needs_space = false;
var tag_name_str = ZigString.init("");
var tag_name_slice: ZigString.Slice = ZigString.Slice.empty;
var is_tag_kind_primitive = false;
defer if (tag_name_slice.allocated) tag_name_slice.deinit();
if (value.get(this.globalThis, "type")) |type_value| {
const _tag = Tag.get(type_value, this.globalThis);
if (_tag.cell == .Symbol) {} else if (_tag.cell.isStringLike()) {
type_value.toZigString(&tag_name_str, this.globalThis);
is_tag_kind_primitive = true;
} else if (_tag.cell.isObject() or type_value.isCallable(this.globalThis.vm())) {
type_value.getNameProperty(this.globalThis, &tag_name_str);
if (tag_name_str.len == 0) {
tag_name_str = ZigString.init("NoName");
}
} else {
type_value.toZigString(&tag_name_str, this.globalThis);
}
tag_name_slice = tag_name_str.toSlice(default_allocator);
needs_space = true;
} else {
tag_name_slice = ZigString.init("unknown").toSlice(default_allocator);
needs_space = true;
}
if (!is_tag_kind_primitive)
writer.writeAll(comptime Output.prettyFmt("<cyan>", enable_ansi_colors))
else
writer.writeAll(comptime Output.prettyFmt("<green>", enable_ansi_colors));
writer.writeAll(tag_name_slice.slice());
if (enable_ansi_colors) writer.writeAll(comptime Output.prettyFmt("<r>", enable_ansi_colors));
if (value.get(this.globalThis, "key")) |key_value| {
if (!key_value.isUndefinedOrNull()) {
if (needs_space)
writer.writeAll(" key=")
else
writer.writeAll("key=");
const old_quote_strings = this.quote_strings;
this.quote_strings = true;
defer this.quote_strings = old_quote_strings;
this.format(Tag.get(key_value, this.globalThis), Writer, writer_, key_value, this.globalThis, enable_ansi_colors);
needs_space = true;
}
}
if (value.get(this.globalThis, "props")) |props| {
const prev_quote_strings = this.quote_strings;
this.quote_strings = true;
defer this.quote_strings = prev_quote_strings;
var array = CAPI.JSObjectCopyPropertyNames(this.globalThis.ref(), props.asObjectRef());
defer CAPI.JSPropertyNameArrayRelease(array);
const count_ = CAPI.JSPropertyNameArrayGetCount(array);
var children_prop = props.get(this.globalThis, "children");
if (count_ > 0) {
{
var i: usize = 0;
this.indent += 1;
defer this.indent -|= 1;
const count_without_children = count_ - @as(usize, @boolToInt(children_prop != null));
while (i < count_) : (i += 1) {
var property_name_ref = CAPI.JSPropertyNameArrayGetNameAtIndex(array, i);
var prop = CAPI.JSStringGetCharacters8Ptr(property_name_ref)[0..CAPI.JSStringGetLength(property_name_ref)];
if (strings.eqlComptime(prop, "children")) {
CAPI.JSStringRelease(property_name_ref);
continue;
}
defer CAPI.JSStringRelease(property_name_ref);
var property_value = CAPI.JSObjectGetProperty(this.globalThis.ref(), props.asObjectRef(), property_name_ref, null);
const tag = Tag.get(JSValue.fromRef(property_value), this.globalThis);
if (tag.cell.isHidden()) continue;
if (needs_space) writer.writeAll(" ");
needs_space = false;
writer.print(
comptime Output.prettyFmt("<r><blue>{s}<d>=<r>", enable_ansi_colors),
.{prop[0..@minimum(prop.len, 128)]},
);
if (tag.cell.isStringLike()) {
if (comptime enable_ansi_colors) {
writer.writeAll(comptime Output.prettyFmt("<r><green>", true));
}
}
this.format(tag, Writer, writer_, JSValue.fromRef(property_value), this.globalThis, enable_ansi_colors);
if (tag.cell.isStringLike()) {
if (comptime enable_ansi_colors) {
writer.writeAll(comptime Output.prettyFmt("<r>", true));
}
}
if (
// count_without_children is necessary to prevent printing an extra newline
// if there are children and one prop and the child prop is the last prop
i + 1 < count_without_children and
// 3 is arbitrary but basically
// <input type="text" value="foo" />
// ^ should be one line
// <input type="text" value="foo" bar="true" baz={false} />
// ^ should be multiple lines
i > 3)
{
writer.writeAll("\n");
this.writeIndent(Writer, writer_) catch unreachable;
} else if (i + 1 < count_without_children) {
writer.writeAll(" ");
}
}
}
if (children_prop) |children| {
const tag = Tag.get(children, this.globalThis);
const print_children = switch (tag.tag) {
.String, .JSX, .Array => true,
else => false,
};
if (print_children) {
print_children: {
switch (tag.tag) {
.String => {
var children_slice = children.toSlice(this.globalThis, default_allocator);
defer if (children_slice.allocated) children_slice.deinit();
if (children_slice.len == 0) break :print_children;
if (comptime enable_ansi_colors) writer.writeAll(comptime Output.prettyFmt("<r>", true));
writer.writeAll(">");
if (children_slice.len < 128) {
writer.writeAll(children_slice.slice());
} else {
this.indent += 1;
writer.writeAll("\n");
this.writeIndent(Writer, writer_) catch unreachable;
this.indent -|= 1;
writer.writeAll(children_slice.slice());
writer.writeAll("\n");
this.writeIndent(Writer, writer_) catch unreachable;
}
},
.JSX => {
writer.writeAll(">\n");
{
this.indent += 1;
this.writeIndent(Writer, writer_) catch unreachable;
defer this.indent -|= 1;
this.format(Tag.get(children, this.globalThis), Writer, writer_, children, this.globalThis, enable_ansi_colors);
}
writer.writeAll("\n");
this.writeIndent(Writer, writer_) catch unreachable;
},
.Array => {
const length = children.getLengthOfArray(this.globalThis);
if (length == 0) break :print_children;
writer.writeAll(">\n");
{
this.indent += 1;
this.writeIndent(Writer, writer_) catch unreachable;
const _prev_quote_strings = this.quote_strings;
this.quote_strings = false;
defer this.quote_strings = _prev_quote_strings;
defer this.indent -|= 1;
var j: usize = 0;
while (j < length) : (j += 1) {
const child = JSC.JSObject.getIndex(children, this.globalThis, @intCast(u32, j));
this.format(Tag.get(child, this.globalThis), Writer, writer_, child, this.globalThis, enable_ansi_colors);
if (j + 1 < length) {
writer.writeAll("\n");
this.writeIndent(Writer, writer_) catch unreachable;
}
}
}
writer.writeAll("\n");
this.writeIndent(Writer, writer_) catch unreachable;
},
else => unreachable,
}
writer.writeAll("</");
if (!is_tag_kind_primitive)
writer.writeAll(comptime Output.prettyFmt("<r><cyan>", enable_ansi_colors))
else
writer.writeAll(comptime Output.prettyFmt("<r><green>", enable_ansi_colors));
writer.writeAll(tag_name_slice.slice());
if (enable_ansi_colors) writer.writeAll(comptime Output.prettyFmt("<r>", enable_ansi_colors));
writer.writeAll(">");
}
return;
}
}
}
}
writer.writeAll(" />");
},
.Object => {
var object = value.asObjectRef();
var array = CAPI.JSObjectCopyPropertyNames(this.globalThis.ref(), object);
defer CAPI.JSPropertyNameArrayRelease(array);
const count_ = CAPI.JSPropertyNameArrayGetCount(array);
var i: usize = 0;
const prev_quote_strings = this.quote_strings;
this.quote_strings = true;
defer this.quote_strings = prev_quote_strings;
{
var array = CAPI.JSObjectCopyPropertyNames(this.globalThis.ref(), object);
defer CAPI.JSPropertyNameArrayRelease(array);
const count_ = CAPI.JSPropertyNameArrayGetCount(array);
var i: usize = 0;
var name_str = ZigString.init("");
value.getPrototype(this.globalThis).getNameProperty(this.globalThis, &name_str);
const prev_quote_strings = this.quote_strings;
this.quote_strings = true;
defer this.quote_strings = prev_quote_strings;
if (name_str.len > 0 and !strings.eqlComptime(name_str.slice(), "Object")) {
writer.print("{} ", .{name_str});
}
var name_str = ZigString.init("");
value.getPrototype(this.globalThis).getNameProperty(this.globalThis, &name_str);
if (count_ == 0) {
writer.writeAll("{ }");
return;
}
writer.writeAll("{ ");
while (i < count_) : (i += 1) {
var property_name_ref = CAPI.JSPropertyNameArrayGetNameAtIndex(array, i);
defer CAPI.JSStringRelease(property_name_ref);
var prop = CAPI.JSStringGetCharacters8Ptr(property_name_ref)[0..CAPI.JSStringGetLength(property_name_ref)];
var property_value = CAPI.JSObjectGetProperty(this.globalThis.ref(), object, property_name_ref, null);
const tag = Tag.get(JSValue.fromRef(property_value), this.globalThis);
if (tag.cell.isHidden()) continue;
writer.print(
comptime Output.prettyFmt("{s}<d>:<r> ", enable_ansi_colors),
.{prop[0..@minimum(prop.len, 128)]},
);
if (tag.cell.isStringLike()) {
if (comptime enable_ansi_colors) {
writer.writeAll(comptime Output.prettyFmt("<r><green>", true));
}
if (name_str.len > 0 and !strings.eqlComptime(name_str.slice(), "Object")) {
writer.print("{} ", .{name_str});
}
this.format(tag, Writer, writer_, JSValue.fromRef(property_value), this.globalThis, enable_ansi_colors);
if (tag.cell.isStringLike()) {
if (comptime enable_ansi_colors) {
writer.writeAll(comptime Output.prettyFmt("<r>", true));
}
if (count_ == 0) {
writer.writeAll("{ }");
return;
}
if (i + 1 < count_) {
this.printComma(Writer, writer_, enable_ansi_colors) catch unreachable;
writer.writeAll(" ");
writer.writeAll("{ ");
while (i < count_) : (i += 1) {
var property_name_ref = CAPI.JSPropertyNameArrayGetNameAtIndex(array, i);
defer CAPI.JSStringRelease(property_name_ref);
var prop = CAPI.JSStringGetCharacters8Ptr(property_name_ref)[0..CAPI.JSStringGetLength(property_name_ref)];
var property_value = CAPI.JSObjectGetProperty(this.globalThis.ref(), object, property_name_ref, null);
const tag = Tag.get(JSValue.fromRef(property_value), this.globalThis);
if (tag.cell.isHidden()) continue;
const key = prop[0..@minimum(prop.len, 128)];
// TODO: make this one pass?
if (JSLexer.isLatin1Identifier(@TypeOf(key), key)) {
writer.print(
comptime Output.prettyFmt("{s}<d>:<r> ", enable_ansi_colors),
.{key},
);
} else {
writer.print(
comptime Output.prettyFmt("{s}<d>:<r> ", enable_ansi_colors),
.{JSPrinter.formatJSONString(key)},
);
}
if (tag.cell.isStringLike()) {
if (comptime enable_ansi_colors) {
writer.writeAll(comptime Output.prettyFmt("<r><green>", true));
}
}
this.format(tag, Writer, writer_, JSValue.fromRef(property_value), this.globalThis, enable_ansi_colors);
if (tag.cell.isStringLike()) {
if (comptime enable_ansi_colors) {
writer.writeAll(comptime Output.prettyFmt("<r>", true));
}
}
if (i + 1 < count_) {
this.printComma(Writer, writer_, enable_ansi_colors) catch unreachable;
writer.writeAll(" ");
}
}
}
@@ -1778,6 +2043,7 @@ pub const ZigConsoleClient = struct {
.JSON => this.printAs(.JSON, Writer, writer, value, result.cell, enable_ansi_colors),
.NativeCode => this.printAs(.NativeCode, Writer, writer, value, result.cell, enable_ansi_colors),
.ArrayBuffer => this.printAs(.ArrayBuffer, Writer, writer, value, result.cell, enable_ansi_colors),
.JSX => this.printAs(.JSX, Writer, writer, value, result.cell, enable_ansi_colors),
};
}
};

View File

@@ -482,8 +482,6 @@ pub fn getCStruct(comptime T: type) ?NamedStruct {
}
pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comptime fname: []const u8) type {
const all_decls = comptime std.meta.declarations(first_import) ++ std.meta.declarations(second_import);
return struct {
source_file: []const u8 = fname,
gen: C_Generator = undefined,
@@ -533,15 +531,11 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp
pub fn processStaticExport(comptime _: Self, _: anytype, gen: *C_Generator, comptime static_export: StaticExport) void {
const fn_meta = comptime @typeInfo(static_export.Type).Fn;
const DeclData = static_export.Decl().data;
const DeclData = @typeInfo(@TypeOf(@field(static_export.Parent, static_export.local_name)));
gen.gen_func(
comptime static_export.symbol_name,
comptime switch (DeclData) {
.Fn => |Fn| Fn,
.Var => |Var| @typeInfo(Var).Fn,
else => unreachable,
},
DeclData.Fn,
comptime fn_meta,
comptime std.mem.zeroes([]const []const u8),
false,
@@ -552,12 +546,14 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp
comptime _: Self,
_: anytype,
gen: *C_Generator,
comptime _: type,
comptime Decl: std.builtin.TypeInfo.Declaration,
comptime ParentType: type,
comptime _: std.builtin.TypeInfo.Declaration,
comptime name: []const u8,
comptime prefix: []const u8,
) void {
switch (comptime Decl.data) {
const DeclData = @typeInfo(@TypeOf(@field(ParentType, name)));
switch (comptime DeclData) {
.Type => |Type| {
switch (@typeInfo(Type)) {
.Enum => |Enum| {
@@ -587,7 +583,7 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp
gen.gen_func(
comptime prefix ++ "__" ++ name,
comptime func,
comptime @typeInfo(func.fn_type).Fn,
comptime func,
comptime &.{},
comptime ENABLE_REWRITE_RETURN and @typeInfo(func.return_type) == .Struct,
);
@@ -677,16 +673,20 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp
var to_get_sizes: usize = 0;
const exclude_from_cpp = comptime [_][]const u8{ "ZigString", "ZigException" };
inline for (all_decls) |_decls| {
if (comptime _decls.is_pub) {
switch (_decls.data) {
.Type => |Type| {
@setEvalBranchQuota(99999);
const TypeTypeInfo: std.builtin.TypeInfo = @typeInfo(Type);
const TypesToCheck = [_]type{ first_import, second_import };
inline for (TypesToCheck) |BaseType| {
const all_decls = comptime std.meta.declarations(BaseType);
inline for (all_decls) |_decls| {
if (comptime _decls.is_pub) {
@setEvalBranchQuota(99999);
const Type = @field(BaseType, _decls.name);
if (@TypeOf(Type) == type) {
const TypeTypeInfo: std.builtin.TypeInfo = @typeInfo(@field(BaseType, _decls.name));
const is_container_type = switch (TypeTypeInfo) {
.Opaque, .Struct, .Enum => true,
else => false,
};
if (is_container_type and (@hasDecl(Type, "Extern") or @hasDecl(Type, "Export"))) {
const identifier = comptime std.fmt.comptimePrint("{s}_{s}", .{ Type.shim.name, Type.shim.namespace });
if (!bufset.contains(identifier)) {
@@ -783,8 +783,7 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp
}
}
}
},
else => {},
}
}
}
}

View File

@@ -1,4 +1,4 @@
//-- AUTOGENERATED FILE -- 1646285827
//-- AUTOGENERATED FILE -- 1646833921
// clang-format off
#pragma once

View File

@@ -1,17 +1,17 @@
// clang-format: off
//-- AUTOGENERATED FILE -- 1646285827
//-- AUTOGENERATED FILE -- 1646833921
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
#define AUTO_EXTERN_C extern "C"
#define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak))
#define AUTO_EXTERN_C extern "C"
#define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak))
#else
#define AUTO_EXTERN_C
#define AUTO_EXTERN_C_ZIG __attribute__((weak))
#define AUTO_EXTERN_C
#define AUTO_EXTERN_C_ZIG __attribute__((weak))
#endif
#define ZIG_DECL AUTO_EXTERN_C_ZIG
#define CPP_DECL AUTO_EXTERN_C
@@ -26,269 +26,222 @@ typedef void* JSClassRef;
#include <JavaScriptCore/JSClassRef.h>
#endif
#include "headers-handwritten.h"
typedef struct bJSC__SourceCode {
unsigned char bytes[24];
} bJSC__SourceCode;
typedef char* bJSC__SourceCode_buf;
typedef struct bWTF__URL {
unsigned char bytes[40];
} bWTF__URL;
typedef char* bWTF__URL_buf;
typedef struct bJSC__JSModuleRecord {
unsigned char bytes[216];
} bJSC__JSModuleRecord;
typedef char* bJSC__JSModuleRecord_buf;
typedef struct bJSC__ThrowScope {
unsigned char bytes[8];
} bJSC__ThrowScope;
typedef char* bJSC__ThrowScope_buf;
typedef struct bJSC__CallFrame {
unsigned char bytes[8];
} bJSC__CallFrame;
typedef char* bJSC__CallFrame_buf;
typedef struct bJSC__JSFunction {
unsigned char bytes[32];
} bJSC__JSFunction;
typedef char* bJSC__JSFunction_buf;
typedef struct bJSC__PropertyName {
unsigned char bytes[8];
} bJSC__PropertyName;
typedef char* bJSC__PropertyName_buf;
typedef struct bJSC__JSGlobalObject {
unsigned char bytes[2400];
} bJSC__JSGlobalObject;
typedef char* bJSC__JSGlobalObject_buf;
typedef struct bJSC__JSCell {
unsigned char bytes[8];
} bJSC__JSCell;
typedef char* bJSC__JSCell_buf;
typedef struct bJSC__CatchScope {
unsigned char bytes[8];
} bJSC__CatchScope;
typedef char* bJSC__CatchScope_buf;
typedef struct bWTF__String {
unsigned char bytes[8];
} bWTF__String;
typedef char* bWTF__String_buf;
typedef struct bWTF__StringView {
unsigned char bytes[16];
} bWTF__StringView;
typedef char* bWTF__StringView_buf;
typedef struct bJSC__JSModuleLoader {
unsigned char bytes[16];
} bJSC__JSModuleLoader;
typedef char* bJSC__JSModuleLoader_buf;
typedef struct bInspector__ScriptArguments {
unsigned char bytes[32];
} bInspector__ScriptArguments;
typedef char* bInspector__ScriptArguments_buf;
typedef struct bJSC__Exception {
unsigned char bytes[40];
} bJSC__Exception;
typedef char* bJSC__Exception_buf;
typedef struct bJSC__VM {
unsigned char bytes[48824];
} bJSC__VM;
typedef char* bJSC__VM_buf;
typedef struct bJSC__JSString {
unsigned char bytes[16];
} bJSC__JSString;
typedef char* bJSC__JSString_buf;
typedef struct bJSC__SourceOrigin {
unsigned char bytes[48];
} bJSC__SourceOrigin;
typedef char* bJSC__SourceOrigin_buf;
typedef struct bWTF__ExternalStringImpl {
unsigned char bytes[32];
} bWTF__ExternalStringImpl;
typedef char* bWTF__ExternalStringImpl_buf;
typedef struct bJSC__JSInternalPromise {
unsigned char bytes[32];
} bJSC__JSInternalPromise;
typedef char* bJSC__JSInternalPromise_buf;
typedef struct bWTF__StringImpl {
unsigned char bytes[24];
} bWTF__StringImpl;
typedef char* bWTF__StringImpl_buf;
typedef struct bJSC__JSPromise {
unsigned char bytes[32];
} bJSC__JSPromise;
typedef char* bJSC__JSPromise_buf;
typedef struct bJSC__JSObject {
unsigned char bytes[16];
} bJSC__JSObject;
typedef char* bJSC__JSObject_buf;
typedef struct bJSC__Identifier {
unsigned char bytes[8];
} bJSC__Identifier;
typedef char* bJSC__Identifier_buf;
typedef struct bJSC__SourceCode { unsigned char bytes[24]; } bJSC__SourceCode;
typedef char* bJSC__SourceCode_buf;
typedef struct bWTF__URL { unsigned char bytes[40]; } bWTF__URL;
typedef char* bWTF__URL_buf;
typedef struct bJSC__JSModuleRecord { unsigned char bytes[216]; } bJSC__JSModuleRecord;
typedef char* bJSC__JSModuleRecord_buf;
typedef struct bJSC__ThrowScope { unsigned char bytes[8]; } bJSC__ThrowScope;
typedef char* bJSC__ThrowScope_buf;
typedef struct bJSC__CallFrame { unsigned char bytes[8]; } bJSC__CallFrame;
typedef char* bJSC__CallFrame_buf;
typedef struct bJSC__JSFunction { unsigned char bytes[32]; } bJSC__JSFunction;
typedef char* bJSC__JSFunction_buf;
typedef struct bJSC__PropertyName { unsigned char bytes[8]; } bJSC__PropertyName;
typedef char* bJSC__PropertyName_buf;
typedef struct bJSC__JSGlobalObject { unsigned char bytes[2400]; } bJSC__JSGlobalObject;
typedef char* bJSC__JSGlobalObject_buf;
typedef struct bJSC__JSCell { unsigned char bytes[8]; } bJSC__JSCell;
typedef char* bJSC__JSCell_buf;
typedef struct bJSC__CatchScope { unsigned char bytes[8]; } bJSC__CatchScope;
typedef char* bJSC__CatchScope_buf;
typedef struct bWTF__String { unsigned char bytes[8]; } bWTF__String;
typedef char* bWTF__String_buf;
typedef struct bWTF__StringView { unsigned char bytes[16]; } bWTF__StringView;
typedef char* bWTF__StringView_buf;
typedef struct bJSC__JSModuleLoader { unsigned char bytes[16]; } bJSC__JSModuleLoader;
typedef char* bJSC__JSModuleLoader_buf;
typedef struct bInspector__ScriptArguments { unsigned char bytes[32]; } bInspector__ScriptArguments;
typedef char* bInspector__ScriptArguments_buf;
typedef struct bJSC__Exception { unsigned char bytes[40]; } bJSC__Exception;
typedef char* bJSC__Exception_buf;
typedef struct bJSC__VM { unsigned char bytes[48824]; } bJSC__VM;
typedef char* bJSC__VM_buf;
typedef struct bJSC__JSString { unsigned char bytes[16]; } bJSC__JSString;
typedef char* bJSC__JSString_buf;
typedef struct bJSC__SourceOrigin { unsigned char bytes[48]; } bJSC__SourceOrigin;
typedef char* bJSC__SourceOrigin_buf;
typedef struct bWTF__ExternalStringImpl { unsigned char bytes[32]; } bWTF__ExternalStringImpl;
typedef char* bWTF__ExternalStringImpl_buf;
typedef struct bJSC__JSInternalPromise { unsigned char bytes[32]; } bJSC__JSInternalPromise;
typedef char* bJSC__JSInternalPromise_buf;
typedef struct bWTF__StringImpl { unsigned char bytes[24]; } bWTF__StringImpl;
typedef char* bWTF__StringImpl_buf;
typedef struct bJSC__JSPromise { unsigned char bytes[32]; } bJSC__JSPromise;
typedef char* bJSC__JSPromise_buf;
typedef struct bJSC__JSObject { unsigned char bytes[16]; } bJSC__JSObject;
typedef char* bJSC__JSObject_buf;
typedef struct bJSC__Identifier { unsigned char bytes[8]; } bJSC__Identifier;
typedef char* bJSC__Identifier_buf;
#ifndef __cplusplus
typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope
typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype
typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype
typedef ErrorableResolvedSource ErrorableResolvedSource;
typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype
typedef ErrorableZigString ErrorableZigString;
typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName
typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject
typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl
typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype
typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader
typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype
typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype
typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier
typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype
typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback
typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise
typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype
typedef SystemError SystemError;
typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell
typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin
typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord
typedef bWTF__String WTF__String; // WTF::String
typedef bWTF__URL WTF__URL; // WTF::URL
typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype
typedef Bun__Readable Bun__Readable;
typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise
typedef Bun__Writable Bun__Writable;
typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype
typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame
typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype
typedef bWTF__StringView WTF__StringView; // WTF::StringView
typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope
typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl
typedef bJSC__VM JSC__VM; // JSC::VM
typedef JSClassRef JSClassRef;
typedef Bun__ArrayBuffer Bun__ArrayBuffer;
typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject
typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction
typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype
typedef ZigException ZigException;
typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode
typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype
typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype
typedef ZigString ZigString;
typedef int64_t JSC__JSValue;
typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype
typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments
typedef bJSC__Exception JSC__Exception; // JSC::Exception
typedef bJSC__JSString JSC__JSString; // JSC::JSString
typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype
typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype
typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope
typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype
typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype
typedef ErrorableResolvedSource ErrorableResolvedSource;
typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype
typedef ErrorableZigString ErrorableZigString;
typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName
typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject
typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl
typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype
typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader
typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype
typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype
typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier
typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype
typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback
typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise
typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype
typedef SystemError SystemError;
typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell
typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin
typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord
typedef bWTF__String WTF__String; // WTF::String
typedef bWTF__URL WTF__URL; // WTF::URL
typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype
typedef Bun__Readable Bun__Readable;
typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise
typedef Bun__Writable Bun__Writable;
typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype
typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame
typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype
typedef bWTF__StringView WTF__StringView; // WTF::StringView
typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope
typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl
typedef bJSC__VM JSC__VM; // JSC::VM
typedef JSClassRef JSClassRef;
typedef Bun__ArrayBuffer Bun__ArrayBuffer;
typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject
typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction
typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype
typedef ZigException ZigException;
typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode
typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype
typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype
typedef ZigString ZigString;
typedef int64_t JSC__JSValue;
typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype
typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments
typedef bJSC__Exception JSC__Exception; // JSC::Exception
typedef bJSC__JSString JSC__JSString; // JSC::JSString
typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype
typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype
#endif
#ifdef __cplusplus
namespace JSC {
class JSCell;
class Exception;
class JSPromisePrototype;
class StringPrototype;
class GeneratorFunctionPrototype;
class ArrayPrototype;
class JSString;
class JSObject;
class AsyncIteratorPrototype;
class AsyncGeneratorFunctionPrototype;
class Identifier;
class JSPromise;
class RegExpPrototype;
class AsyncFunctionPrototype;
class CatchScope;
class VM;
class BigIntPrototype;
class SourceOrigin;
class ThrowScope;
class SetIteratorPrototype;
class AsyncGeneratorPrototype;
class PropertyName;
class MapIteratorPrototype;
class JSModuleRecord;
class JSInternalPromise;
class ArrayIteratorPrototype;
class JSFunction;
class JSModuleLoader;
class GeneratorPrototype;
class JSGlobalObject;
class SourceCode;
class FunctionPrototype;
class IteratorPrototype;
class CallFrame;
class ObjectPrototype;
}
namespace WTF {
class URL;
class StringImpl;
class String;
class StringView;
class ExternalStringImpl;
}
namespace Zig {
class JSMicrotaskCallback;
}
namespace Inspector {
class ScriptArguments;
}
namespace JSC {
class JSCell;
class Exception;
class JSPromisePrototype;
class StringPrototype;
class GeneratorFunctionPrototype;
class ArrayPrototype;
class JSString;
class JSObject;
class AsyncIteratorPrototype;
class AsyncGeneratorFunctionPrototype;
class Identifier;
class JSPromise;
class RegExpPrototype;
class AsyncFunctionPrototype;
class CatchScope;
class VM;
class BigIntPrototype;
class SourceOrigin;
class ThrowScope;
class SetIteratorPrototype;
class AsyncGeneratorPrototype;
class PropertyName;
class MapIteratorPrototype;
class JSModuleRecord;
class JSInternalPromise;
class ArrayIteratorPrototype;
class JSFunction;
class JSModuleLoader;
class GeneratorPrototype;
class JSGlobalObject;
class SourceCode;
class FunctionPrototype;
class IteratorPrototype;
class CallFrame;
class ObjectPrototype;
}
namespace WTF {
class URL;
class StringImpl;
class String;
class StringView;
class ExternalStringImpl;
}
namespace Zig {
class JSMicrotaskCallback;
}
namespace Inspector {
class ScriptArguments;
}
typedef ErrorableResolvedSource ErrorableResolvedSource;
typedef ErrorableZigString ErrorableZigString;
typedef SystemError SystemError;
typedef Bun__Readable Bun__Readable;
typedef Bun__Writable Bun__Writable;
typedef JSClassRef JSClassRef;
typedef Bun__ArrayBuffer Bun__ArrayBuffer;
typedef ZigException ZigException;
typedef ZigString ZigString;
typedef int64_t JSC__JSValue;
using JSC__JSCell = JSC::JSCell;
using JSC__Exception = JSC::Exception;
using JSC__JSPromisePrototype = JSC::JSPromisePrototype;
using JSC__StringPrototype = JSC::StringPrototype;
using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype;
using JSC__ArrayPrototype = JSC::ArrayPrototype;
using JSC__JSString = JSC::JSString;
using JSC__JSObject = JSC::JSObject;
using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype;
using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype;
using JSC__Identifier = JSC::Identifier;
using JSC__JSPromise = JSC::JSPromise;
using JSC__RegExpPrototype = JSC::RegExpPrototype;
using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype;
using JSC__CatchScope = JSC::CatchScope;
using JSC__VM = JSC::VM;
using JSC__BigIntPrototype = JSC::BigIntPrototype;
using JSC__SourceOrigin = JSC::SourceOrigin;
using JSC__ThrowScope = JSC::ThrowScope;
using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype;
using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype;
using JSC__PropertyName = JSC::PropertyName;
using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype;
using JSC__JSModuleRecord = JSC::JSModuleRecord;
using JSC__JSInternalPromise = JSC::JSInternalPromise;
using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype;
using JSC__JSFunction = JSC::JSFunction;
using JSC__JSModuleLoader = JSC::JSModuleLoader;
using JSC__GeneratorPrototype = JSC::GeneratorPrototype;
using JSC__JSGlobalObject = JSC::JSGlobalObject;
using JSC__SourceCode = JSC::SourceCode;
using JSC__FunctionPrototype = JSC::FunctionPrototype;
using JSC__IteratorPrototype = JSC::IteratorPrototype;
using JSC__CallFrame = JSC::CallFrame;
using JSC__ObjectPrototype = JSC::ObjectPrototype;
using WTF__URL = WTF::URL;
using WTF__StringImpl = WTF::StringImpl;
using WTF__String = WTF::String;
using WTF__StringView = WTF::StringView;
using WTF__ExternalStringImpl = WTF::ExternalStringImpl;
using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback;
using Inspector__ScriptArguments = Inspector::ScriptArguments;
typedef ErrorableResolvedSource ErrorableResolvedSource;
typedef ErrorableZigString ErrorableZigString;
typedef SystemError SystemError;
typedef Bun__Readable Bun__Readable;
typedef Bun__Writable Bun__Writable;
typedef JSClassRef JSClassRef;
typedef Bun__ArrayBuffer Bun__ArrayBuffer;
typedef ZigException ZigException;
typedef ZigString ZigString;
typedef int64_t JSC__JSValue;
using JSC__JSCell = JSC::JSCell;
using JSC__Exception = JSC::Exception;
using JSC__JSPromisePrototype = JSC::JSPromisePrototype;
using JSC__StringPrototype = JSC::StringPrototype;
using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype;
using JSC__ArrayPrototype = JSC::ArrayPrototype;
using JSC__JSString = JSC::JSString;
using JSC__JSObject = JSC::JSObject;
using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype;
using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype;
using JSC__Identifier = JSC::Identifier;
using JSC__JSPromise = JSC::JSPromise;
using JSC__RegExpPrototype = JSC::RegExpPrototype;
using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype;
using JSC__CatchScope = JSC::CatchScope;
using JSC__VM = JSC::VM;
using JSC__BigIntPrototype = JSC::BigIntPrototype;
using JSC__SourceOrigin = JSC::SourceOrigin;
using JSC__ThrowScope = JSC::ThrowScope;
using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype;
using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype;
using JSC__PropertyName = JSC::PropertyName;
using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype;
using JSC__JSModuleRecord = JSC::JSModuleRecord;
using JSC__JSInternalPromise = JSC::JSInternalPromise;
using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype;
using JSC__JSFunction = JSC::JSFunction;
using JSC__JSModuleLoader = JSC::JSModuleLoader;
using JSC__GeneratorPrototype = JSC::GeneratorPrototype;
using JSC__JSGlobalObject = JSC::JSGlobalObject;
using JSC__SourceCode = JSC::SourceCode;
using JSC__FunctionPrototype = JSC::FunctionPrototype;
using JSC__IteratorPrototype = JSC::IteratorPrototype;
using JSC__CallFrame = JSC::CallFrame;
using JSC__ObjectPrototype = JSC::ObjectPrototype;
using WTF__URL = WTF::URL;
using WTF__StringImpl = WTF::StringImpl;
using WTF__String = WTF::String;
using WTF__StringView = WTF::StringView;
using WTF__ExternalStringImpl = WTF::ExternalStringImpl;
using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback;
using Inspector__ScriptArguments = Inspector::ScriptArguments;
#endif
#pragma mark - JSC::JSObject
CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (*ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2));
CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (* ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2));
CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0);
CPP_DECL JSC__JSValue JSC__JSObject__getDirect(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, const ZigString* arg2);
CPP_DECL JSC__JSValue JSC__JSObject__getIndex(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, uint32_t arg2);
@@ -386,7 +339,7 @@ CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSVal
CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const unsigned char* arg6);
CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const unsigned char* arg4);
CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const unsigned char* arg3);
CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* arg3, JSC__JSValue (*ArgFn4)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2));
CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* arg3, JSC__JSValue (* ArgFn4)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2));
CPP_DECL bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1);
CPP_DECL bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1);
@@ -485,7 +438,7 @@ CPP_DECL JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject* arg0,
CPP_DECL JSC__JSValue JSC__JSValue__createTypeError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2);
CPP_DECL bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell* arg1);
CPP_DECL bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1);
CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (*ArgFn3)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, void* arg2, JSC__JSValue JSValue3));
CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, void* arg2, JSC__JSValue JSValue3));
CPP_DECL JSC__JSValue JSC__JSValue__fromEntries(JSC__JSGlobalObject* arg0, ZigString* arg1, ZigString* arg2, size_t arg3, bool arg4);
CPP_DECL void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
CPP_DECL JSC__JSValue JSC__JSValue__getErrorsProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
@@ -494,6 +447,7 @@ CPP_DECL uint32_t JSC__JSValue__getLengthOfArray(JSC__JSValue JSValue0, JSC__JSG
CPP_DECL void JSC__JSValue__getNameProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
CPP_DECL JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
CPP_DECL Bun__Readable* JSC__JSValue__getReadableStreamState(JSC__JSValue JSValue0, JSC__VM* arg1);
CPP_DECL void JSC__JSValue__getSymbolDescription(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
CPP_DECL Bun__Writable* JSC__JSValue__getWritableStreamState(JSC__JSValue JSValue0, JSC__VM* arg1);
CPP_DECL bool JSC__JSValue__isAggregateError(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
CPP_DECL bool JSC__JSValue__isAnyInt(JSC__JSValue JSValue0);
@@ -536,6 +490,8 @@ CPP_DECL JSC__JSValue JSC__JSValue__jsTDZValue();
CPP_DECL unsigned char JSC__JSValue__jsType(JSC__JSValue JSValue0);
CPP_DECL JSC__JSValue JSC__JSValue__jsUndefined();
CPP_DECL void JSC__JSValue__putRecord(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3, size_t arg4);
CPP_DECL JSC__JSValue JSC__JSValue__symbolFor(JSC__JSGlobalObject* arg0, ZigString* arg1);
CPP_DECL bool JSC__JSValue__symbolKeyFor(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
CPP_DECL bool JSC__JSValue__toBoolean(JSC__JSValue JSValue0);
CPP_DECL int32_t JSC__JSValue__toInt32(JSC__JSValue JSValue0);
CPP_DECL JSC__JSObject* JSC__JSValue__toObject(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
@@ -569,7 +525,7 @@ CPP_DECL void JSC__VM__deinit(JSC__VM* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL void JSC__VM__deleteAllCode(JSC__VM* arg0, JSC__JSGlobalObject* arg1);
CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM* arg0);
CPP_DECL bool JSC__VM__executionForbidden(JSC__VM* arg0);
CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (*ArgFn2)(void* arg0));
CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (* ArgFn2)(void* arg0));
CPP_DECL bool JSC__VM__isEntered(JSC__VM* arg0);
CPP_DECL bool JSC__VM__isJITEnabled();
CPP_DECL JSC__JSValue JSC__VM__runGC(JSC__VM* arg0, bool arg1);
@@ -577,7 +533,7 @@ CPP_DECL void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1);
CPP_DECL void JSC__VM__setExecutionTimeLimit(JSC__VM* arg0, double arg1);
CPP_DECL void JSC__VM__shrinkFootprint(JSC__VM* arg0);
CPP_DECL bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const unsigned char* arg3, size_t arg4);
CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (*ArgFn1)());
CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (* ArgFn1)());
#pragma mark - JSC::ThrowScope
@@ -635,7 +591,7 @@ CPP_DECL size_t WTF__StringImpl__length(const WTF__StringImpl* arg0);
CPP_DECL const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0);
CPP_DECL const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0);
CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (*ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2));
CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (* ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2));
CPP_DECL bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl* arg0);
CPP_DECL bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl* arg0);
CPP_DECL bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl* arg0);
@@ -747,6 +703,7 @@ CPP_DECL ZigException ZigException__fromException(JSC__Exception* arg0);
#pragma mark - Zig::ConsoleClient
#ifdef __cplusplus
ZIG_DECL void Zig__ConsoleClient__count(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
@@ -767,6 +724,7 @@ ZIG_DECL void Zig__ConsoleClient__timeStamp(void* arg0, JSC__JSGlobalObject* arg
#pragma mark - Bun__Timer
#ifdef __cplusplus
ZIG_DECL JSC__JSValue Bun__Timer__clearInterval(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);

View File

@@ -295,6 +295,7 @@ pub extern fn JSC__JSValue__getLengthOfArray(JSValue0: JSC__JSValue, arg1: [*c]J
pub extern fn JSC__JSValue__getNameProperty(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString) void;
pub extern fn JSC__JSValue__getPrototype(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
pub extern fn JSC__JSValue__getReadableStreamState(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) [*c]Bun__Readable;
pub extern fn JSC__JSValue__getSymbolDescription(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString) void;
pub extern fn JSC__JSValue__getWritableStreamState(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) [*c]Bun__Writable;
pub extern fn JSC__JSValue__isAggregateError(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bool;
pub extern fn JSC__JSValue__isAnyInt(JSValue0: JSC__JSValue) bool;
@@ -337,6 +338,8 @@ pub extern fn JSC__JSValue__jsTDZValue(...) JSC__JSValue;
pub extern fn JSC__JSValue__jsType(JSValue0: JSC__JSValue) u8;
pub extern fn JSC__JSValue__jsUndefined(...) JSC__JSValue;
pub extern fn JSC__JSValue__putRecord(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString, arg3: [*c]ZigString, arg4: usize) void;
pub extern fn JSC__JSValue__symbolFor(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]ZigString) JSC__JSValue;
pub extern fn JSC__JSValue__symbolKeyFor(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString) bool;
pub extern fn JSC__JSValue__toBoolean(JSValue0: JSC__JSValue) bool;
pub extern fn JSC__JSValue__toInt32(JSValue0: JSC__JSValue) i32;
pub extern fn JSC__JSValue__toObject(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;

View File

@@ -373,7 +373,7 @@ pub const Expect = struct {
JSC.JSError(
getAllocator(ctx),
"test failed\n\tExpected: {}\n\tReceived: {}",
"Expected: {}\n\tReceived: {}",
.{
left.toFmt(ctx.ptr(), &lhs_formatter),
right.toFmt(ctx.ptr(), &rhs_formatter),