aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/__global.zig2
-rw-r--r--src/api/bundle_v2.peechy75
-rw-r--r--src/api/schema.d.ts20
-rw-r--r--src/api/schema.js132
-rw-r--r--src/api/schema.peechy16
-rw-r--r--src/api/schema.zig72
-rw-r--r--src/ast/base.zig185
-rw-r--r--src/baby_list.zig81
-rw-r--r--src/base64/base64.zig2
-rw-r--r--src/bit_set.zig (renamed from src/install/bit_set.zig)187
-rw-r--r--src/build-id2
m---------src/bun.js/WebKit0
-rw-r--r--src/bun.js/api/JSBundler.classes.ts (renamed from src/bun.js/api/transpiler.classes.ts)24
-rw-r--r--src/bun.js/api/JSBundler.zig332
-rw-r--r--src/bun.js/api/JSTranspiler.zig (renamed from src/bun.js/api/transpiler.zig)12
-rw-r--r--src/bun.js/api/bun.zig18
-rw-r--r--src/bun.js/api/ffi.zig1
-rw-r--r--src/bun.js/api/server.zig8
-rw-r--r--src/bun.js/base.zig1
-rw-r--r--src/bun.js/bindings/JSBundler+BunPlugin-impl.h (renamed from src/bun.js/bindings/JSTranspiler+BunPlugin-impl.h)0
-rw-r--r--src/bun.js/bindings/JSSink.cpp2
-rw-r--r--src/bun.js/bindings/JSSink.h2
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h3
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h3
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h6
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h7
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp13814
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h3169
-rw-r--r--src/bun.js/bindings/bindings.zig127
-rw-r--r--src/bun.js/bindings/generated_classes.zig5655
-rw-r--r--src/bun.js/bindings/generated_classes_list.zig37
-rw-r--r--src/bun.js/event_loop.zig216
-rw-r--r--src/bun.js/javascript.zig496
-rw-r--r--src/bun.js/javascript_core_c_api.zig2
-rw-r--r--src/bun.js/module_loader.zig37
-rw-r--r--src/bun.js/test/jest.zig6
-rw-r--r--src/bun.zig137
-rw-r--r--src/bundler.zig131
-rw-r--r--src/bundler/bundle_v2.zig7773
-rw-r--r--src/bundler/generate_node_modules_bundle.zig17
-rw-r--r--src/bunfig.zig6
-rw-r--r--src/c.zig3
-rw-r--r--src/cache.zig2
-rw-r--r--src/cli.zig205
-rw-r--r--src/cli/build_command.zig314
-rw-r--r--src/cli/bun_command.zig242
-rw-r--r--src/comptime_string_map.zig12
-rw-r--r--src/defines-table.zig1345
-rw-r--r--src/defines.zig125
-rw-r--r--src/feature_flags.zig21
-rw-r--r--src/fs.zig27
-rw-r--r--src/import_record.zig63
-rw-r--r--src/install/install.zig2
-rw-r--r--src/install/lockfile.zig2
-rw-r--r--src/install/semver.zig2
-rw-r--r--src/js_ast.zig1569
-rw-r--r--src/js_lexer.zig107
-rw-r--r--src/js_parser.zig3599
-rw-r--r--src/js_printer.zig773
-rw-r--r--src/jsc.zig3
-rw-r--r--src/json_parser.zig8
-rw-r--r--src/linker.zig135
-rw-r--r--src/logger.zig38
-rw-r--r--src/main.zig2
-rw-r--r--src/meta.zig2
-rw-r--r--src/mimalloc_arena.zig65
-rw-r--r--src/multi_array_list.zig724
-rw-r--r--src/options.zig152
-rw-r--r--src/output.zig37
-rw-r--r--src/renamer.zig520
-rw-r--r--src/resolver/package_json.zig232
-rw-r--r--src/resolver/resolve_path.zig2
-rw-r--r--src/resolver/resolver.zig54
-rw-r--r--src/runtime.js142
-rw-r--r--src/runtime.zig37
-rw-r--r--src/sourcemap/sourcemap.zig53
-rw-r--r--src/string_builder.zig35
-rw-r--r--src/string_immutable.zig160
-rw-r--r--src/string_joiner.zig34
-rw-r--r--src/string_mutable.zig27
-rw-r--r--src/sync.zig8
-rw-r--r--src/thread_pool.zig263
-rw-r--r--src/util.zig341
83 files changed, 28365 insertions, 15938 deletions
diff --git a/src/__global.zig b/src/__global.zig
index dcbe18bc4..73afe70c2 100644
--- a/src/__global.zig
+++ b/src/__global.zig
@@ -7,7 +7,7 @@ const StringTypes = @import("./string_types.zig");
const Mimalloc = @import("bun").Mimalloc;
const bun = @import("bun");
-const BASE_VERSION = "0.5";
+const BASE_VERSION = "0.6";
pub const build_id = std.fmt.parseInt(u64, std.mem.trim(u8, @embedFile("./build-id"), "\n \r\t"), 10) catch unreachable;
pub const package_json_version = if (Environment.isDebug)
diff --git a/src/api/bundle_v2.peechy b/src/api/bundle_v2.peechy
deleted file mode 100644
index db83d257b..000000000
--- a/src/api/bundle_v2.peechy
+++ /dev/null
@@ -1,75 +0,0 @@
-struct Export {
- uint32 part_id;
- StringPointer name;
-}
-
-
-struct JavascriptBundledPart {
- StringPointer code;
-
- uint32 dependencies_offset;
- uint32 dependencies_length;
-
- uint32 exports_offset;
- uint32 exports_length;
-
- uint32 from_module;
-
- // The ESM export is this id ("$" + number.toString(16))
- uint32 id;
-}
-
-struct JavascriptBundledModule {
- // package-relative path including file extension
- StringPointer path;
-
- uint32 parts_offset;
- uint32 parts_length;
-
- uint32 exports_offset;
- uint32 exports_length;
-
- // index into JavascriptBundle.packages
- uint32 package_id;
-
- // This lets us efficiently compare strings ignoring the extension
- byte path_extname_length;
-}
-
-struct JavascriptBundledPackage {
- StringPointer name;
- StringPointer version;
- uint32 hash;
-
- uint32 modules_offset;
- uint32 modules_length;
-}
-
-struct JavascriptBundle {
- // These are sorted alphabetically so you can do binary search
- JavascriptBundledModule[] modules;
- JavascriptBundledPackage[] packages;
-
- // This is ASCII-encoded so you can send it directly over HTTP
- byte[] etag;
-
- uint32 generated_at;
-
- byte[] import_from_name;
-
- // This is what StringPointer refers to
- byte[] manifest_string;
-}
-
-message JavascriptBundleContainer {
- uint32 bundle_format_version = 1;
-
- // These go first so if we change JavaScriptBundle we can still read these
- LoadedRouteConfig routes = 3;
- LoadedFramework framework = 2;
-
- JavascriptBundle bundle = 4;
-
- // Don't technically need to store this, but it may be helpful as a sanity check
- uint32 code_length = 5;
-}
diff --git a/src/api/schema.d.ts b/src/api/schema.d.ts
index a303f83b9..e406fbc52 100644
--- a/src/api/schema.d.ts
+++ b/src/api/schema.d.ts
@@ -702,6 +702,22 @@ export interface BunInstall {
global_bin_dir?: string;
}
+export interface ClientServerModule {
+ moduleId: uint32;
+ inputName: StringPointer;
+ assetName: StringPointer;
+ exportNames: StringPointer;
+}
+
+export interface ClientServerModuleManifest {
+ version: uint32;
+ clientModules: ClientServerModule[];
+ serverModules: ClientServerModule[];
+ ssrModules: ClientServerModule[];
+ exportNames: StringPointer[];
+ contents: Uint8Array;
+}
+
export declare function encodeStackFrame(message: StackFrame, bb: ByteBuffer): void;
export declare function decodeStackFrame(buffer: ByteBuffer): StackFrame;
export declare function encodeStackFramePosition(message: StackFramePosition, bb: ByteBuffer): void;
@@ -816,3 +832,7 @@ export declare function encodeNPMRegistryMap(message: NPMRegistryMap, bb: ByteBu
export declare function decodeNPMRegistryMap(buffer: ByteBuffer): NPMRegistryMap;
export declare function encodeBunInstall(message: BunInstall, bb: ByteBuffer): void;
export declare function decodeBunInstall(buffer: ByteBuffer): BunInstall;
+export declare function encodeClientServerModule(message: ClientServerModule, bb: ByteBuffer): void;
+export declare function decodeClientServerModule(buffer: ByteBuffer): ClientServerModule;
+export declare function encodeClientServerModuleManifest(message: ClientServerModuleManifest, bb: ByteBuffer): void;
+export declare function decodeClientServerModuleManifest(buffer: ByteBuffer): ClientServerModuleManifest;
diff --git a/src/api/schema.js b/src/api/schema.js
index cc25603b3..16c2ca119 100644
--- a/src/api/schema.js
+++ b/src/api/schema.js
@@ -3155,6 +3155,134 @@ function encodeBunInstall(message, bb) {
bb.writeByte(0);
}
+function decodeClientServerModule(bb) {
+ var result = {};
+
+ result["moduleId"] = bb.readUint32();
+ result["inputName"] = decodeStringPointer(bb);
+ result["assetName"] = decodeStringPointer(bb);
+ result["exportNames"] = decodeStringPointer(bb);
+ return result;
+}
+
+function encodeClientServerModule(message, bb) {
+ var value = message["moduleId"];
+ if (value != null) {
+ bb.writeUint32(value);
+ } else {
+ throw new Error('Missing required field "moduleId"');
+ }
+
+ var value = message["inputName"];
+ if (value != null) {
+ encodeStringPointer(value, bb);
+ } else {
+ throw new Error('Missing required field "inputName"');
+ }
+
+ var value = message["assetName"];
+ if (value != null) {
+ encodeStringPointer(value, bb);
+ } else {
+ throw new Error('Missing required field "assetName"');
+ }
+
+ var value = message["exportNames"];
+ if (value != null) {
+ encodeStringPointer(value, bb);
+ } else {
+ throw new Error('Missing required field "exportNames"');
+ }
+}
+
+function decodeClientServerModuleManifest(bb) {
+ var result = {};
+
+ result["version"] = bb.readUint32();
+ var length = bb.readVarUint();
+ var values = (result["clientModules"] = Array(length));
+ for (var i = 0; i < length; i++) values[i] = decodeClientServerModule(bb);
+ var length = bb.readVarUint();
+ var values = (result["serverModules"] = Array(length));
+ for (var i = 0; i < length; i++) values[i] = decodeClientServerModule(bb);
+ var length = bb.readVarUint();
+ var values = (result["ssrModules"] = Array(length));
+ for (var i = 0; i < length; i++) values[i] = decodeClientServerModule(bb);
+ var length = bb.readVarUint();
+ var values = (result["exportNames"] = Array(length));
+ for (var i = 0; i < length; i++) values[i] = decodeStringPointer(bb);
+ result["contents"] = bb.readByteArray();
+ return result;
+}
+
+function encodeClientServerModuleManifest(message, bb) {
+ var value = message["version"];
+ if (value != null) {
+ bb.writeUint32(value);
+ } else {
+ throw new Error('Missing required field "version"');
+ }
+
+ var value = message["clientModules"];
+ if (value != null) {
+ var values = value,
+ n = values.length;
+ bb.writeVarUint(n);
+ for (var i = 0; i < n; i++) {
+ value = values[i];
+ encodeClientServerModule(value, bb);
+ }
+ } else {
+ throw new Error('Missing required field "clientModules"');
+ }
+
+ var value = message["serverModules"];
+ if (value != null) {
+ var values = value,
+ n = values.length;
+ bb.writeVarUint(n);
+ for (var i = 0; i < n; i++) {
+ value = values[i];
+ encodeClientServerModule(value, bb);
+ }
+ } else {
+ throw new Error('Missing required field "serverModules"');
+ }
+
+ var value = message["ssrModules"];
+ if (value != null) {
+ var values = value,
+ n = values.length;
+ bb.writeVarUint(n);
+ for (var i = 0; i < n; i++) {
+ value = values[i];
+ encodeClientServerModule(value, bb);
+ }
+ } else {
+ throw new Error('Missing required field "ssrModules"');
+ }
+
+ var value = message["exportNames"];
+ if (value != null) {
+ var values = value,
+ n = values.length;
+ bb.writeVarUint(n);
+ for (var i = 0; i < n; i++) {
+ value = values[i];
+ encodeStringPointer(value, bb);
+ }
+ } else {
+ throw new Error('Missing required field "exportNames"');
+ }
+
+ var value = message["contents"];
+ if (value != null) {
+ bb.writeByteArray(value);
+ } else {
+ throw new Error('Missing required field "contents"');
+ }
+}
+
export { Loader };
export { LoaderKeys };
export { FrameworkEntryPointType };
@@ -3297,3 +3425,7 @@ export { decodeNPMRegistryMap };
export { encodeNPMRegistryMap };
export { decodeBunInstall };
export { encodeBunInstall };
+export { decodeClientServerModule };
+export { encodeClientServerModule };
+export { decodeClientServerModuleManifest };
+export { encodeClientServerModuleManifest };
diff --git a/src/api/schema.peechy b/src/api/schema.peechy
index 225fcaac3..f6e3e5617 100644
--- a/src/api/schema.peechy
+++ b/src/api/schema.peechy
@@ -588,3 +588,19 @@ message BunInstall {
string global_dir = 17;
string global_bin_dir = 18;
}
+
+struct ClientServerModule {
+ uint32 moduleId;
+ StringPointer inputName;
+ StringPointer assetName;
+ StringPointer exportNames;
+}
+
+struct ClientServerModuleManifest {
+ uint32 version;
+ ClientServerModule[] clientModules;
+ ClientServerModule[] serverModules;
+ ClientServerModule[] ssrModules;
+ StringPointer[] exportNames;
+ byte[] contents;
+}
diff --git a/src/api/schema.zig b/src/api/schema.zig
index db2cdee49..acac06114 100644
--- a/src/api/schema.zig
+++ b/src/api/schema.zig
@@ -3039,4 +3039,76 @@ pub const Api = struct {
try writer.endMessage();
}
};
+
+ pub const ClientServerModule = struct {
+ /// moduleId
+ module_id: u32 = 0,
+
+ /// inputName
+ input_name: StringPointer,
+
+ /// assetName
+ asset_name: StringPointer,
+
+ /// exportNames
+ export_names: StringPointer,
+
+ pub fn decode(reader: anytype) anyerror!ClientServerModule {
+ var this = std.mem.zeroes(ClientServerModule);
+
+ this.module_id = try reader.readValue(u32);
+ this.input_name = try reader.readValue(StringPointer);
+ this.asset_name = try reader.readValue(StringPointer);
+ this.export_names = try reader.readValue(StringPointer);
+ return this;
+ }
+
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.module_id);
+ try writer.writeValue(@TypeOf(this.input_name), this.input_name);
+ try writer.writeValue(@TypeOf(this.asset_name), this.asset_name);
+ try writer.writeValue(@TypeOf(this.export_names), this.export_names);
+ }
+ };
+
+ pub const ClientServerModuleManifest = struct {
+ /// version
+ version: u32 = 0,
+
+ /// clientModules
+ client_modules: []const ClientServerModule,
+
+ /// serverModules
+ server_modules: []const ClientServerModule,
+
+ /// ssrModules
+ ssr_modules: []const ClientServerModule,
+
+ /// exportNames
+ export_names: []const StringPointer,
+
+ /// contents
+ contents: []const u8,
+
+ pub fn decode(reader: anytype) anyerror!ClientServerModuleManifest {
+ var this = std.mem.zeroes(ClientServerModuleManifest);
+
+ this.version = try reader.readValue(u32);
+ this.client_modules = try reader.readArray(ClientServerModule);
+ this.server_modules = try reader.readArray(ClientServerModule);
+ this.ssr_modules = try reader.readArray(ClientServerModule);
+ this.export_names = try reader.readArray(StringPointer);
+ this.contents = try reader.readArray(u8);
+ return this;
+ }
+
+ pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
+ try writer.writeInt(this.version);
+ try writer.writeArray(ClientServerModule, this.client_modules);
+ try writer.writeArray(ClientServerModule, this.server_modules);
+ try writer.writeArray(ClientServerModule, this.ssr_modules);
+ try writer.writeArray(StringPointer, this.export_names);
+ try writer.writeArray(u8, this.contents);
+ }
+ };
};
diff --git a/src/ast/base.zig b/src/ast/base.zig
index f3cc34925..634bd9852 100644
--- a/src/ast/base.zig
+++ b/src/ast/base.zig
@@ -1,4 +1,5 @@
const std = @import("std");
+const bun = @import("bun");
const unicode = std.unicode;
pub const JavascriptString = []u16;
@@ -126,94 +127,142 @@ pub inline fn getBits(comptime TargetType: type, target: anytype, comptime start
return @truncate(TargetType, target >> start_bit);
}
-pub const Ref = enum(TotalSize) {
- default = std.math.maxInt(TotalSize),
- _,
+/// In some parts of Bun, we have many different IDs pointing to different things.
+/// It's easy for them to get mixed up, so we use this type to make sure we don't.
+///
+pub const Index = packed struct(u32) {
+ value: Int,
+
+ pub fn set(this: *Index, val: Int) void {
+ this.value = val;
+ }
+
+ pub inline fn isRuntime(this: Index) bool {
+ return this.value == runtime.value;
+ }
+
+ pub const invalid = Index{ .value = std.math.maxInt(Int) };
+ pub const runtime = Index{
+ .value = 0,
+ };
+
+ pub const Int = u32;
+
+ pub inline fn source(num: anytype) Index {
+ return .{ .value = @truncate(Int, num) };
+ }
- pub const TotalSize = u62;
+ pub inline fn part(num: anytype) Index {
+ return .{ .value = @truncate(Int, num) };
+ }
+
+ pub fn init(num: anytype) Index {
+ const NumType = @TypeOf(num);
+ if (comptime @typeInfo(NumType) == .Pointer) {
+ return init(num.*);
+ }
+
+ if (comptime bun.Environment.allow_assert) {
+ return .{
+ .value = @intCast(Int, num),
+ };
+ }
+
+ return .{
+ .value = @intCast(Int, num),
+ };
+ }
+
+ pub inline fn isValid(this: Index) bool {
+ return this.value != invalid.value;
+ }
+
+ pub inline fn isInvalid(this: Index) bool {
+ return !this.isValid();
+ }
+
+ pub inline fn get(this: Index) Int {
+ return this.value;
+ }
+};
+
+pub const Ref = packed struct(u64) {
+ inner_index: Int = 0,
+
+ tag: enum(u2) {
+ invalid,
+ allocated_name,
+ source_contents_slice,
+ symbol,
+ } = .invalid,
+
+ source_index: Int = 0,
+
+ pub inline fn isEmpty(this: Ref) bool {
+ return this.asU64() == 0;
+ }
+
+ pub const ArrayHashCtx = RefHashCtx;
+
+ pub const Int = std.meta.Int(.unsigned, (64 - 2) / 2);
+
+ pub fn toInt(value: anytype) Int {
+ return @intCast(Int, value);
+ }
+
+ pub fn isSourceIndexNull(this: anytype) bool {
+ return this == std.math.maxInt(Int);
+ }
+
+ pub fn isSymbol(this: Ref) bool {
+ return this.tag == .symbol;
+ }
pub fn format(ref: Ref, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
try std.fmt.format(
writer,
- "Ref: sourceIndex = {d}, innerIndex = {d}, is_source_contents_slice = {}",
+ "Ref[{d}, {d}, {s}]",
.{
ref.sourceIndex(),
ref.innerIndex(),
- ref.isSourceContentsSlice(),
+ @tagName(ref.tag),
},
);
}
- const max_ref_int = std.math.maxInt(Ref.Int);
- pub const BitInt = std.meta.Int(.unsigned, @bitSizeOf(Ref));
-
- pub inline fn asBitInt(this: Ref) BitInt {
- return @bitCast(BitInt, this);
+ pub fn isValid(this: Ref) bool {
+ return this.tag != .invalid;
}
// 2 bits of padding for whatever is the parent
- pub const Int = u30;
- pub const None = Ref.init(std.math.maxInt(u30), std.math.maxInt(u30), false);
- pub const RuntimeRef = Ref.init(std.math.maxInt(u30), std.math.maxInt(u30) - 1, false);
-
- const source_index_offset = 1;
- const inner_index_offset = 1 + 30;
+ pub const None = Ref{ .inner_index = 0, .source_index = 0, .tag = .invalid };
pub inline fn sourceIndex(this: Ref) Int {
- return @truncate(Int, getBits(TotalSize, @enumToInt(this), source_index_offset, 30));
+ return this.source_index;
}
pub inline fn innerIndex(this: Ref) Int {
- return @truncate(Int, getBits(TotalSize, @enumToInt(this), inner_index_offset, 30));
+ return this.inner_index;
}
pub inline fn isSourceContentsSlice(this: Ref) bool {
- return (getBits(TotalSize, @enumToInt(this), 0, 1) & 1) != 0;
- }
-
- pub fn atIndex(value: anytype) Ref {
- return @intToEnum(Ref, setBits(TotalSize, 0, inner_index_offset, 30, @truncate(Int, value)));
- }
-
- pub fn init(inner_index: Int, source_index: Int, is_source_contents_slice: bool) Ref {
- return @intToEnum(
- Ref,
- setBits(
- TotalSize,
- 0,
- 0,
- 1,
- @as(
- TotalSize,
- @boolToInt(is_source_contents_slice),
- ),
- ) | setBits(
- TotalSize,
- 0,
- source_index_offset,
- 30,
- source_index,
- ) | setBits(
- TotalSize,
- 0,
- inner_index_offset,
- 30,
- inner_index,
- ),
- );
+ return this.tag == .source_contents_slice;
}
- const Old = struct {
- inner_index: Int = 0,
- source_index: Int = std.math.maxInt(Int),
- is_source_contents_slice: bool = false,
- };
- pub fn initSourceEnd(old: Old) Ref {
- return init(old.inner_index, old.source_index, old.is_source_contents_slice);
+ pub fn init(inner_index: Int, source_index: usize, is_source_contents_slice: bool) Ref {
+ return .{
+ .inner_index = inner_index,
+
+ // if we overflow, we want a panic
+ .source_index = @intCast(Int, source_index),
+
+ .tag = if (is_source_contents_slice) .source_contents_slice else .allocated_name,
+ };
}
- pub fn toInt(int: anytype) Int {
- return @intCast(Int, int);
+ pub fn initSourceEnd(old: Ref) Ref {
+ std.debug.assert(old.tag != .invalid);
+ return init(old.inner_index, old.source_index, old.tag == .source_contents_slice);
}
pub fn hash(key: Ref) u32 {
@@ -221,13 +270,7 @@ pub const Ref = enum(TotalSize) {
}
pub inline fn asU64(key: Ref) u64 {
- // This type isn't quite a u64 because it is used in a few other packed structs which have variables in them
- // But, there are some footguns with the stage1 implementation of packed structs
- // so it is safer to do comparisons as u64
- // but we want to ensure that the value of the unused bits in the u64 are 0
- // i have not looked at the assembly to verify that the unused bits default to 0
- // so we set it to u64 0 just to be sure
- return @as(u64, @enumToInt(key));
+ return @bitCast(u64, key);
}
pub inline fn hash64(key: Ref) u64 {
@@ -238,11 +281,7 @@ pub const Ref = enum(TotalSize) {
return asU64(ref) == b.asU64();
}
pub inline fn isNull(self: Ref) bool {
- return self.eql(Ref.None);
- }
-
- pub fn isSourceIndexNull(int: anytype) bool {
- return int == max_ref_int;
+ return self.tag == .invalid;
}
pub fn jsonStringify(self: *const Ref, options: anytype, writer: anytype) !void {
diff --git a/src/baby_list.zig b/src/baby_list.zig
index 2ebb383e6..4edbf0b60 100644
--- a/src/baby_list.zig
+++ b/src/baby_list.zig
@@ -5,8 +5,6 @@ const bun = @import("bun");
/// This is like ArrayList except it stores the length and capacity as u32
/// In practice, it is very unusual to have lengths above 4 GB
-///
-/// This lets us have array lists which occupy the same amount of space as a slice
pub fn BabyList(comptime Type: type) type {
return struct {
const ListType = @This();
@@ -14,6 +12,14 @@ pub fn BabyList(comptime Type: type) type {
len: u32 = 0,
cap: u32 = 0,
+ pub const Elem = Type;
+
+ pub fn set(this: *@This(), slice_: []Type) void {
+ this.ptr = slice_.ptr;
+ this.len = @truncate(u32, slice_.len);
+ this.cap = @truncate(u32, slice_.len);
+ }
+
pub fn available(this: *@This()) []Type {
return this.ptr[this.len..this.cap];
}
@@ -28,6 +34,7 @@ pub fn BabyList(comptime Type: type) type {
}
pub inline fn initConst(items: []const Type) ListType {
+ @setRuntimeSafety(false);
return ListType{
// Remove the const qualifier from the items
.ptr = @intToPtr([*]Type, @ptrToInt(items.ptr)),
@@ -37,9 +44,57 @@ pub fn BabyList(comptime Type: type) type {
};
}
- pub inline fn init(items: []Type) ListType {
+ pub fn ensureUnusedCapacity(this: *@This(), allocator: std.mem.Allocator, count: usize) !void {
+ var list_ = this.listManaged(allocator);
+ try list_.ensureUnusedCapacity(count);
+ this.update(list_);
+ }
+
+ pub fn popOrNull(this: *@This()) ?Type {
+ if (this.len == 0) return null;
+ this.len -= 1;
+ return this.ptr[this.len];
+ }
+
+ pub fn clone(this: @This(), allocator: std.mem.Allocator) !@This() {
+ var list_ = this.listManaged(allocator);
+ var copy = try list_.clone();
+ return ListType{
+ .ptr = copy.items.ptr,
+ .len = @truncate(u32, copy.items.len),
+ .cap = @truncate(u32, copy.capacity),
+ };
+ }
+
+ pub inline fn appendAssumeCapacity(this: *@This(), value: Type) void {
+ this.ptr[this.len] = value;
+ this.len += 1;
+ std.debug.assert(this.cap >= this.len);
+ }
+
+ pub inline fn appendSliceAssumeCapacity(this: *@This(), values: []const Type) void {
+ var tail = this.ptr[this.len .. this.len + values.len];
+ std.debug.assert(this.cap >= this.len + @truncate(u32, values.len));
+ bun.copy(Type, tail, values);
+ this.len += @truncate(u32, values.len);
+ std.debug.assert(this.cap >= this.len);
+ }
+
+ pub inline fn initCapacity(allocator: std.mem.Allocator, len: usize) !ListType {
+ var items = try allocator.alloc(Type, len);
+ return ListType{
+ .ptr = @ptrCast([*]Type, items.ptr),
+ .len = 0,
+ .cap = @truncate(u32, len),
+ };
+ }
+
+ pub inline fn init(items: []const Type) ListType {
+ @setRuntimeSafety(false);
return ListType{
- .ptr = items.ptr,
+ // Remove the const qualifier from the items
+ .ptr = @intToPtr([*]Type, @ptrToInt(items.ptr)),
+
.len = @truncate(u32, items.len),
.cap = @truncate(u32, items.len),
};
@@ -96,6 +151,16 @@ pub fn BabyList(comptime Type: type) type {
return this.ptr[0];
}
+ pub inline fn at(this: ListType, index: usize) *const Type {
+ std.debug.assert(index < this.len);
+ return &this.ptr[index];
+ }
+
+ pub inline fn mut(this: ListType, index: usize) *Type {
+ std.debug.assert(index < this.len);
+ return &this.ptr[index];
+ }
+
pub fn one(allocator: std.mem.Allocator, value: Type) !ListType {
var items = try allocator.alloc(Type, 1);
items[0] = value;
@@ -117,10 +182,10 @@ pub fn BabyList(comptime Type: type) type {
this.update(list_);
}
- pub fn append(this: *ListType, allocator: std.mem.Allocator, value: []const Type) OOM!void {
- var list_ = this.list();
- try list_.appendSlice(allocator, value);
- this.update(list_);
+ pub fn append(this: *@This(), allocator: std.mem.Allocator, value: []const Type) !void {
+ var list__ = this.listManaged(allocator);
+ try list__.appendSlice(value);
+ this.update(list__);
}
pub inline fn slice(this: ListType) []Type {
diff --git a/src/base64/base64.zig b/src/base64/base64.zig
index 0cd16fb8c..bddc44564 100644
--- a/src/base64/base64.zig
+++ b/src/base64/base64.zig
@@ -180,7 +180,7 @@ const zig_base64 = struct {
out_idx += 1;
}
if (encoder.pad_char) |pad_char| {
- for (dest[out_idx..]) |*pad| {
+ for (dest[out_idx..out_len]) |*pad| {
pad.* = pad_char;
}
}
diff --git a/src/install/bit_set.zig b/src/bit_set.zig
index 661a3a4bf..4c39cd8c4 100644
--- a/src/install/bit_set.zig
+++ b/src/bit_set.zig
@@ -500,14 +500,14 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
/// in the toggles bit set.
pub fn toggleSet(self: *Self, toggles: *const Self) void {
const other = &toggles.masks;
- for (&self.masks, 0..) |*mask, i| {
- mask.* ^= other[i];
+ for (self.masks, other) |*mask, b| {
+ mask.* ^= b;
}
}
/// Flips every bit in the bit set.
pub fn toggleAll(self: *Self) void {
- for (&self.masks) |*mask| {
+ for (self.masks) |*mask| {
mask.* = ~mask.*;
}
@@ -521,8 +521,8 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
/// result in the first one. Bits in the result are
/// set if the corresponding bits were set in either input.
pub fn setUnion(self: *Self, other: *const Self) void {
- for (&self.masks, 0..) |*mask, i| {
- mask.* |= other.masks[i];
+ for (&self.masks, other[0..self.masks.len]) |*mask, alt| {
+ mask.* |= alt;
}
}
@@ -530,8 +530,8 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
/// the result in the first one. Bits in the result are
/// set if the corresponding bits were set in both inputs.
pub fn setIntersection(self: *Self, other: *const Self) void {
- for (&self.masks, 0..) |*mask, i| {
- mask.* &= other.masks[i];
+ for (&self.masks, other.masks[0..self.masks.len]) |*mask, alt| {
+ mask.* &= alt;
}
}
@@ -608,6 +608,14 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
return result;
}
+ pub fn hasIntersection(self: *const Self, other: *const Self) bool {
+ for (self.masks, other.masks) |a, b| {
+ if (a & b != 0) return true;
+ }
+
+ return false;
+ }
+
/// Returns the xor of two bit sets. Bits in the
/// result are set if the corresponding bits were
/// not the same in both inputs.
@@ -770,7 +778,7 @@ pub const DynamicBitSetUnmanaged = struct {
const num_masks = numMasks(self.bit_length);
var copy = Self{};
try copy.resize(new_allocator, self.bit_length, false);
- bun.copy(MaskInt, copy.masks, self.masks[0..num_masks]);
+ bun.copy(MaskInt, copy.masks[0..num_masks], self.masks[0..num_masks]);
return copy;
}
@@ -786,6 +794,10 @@ pub const DynamicBitSetUnmanaged = struct {
return (self.masks[maskIndex(index)] & maskBit(index)) != 0;
}
+ pub fn bytes(self: Self) []const u8 {
+ return std.mem.sliceAsBytes(self.masks[0 .. numMasks(self.bit_length) + 1]);
+ }
+
/// Returns the total number of set bits in this bit set.
pub fn count(self: Self) usize {
const num_masks = (self.bit_length + (@bitSizeOf(MaskInt) - 1)) / @bitSizeOf(MaskInt);
@@ -797,6 +809,15 @@ pub const DynamicBitSetUnmanaged = struct {
return total;
}
+ pub fn hasIntersection(self: Self, other: Self) bool {
+ const num_masks = (self.bit_length + (@bitSizeOf(MaskInt) - 1)) / @bitSizeOf(MaskInt);
+ for (self.masks[0..num_masks], other.masks[0..num_masks]) |mask, other_mask| {
+ if ((mask & other_mask) != 0) return true;
+ }
+
+ return false;
+ }
+
/// Changes the value of the specified bit of the bit
/// set to match the passed boolean.
pub fn setValue(self: *Self, index: usize, value: bool) void {
@@ -845,8 +866,8 @@ pub const DynamicBitSetUnmanaged = struct {
bulk_mask_index = start_mask_index;
}
- while (bulk_mask_index < end_mask_index) : (bulk_mask_index += 1) {
- self.masks[bulk_mask_index] = std.math.boolMask(MaskInt, value);
+ for (self.masks[bulk_mask_index..end_mask_index]) |*mask| {
+ mask.* = std.math.boolMask(MaskInt, value);
}
if (end_bit > 0) {
@@ -874,10 +895,29 @@ pub const DynamicBitSetUnmanaged = struct {
/// same bit_length.
pub fn toggleSet(self: *Self, toggles: Self) void {
if (comptime Environment.allow_assert) std.debug.assert(toggles.bit_length == self.bit_length);
+ const bit_length = self.bit_length;
+ if (bit_length == 0) return;
const num_masks = numMasks(self.bit_length);
- for (&self.masks[0..num_masks], 0..) |*mask, i| {
- mask.* ^= toggles.masks[i];
+ for (self.masks[0..num_masks], toggles.masks[0..num_masks]) |*mask, other_mask| {
+ mask.* ^= other_mask;
}
+
+ const padding_bits = num_masks * @bitSizeOf(MaskInt) - bit_length;
+ const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits);
+ self.masks[num_masks - 1] &= last_item_mask;
+ }
+
+ pub fn setAll(self: *Self, value: bool) void {
+ const bit_length = self.bit_length;
+ if (bit_length == 0) return;
+ const num_masks = numMasks(self.bit_length);
+ for (self.masks[0..num_masks]) |*mask| {
+ mask.* = std.math.boolMask(MaskInt, value);
+ }
+
+ const padding_bits = num_masks * @bitSizeOf(MaskInt) - bit_length;
+ const last_item_mask = (~@as(MaskInt, 0)) >> @intCast(ShiftInt, padding_bits);
+ self.masks[num_masks - 1] &= last_item_mask;
}
/// Flips every bit in the bit set.
@@ -887,7 +927,7 @@ pub const DynamicBitSetUnmanaged = struct {
if (bit_length == 0) return;
const num_masks = numMasks(self.bit_length);
- for (&self.masks[0..num_masks]) |*mask| {
+ for (self.masks[0..num_masks]) |*mask| {
mask.* = ~mask.*;
}
@@ -902,8 +942,8 @@ pub const DynamicBitSetUnmanaged = struct {
if (bit_length == 0) return;
const num_masks = numMasks(self.bit_length);
- for (&self.masks[0..num_masks], 0..) |*mask, i| {
- mask.* = other.masks[i];
+ for (self.masks[0..num_masks], other.masks) |*mask, other_mask| {
+ mask.* = other_mask;
}
const padding_bits = num_masks * @bitSizeOf(MaskInt) - bit_length;
@@ -918,8 +958,8 @@ pub const DynamicBitSetUnmanaged = struct {
pub fn setUnion(self: *Self, other: Self) void {
if (comptime Environment.allow_assert) std.debug.assert(other.bit_length == self.bit_length);
const num_masks = numMasks(self.bit_length);
- for (&self.masks[0..num_masks], 0..) |*mask, i| {
- mask.* |= other.masks[i];
+ for (self.masks[0..num_masks], other.masks) |*mask, other_mask| {
+ mask.* |= other_mask;
}
}
@@ -930,25 +970,25 @@ pub const DynamicBitSetUnmanaged = struct {
pub fn setIntersection(self: *Self, other: Self) void {
if (comptime Environment.allow_assert) std.debug.assert(other.bit_length == self.bit_length);
const num_masks = numMasks(self.bit_length);
- for (&self.masks[0..num_masks], 0..) |*mask, i| {
- mask.* &= other.masks[i];
+ for (self.masks[0..num_masks], other.masks) |*mask, other_mask| {
+ mask.* &= other_mask;
}
}
pub fn setExcludeTwo(self: *Self, other: Self, third: Self) void {
if (comptime Environment.allow_assert) std.debug.assert(other.bit_length == self.bit_length);
const num_masks = numMasks(self.bit_length);
- for (&self.masks[0..num_masks], 0..) |*mask, i| {
- mask.* &= ~other.masks[i];
- mask.* &= ~third.masks[i];
+ for (self.masks[0..num_masks], other.masks[0..num_masks], third.masks[0..num_masks]) |*mask, other_mask, third_mask| {
+ mask.* &= ~other_mask;
+ mask.* &= ~third_mask;
}
}
pub fn setExclude(self: *Self, other: Self) void {
if (comptime Environment.allow_assert) std.debug.assert(other.bit_length == self.bit_length);
const num_masks = numMasks(self.bit_length);
- for (&self.masks[0..num_masks], 0..) |*mask, i| {
- mask.* &= ~other.masks[i];
+ for (self.masks[0..num_masks], other.masks) |*mask, other_mask| {
+ mask.* &= ~other_mask;
}
}
@@ -1055,6 +1095,103 @@ pub const DynamicBitSetUnmanaged = struct {
}
};
+pub const AutoBitSet = union(enum) {
+ pub const Static = ArrayBitSet(usize, (@bitSizeOf(DynamicBitSetUnmanaged) - 1));
+
+ static: Static,
+ dynamic: DynamicBitSetUnmanaged,
+
+ pub inline fn needsDynamic(bit_length: usize) bool {
+ return bit_length > Static.bit_length;
+ }
+
+ pub fn initEmpty(allocator: Allocator, bit_length: usize) !AutoBitSet {
+ if (bit_length <= Static.bit_length) {
+ return AutoBitSet{ .static = Static.initEmpty() };
+ } else {
+ return AutoBitSet{ .dynamic = try DynamicBitSetUnmanaged.initEmpty(allocator, bit_length) };
+ }
+ }
+
+ pub fn isSet(this: *const AutoBitSet, index: usize) bool {
+ return switch (std.meta.activeTag(this.*)) {
+ .static => this.static.isSet(index),
+ .dynamic => this.dynamic.isSet(index),
+ };
+ }
+
+ /// Are any of the bits in `this` also set in `other`?
+ pub fn hasIntersection(this: *const AutoBitSet, other: *const AutoBitSet) bool {
+ if (std.meta.activeTag(this.*) != std.meta.activeTag(other.*)) {
+ return false;
+ }
+
+ return switch (std.meta.activeTag(this.*)) {
+ .static => this.static.hasIntersection(&other.static),
+ .dynamic => this.dynamic.hasIntersection(other.dynamic),
+ };
+ }
+
+ pub fn clone(this: *const AutoBitSet, allocator: std.mem.Allocator) !AutoBitSet {
+ return switch (std.meta.activeTag(this.*)) {
+ .static => AutoBitSet{ .static = this.static },
+ .dynamic => AutoBitSet{ .dynamic = try this.dynamic.clone(allocator) },
+ };
+ }
+
+ pub fn set(this: *AutoBitSet, index: usize) void {
+ switch (std.meta.activeTag(this.*)) {
+ .static => this.static.set(index),
+ .dynamic => this.dynamic.set(index),
+ }
+ }
+
+ pub fn rawBytes(this: *const AutoBitSet) []const u8 {
+ return switch (std.meta.activeTag(this.*)) {
+ .static => std.mem.asBytes(&this.static.masks),
+ .dynamic => this.dynamic.bytes(),
+ };
+ }
+
+ pub fn bytes(this: *const AutoBitSet, _: usize) []const u8 {
+ return this.rawBytes();
+ }
+
+ pub fn eql(this: *const AutoBitSet, b: *const AutoBitSet) bool {
+ return bun.strings.eqlLong(this.rawBytes(), b.rawBytes(), true);
+ }
+
+ pub fn hash(this: *const AutoBitSet) u64 {
+ return bun.hash(this.rawBytes());
+ }
+
+ pub fn forEach(this: *const AutoBitSet, comptime Ctx: type, ctx: *Ctx, comptime Function: fn (*Ctx, usize) void) void {
+ return switch (std.meta.activeTag(this.*)) {
+ .static => {
+ var iter = this.static.iterator(.{});
+ while (iter.next()) |index| {
+ Function(ctx, index);
+ }
+ },
+ .dynamic => {
+ var iter = this.dynamic.iterator(.{});
+ while (iter.next()) |index| {
+ Function(ctx, index);
+ }
+ },
+ };
+ }
+
+ pub fn deinit(this: *AutoBitSet, allocator: std.mem.Allocator) void {
+ switch (std.meta.activeTag(this.*)) {
+ .static => {},
+ .dynamic => {
+ this.dynamic.deinit(allocator);
+ },
+ }
+ }
+};
+
/// A bit set with runtime-known size, backed by an allocated slice
/// of usize. Thin wrapper around DynamicBitSetUnmanaged which keeps
/// track of the allocator instance.
@@ -1235,7 +1372,7 @@ pub const IteratorOptions = struct {
};
// The iterator is reusable between several bit set types
-fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) type {
+pub fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) type {
const ShiftInt = std.math.Log2Int(MaskInt);
const kind = options.kind;
const direction = options.direction;
diff --git a/src/build-id b/src/build-id
index f599e28b8..573541ac9 100644
--- a/src/build-id
+++ b/src/build-id
@@ -1 +1 @@
-10
+0
diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit
-Subproject 8cb1760055c10c700c07cc2c09775e8d3451bc0
+Subproject a74bf4b5fc4d87e25b935c843ab906e8d6f3d89
diff --git a/src/bun.js/api/transpiler.classes.ts b/src/bun.js/api/JSBundler.classes.ts
index f016a1844..5eeed30f0 100644
--- a/src/bun.js/api/transpiler.classes.ts
+++ b/src/bun.js/api/JSBundler.classes.ts
@@ -27,14 +27,24 @@ export default [
length: 2,
},
},
- custom: {
- onLoadPlugins: {
- extraHeaderIncludes: ["BunPlugin.h"],
- impl: "JSTranspiler+BunPlugin-impl.h",
- type: `WTF::Vector<std::unique_ptr<BunPlugin::OnLoad>>`,
+ }),
+
+ define({
+ name: "Bundler",
+ construct: true,
+ finalize: true,
+ hasPendingActivity: true,
+ configurable: false,
+ klass: {},
+ JSType: "0b11101110",
+ proto: {
+ handle: {
+ fn: "handleRequest",
+ length: 2,
},
- onResolvePlugins: {
- type: `WTF::Vector<std::unique_ptr<BunPlugin::OnResolve>>`,
+ write: {
+ fn: "write",
+ length: 1,
},
},
}),
diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig
new file mode 100644
index 000000000..e8ce7a0e5
--- /dev/null
+++ b/src/bun.js/api/JSBundler.zig
@@ -0,0 +1,332 @@
+const std = @import("std");
+const Api = @import("../../api/schema.zig").Api;
+const http = @import("../../http.zig");
+const JavaScript = @import("../javascript.zig");
+const QueryStringMap = @import("../../url.zig").QueryStringMap;
+const CombinedScanner = @import("../../url.zig").CombinedScanner;
+const bun = @import("bun");
+const string = bun.string;
+const JSC = bun.JSC;
+const js = JSC.C;
+const WebCore = @import("../webcore/response.zig");
+const Bundler = bun.bundler;
+const options = @import("../../options.zig");
+const VirtualMachine = JavaScript.VirtualMachine;
+const ScriptSrcStream = std.io.FixedBufferStream([]u8);
+const ZigString = JSC.ZigString;
+const Fs = @import("../../fs.zig");
+const Base = @import("../base.zig");
+const getAllocator = Base.getAllocator;
+const JSObject = JSC.JSObject;
+const JSError = Base.JSError;
+const JSValue = bun.JSC.JSValue;
+const JSGlobalObject = JSC.JSGlobalObject;
+const strings = bun.strings;
+const NewClass = Base.NewClass;
+const To = Base.To;
+const Request = WebCore.Request;
+
+const FetchEvent = WebCore.FetchEvent;
+const MacroMap = @import("../../resolver/package_json.zig").MacroMap;
+const TSConfigJSON = @import("../../resolver/tsconfig_json.zig").TSConfigJSON;
+const PackageJSON = @import("../../resolver/package_json.zig").PackageJSON;
+const logger = bun.logger;
+const Loader = options.Loader;
+const Platform = options.Platform;
+const JSAst = bun.JSAst;
+const JSParser = bun.js_parser;
+const JSPrinter = bun.js_printer;
+const ScanPassResult = JSParser.ScanPassResult;
+const Mimalloc = @import("../../mimalloc_arena.zig");
+const Runtime = @import("../../runtime.zig").Runtime;
+const JSLexer = bun.js_lexer;
+const Expr = JSAst.Expr;
+
+pub const JSBundler = struct {
+ heap: Mimalloc.Arena,
+ allocator: std.mem.Allocator,
+ configs: Config.List = .{},
+ has_pending_activity: std.atomic.Atomic(bool) = std.atomic.Atomic(bool).init(true),
+
+ pub usingnamespace JSC.Codegen.JSBundler;
+
+ const OwnedString = bun.MutableString;
+
+ pub const Config = struct {
+ target: options.Platform = options.Platform.browser,
+ entry_points: std.BufSet = std.BufSet.init(bun.default_allocator),
+ hot: bool = false,
+ define: std.BufMap = std.BufMap.init(bun.default_allocator),
+ dir: OwnedString = OwnedString.initEmpty(bun.default_allocator),
+ serve: Serve = .{},
+ jsx: options.JSX.Pragma = .{},
+ code_splitting: bool = false,
+ minify: Minify = .{},
+ server_components: ServerComponents = ServerComponents{},
+ plugins: PluginDeclaration.List = .{},
+
+ names: Names = .{},
+ label: OwnedString = OwnedString.initEmpty(bun.default_allocator),
+
+ pub const List = bun.StringArrayHashMapUnmanaged(Config);
+
+ ///
+ /// { name: "", setup: (build) {} }
+ pub const PluginDeclaration = struct {
+ name: OwnedString = OwnedString.initEmpty(bun.default_allocator),
+ setup: JSC.Strong = .{},
+
+ pub const List = std.ArrayListUnmanaged(PluginDeclaration);
+
+ pub fn deinit(this: *PluginDeclaration) void {
+ this.name.deinit();
+ this.setup.deinit();
+ }
+ };
+
+ pub fn fromJS(globalThis: *JSC.JSGlobalObject, config: JSC.JSValue, allocator: std.mem.Allocator) !Config {
+ var this = Config{
+ .entry_points = std.BufSet.init(allocator),
+ .define = std.BufMap.init(allocator),
+ .dir = OwnedString.initEmpty(allocator),
+ .label = OwnedString.initEmpty(allocator),
+ .names = .{
+ .owned_entry_point = OwnedString.initEmpty(allocator),
+ .owned_chunk = OwnedString.initEmpty(allocator),
+ },
+ };
+ errdefer this.deinit(allocator);
+
+ if (try config.getOptionalEnum(globalThis, "target", options.Platform)) |target| {
+ this.target = target;
+ }
+
+ if (try config.getOptional(globalThis, "hot", bool)) |hot| {
+ this.hot = hot;
+ }
+
+ if (try config.getOptional(globalThis, "splitting", bool)) |hot| {
+ this.code_splitting = hot;
+ }
+
+ if (try config.getOptional(globalThis, "minifyWhitespace", bool)) |hot| {
+ this.minify.whitespace = hot;
+ }
+
+ if (try config.getArray(globalThis, "entrypoints")) |entry_points| {
+ var iter = entry_points.arrayIterator(globalThis);
+ while (iter.next()) |entry_point| {
+ var slice = entry_point.toSliceOrNull(globalThis, allocator) orelse {
+ globalThis.throwInvalidArguments("Expected entrypoints to be an array of strings", .{});
+ return error.JSException;
+ };
+ defer slice.deinit();
+ try this.entry_points.insert(slice.slice());
+ }
+ } else {
+ globalThis.throwInvalidArguments("Expected entrypoints to be an array of strings", .{});
+ return error.JSException;
+ }
+
+ if (try config.getOptional(globalThis, "name", ZigString.Slice)) |slice| {
+ defer slice.deinit();
+ this.label.appendSliceExact(slice.slice()) catch unreachable;
+ }
+
+ if (try config.getOptional(globalThis, "dir", ZigString.Slice)) |slice| {
+ defer slice.deinit();
+ this.dir.appendSliceExact(slice.slice()) catch unreachable;
+ } else {
+ this.dir.appendSliceExact(globalThis.bunVM().bundler.fs.top_level_dir) catch unreachable;
+ }
+
+ if (try config.getOptional(globalThis, "entryNames", ZigString.Slice)) |slice| {
+ defer slice.deinit();
+ this.names.owned_entry_point.appendSliceExact(slice.slice()) catch unreachable;
+ this.names.entry_point.data = this.names.owned_entry_point.list.items;
+ }
+
+ if (try config.getOptional(globalThis, "chunkNames", ZigString.Slice)) |slice| {
+ defer slice.deinit();
+ this.names.owned_chunk.appendSliceExact(slice.slice()) catch unreachable;
+ this.names.chunk.data = this.names.owned_chunk.list.items;
+ }
+
+ if (try config.getArray(globalThis, "plugins")) |array| {
+ var iter = array.arrayIterator(globalThis);
+ while (iter.next()) |plugin| {
+ var decl = PluginDeclaration{
+ .name = OwnedString.initEmpty(allocator),
+ .setup = .{},
+ };
+ errdefer decl.deinit();
+
+ if (plugin.getObject(globalThis, "SECRET_SERVER_COMPONENTS_INTERNALS")) |internals| {
+ if (try internals.get(globalThis, "router")) |router_value| {
+ if (router_value.as(JSC.API.FileSystemRouter) != null) {
+ this.server_components.router.set(globalThis, router_value);
+ } else {
+ globalThis.throwInvalidArguments("Expected router to be a Bun.FileSystemRouter", .{});
+ return error.JSError;
+ }
+ }
+
+ const directive_object = (try internals.getObject(globalThis, "directive")) orelse {
+ globalThis.throwInvalidArguments("Expected directive to be an object", .{});
+ return error.JSError;
+ };
+
+ if (try directive_object.getArray(globalThis, "client")) |client_names_array| {
+ var array_iter = client_names_array.arrayIterator(globalThis);
+ while (array_iter.next()) |client_name| {
+ var slice = client_name.toSliceOrNull(globalThis, allocator) orelse {
+ globalThis.throwInvalidArguments("Expected directive.client to be an array of strings", .{});
+ return error.JSException;
+ };
+ defer slice.deinit();
+ try this.server_components.client.append(allocator, OwnedString.initCopy(allocator, slice.slice()) catch unreachable);
+ }
+ } else {
+ globalThis.throwInvalidArguments("Expected directive.client to be an array of strings", .{});
+ return error.JSException;
+ }
+
+ if (try directive_object.getArray(globalThis, "server")) |server_names_array| {
+ var array_iter = server_names_array.arrayIterator(globalThis);
+ while (array_iter.next()) |server_name| {
+ var slice = server_name.toSliceOrNull(globalThis, allocator) orelse {
+ globalThis.throwInvalidArguments("Expected directive.server to be an array of strings", .{});
+ return error.JSException;
+ };
+ defer slice.deinit();
+ try this.server_components.server.append(allocator, OwnedString.initCopy(allocator, slice.slice()) catch unreachable);
+ }
+ } else {
+ globalThis.throwInvalidArguments("Expected directive.server to be an array of strings", .{});
+ return error.JSException;
+ }
+ }
+
+ if (try plugin.getOptional(globalThis, "name", ZigString.Slice)) |slice| {
+ defer slice.deinit();
+ decl.name.appendSliceExact(slice.slice()) catch unreachable;
+ }
+
+ if (try plugin.getFunction(globalThis, "setup", JSC.JSValue)) |setup| {
+ decl.setup.set(globalThis, setup);
+ } else {
+ globalThis.throwInvalidArguments("Expected plugin to have a setup() function", .{});
+ return error.JSError;
+ }
+
+ try this.plugins.append(allocator, decl);
+ }
+ }
+
+ return config;
+ }
+
+ pub const Names = struct {
+ owned_entry_point: OwnedString = OwnedString.initEmpty(bun.default_allocator),
+ entry_point: options.PathTemplate = options.PathTemplate.file,
+ owned_chunk: OwnedString = OwnedString.initEmpty(bun.default_allocator),
+ chunk: options.PathTemplate = options.PathTemplate.chunk,
+
+ pub fn deinit(self: *Names) void {
+ self.owned_entry_point.deinit();
+ self.owned_chunk.deinit();
+ }
+ };
+
+ pub const ServerComponents = struct {
+ router: JSC.Strong = .{},
+ client: std.ArrayListUnmanaged(OwnedString) = .{},
+ server: std.ArrayListUnmanaged(OwnedString) = .{},
+
+ pub fn deinit(self: *ServerComponents, allocator: std.mem.Allocator) void {
+ self.router.deinit();
+ self.client.clearAndFree(allocator);
+ self.server.clearAndFree(allocator);
+ }
+ };
+
+ pub const Minify = struct {
+ whitespace: bool = false,
+ };
+
+ pub const Serve = struct {
+ handler_path: OwnedString = OwnedString.initEmpty(bun.default_allocator),
+ prefix: OwnedString = OwnedString.initEmpty(bun.default_allocator),
+
+ pub fn deinit(self: *Serve, allocator: std.mem.Allocator) void {
+ _ = allocator;
+ self.handler_path.deinit();
+ self.prefix.deinit();
+ }
+ };
+
+ pub fn deinit(self: *Config, allocator: std.mem.Allocator) void {
+ self.entry_points.deinit();
+ self.define.deinit();
+ self.dir.deinit();
+ self.serve.deinit(allocator);
+ self.plugins.deinit();
+ self.server_components.deinit(allocator);
+ self.names.deinit();
+ self.label.deinit();
+ }
+ };
+
+ pub fn constructor(
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) ?*JSBundler {
+ var temp = std.heap.ArenaAllocator.init(getAllocator(globalThis));
+ const arguments = callframe.arguments(3);
+ var args = JSC.Node.ArgumentsSlice.init(
+ globalThis.bunVM(),
+ arguments.ptr[0..arguments.len],
+ );
+ _ = args;
+
+ defer temp.deinit();
+
+ return null;
+ }
+
+ pub fn handleRequest(
+ this: *JSBundler,
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSValue {
+ _ = callframe;
+ _ = globalThis;
+ _ = this;
+
+ return .zero;
+ }
+
+ pub fn write(
+ this: *JSBundler,
+ globalThis: *JSC.JSGlobalObject,
+ callframe: *JSC.CallFrame,
+ ) callconv(.C) JSValue {
+ _ = callframe;
+ _ = globalThis;
+ _ = this;
+
+ return .zero;
+ }
+
+ pub fn hasPendingActivity(this: *JSBundler) callconv(.C) bool {
+ @fence(.Acquire);
+ return this.has_pending_activity.load(.Acquire);
+ }
+
+ pub fn finalize(
+ this: *JSBundler,
+ ) callconv(.C) void {
+ this.heap.deinit();
+ JSC.VirtualMachine.get().allocator.destroy(this);
+ }
+};
diff --git a/src/bun.js/api/transpiler.zig b/src/bun.js/api/JSTranspiler.zig
index 8562a3204..465ab0ad4 100644
--- a/src/bun.js/api/transpiler.zig
+++ b/src/bun.js/api/JSTranspiler.zig
@@ -6,7 +6,7 @@ const QueryStringMap = @import("../../url.zig").QueryStringMap;
const CombinedScanner = @import("../../url.zig").CombinedScanner;
const bun = @import("bun");
const string = bun.string;
-const JSC = @import("bun").JSC;
+const JSC = bun.JSC;
const js = JSC.C;
const WebCore = @import("../webcore/response.zig");
const Bundler = bun.bundler;
@@ -19,9 +19,9 @@ const Base = @import("../base.zig");
const getAllocator = Base.getAllocator;
const JSObject = JSC.JSObject;
const JSError = Base.JSError;
-const JSValue = JSC.JSValue;
+const JSValue = bun.JSC.JSValue;
const JSGlobalObject = JSC.JSGlobalObject;
-const strings = @import("bun").strings;
+const strings = bun.strings;
const NewClass = Base.NewClass;
const To = Base.To;
const Request = WebCore.Request;
@@ -30,7 +30,7 @@ const FetchEvent = WebCore.FetchEvent;
const MacroMap = @import("../../resolver/package_json.zig").MacroMap;
const TSConfigJSON = @import("../../resolver/tsconfig_json.zig").TSConfigJSON;
const PackageJSON = @import("../../resolver/package_json.zig").PackageJSON;
-const logger = @import("bun").logger;
+const logger = bun.logger;
const Loader = options.Loader;
const Platform = options.Platform;
const JSAst = bun.JSAst;
@@ -838,7 +838,7 @@ fn getParseResult(this: *Transpiler, allocator: std.mem.Allocator, code: []const
// necessary because we don't run the linker
if (parse_result) |*res| {
- for (res.ast.import_records) |*import| {
+ for (res.ast.import_records.slice()) |*import| {
if (import.kind.isCommonJS()) {
import.do_commonjs_transform_in_printer = true;
import.module_id = @truncate(u32, std.hash.Wyhash.hash(0, import.path.pretty));
@@ -923,7 +923,7 @@ pub fn scan(
const imports_label = JSC.ZigString.static("imports");
const named_imports_value = namedImportsToJS(
globalThis,
- parse_result.ast.import_records,
+ parse_result.ast.import_records.slice(),
exception,
);
if (exception.* != null) {
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig
index 5dc3abcf9..7c6473727 100644
--- a/src/bun.js/api/bun.zig
+++ b/src/bun.js/api/bun.zig
@@ -71,7 +71,8 @@ const VM = @import("bun").JSC.VM;
const JSFunction = @import("bun").JSC.JSFunction;
const Config = @import("../config.zig");
const URL = @import("../../url.zig").URL;
-const Transpiler = @import("./transpiler.zig");
+const Transpiler = bun.JSC.API.JSTranspiler;
+const JSBundler = bun.JSC.API.JSBundler;
const VirtualMachine = JSC.VirtualMachine;
const IOTask = JSC.IOTask;
const zlib = @import("../../zlib.zig");
@@ -1319,6 +1320,9 @@ pub const Class = NewClass(
.Transpiler = .{
.get = getTranspilerConstructor,
},
+ .Bundler = .{
+ .get = getBundlerConstructor,
+ },
.hash = .{
.get = getHashObject,
},
@@ -2339,6 +2343,16 @@ pub fn mmapFile(
}.x, @intToPtr(?*anyopaque, map.len), exception);
}
+pub fn getBundlerConstructor(
+ _: void,
+ ctx: js.JSContextRef,
+ _: js.JSValueRef,
+ _: js.JSStringRef,
+ _: js.ExceptionRef,
+) js.JSValueRef {
+ return JSC.API.JSBundler.getConstructor(ctx).asObjectRef();
+}
+
pub fn getTranspilerConstructor(
_: void,
ctx: js.JSContextRef,
@@ -2346,7 +2360,7 @@ pub fn getTranspilerConstructor(
_: js.JSStringRef,
_: js.ExceptionRef,
) js.JSValueRef {
- return JSC.API.Bun.Transpiler.getConstructor(ctx).asObjectRef();
+ return JSC.API.JSTranspiler.getConstructor(ctx).asObjectRef();
}
pub fn getFileSystemRouter(
diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig
index 89192dc85..6e2ad4242 100644
--- a/src/bun.js/api/ffi.zig
+++ b/src/bun.js/api/ffi.zig
@@ -71,7 +71,6 @@ const VM = @import("bun").JSC.VM;
const JSFunction = @import("bun").JSC.JSFunction;
const Config = @import("../config.zig");
const URL = @import("../../url.zig").URL;
-const Transpiler = @import("./transpiler.zig");
const VirtualMachine = JSC.VirtualMachine;
const IOTask = JSC.IOTask;
const ComptimeStringMap = @import("../../comptime_string_map.zig").ComptimeStringMap;
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index 11237844a..bc83a021b 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -70,7 +70,6 @@ const VM = @import("bun").JSC.VM;
const JSFunction = @import("bun").JSC.JSFunction;
const Config = @import("../config.zig");
const URL = @import("../../url.zig").URL;
-const Transpiler = @import("./transpiler.zig");
const VirtualMachine = JSC.VirtualMachine;
const IOTask = JSC.IOTask;
const is_bindgen = JSC.is_bindgen;
@@ -5173,4 +5172,11 @@ pub const SSLServer = NewServer(true, false);
pub const DebugServer = NewServer(false, true);
pub const DebugSSLServer = NewServer(true, true);
+pub const AnyServer = union(enum) {
+ Server: *Server,
+ SSLServer: *SSLServer,
+ DebugServer: *DebugServer,
+ DebugSSLServer: *DebugSSLServer,
+};
+
const welcome_page_html_gz = @embedFile("welcome-page.html.gz");
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig
index adb540304..a411beac2 100644
--- a/src/bun.js/base.zig
+++ b/src/bun.js/base.zig
@@ -2173,7 +2173,6 @@ const Expect = Test.Expect;
const DescribeScope = Test.DescribeScope;
const TestScope = Test.TestScope;
const NodeFS = JSC.Node.NodeFS;
-const Transpiler = @import("./api/transpiler.zig");
const TextEncoder = WebCore.TextEncoder;
const TextDecoder = WebCore.TextDecoder;
const HTMLRewriter = JSC.Cloudflare.HTMLRewriter;
diff --git a/src/bun.js/bindings/JSTranspiler+BunPlugin-impl.h b/src/bun.js/bindings/JSBundler+BunPlugin-impl.h
index e69de29bb..e69de29bb 100644
--- a/src/bun.js/bindings/JSTranspiler+BunPlugin-impl.h
+++ b/src/bun.js/bindings/JSBundler+BunPlugin-impl.h
diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp
index 9d3d5f16f..3459a2b7e 100644
--- a/src/bun.js/bindings/JSSink.cpp
+++ b/src/bun.js/bindings/JSSink.cpp
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2022-11-25T07:36:18.561Z
+// Generated by 'make generate-sink' at 2023-04-06T11:56:47.104Z
// To regenerate this file, run:
//
// make generate-sink
diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h
index 237e8083a..6df7a0e2f 100644
--- a/src/bun.js/bindings/JSSink.h
+++ b/src/bun.js/bindings/JSSink.h
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2022-11-25T07:36:18.559Z
+// Generated by 'make generate-sink' at 2023-04-06T11:56:47.103Z
//
#pragma once
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
index f38c22831..13fec5327 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h
@@ -1,5 +1,6 @@
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlob;
-std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlobConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasher;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlobConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBundler;
+std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBundlerConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasher;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasherConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirent;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirentConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpect;
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectAny;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
index 80ada929c..53dfe672a 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h
@@ -1,5 +1,6 @@
std::unique_ptr<IsoSubspace> m_subspaceForBlob;
-std::unique_ptr<IsoSubspace> m_subspaceForBlobConstructor;std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasher;
+std::unique_ptr<IsoSubspace> m_subspaceForBlobConstructor;std::unique_ptr<IsoSubspace> m_subspaceForBundler;
+std::unique_ptr<IsoSubspace> m_subspaceForBundlerConstructor;std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasher;
std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasherConstructor;std::unique_ptr<IsoSubspace> m_subspaceForDirent;
std::unique_ptr<IsoSubspace> m_subspaceForDirentConstructor;std::unique_ptr<IsoSubspace> m_subspaceForExpect;
std::unique_ptr<IsoSubspace> m_subspaceForExpectConstructor;std::unique_ptr<IsoSubspace> m_subspaceForExpectAny;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
index ae3e4233a..19e4c00d7 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h
@@ -4,6 +4,12 @@ JSC::Structure* JSBlobStructure() { return m_JSBlob.getInitializedOnMainThread(t
JSC::LazyClassStructure m_JSBlob;
bool hasJSBlobSetterValue { false };
mutable JSC::WriteBarrier<JSC::Unknown> m_JSBlobSetterValue;
+JSC::Structure* JSBundlerStructure() { return m_JSBundler.getInitializedOnMainThread(this); }
+ JSC::JSObject* JSBundlerConstructor() { return m_JSBundler.constructorInitializedOnMainThread(this); }
+ JSC::JSValue JSBundlerPrototype() { return m_JSBundler.prototypeInitializedOnMainThread(this); }
+ JSC::LazyClassStructure m_JSBundler;
+ bool hasJSBundlerSetterValue { false };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_JSBundlerSetterValue;
JSC::Structure* JSCryptoHasherStructure() { return m_JSCryptoHasher.getInitializedOnMainThread(this); }
JSC::JSObject* JSCryptoHasherConstructor() { return m_JSCryptoHasher.constructorInitializedOnMainThread(this); }
JSC::JSValue JSCryptoHasherPrototype() { return m_JSCryptoHasher.prototypeInitializedOnMainThread(this); }
diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
index a90753aa8..171a29303 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h
@@ -5,6 +5,12 @@ void GlobalObject::initGeneratedLazyClasses() {
init.setStructure(WebCore::JSBlob::createStructure(init.vm, init.global, init.prototype));
init.setConstructor(WebCore::JSBlob::createConstructor(init.vm, init.global, init.prototype));
});
+ m_JSBundler.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setPrototype(WebCore::JSBundler::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
+ init.setStructure(WebCore::JSBundler::createStructure(init.vm, init.global, init.prototype));
+ init.setConstructor(WebCore::JSBundler::createConstructor(init.vm, init.global, init.prototype));
+ });
m_JSCryptoHasher.initLater(
[](LazyClassStructure::Initializer& init) {
init.setPrototype(WebCore::JSCryptoHasher::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global)));
@@ -166,6 +172,7 @@ template<typename Visitor>
void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor& visitor)
{
thisObject->m_JSBlob.visit(visitor); visitor.append(thisObject->m_JSBlobSetterValue);
+ thisObject->m_JSBundler.visit(visitor); visitor.append(thisObject->m_JSBundlerSetterValue);
thisObject->m_JSCryptoHasher.visit(visitor); visitor.append(thisObject->m_JSCryptoHasherSetterValue);
thisObject->m_JSDirent.visit(visitor); visitor.append(thisObject->m_JSDirentSetterValue);
thisObject->m_JSExpect.visit(visitor); visitor.append(thisObject->m_JSExpectSetterValue);
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp
index 6496c281b..63df4a294 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.cpp
+++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp
@@ -23,151 +23,130 @@
#include "JSDOMConvertBufferSource.h"
#include "ZigGeneratedClasses.h"
-
-
-
namespace WebCore {
using namespace JSC;
using namespace Zig;
+class JSBlobPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSBlobPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSBlobPrototype* ptr = new (NotNull, JSC::allocateCell<JSBlobPrototype>(vm)) JSBlobPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
- class JSBlobPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSBlobPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSBlobPrototype* ptr = new (NotNull, JSC::allocateCell<JSBlobPrototype>(vm)) JSBlobPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSBlobPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSBlobPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSBlobConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSBlobConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBlobPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSBlobConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForBlobConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBlobConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForBlobConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForBlobConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSBlobConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSBlobConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBlobPrototype* prototype);
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSBlobConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForBlobConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBlobConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForBlobConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForBlobConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSBlobConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype);
+};
extern "C" void* BlobClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsBlobConstructor);
extern "C" void BlobClass__finalize(void*);
-
extern "C" EncodedJSValue BlobPrototype__getArrayBuffer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback);
-
extern "C" EncodedJSValue BlobPrototype__getFormData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(BlobPrototype__formDataCallback);
-
extern "C" EncodedJSValue BlobPrototype__getJSON(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(BlobPrototype__jsonCallback);
-
extern "C" JSC::EncodedJSValue BlobPrototype__getLastModified(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(BlobPrototype__lastModifiedGetterWrap);
-
extern "C" JSC::EncodedJSValue BlobPrototype__getSize(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(BlobPrototype__sizeGetterWrap);
-
extern "C" EncodedJSValue BlobPrototype__getSlice(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(BlobPrototype__sliceCallback);
-
extern "C" EncodedJSValue BlobPrototype__getStream(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(BlobPrototype__streamCallback);
-
extern "C" EncodedJSValue BlobPrototype__getText(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(BlobPrototype__textCallback);
-
extern "C" JSC::EncodedJSValue BlobPrototype__getType(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(BlobPrototype__typeGetterWrap);
-
extern "C" EncodedJSValue BlobPrototype__getWriter(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(BlobPrototype__writerCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBlobPrototype, JSBlobPrototype::Base);
-
- static const HashTableValue JSBlobPrototypeTableValues[] = {
-{ "arrayBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__arrayBufferCallback, 0 } } ,
-{ "formData"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__formDataCallback, 0 } } ,
-{ "json"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__jsonCallback, 0 } } ,
-{ "lastModified"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BlobPrototype__lastModifiedGetterWrap, 0 } } ,
-{ "size"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BlobPrototype__sizeGetterWrap, 0 } } ,
-{ "slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__sliceCallback, 2 } } ,
-{ "stream"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__streamCallback, 1 } } ,
-{ "text"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__textCallback, 0 } } ,
-{ "type"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BlobPrototype__typeGetterWrap, 0 } } ,
-{ "writer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__writerCallback, 1 } }
+static const HashTableValue JSBlobPrototypeTableValues[] = {
+ { "arrayBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__arrayBufferCallback, 0 } },
+ { "formData"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__formDataCallback, 0 } },
+ { "json"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__jsonCallback, 0 } },
+ { "lastModified"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BlobPrototype__lastModifiedGetterWrap, 0 } },
+ { "size"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BlobPrototype__sizeGetterWrap, 0 } },
+ { "slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__sliceCallback, 2 } },
+ { "stream"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__streamCallback, 1 } },
+ { "text"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__textCallback, 0 } },
+ { "type"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, BlobPrototype__typeGetterWrap, 0 } },
+ { "writer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BlobPrototype__writerCallback, 1 } }
};
-
-
const ClassInfo JSBlobPrototype::s_info = { "Blob"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBlobPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsBlobConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -178,65 +157,60 @@ JSC_DEFINE_CUSTOM_GETTER(jsBlobConstructor, (JSGlobalObject * lexicalGlobalObjec
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSBlobConstructor());
-}
-
-
-
- JSC_DEFINE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(BlobPrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
- return BlobPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(BlobPrototype__formDataCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
+ return BlobPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(BlobPrototype__formDataCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
- return BlobPrototype__getFormData(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(BlobPrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
+ return BlobPrototype__getFormData(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(BlobPrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
- return BlobPrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return BlobPrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__lastModifiedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSBlob* thisObject = jsCast<JSBlob*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -244,12 +218,11 @@ JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__lastModifiedGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__sizeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSBlob* thisObject = jsCast<JSBlob*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -257,63 +230,59 @@ JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__sizeGetterWrap, (JSGlobalObject * lexica
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(BlobPrototype__sliceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(BlobPrototype__sliceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
- return BlobPrototype__getSlice(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(BlobPrototype__streamCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
+ return BlobPrototype__getSlice(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(BlobPrototype__streamCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
- return BlobPrototype__getStream(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(BlobPrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
+ return BlobPrototype__getStream(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(BlobPrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
- return BlobPrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return BlobPrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__typeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSBlob* thisObject = jsCast<JSBlob*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -321,24 +290,22 @@ JSC_DEFINE_CUSTOM_GETTER(BlobPrototype__typeGetterWrap, (JSGlobalObject * lexica
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(BlobPrototype__writerCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(BlobPrototype__writerCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
+ JSBlob* thisObject = jsDynamicCast<JSBlob*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return BlobPrototype__getWriter(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return BlobPrototype__getWriter(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSBlobPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -350,67 +317,64 @@ void JSBlobPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObj
void JSBlobConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype)
{
Base::finishCreation(vm, 0, "Blob"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSBlobConstructor::JSBlobConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSBlobConstructor::JSBlobConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSBlobConstructor* JSBlobConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBlobPrototype* prototype) {
+JSBlobConstructor* JSBlobConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBlobPrototype* prototype)
+{
JSBlobConstructor* ptr = new (NotNull, JSC::allocateCell<JSBlobConstructor>(vm)) JSBlobConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBlobConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSBlobConstructor();
Structure* structure = globalObject->JSBlobStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSBlobStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSBlobStructure());
}
void* ptr = BlobClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSBlob* instance = JSBlob::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSBlobConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSBlobPrototype* prototype)
{
-
}
const ClassInfo JSBlobConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBlobConstructor) };
-
- extern "C" EncodedJSValue Blob__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue Blob__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSBlobConstructor());
- }
+}
JSBlob::~JSBlob()
{
@@ -422,7 +386,7 @@ void JSBlob::destroy(JSCell* cell)
{
static_cast<JSBlob*>(cell)->JSBlob::~JSBlob();
}
-
+
const ClassInfo JSBlob::s_info = { "Blob"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBlob) };
void JSBlob::finishCreation(VM& vm)
@@ -431,36 +395,37 @@ void JSBlob::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSBlob* JSBlob::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSBlob* ptr = new (NotNull, JSC::allocateCell<JSBlob>(vm)) JSBlob(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSBlob* JSBlob::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSBlob* ptr = new (NotNull, JSC::allocateCell<JSBlob>(vm)) JSBlob(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Blob__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Blob__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSBlob* object = JSC::jsDynamicCast<JSBlob*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSBlob* object = JSC::jsDynamicCast<JSBlob*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Blob__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSBlob* object = JSC::jsDynamicCast<JSBlob*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Blob__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSBlob* object = JSC::jsDynamicCast<JSBlob*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Blob__ptrOffset = JSBlob::offsetOfWrapped();
@@ -476,7 +441,7 @@ void JSBlob::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSBlob::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSBlobConstructor::create(vm, globalObject, WebCore::JSBlobConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSBlobPrototype*>(prototype));
+ return WebCore::JSBlobConstructor::create(vm, globalObject, WebCore::JSBlobConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSBlobPrototype*>(prototype));
}
JSObject* JSBlob::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -484,119 +449,429 @@ JSObject* JSBlob::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSBlobPrototype::create(vm, globalObject, JSBlobPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Blob__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSBlobStructure();
- JSBlob* instance = JSBlob::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSCryptoHasherPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSCryptoHasherPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSCryptoHasherPrototype* ptr = new (NotNull, JSC::allocateCell<JSCryptoHasherPrototype>(vm)) JSCryptoHasherPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSCryptoHasherPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue Blob__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSBlobStructure();
+ JSBlob* instance = JSBlob::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSBundlerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSBundlerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSBundlerPrototype* ptr = new (NotNull, JSC::allocateCell<JSBundlerPrototype>(vm)) JSBundlerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSBundlerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+class JSBundlerConstructor final : public JSC::InternalFunction {
+public:
+ using Base = JSC::InternalFunction;
+ static JSBundlerConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBundlerPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSBundlerConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForBundlerConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBundlerConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForBundlerConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForBundlerConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSBundlerPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSBundlerConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSBundlerPrototype* prototype);
+};
+
+extern "C" void* BundlerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+JSC_DECLARE_CUSTOM_GETTER(jsBundlerConstructor);
+extern "C" void BundlerClass__finalize(void*);
+
+extern "C" EncodedJSValue BundlerPrototype__handleRequest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(BundlerPrototype__handleCallback);
+
+extern "C" EncodedJSValue BundlerPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(BundlerPrototype__writeCallback);
+
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSBundlerPrototype, JSBundlerPrototype::Base);
+
+static const HashTableValue JSBundlerPrototypeTableValues[] = {
+ { "handle"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BundlerPrototype__handleCallback, 2 } },
+ { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, BundlerPrototype__writeCallback, 1 } }
+};
+
+const ClassInfo JSBundlerPrototype::s_info = { "Bundler"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBundlerPrototype) };
+
+JSC_DEFINE_CUSTOM_GETTER(jsBundlerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ auto* prototype = jsDynamicCast<JSBundlerPrototype*>(JSValue::decode(thisValue));
+
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(globalObject->JSBundlerConstructor());
+}
+
+JSC_DEFINE_HOST_FUNCTION(BundlerPrototype__handleCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSBundler* thisObject = jsDynamicCast<JSBundler*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return BundlerPrototype__handleRequest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+JSC_DEFINE_HOST_FUNCTION(BundlerPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSBundler* thisObject = jsDynamicCast<JSBundler*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return BundlerPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+void JSBundlerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSBundler::info(), JSBundlerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+void JSBundlerConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSBundlerPrototype* prototype)
+{
+ Base::finishCreation(vm, 0, "Bundler"_s, PropertyAdditionMode::WithoutStructureTransition);
+
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ ASSERT(inherits(info()));
+}
+
+JSBundlerConstructor::JSBundlerConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
+
+JSBundlerConstructor* JSBundlerConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSBundlerPrototype* prototype)
+{
+ JSBundlerConstructor* ptr = new (NotNull, JSC::allocateCell<JSBundlerConstructor>(vm)) JSBundlerConstructor(vm, structure);
+ ptr->finishCreation(vm, globalObject, prototype);
+ return ptr;
+}
+
+JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBundlerConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
+{
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
+ JSObject* newTarget = asObject(callFrame->newTarget());
+ auto* constructor = globalObject->JSBundlerConstructor();
+ Structure* structure = globalObject->JSBundlerStructure();
+ if (constructor != newTarget) {
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSBundlerStructure());
+ }
+
+ void* ptr = BundlerClass__construct(globalObject, callFrame);
+
+ if (UNLIKELY(!ptr)) {
+ return JSValue::encode(JSC::jsUndefined());
+ }
+
+ JSBundler* instance = JSBundler::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+void JSBundlerConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSBundlerPrototype* prototype)
+{
+}
+
+const ClassInfo JSBundlerConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBundlerConstructor) };
+
+extern "C" EncodedJSValue Bundler__getConstructor(Zig::GlobalObject* globalObject)
+{
+ return JSValue::encode(globalObject->JSBundlerConstructor());
+}
+
+extern "C" bool Bundler__hasPendingActivity(void* ptr);
+bool JSBundler::hasPendingActivity(void* ctx)
+{
+ return Bundler__hasPendingActivity(ctx);
+}
+
+JSBundler::~JSBundler()
+{
+ if (m_ctx) {
+ BundlerClass__finalize(m_ctx);
+ }
+}
+void JSBundler::destroy(JSCell* cell)
+{
+ static_cast<JSBundler*>(cell)->JSBundler::~JSBundler();
+}
+
+const ClassInfo JSBundler::s_info = { "Bundler"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBundler) };
+
+void JSBundler::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+}
+
+JSBundler* JSBundler::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSBundler* ptr = new (NotNull, JSC::allocateCell<JSBundler>(vm)) JSBundler(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
+}
+
+extern "C" void* Bundler__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSBundler* object = JSC::jsDynamicCast<JSBundler*>(cell);
+
+ if (!object)
+ return nullptr;
+
+ return object->wrapped();
+}
+
+extern "C" bool Bundler__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSBundler* object = JSC::jsDynamicCast<JSBundler*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
+
+extern "C" const size_t Bundler__ptrOffset = JSBundler::offsetOfWrapped();
+
+void JSBundler::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSBundler*>(cell);
+ if (void* wrapped = thisObject->wrapped()) {
+ // if (thisObject->scriptExecutionContext())
+ // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ }
+ Base::analyzeHeap(cell, analyzer);
+}
+
+JSObject* JSBundler::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+ return WebCore::JSBundlerConstructor::create(vm, globalObject, WebCore::JSBundlerConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSBundlerPrototype*>(prototype));
+}
+
+JSObject* JSBundler::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
+{
+ return JSBundlerPrototype::create(vm, globalObject, JSBundlerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
+}
+
+extern "C" EncodedJSValue Bundler__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSBundlerStructure();
+ JSBundler* instance = JSBundler::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+
+template<typename Visitor>
+void JSBundler::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSBundler* thisObject = jsCast<JSBundler*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.addOpaqueRoot(thisObject->wrapped());
+}
+
+DEFINE_VISIT_CHILDREN(JSBundler);
+
+template<typename Visitor>
+void JSBundler::visitAdditionalChildren(Visitor& visitor)
+{
+ JSBundler* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+
+ visitor.addOpaqueRoot(this->wrapped());
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSBundler);
+
+template<typename Visitor>
+void JSBundler::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSBundler* thisObject = jsCast<JSBundler*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSBundler);
+class JSCryptoHasherPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSCryptoHasherPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSCryptoHasherPrototype* ptr = new (NotNull, JSC::allocateCell<JSCryptoHasherPrototype>(vm)) JSCryptoHasherPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSCryptoHasherPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSCryptoHasherConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSCryptoHasherConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSCryptoHasherPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSCryptoHasherConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForCryptoHasherConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCryptoHasherConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForCryptoHasherConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForCryptoHasherConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSCryptoHasherPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSCryptoHasherConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSCryptoHasherPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSCryptoHasherConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSCryptoHasherPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSCryptoHasherConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForCryptoHasherConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCryptoHasherConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForCryptoHasherConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForCryptoHasherConstructor = std::forward<decltype(space)>(space); });
+ }
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSCryptoHasherPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSCryptoHasherConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSCryptoHasherPrototype* prototype);
+};
extern "C" void* CryptoHasherClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsCryptoHasherConstructor);
extern "C" void CryptoHasherClass__finalize(void*);
-
extern "C" JSC::EncodedJSValue CryptoHasherPrototype__getAlgorithm(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(CryptoHasherPrototype__algorithmGetterWrap);
-
extern "C" JSC::EncodedJSValue CryptoHasherPrototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(CryptoHasherPrototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue CryptoHasherPrototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(CryptoHasherPrototype__digestCallback);
-
extern "C" EncodedJSValue CryptoHasherPrototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(CryptoHasherPrototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSCryptoHasherPrototype, JSCryptoHasherPrototype::Base);
-
- static const HashTableValue JSCryptoHasherPrototypeTableValues[] = {
-{ "algorithm"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, CryptoHasherPrototype__algorithmGetterWrap, 0 } } ,
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, CryptoHasherPrototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, CryptoHasherPrototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, CryptoHasherPrototype__updateCallback, 2 } }
+static const HashTableValue JSCryptoHasherPrototypeTableValues[] = {
+ { "algorithm"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, CryptoHasherPrototype__algorithmGetterWrap, 0 } },
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, CryptoHasherPrototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, CryptoHasherPrototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, CryptoHasherPrototype__updateCallback, 2 } }
};
-
-
const ClassInfo JSCryptoHasherPrototype::s_info = { "CryptoHasher"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCryptoHasherPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsCryptoHasherConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -607,49 +882,43 @@ JSC_DEFINE_CUSTOM_GETTER(jsCryptoHasherConstructor, (JSGlobalObject * lexicalGlo
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSCryptoHasherConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(CryptoHasherPrototype__algorithmGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSCryptoHasher* thisObject = jsCast<JSCryptoHasher*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_algorithm.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- CryptoHasherPrototype__getAlgorithm(thisObject->wrapped(), globalObject)
- );
+ CryptoHasherPrototype__getAlgorithm(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_algorithm.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void CryptoHasherPrototype__algorithmSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSCryptoHasher*>(JSValue::decode(thisValue));
+ thisObject->m_algorithm.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void CryptoHasherPrototype__algorithmSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSCryptoHasher*>(JSValue::decode(thisValue));
- thisObject->m_algorithm.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue CryptoHasherPrototype__algorithmGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue CryptoHasherPrototype__algorithmGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSCryptoHasher*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_algorithm.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(CryptoHasherPrototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSCryptoHasher* thisObject = jsCast<JSCryptoHasher*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -657,41 +926,38 @@ JSC_DEFINE_CUSTOM_GETTER(CryptoHasherPrototype__byteLengthGetterWrap, (JSGlobalO
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(CryptoHasherPrototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSCryptoHasher* thisObject = jsDynamicCast<JSCryptoHasher*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(CryptoHasherPrototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSCryptoHasher* thisObject = jsDynamicCast<JSCryptoHasher*>(callFrame->thisValue());
- return CryptoHasherPrototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(CryptoHasherPrototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSCryptoHasher* thisObject = jsDynamicCast<JSCryptoHasher*>(callFrame->thisValue());
+ return CryptoHasherPrototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(CryptoHasherPrototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSCryptoHasher* thisObject = jsDynamicCast<JSCryptoHasher*>(callFrame->thisValue());
- return CryptoHasherPrototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return CryptoHasherPrototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSCryptoHasherPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -703,12 +969,11 @@ void JSCryptoHasherPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* g
extern "C" JSC_DECLARE_CUSTOM_GETTER(CryptoHasherClass__getAlgorithms);
extern "C" JSC_DECLARE_HOST_FUNCTION(CryptoHasherClass__hash);
- static const HashTableValue JSCryptoHasherConstructorTableValues[] = {
-{ "algorithms"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, CryptoHasherClass__getAlgorithms, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, CryptoHasherClass__hash, 2 } }
+static const HashTableValue JSCryptoHasherConstructorTableValues[] = {
+ { "algorithms"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, CryptoHasherClass__getAlgorithms, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, CryptoHasherClass__hash, 2 } }
};
-
void JSCryptoHasherConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSCryptoHasherPrototype* prototype)
{
Base::finishCreation(vm, 0, "CryptoHasher"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -717,62 +982,59 @@ void JSCryptoHasherConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* glob
ASSERT(inherits(info()));
}
-JSCryptoHasherConstructor::JSCryptoHasherConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSCryptoHasherConstructor::JSCryptoHasherConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSCryptoHasherConstructor* JSCryptoHasherConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSCryptoHasherPrototype* prototype) {
+JSCryptoHasherConstructor* JSCryptoHasherConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSCryptoHasherPrototype* prototype)
+{
JSCryptoHasherConstructor* ptr = new (NotNull, JSC::allocateCell<JSCryptoHasherConstructor>(vm)) JSCryptoHasherConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSCryptoHasherConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSCryptoHasherConstructor();
Structure* structure = globalObject->JSCryptoHasherStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSCryptoHasherStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSCryptoHasherStructure());
}
void* ptr = CryptoHasherClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSCryptoHasher* instance = JSCryptoHasher::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSCryptoHasherConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSCryptoHasherPrototype* prototype)
{
-
}
const ClassInfo JSCryptoHasherConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCryptoHasherConstructor) };
-
- extern "C" EncodedJSValue CryptoHasher__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue CryptoHasher__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSCryptoHasherConstructor());
- }
+}
JSCryptoHasher::~JSCryptoHasher()
{
@@ -784,7 +1046,7 @@ void JSCryptoHasher::destroy(JSCell* cell)
{
static_cast<JSCryptoHasher*>(cell)->JSCryptoHasher::~JSCryptoHasher();
}
-
+
const ClassInfo JSCryptoHasher::s_info = { "CryptoHasher"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCryptoHasher) };
void JSCryptoHasher::finishCreation(VM& vm)
@@ -793,36 +1055,37 @@ void JSCryptoHasher::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSCryptoHasher* JSCryptoHasher::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSCryptoHasher* ptr = new (NotNull, JSC::allocateCell<JSCryptoHasher>(vm)) JSCryptoHasher(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSCryptoHasher* JSCryptoHasher::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSCryptoHasher* ptr = new (NotNull, JSC::allocateCell<JSCryptoHasher>(vm)) JSCryptoHasher(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* CryptoHasher__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* CryptoHasher__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSCryptoHasher* object = JSC::jsDynamicCast<JSCryptoHasher*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSCryptoHasher* object = JSC::jsDynamicCast<JSCryptoHasher*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool CryptoHasher__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSCryptoHasher* object = JSC::jsDynamicCast<JSCryptoHasher*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool CryptoHasher__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSCryptoHasher* object = JSC::jsDynamicCast<JSCryptoHasher*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t CryptoHasher__ptrOffset = JSCryptoHasher::offsetOfWrapped();
@@ -838,7 +1101,7 @@ void JSCryptoHasher::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSCryptoHasher::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSCryptoHasherConstructor::create(vm, globalObject, WebCore::JSCryptoHasherConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSCryptoHasherPrototype*>(prototype));
+ return WebCore::JSCryptoHasherConstructor::create(vm, globalObject, WebCore::JSCryptoHasherConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSCryptoHasherPrototype*>(prototype));
}
JSObject* JSCryptoHasher::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -846,12 +1109,13 @@ JSObject* JSCryptoHasher::createPrototype(VM& vm, JSDOMGlobalObject* globalObjec
return JSCryptoHasherPrototype::create(vm, globalObject, JSCryptoHasherPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue CryptoHasher__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSCryptoHasherStructure();
- JSCryptoHasher* instance = JSCryptoHasher::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue CryptoHasher__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSCryptoHasherStructure();
+ JSCryptoHasher* instance = JSCryptoHasher::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -860,11 +1124,9 @@ void JSCryptoHasher::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSCryptoHasher* thisObject = jsCast<JSCryptoHasher*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_algorithms);
visitor.append(thisObject->m_algorithm);
-
}
DEFINE_VISIT_CHILDREN(JSCryptoHasher);
@@ -872,10 +1134,10 @@ DEFINE_VISIT_CHILDREN(JSCryptoHasher);
template<typename Visitor>
void JSCryptoHasher::visitAdditionalChildren(Visitor& visitor)
{
- JSCryptoHasher* thisObject = this;
+ JSCryptoHasher* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_algorithms);
+
+ visitor.append(thisObject->m_algorithms);
visitor.append(thisObject->m_algorithm);
;
}
@@ -883,7 +1145,7 @@ void JSCryptoHasher::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSCryptoHasher);
template<typename Visitor>
-void JSCryptoHasher::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSCryptoHasher::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSCryptoHasher* thisObject = jsCast<JSCryptoHasher*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -891,132 +1153,117 @@ void JSCryptoHasher::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSCryptoHasher);
- class JSDirentPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSDirentPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSDirentPrototype* ptr = new (NotNull, JSC::allocateCell<JSDirentPrototype>(vm)) JSDirentPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSDirentPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSDirentPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSDirentPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSDirentPrototype* ptr = new (NotNull, JSC::allocateCell<JSDirentPrototype>(vm)) JSDirentPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSDirentPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSDirentConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSDirentConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSDirentPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSDirentConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForDirentConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForDirentConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForDirentConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForDirentConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSDirentPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSDirentConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSDirentPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSDirentConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSDirentPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSDirentConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForDirentConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForDirentConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForDirentConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForDirentConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSDirentPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSDirentConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSDirentPrototype* prototype);
+};
extern "C" void* DirentClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsDirentConstructor);
extern "C" void DirentClass__finalize(void*);
-
extern "C" EncodedJSValue DirentPrototype__isBlockDevice(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(DirentPrototype__isBlockDeviceCallback);
-
extern "C" EncodedJSValue DirentPrototype__isCharacterDevice(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(DirentPrototype__isCharacterDeviceCallback);
-
extern "C" EncodedJSValue DirentPrototype__isDirectory(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(DirentPrototype__isDirectoryCallback);
-
extern "C" EncodedJSValue DirentPrototype__isFIFO(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(DirentPrototype__isFIFOCallback);
-
extern "C" EncodedJSValue DirentPrototype__isFile(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(DirentPrototype__isFileCallback);
-
extern "C" EncodedJSValue DirentPrototype__isSocket(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(DirentPrototype__isSocketCallback);
-
extern "C" EncodedJSValue DirentPrototype__isSymbolicLink(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(DirentPrototype__isSymbolicLinkCallback);
-
extern "C" JSC::EncodedJSValue DirentPrototype__getName(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(DirentPrototype__nameGetterWrap);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSDirentPrototype, JSDirentPrototype::Base);
-
- static const HashTableValue JSDirentPrototypeTableValues[] = {
-{ "isBlockDevice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isBlockDeviceCallback, 0 } } ,
-{ "isCharacterDevice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isCharacterDeviceCallback, 0 } } ,
-{ "isDirectory"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isDirectoryCallback, 0 } } ,
-{ "isFIFO"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isFIFOCallback, 0 } } ,
-{ "isFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isFileCallback, 0 } } ,
-{ "isSocket"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isSocketCallback, 0 } } ,
-{ "isSymbolicLink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isSymbolicLinkCallback, 0 } } ,
-{ "name"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DirentPrototype__nameGetterWrap, 0 } }
+static const HashTableValue JSDirentPrototypeTableValues[] = {
+ { "isBlockDevice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isBlockDeviceCallback, 0 } },
+ { "isCharacterDevice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isCharacterDeviceCallback, 0 } },
+ { "isDirectory"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isDirectoryCallback, 0 } },
+ { "isFIFO"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isFIFOCallback, 0 } },
+ { "isFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isFileCallback, 0 } },
+ { "isSocket"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isSocketCallback, 0 } },
+ { "isSymbolicLink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, DirentPrototype__isSymbolicLinkCallback, 0 } },
+ { "name"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, DirentPrototype__nameGetterWrap, 0 } }
};
-
-
const ClassInfo JSDirentPrototype::s_info = { "Dirent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDirentPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsDirentConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -1027,163 +1274,150 @@ JSC_DEFINE_CUSTOM_GETTER(jsDirentConstructor, (JSGlobalObject * lexicalGlobalObj
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSDirentConstructor());
-}
-
-
-
- JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isBlockDeviceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isBlockDeviceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
- return DirentPrototype__isBlockDevice(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isCharacterDeviceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
+ return DirentPrototype__isBlockDevice(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isCharacterDeviceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
- return DirentPrototype__isCharacterDevice(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isDirectoryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
+ return DirentPrototype__isCharacterDevice(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isDirectoryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
- return DirentPrototype__isDirectory(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isFIFOCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
+ return DirentPrototype__isDirectory(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isFIFOCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
- return DirentPrototype__isFIFO(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
+ return DirentPrototype__isFIFO(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
- return DirentPrototype__isFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isSocketCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
+ return DirentPrototype__isFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isSocketCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
- return DirentPrototype__isSocket(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isSymbolicLinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
+ return DirentPrototype__isSocket(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(DirentPrototype__isSymbolicLinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSDirent* thisObject = jsDynamicCast<JSDirent*>(callFrame->thisValue());
- return DirentPrototype__isSymbolicLink(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return DirentPrototype__isSymbolicLink(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(DirentPrototype__nameGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSDirent* thisObject = jsCast<JSDirent*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_name.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- DirentPrototype__getName(thisObject->wrapped(), globalObject)
- );
+ DirentPrototype__getName(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_name.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void DirentPrototype__nameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSDirent*>(JSValue::decode(thisValue));
+ thisObject->m_name.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void DirentPrototype__nameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSDirent*>(JSValue::decode(thisValue));
- thisObject->m_name.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue DirentPrototype__nameGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue DirentPrototype__nameGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSDirent*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_name.get());
- }
-
-
+}
void JSDirentPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -1195,67 +1429,64 @@ void JSDirentPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalO
void JSDirentConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSDirentPrototype* prototype)
{
Base::finishCreation(vm, 0, "Dirent"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSDirentConstructor::JSDirentConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSDirentConstructor::JSDirentConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSDirentConstructor* JSDirentConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSDirentPrototype* prototype) {
+JSDirentConstructor* JSDirentConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSDirentPrototype* prototype)
+{
JSDirentConstructor* ptr = new (NotNull, JSC::allocateCell<JSDirentConstructor>(vm)) JSDirentConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSDirentConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSDirentConstructor();
Structure* structure = globalObject->JSDirentStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSDirentStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSDirentStructure());
}
void* ptr = DirentClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSDirent* instance = JSDirent::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSDirentConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSDirentPrototype* prototype)
{
-
}
const ClassInfo JSDirentConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDirentConstructor) };
-
- extern "C" EncodedJSValue Dirent__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue Dirent__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSDirentConstructor());
- }
+}
JSDirent::~JSDirent()
{
@@ -1267,7 +1498,7 @@ void JSDirent::destroy(JSCell* cell)
{
static_cast<JSDirent*>(cell)->JSDirent::~JSDirent();
}
-
+
const ClassInfo JSDirent::s_info = { "Dirent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDirent) };
void JSDirent::finishCreation(VM& vm)
@@ -1276,36 +1507,37 @@ void JSDirent::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSDirent* JSDirent::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSDirent* ptr = new (NotNull, JSC::allocateCell<JSDirent>(vm)) JSDirent(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSDirent* JSDirent::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSDirent* ptr = new (NotNull, JSC::allocateCell<JSDirent>(vm)) JSDirent(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Dirent__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Dirent__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSDirent* object = JSC::jsDynamicCast<JSDirent*>(cell);
- JSC::JSCell* cell = decodedValue.asCell();
- JSDirent* object = JSC::jsDynamicCast<JSDirent*>(cell);
+ if (!object)
+ return nullptr;
- if (!object)
- return nullptr;
-
- return object->wrapped();
+ return object->wrapped();
}
-extern "C" bool Dirent__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSDirent* object = JSC::jsDynamicCast<JSDirent*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
-}
+extern "C" bool Dirent__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSDirent* object = JSC::jsDynamicCast<JSDirent*>(JSValue::decode(value));
+ if (!object)
+ return false;
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Dirent__ptrOffset = JSDirent::offsetOfWrapped();
@@ -1321,7 +1553,7 @@ void JSDirent::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSDirent::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSDirentConstructor::create(vm, globalObject, WebCore::JSDirentConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSDirentPrototype*>(prototype));
+ return WebCore::JSDirentConstructor::create(vm, globalObject, WebCore::JSDirentConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSDirentPrototype*>(prototype));
}
JSObject* JSDirent::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -1329,12 +1561,13 @@ JSObject* JSDirent::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSDirentPrototype::create(vm, globalObject, JSDirentPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Dirent__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSDirentStructure();
- JSDirent* instance = JSDirent::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue Dirent__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSDirentStructure();
+ JSDirent* instance = JSDirent::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -1343,10 +1576,8 @@ void JSDirent::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSDirent* thisObject = jsCast<JSDirent*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
- visitor.append(thisObject->m_name);
+ visitor.append(thisObject->m_name);
}
DEFINE_VISIT_CHILDREN(JSDirent);
@@ -1354,17 +1585,17 @@ DEFINE_VISIT_CHILDREN(JSDirent);
template<typename Visitor>
void JSDirent::visitAdditionalChildren(Visitor& visitor)
{
- JSDirent* thisObject = this;
+ JSDirent* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_name);
+
+ visitor.append(thisObject->m_name);
;
}
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSDirent);
template<typename Visitor>
-void JSDirent::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSDirent::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSDirent* thisObject = jsCast<JSDirent*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -1372,277 +1603,234 @@ void JSDirent::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSDirent);
- class JSExpectPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSExpectPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSExpectPrototype* ptr = new (NotNull, JSC::allocateCell<JSExpectPrototype>(vm)) JSExpectPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSExpectPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSExpectPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSExpectPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSExpectPrototype* ptr = new (NotNull, JSC::allocateCell<JSExpectPrototype>(vm)) JSExpectPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSExpectPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSExpectConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSExpectConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSExpectPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSExpectConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForExpectConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForExpectConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForExpectConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForExpectConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSExpectConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSExpectConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSExpectPrototype* prototype);
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSExpectConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForExpectConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForExpectConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForExpectConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForExpectConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSExpectConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype);
+};
extern "C" void* ExpectClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsExpectConstructor);
extern "C" void ExpectClass__finalize(void*);
extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__call);
-extern "C" JSC::EncodedJSValue ExpectPrototype__getNot(void* ptr, JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* lexicalGlobalObject);
+extern "C" JSC::EncodedJSValue ExpectPrototype__getNot(void* ptr, JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ExpectPrototype__notGetterWrap);
-
-extern "C" JSC::EncodedJSValue ExpectPrototype__getRejects(void* ptr, JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* lexicalGlobalObject);
+extern "C" JSC::EncodedJSValue ExpectPrototype__getRejects(void* ptr, JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ExpectPrototype__rejectsGetterWrap);
-
-extern "C" JSC::EncodedJSValue ExpectPrototype__getResolves(void* ptr, JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* lexicalGlobalObject);
+extern "C" JSC::EncodedJSValue ExpectPrototype__getResolves(void* ptr, JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ExpectPrototype__resolvesGetterWrap);
-
extern "C" EncodedJSValue ExpectPrototype__toBe(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeCloseTo(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeCloseToCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeDefined(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeDefinedCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeFalsy(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeFalsyCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeGreaterThan(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeGreaterThanOrEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanOrEqualCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeInstanceOf(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeInstanceOfCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeLessThan(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeLessThanCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeLessThanOrEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeLessThanOrEqualCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeNaN(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeNaNCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeNull(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeNullCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeTruthy(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeTruthyCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toBeUndefined(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toBeUndefinedCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toContain(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toContainCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toContainEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toContainEqualCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toEqualCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveBeenCalledTimes(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledTimesCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveBeenCalledWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledWithCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveBeenLastCalledWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveBeenLastCalledWithCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveBeenNthCalledWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveBeenNthCalledWithCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveLastReturnedWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveLastReturnedWithCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveLengthCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveNthReturnedWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveNthReturnedWithCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveProperty(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHavePropertyCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveReturnedTimes(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedTimesCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toHaveReturnedWith(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedWithCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toMatch(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toMatchCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toMatchInlineSnapshot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toMatchInlineSnapshotCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toMatchObject(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toMatchObjectCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toMatchSnapshot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toMatchSnapshotCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toStrictEqual(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toStrictEqualCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toThrow(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toThrowCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toThrowErrorMatchingInlineSnapshot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingInlineSnapshotCallback);
-
extern "C" EncodedJSValue ExpectPrototype__toThrowErrorMatchingSnapshot(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingSnapshotCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectPrototype, JSExpectPrototype::Base);
-
- static const HashTableValue JSExpectPrototypeTableValues[] = {
-{ "not"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__notGetterWrap, 0 } } ,
-{ "rejects"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__rejectsGetterWrap, 0 } } ,
-{ "resolves"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__resolvesGetterWrap, 0 } } ,
-{ "toBe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeCallback, 1 } } ,
-{ "toBeCloseTo"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeCloseToCallback, 1 } } ,
-{ "toBeDefined"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeDefinedCallback, 0 } } ,
-{ "toBeFalsy"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeFalsyCallback, 0 } } ,
-{ "toBeGreaterThan"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeGreaterThanCallback, 1 } } ,
-{ "toBeGreaterThanOrEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeGreaterThanOrEqualCallback, 1 } } ,
-{ "toBeInstanceOf"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeInstanceOfCallback, 1 } } ,
-{ "toBeLessThan"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeLessThanCallback, 1 } } ,
-{ "toBeLessThanOrEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeLessThanOrEqualCallback, 1 } } ,
-{ "toBeNaN"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeNaNCallback, 0 } } ,
-{ "toBeNull"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeNullCallback, 0 } } ,
-{ "toBeTruthy"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeTruthyCallback, 0 } } ,
-{ "toBeUndefined"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeUndefinedCallback, 0 } } ,
-{ "toContain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toContainCallback, 1 } } ,
-{ "toContainEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toContainEqualCallback, 1 } } ,
-{ "toEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toEqualCallback, 1 } } ,
-{ "toHaveBeenCalledTimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenCalledTimesCallback, 1 } } ,
-{ "toHaveBeenCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenCalledWithCallback, 1 } } ,
-{ "toHaveBeenLastCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenLastCalledWithCallback, 1 } } ,
-{ "toHaveBeenNthCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenNthCalledWithCallback, 1 } } ,
-{ "toHaveLastReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveLastReturnedWithCallback, 1 } } ,
-{ "toHaveLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveLengthCallback, 1 } } ,
-{ "toHaveNthReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveNthReturnedWithCallback, 1 } } ,
-{ "toHaveProperty"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHavePropertyCallback, 2 } } ,
-{ "toHaveReturnedTimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveReturnedTimesCallback, 1 } } ,
-{ "toHaveReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveReturnedWithCallback, 1 } } ,
-{ "toMatch"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchCallback, 1 } } ,
-{ "toMatchInlineSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchInlineSnapshotCallback, 1 } } ,
-{ "toMatchObject"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchObjectCallback, 1 } } ,
-{ "toMatchSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchSnapshotCallback, 1 } } ,
-{ "toStrictEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toStrictEqualCallback, 1 } } ,
-{ "toThrow"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowCallback, 1 } } ,
-{ "toThrowErrorMatchingInlineSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowErrorMatchingInlineSnapshotCallback, 1 } } ,
-{ "toThrowErrorMatchingSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowErrorMatchingSnapshotCallback, 1 } }
+static const HashTableValue JSExpectPrototypeTableValues[] = {
+ { "not"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__notGetterWrap, 0 } },
+ { "rejects"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__rejectsGetterWrap, 0 } },
+ { "resolves"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectPrototype__resolvesGetterWrap, 0 } },
+ { "toBe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeCallback, 1 } },
+ { "toBeCloseTo"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeCloseToCallback, 1 } },
+ { "toBeDefined"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeDefinedCallback, 0 } },
+ { "toBeFalsy"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeFalsyCallback, 0 } },
+ { "toBeGreaterThan"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeGreaterThanCallback, 1 } },
+ { "toBeGreaterThanOrEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeGreaterThanOrEqualCallback, 1 } },
+ { "toBeInstanceOf"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeInstanceOfCallback, 1 } },
+ { "toBeLessThan"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeLessThanCallback, 1 } },
+ { "toBeLessThanOrEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeLessThanOrEqualCallback, 1 } },
+ { "toBeNaN"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeNaNCallback, 0 } },
+ { "toBeNull"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeNullCallback, 0 } },
+ { "toBeTruthy"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeTruthyCallback, 0 } },
+ { "toBeUndefined"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toBeUndefinedCallback, 0 } },
+ { "toContain"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toContainCallback, 1 } },
+ { "toContainEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toContainEqualCallback, 1 } },
+ { "toEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toEqualCallback, 1 } },
+ { "toHaveBeenCalledTimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenCalledTimesCallback, 1 } },
+ { "toHaveBeenCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenCalledWithCallback, 1 } },
+ { "toHaveBeenLastCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenLastCalledWithCallback, 1 } },
+ { "toHaveBeenNthCalledWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveBeenNthCalledWithCallback, 1 } },
+ { "toHaveLastReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveLastReturnedWithCallback, 1 } },
+ { "toHaveLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveLengthCallback, 1 } },
+ { "toHaveNthReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveNthReturnedWithCallback, 1 } },
+ { "toHaveProperty"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHavePropertyCallback, 2 } },
+ { "toHaveReturnedTimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveReturnedTimesCallback, 1 } },
+ { "toHaveReturnedWith"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toHaveReturnedWithCallback, 1 } },
+ { "toMatch"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchCallback, 1 } },
+ { "toMatchInlineSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchInlineSnapshotCallback, 1 } },
+ { "toMatchObject"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchObjectCallback, 1 } },
+ { "toMatchSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toMatchSnapshotCallback, 1 } },
+ { "toStrictEqual"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toStrictEqualCallback, 1 } },
+ { "toThrow"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowCallback, 1 } },
+ { "toThrowErrorMatchingInlineSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowErrorMatchingInlineSnapshotCallback, 1 } },
+ { "toThrowErrorMatchingSnapshot"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectPrototype__toThrowErrorMatchingSnapshotCallback, 1 } }
};
-
-
const ClassInfo JSExpectPrototype::s_info = { "Expect"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSExpectPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsExpectConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -1653,658 +1841,613 @@ JSC_DEFINE_CUSTOM_GETTER(jsExpectConstructor, (JSGlobalObject * lexicalGlobalObj
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSExpectConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(ExpectPrototype__notGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSExpect* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSC::EncodedJSValue result = ExpectPrototype__getNot(thisObject->wrapped(), thisValue, globalObject);
+ JSC::EncodedJSValue result = ExpectPrototype__getNot(thisObject->wrapped(), thisValue, globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(ExpectPrototype__rejectsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSExpect* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSC::EncodedJSValue result = ExpectPrototype__getRejects(thisObject->wrapped(), thisValue, globalObject);
+ JSC::EncodedJSValue result = ExpectPrototype__getRejects(thisObject->wrapped(), thisValue, globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(ExpectPrototype__resolvesGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSExpect* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSC::EncodedJSValue result = ExpectPrototype__getResolves(thisObject->wrapped(), thisValue, globalObject);
+ JSC::EncodedJSValue result = ExpectPrototype__getResolves(thisObject->wrapped(), thisValue, globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBe(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeCloseToCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBe(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeCloseToCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeCloseTo(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeDefinedCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeCloseTo(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeDefinedCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeDefined(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeFalsyCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeDefined(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeFalsyCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeFalsy(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeFalsy(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeGreaterThan(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanOrEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeGreaterThan(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeGreaterThanOrEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeGreaterThanOrEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeInstanceOfCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeGreaterThanOrEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeInstanceOfCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeInstanceOf(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeLessThanCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeInstanceOf(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeLessThanCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeLessThan(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeLessThanOrEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeLessThan(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeLessThanOrEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeLessThanOrEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNaNCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeLessThanOrEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNaNCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeNaN(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNullCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeNaN(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeNullCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeNull(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeTruthyCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeNull(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeTruthyCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeTruthy(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeUndefinedCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeTruthy(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toBeUndefinedCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toBeUndefined(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toContainCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toBeUndefined(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toContainCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toContain(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toContainEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toContain(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toContainEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toContainEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toContainEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledTimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledTimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveBeenCalledTimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveBeenCalledTimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveBeenCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenLastCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveBeenCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenLastCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveBeenLastCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenNthCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveBeenLastCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveBeenNthCalledWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveBeenNthCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveLastReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveBeenNthCalledWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveLastReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveLastReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveLengthCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveLastReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveLengthCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveLength(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveNthReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveLength(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveNthReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveNthReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHavePropertyCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveNthReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHavePropertyCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveProperty(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedTimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveProperty(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedTimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveReturnedTimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveReturnedTimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toHaveReturnedWithCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toHaveReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toHaveReturnedWith(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toMatch(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchInlineSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toMatch(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchInlineSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toMatchInlineSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchObjectCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toMatchInlineSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchObjectCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toMatchObject(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toMatchObject(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toMatchSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toMatchSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toStrictEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toMatchSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toStrictEqualCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toStrictEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toStrictEqual(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toThrow(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingInlineSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toThrow(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingInlineSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toThrowErrorMatchingInlineSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
+ return ExpectPrototype__toThrowErrorMatchingInlineSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ExpectPrototype__toThrowErrorMatchingSnapshotCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSExpect* thisObject = jsDynamicCast<JSExpect*>(callFrame->thisValue());
- return ExpectPrototype__toThrowErrorMatchingSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ExpectPrototype__toThrowErrorMatchingSnapshot(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
+extern "C" void ExpectPrototype__capturedValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
+ thisObject->m_capturedValue.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ExpectPrototype__capturedValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
- thisObject->m_capturedValue.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ExpectPrototype__capturedValueGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ExpectPrototype__capturedValueGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_capturedValue.get());
- }
-
-
-
-
- extern "C" void ExpectPrototype__resultValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
- thisObject->m_resultValue.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ExpectPrototype__resultValueGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+}
+
+extern "C" void ExpectPrototype__resultValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
+ thisObject->m_resultValue.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue ExpectPrototype__resultValueGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSExpect*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_resultValue.get());
- }
-
-
+}
void JSExpectPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -2327,23 +2470,22 @@ extern "C" JSC_DECLARE_CUSTOM_GETTER(ExpectClass__getStaticResolves);
extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__stringContaining);
extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectClass__stringMatching);
- static const HashTableValue JSExpectConstructorTableValues[] = {
-{ "addSnapshotSerializer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__addSnapshotSerializer, 1 } } ,
-{ "any"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__any, 1 } } ,
-{ "anything"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__anything, 1 } } ,
-{ "arrayContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__arrayContaining, 1 } } ,
-{ "assertions"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__assertions, 1 } } ,
-{ "extend"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__extend, 1 } } ,
-{ "hasAssertions"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__hasAssertions, 1 } } ,
-{ "not"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticNot, 0 } } ,
-{ "objectContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__objectContaining, 1 } } ,
-{ "rejects"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticRejects, 0 } } ,
-{ "resolves"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticResolves, 0 } } ,
-{ "stringContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__stringContaining, 1 } } ,
-{ "stringMatching"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__stringMatching, 1 } }
+static const HashTableValue JSExpectConstructorTableValues[] = {
+ { "addSnapshotSerializer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__addSnapshotSerializer, 1 } },
+ { "any"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__any, 1 } },
+ { "anything"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__anything, 1 } },
+ { "arrayContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__arrayContaining, 1 } },
+ { "assertions"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__assertions, 1 } },
+ { "extend"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__extend, 1 } },
+ { "hasAssertions"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__hasAssertions, 1 } },
+ { "not"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticNot, 0 } },
+ { "objectContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__objectContaining, 1 } },
+ { "rejects"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticRejects, 0 } },
+ { "resolves"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ExpectClass__getStaticResolves, 0 } },
+ { "stringContaining"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__stringContaining, 1 } },
+ { "stringMatching"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ExpectClass__stringMatching, 1 } }
};
-
void JSExpectConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype)
{
Base::finishCreation(vm, 0, "Expect"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -2352,62 +2494,59 @@ void JSExpectConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje
ASSERT(inherits(info()));
}
-JSExpectConstructor::JSExpectConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, ExpectClass__call, construct) {
-
- }
+JSExpectConstructor::JSExpectConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, ExpectClass__call, construct)
+{
+}
-JSExpectConstructor* JSExpectConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSExpectPrototype* prototype) {
+JSExpectConstructor* JSExpectConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSExpectPrototype* prototype)
+{
JSExpectConstructor* ptr = new (NotNull, JSC::allocateCell<JSExpectConstructor>(vm)) JSExpectConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSExpectConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSExpectConstructor();
Structure* structure = globalObject->JSExpectStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSExpectStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSExpectStructure());
}
void* ptr = ExpectClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSExpect* instance = JSExpect::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSExpectConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSExpectPrototype* prototype)
{
-
}
const ClassInfo JSExpectConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSExpectConstructor) };
-
- extern "C" EncodedJSValue Expect__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue Expect__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSExpectConstructor());
- }
+}
JSExpect::~JSExpect()
{
@@ -2419,7 +2558,7 @@ void JSExpect::destroy(JSCell* cell)
{
static_cast<JSExpect*>(cell)->JSExpect::~JSExpect();
}
-
+
const ClassInfo JSExpect::s_info = { "Expect"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSExpect) };
void JSExpect::finishCreation(VM& vm)
@@ -2428,36 +2567,37 @@ void JSExpect::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSExpect* JSExpect::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSExpect* ptr = new (NotNull, JSC::allocateCell<JSExpect>(vm)) JSExpect(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSExpect* JSExpect::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSExpect* ptr = new (NotNull, JSC::allocateCell<JSExpect>(vm)) JSExpect(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Expect__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Expect__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSExpect* object = JSC::jsDynamicCast<JSExpect*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSExpect* object = JSC::jsDynamicCast<JSExpect*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Expect__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSExpect* object = JSC::jsDynamicCast<JSExpect*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Expect__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSExpect* object = JSC::jsDynamicCast<JSExpect*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Expect__ptrOffset = JSExpect::offsetOfWrapped();
@@ -2473,7 +2613,7 @@ void JSExpect::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSExpect::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSExpectConstructor::create(vm, globalObject, WebCore::JSExpectConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSExpectPrototype*>(prototype));
+ return WebCore::JSExpectConstructor::create(vm, globalObject, WebCore::JSExpectConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSExpectPrototype*>(prototype));
}
JSObject* JSExpect::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -2481,12 +2621,13 @@ JSObject* JSExpect::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSExpectPrototype::create(vm, globalObject, JSExpectPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Expect__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSExpectStructure();
- JSExpect* instance = JSExpect::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue Expect__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSExpectStructure();
+ JSExpect* instance = JSExpect::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -2496,10 +2637,7 @@ void JSExpect::visitChildrenImpl(JSCell* cell, Visitor& visitor)
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
visitor.append(thisObject->m_capturedValue);
-visitor.append(thisObject->m_resultValue);
-
-
-
+ visitor.append(thisObject->m_resultValue);
}
DEFINE_VISIT_CHILDREN(JSExpect);
@@ -2507,18 +2645,18 @@ DEFINE_VISIT_CHILDREN(JSExpect);
template<typename Visitor>
void JSExpect::visitAdditionalChildren(Visitor& visitor)
{
- JSExpect* thisObject = this;
+ JSExpect* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
visitor.append(thisObject->m_capturedValue);
-visitor.append(thisObject->m_resultValue);
-
+ visitor.append(thisObject->m_resultValue);
+
;
}
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSExpect);
template<typename Visitor>
-void JSExpect::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSExpect::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSExpect* thisObject = jsCast<JSExpect*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -2526,71 +2664,63 @@ void JSExpect::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSExpect);
- class JSExpectAnyPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSExpectAnyPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSExpectAnyPrototype* ptr = new (NotNull, JSC::allocateCell<JSExpectAnyPrototype>(vm)) JSExpectAnyPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSExpectAnyPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSExpectAnyPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
-extern "C" void ExpectAnyClass__finalize(void*);
-extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectAnyClass__call);
+ static JSExpectAnyPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSExpectAnyPrototype* ptr = new (NotNull, JSC::allocateCell<JSExpectAnyPrototype>(vm)) JSExpectAnyPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
-STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectAnyPrototype, JSExpectAnyPrototype::Base);
+private:
+ JSExpectAnyPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
- static const HashTableValue JSExpectAnyPrototypeTableValues[] = {};
+extern "C" void ExpectAnyClass__finalize(void*);
+extern "C" JSC_DECLARE_HOST_FUNCTION(ExpectAnyClass__call);
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSExpectAnyPrototype, JSExpectAnyPrototype::Base);
+static const HashTableValue JSExpectAnyPrototypeTableValues[] = {};
const ClassInfo JSExpectAnyPrototype::s_info = { "ExpectAny"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSExpectAnyPrototype) };
+extern "C" void ExpectAnyPrototype__constructorValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSExpectAny*>(JSValue::decode(thisValue));
+ thisObject->m_constructorValue.set(vm, thisObject, JSValue::decode(value));
+}
-
- extern "C" void ExpectAnyPrototype__constructorValueSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSExpectAny*>(JSValue::decode(thisValue));
- thisObject->m_constructorValue.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ExpectAnyPrototype__constructorValueGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ExpectAnyPrototype__constructorValueGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSExpectAny*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_constructorValue.get());
- }
-
-
+}
void JSExpectAnyPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
Base::finishCreation(vm);
-
+
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
}
@@ -2604,7 +2734,7 @@ void JSExpectAny::destroy(JSCell* cell)
{
static_cast<JSExpectAny*>(cell)->JSExpectAny::~JSExpectAny();
}
-
+
const ClassInfo JSExpectAny::s_info = { "ExpectAny"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSExpectAny) };
void JSExpectAny::finishCreation(VM& vm)
@@ -2613,36 +2743,37 @@ void JSExpectAny::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSExpectAny* JSExpectAny::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSExpectAny* ptr = new (NotNull, JSC::allocateCell<JSExpectAny>(vm)) JSExpectAny(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSExpectAny* JSExpectAny::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSExpectAny* ptr = new (NotNull, JSC::allocateCell<JSExpectAny>(vm)) JSExpectAny(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* ExpectAny__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* ExpectAny__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSExpectAny* object = JSC::jsDynamicCast<JSExpectAny*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSExpectAny* object = JSC::jsDynamicCast<JSExpectAny*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool ExpectAny__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSExpectAny* object = JSC::jsDynamicCast<JSExpectAny*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool ExpectAny__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSExpectAny* object = JSC::jsDynamicCast<JSExpectAny*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t ExpectAny__ptrOffset = JSExpectAny::offsetOfWrapped();
@@ -2656,19 +2787,18 @@ void JSExpectAny::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
Base::analyzeHeap(cell, analyzer);
}
-
-
JSObject* JSExpectAny::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
{
return JSExpectAnyPrototype::create(vm, globalObject, JSExpectAnyPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue ExpectAny__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSExpectAnyStructure();
- JSExpectAny* instance = JSExpectAny::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue ExpectAny__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSExpectAnyStructure();
+ JSExpectAny* instance = JSExpectAny::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -2678,9 +2808,6 @@ void JSExpectAny::visitChildrenImpl(JSCell* cell, Visitor& visitor)
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
visitor.append(thisObject->m_constructorValue);
-
-
-
}
DEFINE_VISIT_CHILDREN(JSExpectAny);
@@ -2688,17 +2815,17 @@ DEFINE_VISIT_CHILDREN(JSExpectAny);
template<typename Visitor>
void JSExpectAny::visitAdditionalChildren(Visitor& visitor)
{
- JSExpectAny* thisObject = this;
+ JSExpectAny* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
visitor.append(thisObject->m_constructorValue);
-
+
;
}
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSExpectAny);
template<typename Visitor>
-void JSExpectAny::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSExpectAny::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSExpectAny* thisObject = jsCast<JSExpectAny*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -2706,117 +2833,105 @@ void JSExpectAny::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSExpectAny);
- class JSFileSystemRouterPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSFileSystemRouterPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSFileSystemRouterPrototype* ptr = new (NotNull, JSC::allocateCell<JSFileSystemRouterPrototype>(vm)) JSFileSystemRouterPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSFileSystemRouterPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSFileSystemRouterPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSFileSystemRouterPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSFileSystemRouterPrototype* ptr = new (NotNull, JSC::allocateCell<JSFileSystemRouterPrototype>(vm)) JSFileSystemRouterPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSFileSystemRouterPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSFileSystemRouterConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSFileSystemRouterConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSFileSystemRouterPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSFileSystemRouterConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForFileSystemRouterConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForFileSystemRouterConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForFileSystemRouterConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForFileSystemRouterConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSFileSystemRouterPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSFileSystemRouterConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSFileSystemRouterPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSFileSystemRouterConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSFileSystemRouterPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSFileSystemRouterConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForFileSystemRouterConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForFileSystemRouterConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForFileSystemRouterConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForFileSystemRouterConstructor = std::forward<decltype(space)>(space); });
+ }
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSFileSystemRouterPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSFileSystemRouterConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSFileSystemRouterPrototype* prototype);
+};
extern "C" void* FileSystemRouterClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsFileSystemRouterConstructor);
extern "C" void FileSystemRouterClass__finalize(void*);
-
extern "C" EncodedJSValue FileSystemRouterPrototype__match(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(FileSystemRouterPrototype__matchCallback);
-
extern "C" JSC::EncodedJSValue FileSystemRouterPrototype__getOrigin(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(FileSystemRouterPrototype__originGetterWrap);
-
extern "C" EncodedJSValue FileSystemRouterPrototype__reload(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(FileSystemRouterPrototype__reloadCallback);
-
extern "C" JSC::EncodedJSValue FileSystemRouterPrototype__getRoutes(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(FileSystemRouterPrototype__routesGetterWrap);
-
extern "C" JSC::EncodedJSValue FileSystemRouterPrototype__getStyle(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(FileSystemRouterPrototype__styleGetterWrap);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSFileSystemRouterPrototype, JSFileSystemRouterPrototype::Base);
-
- static const HashTableValue JSFileSystemRouterPrototypeTableValues[] = {
-{ "match"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSystemRouterPrototype__matchCallback, 1 } } ,
-{ "origin"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, FileSystemRouterPrototype__originGetterWrap, 0 } } ,
-{ "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSystemRouterPrototype__reloadCallback, 0 } } ,
-{ "routes"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, FileSystemRouterPrototype__routesGetterWrap, 0 } } ,
-{ "style"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, FileSystemRouterPrototype__styleGetterWrap, 0 } }
+static const HashTableValue JSFileSystemRouterPrototypeTableValues[] = {
+ { "match"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSystemRouterPrototype__matchCallback, 1 } },
+ { "origin"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, FileSystemRouterPrototype__originGetterWrap, 0 } },
+ { "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSystemRouterPrototype__reloadCallback, 0 } },
+ { "routes"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, FileSystemRouterPrototype__routesGetterWrap, 0 } },
+ { "style"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, FileSystemRouterPrototype__styleGetterWrap, 0 } }
};
-
-
const ClassInfo JSFileSystemRouterPrototype::s_info = { "FileSystemRouter"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemRouterPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsFileSystemRouterConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -2827,148 +2942,132 @@ JSC_DEFINE_CUSTOM_GETTER(jsFileSystemRouterConstructor, (JSGlobalObject * lexica
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSFileSystemRouterConstructor());
-}
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(FileSystemRouterPrototype__matchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(FileSystemRouterPrototype__matchCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSFileSystemRouter* thisObject = jsDynamicCast<JSFileSystemRouter*>(callFrame->thisValue());
+ JSFileSystemRouter* thisObject = jsDynamicCast<JSFileSystemRouter*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return FileSystemRouterPrototype__match(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return FileSystemRouterPrototype__match(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(FileSystemRouterPrototype__originGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSFileSystemRouter* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_origin.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- FileSystemRouterPrototype__getOrigin(thisObject->wrapped(), globalObject)
- );
+ FileSystemRouterPrototype__getOrigin(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_origin.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void FileSystemRouterPrototype__originSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
+ thisObject->m_origin.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void FileSystemRouterPrototype__originSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
- thisObject->m_origin.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue FileSystemRouterPrototype__originGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue FileSystemRouterPrototype__originGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_origin.get());
- }
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(FileSystemRouterPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(FileSystemRouterPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSFileSystemRouter* thisObject = jsDynamicCast<JSFileSystemRouter*>(callFrame->thisValue());
+ JSFileSystemRouter* thisObject = jsDynamicCast<JSFileSystemRouter*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return FileSystemRouterPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return FileSystemRouterPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(FileSystemRouterPrototype__routesGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSFileSystemRouter* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_routes.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- FileSystemRouterPrototype__getRoutes(thisObject->wrapped(), globalObject)
- );
+ FileSystemRouterPrototype__getRoutes(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_routes.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void FileSystemRouterPrototype__routesSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
+ thisObject->m_routes.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void FileSystemRouterPrototype__routesSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
- thisObject->m_routes.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue FileSystemRouterPrototype__routesGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue FileSystemRouterPrototype__routesGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_routes.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(FileSystemRouterPrototype__styleGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSFileSystemRouter* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_style.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- FileSystemRouterPrototype__getStyle(thisObject->wrapped(), globalObject)
- );
+ FileSystemRouterPrototype__getStyle(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_style.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void FileSystemRouterPrototype__styleSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
+ thisObject->m_style.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void FileSystemRouterPrototype__styleSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
- thisObject->m_style.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue FileSystemRouterPrototype__styleGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue FileSystemRouterPrototype__styleGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSFileSystemRouter*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_style.get());
- }
-
-
+}
void JSFileSystemRouterPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -2980,67 +3079,64 @@ void JSFileSystemRouterPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObjec
void JSFileSystemRouterConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSFileSystemRouterPrototype* prototype)
{
Base::finishCreation(vm, 0, "FileSystemRouter"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSFileSystemRouterConstructor::JSFileSystemRouterConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSFileSystemRouterConstructor::JSFileSystemRouterConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSFileSystemRouterConstructor* JSFileSystemRouterConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSFileSystemRouterPrototype* prototype) {
+JSFileSystemRouterConstructor* JSFileSystemRouterConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSFileSystemRouterPrototype* prototype)
+{
JSFileSystemRouterConstructor* ptr = new (NotNull, JSC::allocateCell<JSFileSystemRouterConstructor>(vm)) JSFileSystemRouterConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSFileSystemRouterConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSFileSystemRouterConstructor();
Structure* structure = globalObject->JSFileSystemRouterStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSFileSystemRouterStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSFileSystemRouterStructure());
}
void* ptr = FileSystemRouterClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSFileSystemRouter* instance = JSFileSystemRouter::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSFileSystemRouterConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSFileSystemRouterPrototype* prototype)
{
-
}
const ClassInfo JSFileSystemRouterConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemRouterConstructor) };
-
- extern "C" EncodedJSValue FileSystemRouter__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue FileSystemRouter__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSFileSystemRouterConstructor());
- }
+}
JSFileSystemRouter::~JSFileSystemRouter()
{
@@ -3052,7 +3148,7 @@ void JSFileSystemRouter::destroy(JSCell* cell)
{
static_cast<JSFileSystemRouter*>(cell)->JSFileSystemRouter::~JSFileSystemRouter();
}
-
+
const ClassInfo JSFileSystemRouter::s_info = { "FileSystemRouter"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemRouter) };
void JSFileSystemRouter::finishCreation(VM& vm)
@@ -3061,36 +3157,37 @@ void JSFileSystemRouter::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSFileSystemRouter* JSFileSystemRouter::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSFileSystemRouter* ptr = new (NotNull, JSC::allocateCell<JSFileSystemRouter>(vm)) JSFileSystemRouter(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSFileSystemRouter* JSFileSystemRouter::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSFileSystemRouter* ptr = new (NotNull, JSC::allocateCell<JSFileSystemRouter>(vm)) JSFileSystemRouter(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* FileSystemRouter__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* FileSystemRouter__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSFileSystemRouter* object = JSC::jsDynamicCast<JSFileSystemRouter*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSFileSystemRouter* object = JSC::jsDynamicCast<JSFileSystemRouter*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool FileSystemRouter__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSFileSystemRouter* object = JSC::jsDynamicCast<JSFileSystemRouter*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool FileSystemRouter__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSFileSystemRouter* object = JSC::jsDynamicCast<JSFileSystemRouter*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t FileSystemRouter__ptrOffset = JSFileSystemRouter::offsetOfWrapped();
@@ -3106,7 +3203,7 @@ void JSFileSystemRouter::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSFileSystemRouter::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSFileSystemRouterConstructor::create(vm, globalObject, WebCore::JSFileSystemRouterConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSFileSystemRouterPrototype*>(prototype));
+ return WebCore::JSFileSystemRouterConstructor::create(vm, globalObject, WebCore::JSFileSystemRouterConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSFileSystemRouterPrototype*>(prototype));
}
JSObject* JSFileSystemRouter::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -3114,12 +3211,13 @@ JSObject* JSFileSystemRouter::createPrototype(VM& vm, JSDOMGlobalObject* globalO
return JSFileSystemRouterPrototype::create(vm, globalObject, JSFileSystemRouterPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue FileSystemRouter__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSFileSystemRouterStructure();
- JSFileSystemRouter* instance = JSFileSystemRouter::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue FileSystemRouter__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSFileSystemRouterStructure();
+ JSFileSystemRouter* instance = JSFileSystemRouter::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -3128,12 +3226,10 @@ void JSFileSystemRouter::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSFileSystemRouter* thisObject = jsCast<JSFileSystemRouter*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_origin);
visitor.append(thisObject->m_routes);
visitor.append(thisObject->m_style);
-
}
DEFINE_VISIT_CHILDREN(JSFileSystemRouter);
@@ -3141,10 +3237,10 @@ DEFINE_VISIT_CHILDREN(JSFileSystemRouter);
template<typename Visitor>
void JSFileSystemRouter::visitAdditionalChildren(Visitor& visitor)
{
- JSFileSystemRouter* thisObject = this;
+ JSFileSystemRouter* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_origin);
+
+ visitor.append(thisObject->m_origin);
visitor.append(thisObject->m_routes);
visitor.append(thisObject->m_style);
;
@@ -3153,7 +3249,7 @@ void JSFileSystemRouter::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSFileSystemRouter);
template<typename Visitor>
-void JSFileSystemRouter::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSFileSystemRouter::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSFileSystemRouter* thisObject = jsCast<JSFileSystemRouter*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -3161,98 +3257,83 @@ void JSFileSystemRouter::visitOutputConstraintsImpl(JSCell *cell, Visitor& visit
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSFileSystemRouter);
- class JSListenerPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSListenerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSListenerPrototype* ptr = new (NotNull, JSC::allocateCell<JSListenerPrototype>(vm)) JSListenerPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSListenerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSListenerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSListenerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSListenerPrototype* ptr = new (NotNull, JSC::allocateCell<JSListenerPrototype>(vm)) JSListenerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSListenerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
extern "C" void* ListenerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsListenerConstructor);
extern "C" void ListenerClass__finalize(void*);
-
extern "C" JSC::EncodedJSValue ListenerPrototype__getData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ListenerPrototype__dataGetterWrap);
-
extern "C" bool ListenerPrototype__setData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::EncodedJSValue value);
JSC_DECLARE_CUSTOM_SETTER(ListenerPrototype__dataSetterWrap);
-
extern "C" JSC::EncodedJSValue ListenerPrototype__getHostname(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ListenerPrototype__hostnameGetterWrap);
-
extern "C" JSC::EncodedJSValue ListenerPrototype__getPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ListenerPrototype__portGetterWrap);
-
extern "C" EncodedJSValue ListenerPrototype__ref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ListenerPrototype__refCallback);
-
extern "C" EncodedJSValue ListenerPrototype__reload(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ListenerPrototype__reloadCallback);
-
extern "C" EncodedJSValue ListenerPrototype__stop(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ListenerPrototype__stopCallback);
-
extern "C" JSC::EncodedJSValue ListenerPrototype__getUnix(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ListenerPrototype__unixGetterWrap);
-
extern "C" EncodedJSValue ListenerPrototype__unref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ListenerPrototype__unrefCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSListenerPrototype, JSListenerPrototype::Base);
-
- static const HashTableValue JSListenerPrototypeTableValues[] = {
-{ "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ListenerPrototype__dataGetterWrap, ListenerPrototype__dataSetterWrap } } ,
-{ "hostname"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ListenerPrototype__hostnameGetterWrap, 0 } } ,
-{ "port"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ListenerPrototype__portGetterWrap, 0 } } ,
-{ "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ListenerPrototype__refCallback, 0 } } ,
-{ "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ListenerPrototype__reloadCallback, 1 } } ,
-{ "stop"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ListenerPrototype__stopCallback, 1 } } ,
-{ "unix"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ListenerPrototype__unixGetterWrap, 0 } } ,
-{ "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ListenerPrototype__unrefCallback, 0 } }
+static const HashTableValue JSListenerPrototypeTableValues[] = {
+ { "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ListenerPrototype__dataGetterWrap, ListenerPrototype__dataSetterWrap } },
+ { "hostname"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ListenerPrototype__hostnameGetterWrap, 0 } },
+ { "port"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ListenerPrototype__portGetterWrap, 0 } },
+ { "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ListenerPrototype__refCallback, 0 } },
+ { "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ListenerPrototype__reloadCallback, 1 } },
+ { "stop"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ListenerPrototype__stopCallback, 1 } },
+ { "unix"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ListenerPrototype__unixGetterWrap, 0 } },
+ { "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ListenerPrototype__unrefCallback, 0 } }
};
-
-
const ClassInfo JSListenerPrototype::s_info = { "Listener"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSListenerPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsListenerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -3263,14 +3344,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsListenerConstructor, (JSGlobalObject * lexicalGlobalO
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSListenerConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__dataGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSListener* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3278,7 +3357,6 @@ JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__dataGetterWrap, (JSGlobalObject * le
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_SETTER(ListenerPrototype__dataSetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName))
{
@@ -3291,46 +3369,41 @@ JSC_DEFINE_CUSTOM_SETTER(ListenerPrototype__dataSetterWrap, (JSGlobalObject * le
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__hostnameGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSListener* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_hostname.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- ListenerPrototype__getHostname(thisObject->wrapped(), globalObject)
- );
+ ListenerPrototype__getHostname(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_hostname.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void ListenerPrototype__hostnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
+ thisObject->m_hostname.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ListenerPrototype__hostnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
- thisObject->m_hostname.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ListenerPrototype__hostnameGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ListenerPrototype__hostnameGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_hostname.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__portGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSListener* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3338,110 +3411,101 @@ JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__portGetterWrap, (JSGlobalObject * le
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue());
- return ListenerPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue());
+ return ListenerPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue());
- return ListenerPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__stopCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue());
+ return ListenerPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__stopCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue());
- return ListenerPrototype__stop(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ListenerPrototype__stop(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(ListenerPrototype__unixGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSListener* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_unix.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- ListenerPrototype__getUnix(thisObject->wrapped(), globalObject)
- );
+ ListenerPrototype__getUnix(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_unix.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void ListenerPrototype__unixSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
+ thisObject->m_unix.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ListenerPrototype__unixSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
- thisObject->m_unix.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ListenerPrototype__unixGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ListenerPrototype__unixGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSListener*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_unix.get());
- }
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(ListenerPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue());
+ JSListener* thisObject = jsDynamicCast<JSListener*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return ListenerPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return ListenerPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSListenerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -3460,7 +3524,7 @@ void JSListener::destroy(JSCell* cell)
{
static_cast<JSListener*>(cell)->JSListener::~JSListener();
}
-
+
const ClassInfo JSListener::s_info = { "Listener"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSListener) };
void JSListener::finishCreation(VM& vm)
@@ -3469,36 +3533,37 @@ void JSListener::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSListener* JSListener::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSListener* ptr = new (NotNull, JSC::allocateCell<JSListener>(vm)) JSListener(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSListener* JSListener::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSListener* ptr = new (NotNull, JSC::allocateCell<JSListener>(vm)) JSListener(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Listener__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Listener__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSListener* object = JSC::jsDynamicCast<JSListener*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSListener* object = JSC::jsDynamicCast<JSListener*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Listener__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSListener* object = JSC::jsDynamicCast<JSListener*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Listener__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSListener* object = JSC::jsDynamicCast<JSListener*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Listener__ptrOffset = JSListener::offsetOfWrapped();
@@ -3512,19 +3577,18 @@ void JSListener::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
Base::analyzeHeap(cell, analyzer);
}
-
-
JSObject* JSListener::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
{
return JSListenerPrototype::create(vm, globalObject, JSListenerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Listener__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSListenerStructure();
- JSListener* instance = JSListener::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue Listener__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSListenerStructure();
+ JSListener* instance = JSListener::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -3533,11 +3597,9 @@ void JSListener::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSListener* thisObject = jsCast<JSListener*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_hostname);
visitor.append(thisObject->m_unix);
-
}
DEFINE_VISIT_CHILDREN(JSListener);
@@ -3545,10 +3607,10 @@ DEFINE_VISIT_CHILDREN(JSListener);
template<typename Visitor>
void JSListener::visitAdditionalChildren(Visitor& visitor)
{
- JSListener* thisObject = this;
+ JSListener* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_hostname);
+
+ visitor.append(thisObject->m_hostname);
visitor.append(thisObject->m_unix);
;
}
@@ -3556,7 +3618,7 @@ void JSListener::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSListener);
template<typename Visitor>
-void JSListener::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSListener::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSListener* thisObject = jsCast<JSListener*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -3564,107 +3626,97 @@ void JSListener::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSListener);
- class JSMD4Prototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSMD4Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSMD4Prototype* ptr = new (NotNull, JSC::allocateCell<JSMD4Prototype>(vm)) JSMD4Prototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSMD4Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSMD4Prototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSMD4Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSMD4Prototype* ptr = new (NotNull, JSC::allocateCell<JSMD4Prototype>(vm)) JSMD4Prototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSMD4Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSMD4Constructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSMD4Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD4Prototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSMD4Constructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForMD4Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD4Constructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForMD4Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForMD4Constructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSMD4Constructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSMD4Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD4Prototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSMD4Constructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForMD4Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD4Constructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForMD4Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForMD4Constructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSMD4Constructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype);
+};
extern "C" void* MD4Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsMD4Constructor);
extern "C" void MD4Class__finalize(void*);
-
extern "C" JSC::EncodedJSValue MD4Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MD4Prototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue MD4Prototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(MD4Prototype__digestCallback);
-
extern "C" EncodedJSValue MD4Prototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(MD4Prototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMD4Prototype, JSMD4Prototype::Base);
-
- static const HashTableValue JSMD4PrototypeTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MD4Prototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD4Prototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD4Prototype__updateCallback, 1 } }
+static const HashTableValue JSMD4PrototypeTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MD4Prototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD4Prototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD4Prototype__updateCallback, 1 } }
};
-
-
const ClassInfo JSMD4Prototype::s_info = { "MD4"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMD4Prototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsMD4Constructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -3675,14 +3727,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsMD4Constructor, (JSGlobalObject * lexicalGlobalObject
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSMD4Constructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MD4Prototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMD4* thisObject = jsCast<JSMD4*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -3690,41 +3740,38 @@ JSC_DEFINE_CUSTOM_GETTER(MD4Prototype__byteLengthGetterWrap, (JSGlobalObject * l
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(MD4Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSMD4* thisObject = jsDynamicCast<JSMD4*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(MD4Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSMD4* thisObject = jsDynamicCast<JSMD4*>(callFrame->thisValue());
- return MD4Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(MD4Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSMD4* thisObject = jsDynamicCast<JSMD4*>(callFrame->thisValue());
+ return MD4Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(MD4Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSMD4* thisObject = jsDynamicCast<JSMD4*>(callFrame->thisValue());
- return MD4Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return MD4Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSMD4Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -3736,12 +3783,11 @@ void JSMD4Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObje
extern "C" JSC_DECLARE_CUSTOM_GETTER(MD4Class__getByteLengthStatic);
extern "C" JSC_DECLARE_HOST_FUNCTION(MD4Class__hash);
- static const HashTableValue JSMD4ConstructorTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MD4Class__getByteLengthStatic, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD4Class__hash, 2 } }
+static const HashTableValue JSMD4ConstructorTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MD4Class__getByteLengthStatic, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD4Class__hash, 2 } }
};
-
void JSMD4Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype)
{
Base::finishCreation(vm, 0, "MD4"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -3750,62 +3796,59 @@ void JSMD4Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject,
ASSERT(inherits(info()));
}
-JSMD4Constructor::JSMD4Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSMD4Constructor::JSMD4Constructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSMD4Constructor* JSMD4Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD4Prototype* prototype) {
+JSMD4Constructor* JSMD4Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD4Prototype* prototype)
+{
JSMD4Constructor* ptr = new (NotNull, JSC::allocateCell<JSMD4Constructor>(vm)) JSMD4Constructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSMD4Constructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSMD4Constructor();
Structure* structure = globalObject->JSMD4Structure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSMD4Structure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSMD4Structure());
}
void* ptr = MD4Class__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSMD4* instance = JSMD4::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSMD4Constructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSMD4Prototype* prototype)
{
-
}
const ClassInfo JSMD4Constructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMD4Constructor) };
-
- extern "C" EncodedJSValue MD4__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue MD4__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSMD4Constructor());
- }
+}
JSMD4::~JSMD4()
{
@@ -3817,7 +3860,7 @@ void JSMD4::destroy(JSCell* cell)
{
static_cast<JSMD4*>(cell)->JSMD4::~JSMD4();
}
-
+
const ClassInfo JSMD4::s_info = { "MD4"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMD4) };
void JSMD4::finishCreation(VM& vm)
@@ -3826,36 +3869,37 @@ void JSMD4::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSMD4* JSMD4::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSMD4* ptr = new (NotNull, JSC::allocateCell<JSMD4>(vm)) JSMD4(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSMD4* JSMD4::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSMD4* ptr = new (NotNull, JSC::allocateCell<JSMD4>(vm)) JSMD4(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* MD4__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* MD4__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSMD4* object = JSC::jsDynamicCast<JSMD4*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSMD4* object = JSC::jsDynamicCast<JSMD4*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool MD4__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSMD4* object = JSC::jsDynamicCast<JSMD4*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool MD4__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSMD4* object = JSC::jsDynamicCast<JSMD4*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t MD4__ptrOffset = JSMD4::offsetOfWrapped();
@@ -3871,7 +3915,7 @@ void JSMD4::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSMD4::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSMD4Constructor::create(vm, globalObject, WebCore::JSMD4Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSMD4Prototype*>(prototype));
+ return WebCore::JSMD4Constructor::create(vm, globalObject, WebCore::JSMD4Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSMD4Prototype*>(prototype));
}
JSObject* JSMD4::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -3879,114 +3923,105 @@ JSObject* JSMD4::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSMD4Prototype::create(vm, globalObject, JSMD4Prototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue MD4__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSMD4Structure();
- JSMD4* instance = JSMD4::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSMD5Prototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSMD5Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSMD5Prototype* ptr = new (NotNull, JSC::allocateCell<JSMD5Prototype>(vm)) JSMD5Prototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSMD5Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue MD4__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSMD4Structure();
+ JSMD4* instance = JSMD4::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSMD5Prototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSMD5Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSMD5Prototype* ptr = new (NotNull, JSC::allocateCell<JSMD5Prototype>(vm)) JSMD5Prototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSMD5Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSMD5Constructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSMD5Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD5Prototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSMD5Constructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForMD5Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD5Constructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForMD5Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForMD5Constructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSMD5Constructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSMD5Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD5Prototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSMD5Constructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForMD5Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD5Constructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForMD5Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForMD5Constructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSMD5Constructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype);
+};
extern "C" void* MD5Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsMD5Constructor);
extern "C" void MD5Class__finalize(void*);
-
extern "C" JSC::EncodedJSValue MD5Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MD5Prototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue MD5Prototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(MD5Prototype__digestCallback);
-
extern "C" EncodedJSValue MD5Prototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(MD5Prototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMD5Prototype, JSMD5Prototype::Base);
-
- static const HashTableValue JSMD5PrototypeTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MD5Prototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD5Prototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD5Prototype__updateCallback, 1 } }
+static const HashTableValue JSMD5PrototypeTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MD5Prototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD5Prototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD5Prototype__updateCallback, 1 } }
};
-
-
const ClassInfo JSMD5Prototype::s_info = { "MD5"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMD5Prototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsMD5Constructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -3997,14 +4032,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsMD5Constructor, (JSGlobalObject * lexicalGlobalObject
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSMD5Constructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MD5Prototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMD5* thisObject = jsCast<JSMD5*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -4012,41 +4045,38 @@ JSC_DEFINE_CUSTOM_GETTER(MD5Prototype__byteLengthGetterWrap, (JSGlobalObject * l
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(MD5Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
- JSMD5* thisObject = jsDynamicCast<JSMD5*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(MD5Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSMD5* thisObject = jsDynamicCast<JSMD5*>(callFrame->thisValue());
- return MD5Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(MD5Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSMD5* thisObject = jsDynamicCast<JSMD5*>(callFrame->thisValue());
+ return MD5Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(MD5Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSMD5* thisObject = jsDynamicCast<JSMD5*>(callFrame->thisValue());
- return MD5Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return MD5Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSMD5Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -4058,12 +4088,11 @@ void JSMD5Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObje
extern "C" JSC_DECLARE_CUSTOM_GETTER(MD5Class__getByteLengthStatic);
extern "C" JSC_DECLARE_HOST_FUNCTION(MD5Class__hash);
- static const HashTableValue JSMD5ConstructorTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MD5Class__getByteLengthStatic, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD5Class__hash, 2 } }
+static const HashTableValue JSMD5ConstructorTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MD5Class__getByteLengthStatic, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, MD5Class__hash, 2 } }
};
-
void JSMD5Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype)
{
Base::finishCreation(vm, 0, "MD5"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -4072,62 +4101,59 @@ void JSMD5Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject,
ASSERT(inherits(info()));
}
-JSMD5Constructor::JSMD5Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSMD5Constructor::JSMD5Constructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSMD5Constructor* JSMD5Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD5Prototype* prototype) {
+JSMD5Constructor* JSMD5Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSMD5Prototype* prototype)
+{
JSMD5Constructor* ptr = new (NotNull, JSC::allocateCell<JSMD5Constructor>(vm)) JSMD5Constructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSMD5Constructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSMD5Constructor();
Structure* structure = globalObject->JSMD5Structure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSMD5Structure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSMD5Structure());
}
void* ptr = MD5Class__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSMD5* instance = JSMD5::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSMD5Constructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSMD5Prototype* prototype)
{
-
}
const ClassInfo JSMD5Constructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMD5Constructor) };
-
- extern "C" EncodedJSValue MD5__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue MD5__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSMD5Constructor());
- }
+}
JSMD5::~JSMD5()
{
@@ -4139,7 +4165,7 @@ void JSMD5::destroy(JSCell* cell)
{
static_cast<JSMD5*>(cell)->JSMD5::~JSMD5();
}
-
+
const ClassInfo JSMD5::s_info = { "MD5"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMD5) };
void JSMD5::finishCreation(VM& vm)
@@ -4148,36 +4174,37 @@ void JSMD5::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSMD5* JSMD5::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSMD5* ptr = new (NotNull, JSC::allocateCell<JSMD5>(vm)) JSMD5(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSMD5* JSMD5::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSMD5* ptr = new (NotNull, JSC::allocateCell<JSMD5>(vm)) JSMD5(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* MD5__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* MD5__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSMD5* object = JSC::jsDynamicCast<JSMD5*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSMD5* object = JSC::jsDynamicCast<JSMD5*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool MD5__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSMD5* object = JSC::jsDynamicCast<JSMD5*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool MD5__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSMD5* object = JSC::jsDynamicCast<JSMD5*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t MD5__ptrOffset = JSMD5::offsetOfWrapped();
@@ -4193,7 +4220,7 @@ void JSMD5::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSMD5::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSMD5Constructor::create(vm, globalObject, WebCore::JSMD5Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSMD5Prototype*>(prototype));
+ return WebCore::JSMD5Constructor::create(vm, globalObject, WebCore::JSMD5Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSMD5Prototype*>(prototype));
}
JSObject* JSMD5::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -4201,101 +4228,88 @@ JSObject* JSMD5::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSMD5Prototype::create(vm, globalObject, JSMD5Prototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue MD5__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSMD5Structure();
- JSMD5* instance = JSMD5::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSMatchedRoutePrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSMatchedRoutePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSMatchedRoutePrototype* ptr = new (NotNull, JSC::allocateCell<JSMatchedRoutePrototype>(vm)) JSMatchedRoutePrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSMatchedRoutePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue MD5__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSMD5Structure();
+ JSMD5* instance = JSMD5::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSMatchedRoutePrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSMatchedRoutePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSMatchedRoutePrototype* ptr = new (NotNull, JSC::allocateCell<JSMatchedRoutePrototype>(vm)) JSMatchedRoutePrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSMatchedRoutePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
extern "C" void* MatchedRouteClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsMatchedRouteConstructor);
extern "C" void MatchedRouteClass__finalize(void*);
-
extern "C" JSC::EncodedJSValue MatchedRoutePrototype__getFilePath(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MatchedRoutePrototype__filePathGetterWrap);
-
extern "C" JSC::EncodedJSValue MatchedRoutePrototype__getKind(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MatchedRoutePrototype__kindGetterWrap);
-
extern "C" JSC::EncodedJSValue MatchedRoutePrototype__getName(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MatchedRoutePrototype__nameGetterWrap);
-
extern "C" JSC::EncodedJSValue MatchedRoutePrototype__getParams(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MatchedRoutePrototype__paramsGetterWrap);
-
extern "C" JSC::EncodedJSValue MatchedRoutePrototype__getPathname(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MatchedRoutePrototype__pathnameGetterWrap);
-
extern "C" JSC::EncodedJSValue MatchedRoutePrototype__getQuery(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MatchedRoutePrototype__queryGetterWrap);
-
extern "C" JSC::EncodedJSValue MatchedRoutePrototype__getScriptSrc(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MatchedRoutePrototype__scriptSrcGetterWrap);
-
extern "C" JSC::EncodedJSValue MatchedRoutePrototype__getScriptSrc(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(MatchedRoutePrototype__srcGetterWrap);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSMatchedRoutePrototype, JSMatchedRoutePrototype::Base);
-
- static const HashTableValue JSMatchedRoutePrototypeTableValues[] = {
-{ "filePath"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__filePathGetterWrap, 0 } } ,
-{ "kind"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__kindGetterWrap, 0 } } ,
-{ "name"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__nameGetterWrap, 0 } } ,
-{ "params"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__paramsGetterWrap, 0 } } ,
-{ "pathname"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__pathnameGetterWrap, 0 } } ,
-{ "query"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__queryGetterWrap, 0 } } ,
-{ "scriptSrc"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__scriptSrcGetterWrap, 0 } } ,
-{ "src"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__srcGetterWrap, 0 } }
+static const HashTableValue JSMatchedRoutePrototypeTableValues[] = {
+ { "filePath"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__filePathGetterWrap, 0 } },
+ { "kind"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__kindGetterWrap, 0 } },
+ { "name"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__nameGetterWrap, 0 } },
+ { "params"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__paramsGetterWrap, 0 } },
+ { "pathname"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__pathnameGetterWrap, 0 } },
+ { "query"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__queryGetterWrap, 0 } },
+ { "scriptSrc"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__scriptSrcGetterWrap, 0 } },
+ { "src"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, MatchedRoutePrototype__srcGetterWrap, 0 } }
};
-
-
const ClassInfo JSMatchedRoutePrototype::s_info = { "MatchedRoute"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMatchedRoutePrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsMatchedRouteConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -4306,289 +4320,255 @@ JSC_DEFINE_CUSTOM_GETTER(jsMatchedRouteConstructor, (JSGlobalObject * lexicalGlo
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSMatchedRouteConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MatchedRoutePrototype__filePathGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_filePath.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- MatchedRoutePrototype__getFilePath(thisObject->wrapped(), globalObject)
- );
+ MatchedRoutePrototype__getFilePath(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_filePath.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void MatchedRoutePrototype__filePathSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
+ thisObject->m_filePath.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void MatchedRoutePrototype__filePathSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- thisObject->m_filePath.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue MatchedRoutePrototype__filePathGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue MatchedRoutePrototype__filePathGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_filePath.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MatchedRoutePrototype__kindGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_kind.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- MatchedRoutePrototype__getKind(thisObject->wrapped(), globalObject)
- );
+ MatchedRoutePrototype__getKind(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_kind.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void MatchedRoutePrototype__kindSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
+ thisObject->m_kind.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void MatchedRoutePrototype__kindSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- thisObject->m_kind.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue MatchedRoutePrototype__kindGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue MatchedRoutePrototype__kindGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_kind.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MatchedRoutePrototype__nameGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_name.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- MatchedRoutePrototype__getName(thisObject->wrapped(), globalObject)
- );
+ MatchedRoutePrototype__getName(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_name.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void MatchedRoutePrototype__nameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
+ thisObject->m_name.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void MatchedRoutePrototype__nameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- thisObject->m_name.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue MatchedRoutePrototype__nameGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue MatchedRoutePrototype__nameGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_name.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MatchedRoutePrototype__paramsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_params.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- MatchedRoutePrototype__getParams(thisObject->wrapped(), globalObject)
- );
+ MatchedRoutePrototype__getParams(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_params.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void MatchedRoutePrototype__paramsSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
+ thisObject->m_params.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void MatchedRoutePrototype__paramsSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- thisObject->m_params.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue MatchedRoutePrototype__paramsGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue MatchedRoutePrototype__paramsGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_params.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MatchedRoutePrototype__pathnameGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_pathname.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- MatchedRoutePrototype__getPathname(thisObject->wrapped(), globalObject)
- );
+ MatchedRoutePrototype__getPathname(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_pathname.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void MatchedRoutePrototype__pathnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
+ thisObject->m_pathname.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void MatchedRoutePrototype__pathnameSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- thisObject->m_pathname.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue MatchedRoutePrototype__pathnameGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue MatchedRoutePrototype__pathnameGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_pathname.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MatchedRoutePrototype__queryGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_query.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- MatchedRoutePrototype__getQuery(thisObject->wrapped(), globalObject)
- );
+ MatchedRoutePrototype__getQuery(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_query.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void MatchedRoutePrototype__querySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
+ thisObject->m_query.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void MatchedRoutePrototype__querySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- thisObject->m_query.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue MatchedRoutePrototype__queryGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue MatchedRoutePrototype__queryGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_query.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MatchedRoutePrototype__scriptSrcGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_scriptSrc.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- MatchedRoutePrototype__getScriptSrc(thisObject->wrapped(), globalObject)
- );
+ MatchedRoutePrototype__getScriptSrc(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_scriptSrc.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void MatchedRoutePrototype__scriptSrcSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
+ thisObject->m_scriptSrc.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void MatchedRoutePrototype__scriptSrcSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- thisObject->m_scriptSrc.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue MatchedRoutePrototype__scriptSrcGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue MatchedRoutePrototype__scriptSrcGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_scriptSrc.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(MatchedRoutePrototype__srcGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_scriptSrc.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- MatchedRoutePrototype__getScriptSrc(thisObject->wrapped(), globalObject)
- );
+ MatchedRoutePrototype__getScriptSrc(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_scriptSrc.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void MatchedRoutePrototype__srcSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
+ thisObject->m_scriptSrc.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void MatchedRoutePrototype__srcSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
- thisObject->m_scriptSrc.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue MatchedRoutePrototype__srcGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue MatchedRoutePrototype__srcGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSMatchedRoute*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_scriptSrc.get());
- }
-
-
+}
void JSMatchedRoutePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -4607,7 +4587,7 @@ void JSMatchedRoute::destroy(JSCell* cell)
{
static_cast<JSMatchedRoute*>(cell)->JSMatchedRoute::~JSMatchedRoute();
}
-
+
const ClassInfo JSMatchedRoute::s_info = { "MatchedRoute"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMatchedRoute) };
void JSMatchedRoute::finishCreation(VM& vm)
@@ -4616,36 +4596,37 @@ void JSMatchedRoute::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSMatchedRoute* JSMatchedRoute::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSMatchedRoute* ptr = new (NotNull, JSC::allocateCell<JSMatchedRoute>(vm)) JSMatchedRoute(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSMatchedRoute* JSMatchedRoute::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSMatchedRoute* ptr = new (NotNull, JSC::allocateCell<JSMatchedRoute>(vm)) JSMatchedRoute(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* MatchedRoute__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* MatchedRoute__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSMatchedRoute* object = JSC::jsDynamicCast<JSMatchedRoute*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSMatchedRoute* object = JSC::jsDynamicCast<JSMatchedRoute*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool MatchedRoute__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSMatchedRoute* object = JSC::jsDynamicCast<JSMatchedRoute*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool MatchedRoute__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSMatchedRoute* object = JSC::jsDynamicCast<JSMatchedRoute*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t MatchedRoute__ptrOffset = JSMatchedRoute::offsetOfWrapped();
@@ -4659,19 +4640,18 @@ void JSMatchedRoute::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
Base::analyzeHeap(cell, analyzer);
}
-
-
JSObject* JSMatchedRoute::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
{
return JSMatchedRoutePrototype::create(vm, globalObject, JSMatchedRoutePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue MatchedRoute__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSMatchedRouteStructure();
- JSMatchedRoute* instance = JSMatchedRoute::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue MatchedRoute__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSMatchedRouteStructure();
+ JSMatchedRoute* instance = JSMatchedRoute::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -4680,8 +4660,7 @@ void JSMatchedRoute::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_filePath);
visitor.append(thisObject->m_kind);
visitor.append(thisObject->m_name);
@@ -4689,7 +4668,6 @@ void JSMatchedRoute::visitChildrenImpl(JSCell* cell, Visitor& visitor)
visitor.append(thisObject->m_pathname);
visitor.append(thisObject->m_query);
visitor.append(thisObject->m_scriptSrc);
-
}
DEFINE_VISIT_CHILDREN(JSMatchedRoute);
@@ -4697,10 +4675,10 @@ DEFINE_VISIT_CHILDREN(JSMatchedRoute);
template<typename Visitor>
void JSMatchedRoute::visitAdditionalChildren(Visitor& visitor)
{
- JSMatchedRoute* thisObject = this;
+ JSMatchedRoute* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_filePath);
+
+ visitor.append(thisObject->m_filePath);
visitor.append(thisObject->m_kind);
visitor.append(thisObject->m_name);
visitor.append(thisObject->m_params);
@@ -4713,7 +4691,7 @@ void JSMatchedRoute::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSMatchedRoute);
template<typename Visitor>
-void JSMatchedRoute::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSMatchedRoute::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSMatchedRoute* thisObject = jsCast<JSMatchedRoute*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -4721,502 +4699,413 @@ void JSMatchedRoute::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSMatchedRoute);
- class JSNodeJSFSPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSNodeJSFSPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSNodeJSFSPrototype* ptr = new (NotNull, JSC::allocateCell<JSNodeJSFSPrototype>(vm)) JSNodeJSFSPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSNodeJSFSPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSNodeJSFSPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSNodeJSFSPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSNodeJSFSPrototype* ptr = new (NotNull, JSC::allocateCell<JSNodeJSFSPrototype>(vm)) JSNodeJSFSPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSNodeJSFSPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSNodeJSFSConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSNodeJSFSConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSNodeJSFSPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSNodeJSFSConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForNodeJSFSConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForNodeJSFSConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForNodeJSFSConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForNodeJSFSConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSNodeJSFSPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSNodeJSFSConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSNodeJSFSPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSNodeJSFSConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSNodeJSFSPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSNodeJSFSConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForNodeJSFSConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForNodeJSFSConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForNodeJSFSConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForNodeJSFSConstructor = std::forward<decltype(space)>(space); });
+ }
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSNodeJSFSPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSNodeJSFSConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSNodeJSFSPrototype* prototype);
+};
extern "C" void* NodeJSFSClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsNodeJSFSConstructor);
extern "C" void NodeJSFSClass__finalize(void*);
-
extern "C" EncodedJSValue NodeJSFSPrototype__access(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__accessCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__accessSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__accessSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__appendFile(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__appendFileCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__appendFileSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__appendFileSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__chmod(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__chmodCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__chmodSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__chmodSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__chown(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__chownCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__chownSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__chownSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__close(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__closeCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__closeSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__closeSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__copyFile(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__copyFileCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__copyFileSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__copyFileSyncCallback);
-
extern "C" JSC::EncodedJSValue NodeJSFSPrototype__getDirent(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(NodeJSFSPrototype__DirentGetterWrap);
-
extern "C" EncodedJSValue NodeJSFSPrototype__exists(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__existsCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__existsSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__existsSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fchmod(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fchmodCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fchmodSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fchmodSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fchown(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fchownCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fchownSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fchownSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fdatasync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fdatasyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fdatasyncSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fdatasyncSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fstat(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fstatCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fstatSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fstatSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fsync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fsyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__fsyncSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__fsyncSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__ftruncate(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__ftruncateCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__ftruncateSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__ftruncateSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__futimes(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__futimesCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__futimesSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__futimesSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__lchmod(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__lchmodCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__lchmodSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__lchmodSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__lchown(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__lchownCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__lchownSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__lchownSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__link(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__linkCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__linkSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__linkSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__lstat(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__lstatCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__lstatSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__lstatSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__lutimes(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__lutimesCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__lutimesSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__lutimesSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__mkdir(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__mkdirCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__mkdirSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__mkdirSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__mkdtemp(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__mkdtempCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__mkdtempSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__mkdtempSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__open(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__openCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__opendir(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__opendirCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__opendirSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__opendirSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__openSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__openSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__read(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readdir(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readdirCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readdirSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readdirSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readFile(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readFileCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readFileSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readFileSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readlink(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readlinkCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readlinkSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readlinkSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readv(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readvCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__readvSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__readvSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__realpath(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__realpathCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__realpathSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__realpathSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__rename(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__renameCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__renameSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__renameSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__rm(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__rmCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__rmdir(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__rmdirCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__rmdirSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__rmdirSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__rmSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__rmSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__stat(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__statCallback);
-
extern "C" JSC::EncodedJSValue NodeJSFSPrototype__getStats(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(NodeJSFSPrototype__StatsGetterWrap);
-
extern "C" EncodedJSValue NodeJSFSPrototype__statSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__statSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__symlink(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__symlinkCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__symlinkSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__symlinkSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__truncate(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__truncateCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__truncateSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__truncateSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__unlink(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__unlinkCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__unlinkSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__unlinkSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__utimes(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__utimesCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__utimesSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__utimesSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__writeCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__writeFile(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__writeFileCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__writeFileSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__writeFileSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__writeSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__writeSyncCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__writev(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__writevCallback);
-
extern "C" EncodedJSValue NodeJSFSPrototype__writevSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(NodeJSFSPrototype__writevSyncCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSNodeJSFSPrototype, JSNodeJSFSPrototype::Base);
-
- static const HashTableValue JSNodeJSFSPrototypeTableValues[] = {
-{ "access"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__accessCallback, 3 } } ,
-{ "accessSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__accessSyncCallback, 2 } } ,
-{ "appendFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__appendFileCallback, 4 } } ,
-{ "appendFileSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__appendFileSyncCallback, 3 } } ,
-{ "chmod"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__chmodCallback, 3 } } ,
-{ "chmodSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__chmodSyncCallback, 2 } } ,
-{ "chown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__chownCallback, 4 } } ,
-{ "chownSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__chownSyncCallback, 3 } } ,
-{ "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__closeCallback, 1 } } ,
-{ "closeSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__closeSyncCallback, 1 } } ,
-{ "copyFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__copyFileCallback, 4 } } ,
-{ "copyFileSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__copyFileSyncCallback, 3 } } ,
-{ "Dirent"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, NodeJSFSPrototype__DirentGetterWrap, 0 } } ,
-{ "exists"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__existsCallback, 2 } } ,
-{ "existsSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__existsSyncCallback, 1 } } ,
-{ "fchmod"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fchmodCallback, 3 } } ,
-{ "fchmodSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fchmodSyncCallback, 2 } } ,
-{ "fchown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fchownCallback, 4 } } ,
-{ "fchownSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fchownSyncCallback, 3 } } ,
-{ "fdatasync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fdatasyncCallback, 2 } } ,
-{ "fdatasyncSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fdatasyncSyncCallback, 1 } } ,
-{ "fstat"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fstatCallback, 1 } } ,
-{ "fstatSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fstatSyncCallback, 1 } } ,
-{ "fsync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fsyncCallback, 2 } } ,
-{ "fsyncSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fsyncSyncCallback, 1 } } ,
-{ "ftruncate"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__ftruncateCallback, 1 } } ,
-{ "ftruncateSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__ftruncateSyncCallback, 1 } } ,
-{ "futimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__futimesCallback, 4 } } ,
-{ "futimesSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__futimesSyncCallback, 3 } } ,
-{ "lchmod"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lchmodCallback, 3 } } ,
-{ "lchmodSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lchmodSyncCallback, 2 } } ,
-{ "lchown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lchownCallback, 4 } } ,
-{ "lchownSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lchownSyncCallback, 3 } } ,
-{ "link"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__linkCallback, 3 } } ,
-{ "linkSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__linkSyncCallback, 2 } } ,
-{ "lstat"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lstatCallback, 1 } } ,
-{ "lstatSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lstatSyncCallback, 1 } } ,
-{ "lutimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lutimesCallback, 4 } } ,
-{ "lutimesSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lutimesSyncCallback, 3 } } ,
-{ "mkdir"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__mkdirCallback, 3 } } ,
-{ "mkdirSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__mkdirSyncCallback, 2 } } ,
-{ "mkdtemp"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__mkdtempCallback, 3 } } ,
-{ "mkdtempSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__mkdtempSyncCallback, 2 } } ,
-{ "open"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__openCallback, 4 } } ,
-{ "opendir"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__opendirCallback, 3 } } ,
-{ "opendirSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__opendirSyncCallback, 2 } } ,
-{ "openSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__openSyncCallback, 3 } } ,
-{ "read"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readCallback, 6 } } ,
-{ "readdir"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readdirCallback, 3 } } ,
-{ "readdirSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readdirSyncCallback, 2 } } ,
-{ "readFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readFileCallback, 3 } } ,
-{ "readFileSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readFileSyncCallback, 2 } } ,
-{ "readlink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readlinkCallback, 3 } } ,
-{ "readlinkSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readlinkSyncCallback, 2 } } ,
-{ "readSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readSyncCallback, 5 } } ,
-{ "readv"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readvCallback, 4 } } ,
-{ "readvSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readvSyncCallback, 3 } } ,
-{ "realpath"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__realpathCallback, 3 } } ,
-{ "realpathSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__realpathSyncCallback, 2 } } ,
-{ "rename"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__renameCallback, 3 } } ,
-{ "renameSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__renameSyncCallback, 2 } } ,
-{ "rm"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__rmCallback, 3 } } ,
-{ "rmdir"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__rmdirCallback, 3 } } ,
-{ "rmdirSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__rmdirSyncCallback, 2 } } ,
-{ "rmSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__rmSyncCallback, 2 } } ,
-{ "stat"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__statCallback, 1 } } ,
-{ "Stats"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, NodeJSFSPrototype__StatsGetterWrap, 0 } } ,
-{ "statSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__statSyncCallback, 1 } } ,
-{ "symlink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__symlinkCallback, 4 } } ,
-{ "symlinkSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__symlinkSyncCallback, 3 } } ,
-{ "truncate"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__truncateCallback, 3 } } ,
-{ "truncateSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__truncateSyncCallback, 2 } } ,
-{ "unlink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__unlinkCallback, 2 } } ,
-{ "unlinkSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__unlinkSyncCallback, 1 } } ,
-{ "utimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__utimesCallback, 4 } } ,
-{ "utimesSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__utimesSyncCallback, 3 } } ,
-{ "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeCallback, 6 } } ,
-{ "writeFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeFileCallback, 4 } } ,
-{ "writeFileSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeFileSyncCallback, 3 } } ,
-{ "writeSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeSyncCallback, 5 } } ,
-{ "writev"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writevCallback, 4 } } ,
-{ "writevSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writevSyncCallback, 3 } }
+static const HashTableValue JSNodeJSFSPrototypeTableValues[] = {
+ { "access"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__accessCallback, 3 } },
+ { "accessSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__accessSyncCallback, 2 } },
+ { "appendFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__appendFileCallback, 4 } },
+ { "appendFileSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__appendFileSyncCallback, 3 } },
+ { "chmod"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__chmodCallback, 3 } },
+ { "chmodSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__chmodSyncCallback, 2 } },
+ { "chown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__chownCallback, 4 } },
+ { "chownSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__chownSyncCallback, 3 } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__closeCallback, 1 } },
+ { "closeSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__closeSyncCallback, 1 } },
+ { "copyFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__copyFileCallback, 4 } },
+ { "copyFileSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__copyFileSyncCallback, 3 } },
+ { "Dirent"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, NodeJSFSPrototype__DirentGetterWrap, 0 } },
+ { "exists"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__existsCallback, 2 } },
+ { "existsSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__existsSyncCallback, 1 } },
+ { "fchmod"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fchmodCallback, 3 } },
+ { "fchmodSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fchmodSyncCallback, 2 } },
+ { "fchown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fchownCallback, 4 } },
+ { "fchownSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fchownSyncCallback, 3 } },
+ { "fdatasync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fdatasyncCallback, 2 } },
+ { "fdatasyncSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fdatasyncSyncCallback, 1 } },
+ { "fstat"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fstatCallback, 1 } },
+ { "fstatSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fstatSyncCallback, 1 } },
+ { "fsync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fsyncCallback, 2 } },
+ { "fsyncSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__fsyncSyncCallback, 1 } },
+ { "ftruncate"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__ftruncateCallback, 1 } },
+ { "ftruncateSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__ftruncateSyncCallback, 1 } },
+ { "futimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__futimesCallback, 4 } },
+ { "futimesSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__futimesSyncCallback, 3 } },
+ { "lchmod"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lchmodCallback, 3 } },
+ { "lchmodSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lchmodSyncCallback, 2 } },
+ { "lchown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lchownCallback, 4 } },
+ { "lchownSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lchownSyncCallback, 3 } },
+ { "link"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__linkCallback, 3 } },
+ { "linkSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__linkSyncCallback, 2 } },
+ { "lstat"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lstatCallback, 1 } },
+ { "lstatSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lstatSyncCallback, 1 } },
+ { "lutimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lutimesCallback, 4 } },
+ { "lutimesSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__lutimesSyncCallback, 3 } },
+ { "mkdir"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__mkdirCallback, 3 } },
+ { "mkdirSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__mkdirSyncCallback, 2 } },
+ { "mkdtemp"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__mkdtempCallback, 3 } },
+ { "mkdtempSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__mkdtempSyncCallback, 2 } },
+ { "open"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__openCallback, 4 } },
+ { "opendir"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__opendirCallback, 3 } },
+ { "opendirSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__opendirSyncCallback, 2 } },
+ { "openSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__openSyncCallback, 3 } },
+ { "read"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readCallback, 6 } },
+ { "readdir"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readdirCallback, 3 } },
+ { "readdirSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readdirSyncCallback, 2 } },
+ { "readFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readFileCallback, 3 } },
+ { "readFileSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readFileSyncCallback, 2 } },
+ { "readlink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readlinkCallback, 3 } },
+ { "readlinkSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readlinkSyncCallback, 2 } },
+ { "readSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readSyncCallback, 5 } },
+ { "readv"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readvCallback, 4 } },
+ { "readvSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__readvSyncCallback, 3 } },
+ { "realpath"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__realpathCallback, 3 } },
+ { "realpathSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__realpathSyncCallback, 2 } },
+ { "rename"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__renameCallback, 3 } },
+ { "renameSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__renameSyncCallback, 2 } },
+ { "rm"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__rmCallback, 3 } },
+ { "rmdir"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__rmdirCallback, 3 } },
+ { "rmdirSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__rmdirSyncCallback, 2 } },
+ { "rmSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__rmSyncCallback, 2 } },
+ { "stat"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__statCallback, 1 } },
+ { "Stats"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, NodeJSFSPrototype__StatsGetterWrap, 0 } },
+ { "statSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__statSyncCallback, 1 } },
+ { "symlink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__symlinkCallback, 4 } },
+ { "symlinkSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__symlinkSyncCallback, 3 } },
+ { "truncate"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__truncateCallback, 3 } },
+ { "truncateSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__truncateSyncCallback, 2 } },
+ { "unlink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__unlinkCallback, 2 } },
+ { "unlinkSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__unlinkSyncCallback, 1 } },
+ { "utimes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__utimesCallback, 4 } },
+ { "utimesSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__utimesSyncCallback, 3 } },
+ { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeCallback, 6 } },
+ { "writeFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeFileCallback, 4 } },
+ { "writeFileSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeFileSyncCallback, 3 } },
+ { "writeSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writeSyncCallback, 5 } },
+ { "writev"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writevCallback, 4 } },
+ { "writevSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, NodeJSFSPrototype__writevSyncCallback, 3 } }
};
-
-
const ClassInfo JSNodeJSFSPrototype::s_info = { "NodeJSFS"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNodeJSFSPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsNodeJSFSConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -5227,218 +5116,204 @@ JSC_DEFINE_CUSTOM_GETTER(jsNodeJSFSConstructor, (JSGlobalObject * lexicalGlobalO
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSNodeJSFSConstructor());
-}
-
-
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__accessCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__accessCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__access(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__accessSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__access(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__accessSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__accessSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__appendFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__accessSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__appendFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__appendFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__appendFileSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__appendFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__appendFileSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__appendFileSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chmodCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__appendFileSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chmodCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__chmod(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chmodSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__chmod(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chmodSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__chmodSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__chmodSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__chown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chownSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__chown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__chownSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__chownSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__chownSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__close(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__closeSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__close(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__closeSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__closeSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__copyFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__closeSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__copyFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__copyFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__copyFileSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__copyFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__copyFileSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__copyFileSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return NodeJSFSPrototype__copyFileSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(NodeJSFSPrototype__DirentGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSNodeJSFS* thisObject = jsCast<JSNodeJSFS*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -5446,913 +5321,859 @@ JSC_DEFINE_CUSTOM_GETTER(NodeJSFSPrototype__DirentGetterWrap, (JSGlobalObject *
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__existsCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__existsCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__exists(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__existsSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__exists(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__existsSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__existsSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchmodCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__existsSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchmodCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fchmod(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchmodSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fchmod(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchmodSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fchmodSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fchmodSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fchown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchownSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fchown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fchownSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fchownSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fdatasyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fchownSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fdatasyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fdatasync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fdatasyncSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fdatasync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fdatasyncSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fdatasyncSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fstatCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fdatasyncSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fstatCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fstat(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fstatSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fstat(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fstatSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fstatSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fsyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fstatSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fsyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fsync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fsyncSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fsync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__fsyncSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__fsyncSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__ftruncateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__fsyncSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__ftruncateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__ftruncate(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__ftruncateSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__ftruncate(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__ftruncateSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__ftruncateSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__futimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__ftruncateSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__futimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__futimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__futimesSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__futimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__futimesSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__futimesSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchmodCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__futimesSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchmodCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__lchmod(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchmodSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__lchmod(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchmodSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__lchmodSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__lchmodSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__lchown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchownSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__lchown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lchownSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__lchownSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__linkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__lchownSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__linkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__link(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__linkSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__link(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__linkSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__linkSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lstatCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__linkSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lstatCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__lstat(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lstatSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__lstat(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lstatSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__lstatSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lutimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__lstatSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lutimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__lutimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lutimesSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__lutimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__lutimesSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__lutimesSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdirCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__lutimesSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdirCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__mkdir(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdirSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__mkdir(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdirSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__mkdirSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdtempCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__mkdirSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdtempCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__mkdtemp(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdtempSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__mkdtemp(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__mkdtempSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__mkdtempSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__openCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__mkdtempSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__openCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__open(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__opendirCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__open(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__opendirCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__opendir(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__opendirSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__opendir(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__opendirSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__opendirSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__openSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__opendirSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__openSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__openSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__openSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__read(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readdirCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__read(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readdirCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readdir(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readdirSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readdir(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readdirSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readdirSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readdirSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readFileSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readFileSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readFileSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readlinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readFileSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readlinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readlink(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readlinkSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readlink(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readlinkSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readlinkSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readlinkSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readvCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readvCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readv(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readvSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readv(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__readvSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__readvSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__realpathCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__readvSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__realpathCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__realpath(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__realpathSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__realpath(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__realpathSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__realpathSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__renameCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__realpathSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__renameCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__rename(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__renameSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__rename(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__renameSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__renameSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__renameSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__rm(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmdirCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__rm(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmdirCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__rmdir(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmdirSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__rmdir(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmdirSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__rmdirSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__rmdirSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__rmSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__rmSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__statCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__rmSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__statCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__stat(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return NodeJSFSPrototype__stat(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(NodeJSFSPrototype__StatsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSNodeJSFS* thisObject = jsCast<JSNodeJSFS*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -6360,262 +6181,246 @@ JSC_DEFINE_CUSTOM_GETTER(NodeJSFSPrototype__StatsGetterWrap, (JSGlobalObject * l
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__statSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__statSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__statSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__symlinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__statSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__symlinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__symlink(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__symlinkSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__symlink(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__symlinkSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__symlinkSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__truncateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__symlinkSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__truncateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__truncate(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__truncateSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__truncate(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__truncateSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__truncateSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__unlinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__truncateSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__unlinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__unlink(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__unlinkSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__unlink(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__unlinkSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__unlinkSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__utimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__unlinkSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__utimesCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__utimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__utimesSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__utimes(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__utimesSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__utimesSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__utimesSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__writeFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeFileSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__writeFile(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeFileSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__writeFileSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__writeFileSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writeSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__writeSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writevCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__writeSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writevCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__writev(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writevSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
+ return NodeJSFSPrototype__writev(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(NodeJSFSPrototype__writevSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSNodeJSFS* thisObject = jsDynamicCast<JSNodeJSFS*>(callFrame->thisValue());
- return NodeJSFSPrototype__writevSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return NodeJSFSPrototype__writevSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSNodeJSFSPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -6627,67 +6432,64 @@ void JSNodeJSFSPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globa
void JSNodeJSFSConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSNodeJSFSPrototype* prototype)
{
Base::finishCreation(vm, 0, "NodeJSFS"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSNodeJSFSConstructor::JSNodeJSFSConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSNodeJSFSConstructor::JSNodeJSFSConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSNodeJSFSConstructor* JSNodeJSFSConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSNodeJSFSPrototype* prototype) {
+JSNodeJSFSConstructor* JSNodeJSFSConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSNodeJSFSPrototype* prototype)
+{
JSNodeJSFSConstructor* ptr = new (NotNull, JSC::allocateCell<JSNodeJSFSConstructor>(vm)) JSNodeJSFSConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSNodeJSFSConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSNodeJSFSConstructor();
Structure* structure = globalObject->JSNodeJSFSStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSNodeJSFSStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSNodeJSFSStructure());
}
void* ptr = NodeJSFSClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSNodeJSFS* instance = JSNodeJSFS::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSNodeJSFSConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSNodeJSFSPrototype* prototype)
{
-
}
const ClassInfo JSNodeJSFSConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNodeJSFSConstructor) };
-
- extern "C" EncodedJSValue NodeJSFS__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue NodeJSFS__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSNodeJSFSConstructor());
- }
+}
JSNodeJSFS::~JSNodeJSFS()
{
@@ -6696,7 +6498,7 @@ void JSNodeJSFS::destroy(JSCell* cell)
{
static_cast<JSNodeJSFS*>(cell)->JSNodeJSFS::~JSNodeJSFS();
}
-
+
const ClassInfo JSNodeJSFS::s_info = { "NodeJSFS"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNodeJSFS) };
void JSNodeJSFS::finishCreation(VM& vm)
@@ -6705,36 +6507,37 @@ void JSNodeJSFS::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSNodeJSFS* JSNodeJSFS::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSNodeJSFS* ptr = new (NotNull, JSC::allocateCell<JSNodeJSFS>(vm)) JSNodeJSFS(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSNodeJSFS* JSNodeJSFS::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSNodeJSFS* ptr = new (NotNull, JSC::allocateCell<JSNodeJSFS>(vm)) JSNodeJSFS(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* NodeJSFS__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* NodeJSFS__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSNodeJSFS* object = JSC::jsDynamicCast<JSNodeJSFS*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSNodeJSFS* object = JSC::jsDynamicCast<JSNodeJSFS*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool NodeJSFS__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSNodeJSFS* object = JSC::jsDynamicCast<JSNodeJSFS*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool NodeJSFS__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSNodeJSFS* object = JSC::jsDynamicCast<JSNodeJSFS*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t NodeJSFS__ptrOffset = JSNodeJSFS::offsetOfWrapped();
@@ -6750,7 +6553,7 @@ void JSNodeJSFS::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSNodeJSFS::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSNodeJSFSConstructor::create(vm, globalObject, WebCore::JSNodeJSFSConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSNodeJSFSPrototype*>(prototype));
+ return WebCore::JSNodeJSFSConstructor::create(vm, globalObject, WebCore::JSNodeJSFSConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSNodeJSFSPrototype*>(prototype));
}
JSObject* JSNodeJSFS::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -6758,199 +6561,173 @@ JSObject* JSNodeJSFS::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSNodeJSFSPrototype::create(vm, globalObject, JSNodeJSFSPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue NodeJSFS__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSNodeJSFSStructure();
- JSNodeJSFS* instance = JSNodeJSFS::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSRequestPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSRequestPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSRequestPrototype>(vm)) JSRequestPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue NodeJSFS__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSNodeJSFSStructure();
+ JSNodeJSFS* instance = JSNodeJSFS::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSRequestPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSRequestPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSRequestPrototype>(vm)) JSRequestPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSRequestConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSRequestConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSRequestPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSRequestConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForRequestConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequestConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForRequestConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForRequestConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSRequestConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSRequestConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSRequestPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSRequestConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForRequestConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequestConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForRequestConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForRequestConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype);
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSRequestConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype);
+};
extern "C" void* RequestClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsRequestConstructor);
extern "C" void RequestClass__finalize(void*);
-
extern "C" EncodedJSValue RequestPrototype__getArrayBuffer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(RequestPrototype__arrayBufferCallback);
-
extern "C" EncodedJSValue RequestPrototype__getBlob(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(RequestPrototype__blobCallback);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getBody(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__bodyGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getBodyUsed(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__bodyUsedGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getCache(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__cacheGetterWrap);
-
extern "C" EncodedJSValue RequestPrototype__doClone(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(RequestPrototype__cloneCallback);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getCredentials(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__credentialsGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getDestination(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__destinationGetterWrap);
-
extern "C" EncodedJSValue RequestPrototype__getFormData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(RequestPrototype__formDataCallback);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getHeaders(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__headersGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getIntegrity(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__integrityGetterWrap);
-
extern "C" EncodedJSValue RequestPrototype__getJSON(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(RequestPrototype__jsonCallback);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getMethod(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__methodGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getMode(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__modeGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getRedirect(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__redirectGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getReferrer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__referrerGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getReferrerPolicy(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__referrerPolicyGetterWrap);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getSignal(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__signalGetterWrap);
-
extern "C" EncodedJSValue RequestPrototype__getText(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(RequestPrototype__textCallback);
-
extern "C" JSC::EncodedJSValue RequestPrototype__getUrl(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(RequestPrototype__urlGetterWrap);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSRequestPrototype, JSRequestPrototype::Base);
-
- static const HashTableValue JSRequestPrototypeTableValues[] = {
-{ "arrayBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__arrayBufferCallback, 0 } } ,
-{ "blob"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__blobCallback, 0 } } ,
-{ "body"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__bodyGetterWrap, 0 } } ,
-{ "bodyUsed"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__bodyUsedGetterWrap, 0 } } ,
-{ "cache"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__cacheGetterWrap, 0 } } ,
-{ "clone"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__cloneCallback, 1 } } ,
-{ "credentials"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__credentialsGetterWrap, 0 } } ,
-{ "destination"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__destinationGetterWrap, 0 } } ,
-{ "formData"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__formDataCallback, 0 } } ,
-{ "headers"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__headersGetterWrap, 0 } } ,
-{ "integrity"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__integrityGetterWrap, 0 } } ,
-{ "json"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__jsonCallback, 0 } } ,
-{ "method"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__methodGetterWrap, 0 } } ,
-{ "mode"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__modeGetterWrap, 0 } } ,
-{ "redirect"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__redirectGetterWrap, 0 } } ,
-{ "referrer"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__referrerGetterWrap, 0 } } ,
-{ "referrerPolicy"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__referrerPolicyGetterWrap, 0 } } ,
-{ "signal"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__signalGetterWrap, 0 } } ,
-{ "text"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__textCallback, 0 } } ,
-{ "url"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__urlGetterWrap, 0 } }
+static const HashTableValue JSRequestPrototypeTableValues[] = {
+ { "arrayBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__arrayBufferCallback, 0 } },
+ { "blob"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__blobCallback, 0 } },
+ { "body"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__bodyGetterWrap, 0 } },
+ { "bodyUsed"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__bodyUsedGetterWrap, 0 } },
+ { "cache"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__cacheGetterWrap, 0 } },
+ { "clone"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__cloneCallback, 1 } },
+ { "credentials"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__credentialsGetterWrap, 0 } },
+ { "destination"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__destinationGetterWrap, 0 } },
+ { "formData"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__formDataCallback, 0 } },
+ { "headers"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__headersGetterWrap, 0 } },
+ { "integrity"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__integrityGetterWrap, 0 } },
+ { "json"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__jsonCallback, 0 } },
+ { "method"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__methodGetterWrap, 0 } },
+ { "mode"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__modeGetterWrap, 0 } },
+ { "redirect"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__redirectGetterWrap, 0 } },
+ { "referrer"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__referrerGetterWrap, 0 } },
+ { "referrerPolicy"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__referrerPolicyGetterWrap, 0 } },
+ { "signal"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__signalGetterWrap, 0 } },
+ { "text"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, RequestPrototype__textCallback, 0 } },
+ { "url"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, RequestPrototype__urlGetterWrap, 0 } }
};
-
-
const ClassInfo JSRequestPrototype::s_info = { "Request"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRequestPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsRequestConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -6961,83 +6738,75 @@ JSC_DEFINE_CUSTOM_GETTER(jsRequestConstructor, (JSGlobalObject * lexicalGlobalOb
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSRequestConstructor());
-}
-
-
-
- JSC_DEFINE_HOST_FUNCTION(RequestPrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(RequestPrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
- return RequestPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(RequestPrototype__blobCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
+ return RequestPrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(RequestPrototype__blobCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
- return RequestPrototype__getBlob(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return RequestPrototype__getBlob(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__bodyGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_body.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- RequestPrototype__getBody(thisObject->wrapped(), globalObject)
- );
+ RequestPrototype__getBody(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_body.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void RequestPrototype__bodySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
+ thisObject->m_body.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void RequestPrototype__bodySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
- thisObject->m_body.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue RequestPrototype__bodyGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue RequestPrototype__bodyGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_body.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__bodyUsedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7045,12 +6814,11 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__bodyUsedGetterWrap, (JSGlobalObject *
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__cacheGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7058,29 +6826,27 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__cacheGetterWrap, (JSGlobalObject * le
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(RequestPrototype__cloneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(RequestPrototype__cloneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
+ JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return RequestPrototype__doClone(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return RequestPrototype__doClone(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__credentialsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7088,12 +6854,11 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__credentialsGetterWrap, (JSGlobalObjec
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__destinationGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7101,64 +6866,58 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__destinationGetterWrap, (JSGlobalObjec
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(RequestPrototype__formDataCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(RequestPrototype__formDataCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
+ JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return RequestPrototype__getFormData(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return RequestPrototype__getFormData(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__headersGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_headers.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- RequestPrototype__getHeaders(thisObject->wrapped(), globalObject)
- );
+ RequestPrototype__getHeaders(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_headers.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void RequestPrototype__headersSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
+ thisObject->m_headers.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void RequestPrototype__headersSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
- thisObject->m_headers.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue RequestPrototype__headersGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue RequestPrototype__headersGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_headers.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__integrityGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7166,29 +6925,27 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__integrityGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(RequestPrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(RequestPrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
+ JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return RequestPrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return RequestPrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__methodGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7196,12 +6953,11 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__methodGetterWrap, (JSGlobalObject * l
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__modeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7209,12 +6965,11 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__modeGetterWrap, (JSGlobalObject * lex
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__redirectGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7222,12 +6977,11 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__redirectGetterWrap, (JSGlobalObject *
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__referrerGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7235,12 +6989,11 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__referrerGetterWrap, (JSGlobalObject *
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__referrerPolicyGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7248,94 +7001,84 @@ JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__referrerPolicyGetterWrap, (JSGlobalOb
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__signalGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_signal.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- RequestPrototype__getSignal(thisObject->wrapped(), globalObject)
- );
+ RequestPrototype__getSignal(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_signal.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void RequestPrototype__signalSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
+ thisObject->m_signal.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void RequestPrototype__signalSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
- thisObject->m_signal.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue RequestPrototype__signalGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue RequestPrototype__signalGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_signal.get());
- }
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(RequestPrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(RequestPrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
+ JSRequest* thisObject = jsDynamicCast<JSRequest*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return RequestPrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return RequestPrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(RequestPrototype__urlGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSRequest* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_url.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- RequestPrototype__getUrl(thisObject->wrapped(), globalObject)
- );
+ RequestPrototype__getUrl(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_url.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void RequestPrototype__urlSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
+ thisObject->m_url.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void RequestPrototype__urlSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
- thisObject->m_url.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue RequestPrototype__urlGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue RequestPrototype__urlGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSRequest*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_url.get());
- }
-
-
+}
void JSRequestPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -7346,72 +7089,68 @@ void JSRequestPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* global
extern "C" size_t Request__estimatedSize(void* ptr);
-
-
void JSRequestConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype)
{
Base::finishCreation(vm, 0, "Request"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSRequestConstructor::JSRequestConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSRequestConstructor::JSRequestConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSRequestConstructor* JSRequestConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSRequestPrototype* prototype) {
+JSRequestConstructor* JSRequestConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSRequestPrototype* prototype)
+{
JSRequestConstructor* ptr = new (NotNull, JSC::allocateCell<JSRequestConstructor>(vm)) JSRequestConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSRequestConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSRequestConstructor();
Structure* structure = globalObject->JSRequestStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSRequestStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSRequestStructure());
}
void* ptr = RequestClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSRequest* instance = JSRequest::create(vm, globalObject, structure, ptr);
- vm.heap.reportExtraMemoryAllocated(Request__estimatedSize(instance->wrapped()));
+ vm.heap.reportExtraMemoryAllocated(Request__estimatedSize(instance->wrapped()));
return JSValue::encode(instance);
}
void JSRequestConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSRequestPrototype* prototype)
{
-
}
const ClassInfo JSRequestConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRequestConstructor) };
-
- extern "C" EncodedJSValue Request__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue Request__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSRequestConstructor());
- }
+}
JSRequest::~JSRequest()
{
@@ -7423,7 +7162,7 @@ void JSRequest::destroy(JSCell* cell)
{
static_cast<JSRequest*>(cell)->JSRequest::~JSRequest();
}
-
+
const ClassInfo JSRequest::s_info = { "Request"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRequest) };
void JSRequest::finishCreation(VM& vm)
@@ -7432,36 +7171,37 @@ void JSRequest::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSRequest* JSRequest::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSRequest* ptr = new (NotNull, JSC::allocateCell<JSRequest>(vm)) JSRequest(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSRequest* JSRequest::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSRequest* ptr = new (NotNull, JSC::allocateCell<JSRequest>(vm)) JSRequest(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Request__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Request__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSRequest* object = JSC::jsDynamicCast<JSRequest*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSRequest* object = JSC::jsDynamicCast<JSRequest*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Request__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSRequest* object = JSC::jsDynamicCast<JSRequest*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Request__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSRequest* object = JSC::jsDynamicCast<JSRequest*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Request__ptrOffset = JSRequest::offsetOfWrapped();
@@ -7477,7 +7217,7 @@ void JSRequest::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSRequest::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSRequestConstructor::create(vm, globalObject, WebCore::JSRequestConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSRequestPrototype*>(prototype));
+ return WebCore::JSRequestConstructor::create(vm, globalObject, WebCore::JSRequestConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSRequestPrototype*>(prototype));
}
JSObject* JSRequest::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -7485,12 +7225,13 @@ JSObject* JSRequest::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSRequestPrototype::create(vm, globalObject, JSRequestPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Request__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSRequestStructure();
- JSRequest* instance = JSRequest::create(vm, globalObject, structure, ptr);
- vm.heap.reportExtraMemoryAllocated(Request__estimatedSize(ptr));
- return JSValue::encode(instance);
+extern "C" EncodedJSValue Request__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSRequestStructure();
+ JSRequest* instance = JSRequest::create(vm, globalObject, structure, ptr);
+ vm.heap.reportExtraMemoryAllocated(Request__estimatedSize(ptr));
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -7499,15 +7240,14 @@ void JSRequest::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSRequest* thisObject = jsCast<JSRequest*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
+
if (auto* ptr = thisObject->wrapped()) {
-visitor.reportExtraMemoryVisited(Request__estimatedSize(ptr));
-}
+ visitor.reportExtraMemoryVisited(Request__estimatedSize(ptr));
+ }
visitor.append(thisObject->m_body);
visitor.append(thisObject->m_headers);
visitor.append(thisObject->m_signal);
visitor.append(thisObject->m_url);
-
}
DEFINE_VISIT_CHILDREN(JSRequest);
@@ -7515,10 +7255,10 @@ DEFINE_VISIT_CHILDREN(JSRequest);
template<typename Visitor>
void JSRequest::visitAdditionalChildren(Visitor& visitor)
{
- JSRequest* thisObject = this;
+ JSRequest* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_body);
+
+ visitor.append(thisObject->m_body);
visitor.append(thisObject->m_headers);
visitor.append(thisObject->m_signal);
visitor.append(thisObject->m_url);
@@ -7528,7 +7268,7 @@ void JSRequest::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSRequest);
template<typename Visitor>
-void JSRequest::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSRequest::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSRequest* thisObject = jsCast<JSRequest*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -7536,167 +7276,145 @@ void JSRequest::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSRequest);
- class JSResponsePrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSResponsePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSResponsePrototype* ptr = new (NotNull, JSC::allocateCell<JSResponsePrototype>(vm)) JSResponsePrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSResponsePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSResponsePrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSResponsePrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSResponsePrototype* ptr = new (NotNull, JSC::allocateCell<JSResponsePrototype>(vm)) JSResponsePrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSResponsePrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSResponseConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSResponseConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResponsePrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSResponseConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForResponseConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResponseConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForResponseConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForResponseConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSResponseConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSResponseConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResponsePrototype* prototype);
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSResponseConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForResponseConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResponseConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForResponseConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForResponseConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSResponseConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype);
+};
extern "C" void* ResponseClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsResponseConstructor);
extern "C" void ResponseClass__finalize(void*);
-
extern "C" EncodedJSValue ResponsePrototype__getArrayBuffer(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ResponsePrototype__arrayBufferCallback);
-
extern "C" EncodedJSValue ResponsePrototype__getBlob(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ResponsePrototype__blobCallback);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getBody(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__bodyGetterWrap);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getBodyUsed(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__bodyUsedGetterWrap);
-
extern "C" EncodedJSValue ResponsePrototype__doClone(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ResponsePrototype__cloneCallback);
-
extern "C" EncodedJSValue ResponsePrototype__getFormData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ResponsePrototype__formDataCallback);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getHeaders(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__headersGetterWrap);
-
extern "C" EncodedJSValue ResponsePrototype__getJSON(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ResponsePrototype__jsonCallback);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getOK(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__okGetterWrap);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getRedirected(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__redirectedGetterWrap);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getStatus(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__statusGetterWrap);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getStatusText(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__statusTextGetterWrap);
-
extern "C" EncodedJSValue ResponsePrototype__getText(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ResponsePrototype__textCallback);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getResponseType(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__typeGetterWrap);
-
extern "C" JSC::EncodedJSValue ResponsePrototype__getURL(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ResponsePrototype__urlGetterWrap);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSResponsePrototype, JSResponsePrototype::Base);
-
- static const HashTableValue JSResponsePrototypeTableValues[] = {
-{ "arrayBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__arrayBufferCallback, 0 } } ,
-{ "blob"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__blobCallback, 0 } } ,
-{ "body"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__bodyGetterWrap, 0 } } ,
-{ "bodyUsed"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__bodyUsedGetterWrap, 0 } } ,
-{ "clone"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__cloneCallback, 1 } } ,
-{ "formData"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__formDataCallback, 0 } } ,
-{ "headers"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__headersGetterWrap, 0 } } ,
-{ "json"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__jsonCallback, 0 } } ,
-{ "ok"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__okGetterWrap, 0 } } ,
-{ "redirected"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__redirectedGetterWrap, 0 } } ,
-{ "status"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__statusGetterWrap, 0 } } ,
-{ "statusText"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__statusTextGetterWrap, 0 } } ,
-{ "text"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__textCallback, 0 } } ,
-{ "type"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__typeGetterWrap, 0 } } ,
-{ "url"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__urlGetterWrap, 0 } }
+static const HashTableValue JSResponsePrototypeTableValues[] = {
+ { "arrayBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__arrayBufferCallback, 0 } },
+ { "blob"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__blobCallback, 0 } },
+ { "body"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__bodyGetterWrap, 0 } },
+ { "bodyUsed"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__bodyUsedGetterWrap, 0 } },
+ { "clone"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__cloneCallback, 1 } },
+ { "formData"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__formDataCallback, 0 } },
+ { "headers"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__headersGetterWrap, 0 } },
+ { "json"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__jsonCallback, 0 } },
+ { "ok"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__okGetterWrap, 0 } },
+ { "redirected"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__redirectedGetterWrap, 0 } },
+ { "status"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__statusGetterWrap, 0 } },
+ { "statusText"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__statusTextGetterWrap, 0 } },
+ { "text"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponsePrototype__textCallback, 0 } },
+ { "type"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__typeGetterWrap, 0 } },
+ { "url"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ResponsePrototype__urlGetterWrap, 0 } }
};
-
-
const ClassInfo JSResponsePrototype::s_info = { "Response"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSResponsePrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsResponseConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -7707,83 +7425,75 @@ JSC_DEFINE_CUSTOM_GETTER(jsResponseConstructor, (JSGlobalObject * lexicalGlobalO
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSResponseConstructor());
-}
-
-
-
- JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__arrayBufferCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
- return ResponsePrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__blobCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
+ return ResponsePrototype__getArrayBuffer(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__blobCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
- return ResponsePrototype__getBlob(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ResponsePrototype__getBlob(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__bodyGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_body.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- ResponsePrototype__getBody(thisObject->wrapped(), globalObject)
- );
+ ResponsePrototype__getBody(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_body.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void ResponsePrototype__bodySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
+ thisObject->m_body.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ResponsePrototype__bodySetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
- thisObject->m_body.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ResponsePrototype__bodyGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ResponsePrototype__bodyGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_body.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__bodyUsedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7791,98 +7501,90 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__bodyUsedGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__cloneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__cloneCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
- return ResponsePrototype__doClone(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__formDataCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
+ return ResponsePrototype__doClone(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__formDataCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
- return ResponsePrototype__getFormData(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ResponsePrototype__getFormData(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__headersGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_headers.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- ResponsePrototype__getHeaders(thisObject->wrapped(), globalObject)
- );
+ ResponsePrototype__getHeaders(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_headers.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void ResponsePrototype__headersSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
+ thisObject->m_headers.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ResponsePrototype__headersSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
- thisObject->m_headers.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ResponsePrototype__headersGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ResponsePrototype__headersGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_headers.get());
- }
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__jsonCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
+ JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return ResponsePrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return ResponsePrototype__getJSON(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__okGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7890,12 +7592,11 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__okGetterWrap, (JSGlobalObject * lexi
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__redirectedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7903,12 +7604,11 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__redirectedGetterWrap, (JSGlobalObjec
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__statusGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7916,64 +7616,58 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__statusGetterWrap, (JSGlobalObject *
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__statusTextGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_statusText.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- ResponsePrototype__getStatusText(thisObject->wrapped(), globalObject)
- );
+ ResponsePrototype__getStatusText(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_statusText.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void ResponsePrototype__statusTextSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
+ thisObject->m_statusText.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ResponsePrototype__statusTextSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
- thisObject->m_statusText.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ResponsePrototype__statusTextGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ResponsePrototype__statusTextGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_statusText.get());
- }
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(ResponsePrototype__textCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
+ JSResponse* thisObject = jsDynamicCast<JSResponse*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return ResponsePrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return ResponsePrototype__getText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__typeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -7981,42 +7675,37 @@ JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__typeGetterWrap, (JSGlobalObject * le
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(ResponsePrototype__urlGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSResponse* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_url.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- ResponsePrototype__getURL(thisObject->wrapped(), globalObject)
- );
+ ResponsePrototype__getURL(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_url.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void ResponsePrototype__urlSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
+ thisObject->m_url.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ResponsePrototype__urlSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
- thisObject->m_url.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ResponsePrototype__urlGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ResponsePrototype__urlGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSResponse*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_url.get());
- }
-
-
+}
void JSResponsePrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -8030,13 +7719,12 @@ extern "C" JSC_DECLARE_HOST_FUNCTION(ResponseClass__constructError);
extern "C" JSC_DECLARE_HOST_FUNCTION(ResponseClass__constructJSON);
extern "C" JSC_DECLARE_HOST_FUNCTION(ResponseClass__constructRedirect);
- static const HashTableValue JSResponseConstructorTableValues[] = {
-{ "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponseClass__constructError, 0 } } ,
-{ "json"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponseClass__constructJSON, 0 } } ,
-{ "redirect"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponseClass__constructRedirect, 0 } }
+static const HashTableValue JSResponseConstructorTableValues[] = {
+ { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponseClass__constructError, 0 } },
+ { "json"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponseClass__constructJSON, 0 } },
+ { "redirect"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ResponseClass__constructRedirect, 0 } }
};
-
void JSResponseConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype)
{
Base::finishCreation(vm, 0, "Response"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -8045,62 +7733,60 @@ void JSResponseConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalOb
ASSERT(inherits(info()));
}
-JSResponseConstructor::JSResponseConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSResponseConstructor::JSResponseConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSResponseConstructor* JSResponseConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResponsePrototype* prototype) {
+JSResponseConstructor* JSResponseConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSResponsePrototype* prototype)
+{
JSResponseConstructor* ptr = new (NotNull, JSC::allocateCell<JSResponseConstructor>(vm)) JSResponseConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSResponseConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSResponseConstructor();
Structure* structure = globalObject->JSResponseStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSResponseStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSResponseStructure());
}
void* ptr = ResponseClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSResponse* instance = JSResponse::create(vm, globalObject, structure, ptr);
- vm.heap.reportExtraMemoryAllocated(Response__estimatedSize(instance->wrapped()));
+ vm.heap.reportExtraMemoryAllocated(Response__estimatedSize(instance->wrapped()));
return JSValue::encode(instance);
}
void JSResponseConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSResponsePrototype* prototype)
{
-
}
const ClassInfo JSResponseConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSResponseConstructor) };
-
- extern "C" EncodedJSValue Response__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue Response__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSResponseConstructor());
- }
+}
JSResponse::~JSResponse()
{
@@ -8112,7 +7798,7 @@ void JSResponse::destroy(JSCell* cell)
{
static_cast<JSResponse*>(cell)->JSResponse::~JSResponse();
}
-
+
const ClassInfo JSResponse::s_info = { "Response"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSResponse) };
void JSResponse::finishCreation(VM& vm)
@@ -8121,36 +7807,37 @@ void JSResponse::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSResponse* JSResponse::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSResponse* ptr = new (NotNull, JSC::allocateCell<JSResponse>(vm)) JSResponse(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSResponse* JSResponse::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSResponse* ptr = new (NotNull, JSC::allocateCell<JSResponse>(vm)) JSResponse(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Response__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Response__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSResponse* object = JSC::jsDynamicCast<JSResponse*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSResponse* object = JSC::jsDynamicCast<JSResponse*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Response__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSResponse* object = JSC::jsDynamicCast<JSResponse*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Response__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSResponse* object = JSC::jsDynamicCast<JSResponse*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Response__ptrOffset = JSResponse::offsetOfWrapped();
@@ -8166,7 +7853,7 @@ void JSResponse::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSResponse::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSResponseConstructor::create(vm, globalObject, WebCore::JSResponseConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSResponsePrototype*>(prototype));
+ return WebCore::JSResponseConstructor::create(vm, globalObject, WebCore::JSResponseConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSResponsePrototype*>(prototype));
}
JSObject* JSResponse::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -8174,12 +7861,13 @@ JSObject* JSResponse::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSResponsePrototype::create(vm, globalObject, JSResponsePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Response__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSResponseStructure();
- JSResponse* instance = JSResponse::create(vm, globalObject, structure, ptr);
- vm.heap.reportExtraMemoryAllocated(Response__estimatedSize(ptr));
- return JSValue::encode(instance);
+extern "C" EncodedJSValue Response__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSResponseStructure();
+ JSResponse* instance = JSResponse::create(vm, globalObject, structure, ptr);
+ vm.heap.reportExtraMemoryAllocated(Response__estimatedSize(ptr));
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -8188,15 +7876,14 @@ void JSResponse::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSResponse* thisObject = jsCast<JSResponse*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
+
if (auto* ptr = thisObject->wrapped()) {
-visitor.reportExtraMemoryVisited(Response__estimatedSize(ptr));
-}
+ visitor.reportExtraMemoryVisited(Response__estimatedSize(ptr));
+ }
visitor.append(thisObject->m_body);
visitor.append(thisObject->m_headers);
visitor.append(thisObject->m_statusText);
visitor.append(thisObject->m_url);
-
}
DEFINE_VISIT_CHILDREN(JSResponse);
@@ -8204,10 +7891,10 @@ DEFINE_VISIT_CHILDREN(JSResponse);
template<typename Visitor>
void JSResponse::visitAdditionalChildren(Visitor& visitor)
{
- JSResponse* thisObject = this;
+ JSResponse* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_body);
+
+ visitor.append(thisObject->m_body);
visitor.append(thisObject->m_headers);
visitor.append(thisObject->m_statusText);
visitor.append(thisObject->m_url);
@@ -8217,7 +7904,7 @@ void JSResponse::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSResponse);
template<typename Visitor>
-void JSResponse::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSResponse::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSResponse* thisObject = jsCast<JSResponse*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -8225,107 +7912,97 @@ void JSResponse::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSResponse);
- class JSSHA1Prototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSSHA1Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSSHA1Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA1Prototype>(vm)) JSSHA1Prototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSSHA1Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSSHA1Prototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSSHA1Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSSHA1Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA1Prototype>(vm)) JSSHA1Prototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSSHA1Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSSHA1Constructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSSHA1Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA1Prototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA1Constructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA1Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA1Constructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA1Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA1Constructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSSHA1Constructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSSHA1Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA1Prototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA1Constructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA1Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA1Constructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA1Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA1Constructor = std::forward<decltype(space)>(space); });
+ }
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSSHA1Constructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype);
+};
extern "C" void* SHA1Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsSHA1Constructor);
extern "C" void SHA1Class__finalize(void*);
-
extern "C" JSC::EncodedJSValue SHA1Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SHA1Prototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue SHA1Prototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA1Prototype__digestCallback);
-
extern "C" EncodedJSValue SHA1Prototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA1Prototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA1Prototype, JSSHA1Prototype::Base);
-
- static const HashTableValue JSSHA1PrototypeTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA1Prototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA1Prototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA1Prototype__updateCallback, 1 } }
+static const HashTableValue JSSHA1PrototypeTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA1Prototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA1Prototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA1Prototype__updateCallback, 1 } }
};
-
-
const ClassInfo JSSHA1Prototype::s_info = { "SHA1"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA1Prototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsSHA1Constructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -8336,14 +8013,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA1Constructor, (JSGlobalObject * lexicalGlobalObjec
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSSHA1Constructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SHA1Prototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSHA1* thisObject = jsCast<JSSHA1*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8351,41 +8026,38 @@ JSC_DEFINE_CUSTOM_GETTER(SHA1Prototype__byteLengthGetterWrap, (JSGlobalObject *
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSSHA1* thisObject = jsDynamicCast<JSSHA1*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA1* thisObject = jsDynamicCast<JSSHA1*>(callFrame->thisValue());
- return SHA1Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSSHA1* thisObject = jsDynamicCast<JSSHA1*>(callFrame->thisValue());
+ return SHA1Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA1Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA1* thisObject = jsDynamicCast<JSSHA1*>(callFrame->thisValue());
- return SHA1Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return SHA1Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSSHA1Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -8397,12 +8069,11 @@ void JSSHA1Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObj
extern "C" JSC_DECLARE_CUSTOM_GETTER(SHA1Class__getByteLengthStatic);
extern "C" JSC_DECLARE_HOST_FUNCTION(SHA1Class__hash);
- static const HashTableValue JSSHA1ConstructorTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA1Class__getByteLengthStatic, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA1Class__hash, 2 } }
+static const HashTableValue JSSHA1ConstructorTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA1Class__getByteLengthStatic, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA1Class__hash, 2 } }
};
-
void JSSHA1Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype)
{
Base::finishCreation(vm, 0, "SHA1"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -8411,62 +8082,59 @@ void JSSHA1Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject
ASSERT(inherits(info()));
}
-JSSHA1Constructor::JSSHA1Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSSHA1Constructor::JSSHA1Constructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSSHA1Constructor* JSSHA1Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA1Prototype* prototype) {
+JSSHA1Constructor* JSSHA1Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA1Prototype* prototype)
+{
JSSHA1Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA1Constructor>(vm)) JSSHA1Constructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA1Constructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSSHA1Constructor();
Structure* structure = globalObject->JSSHA1Structure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSSHA1Structure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSSHA1Structure());
}
void* ptr = SHA1Class__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSSHA1* instance = JSSHA1::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSSHA1Constructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA1Prototype* prototype)
{
-
}
const ClassInfo JSSHA1Constructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA1Constructor) };
-
- extern "C" EncodedJSValue SHA1__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue SHA1__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSSHA1Constructor());
- }
+}
JSSHA1::~JSSHA1()
{
@@ -8478,7 +8146,7 @@ void JSSHA1::destroy(JSCell* cell)
{
static_cast<JSSHA1*>(cell)->JSSHA1::~JSSHA1();
}
-
+
const ClassInfo JSSHA1::s_info = { "SHA1"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA1) };
void JSSHA1::finishCreation(VM& vm)
@@ -8487,36 +8155,37 @@ void JSSHA1::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSSHA1* JSSHA1::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSSHA1* ptr = new (NotNull, JSC::allocateCell<JSSHA1>(vm)) JSSHA1(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSSHA1* JSSHA1::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSSHA1* ptr = new (NotNull, JSC::allocateCell<JSSHA1>(vm)) JSSHA1(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* SHA1__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* SHA1__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSSHA1* object = JSC::jsDynamicCast<JSSHA1*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSSHA1* object = JSC::jsDynamicCast<JSSHA1*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool SHA1__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSSHA1* object = JSC::jsDynamicCast<JSSHA1*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool SHA1__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSSHA1* object = JSC::jsDynamicCast<JSSHA1*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t SHA1__ptrOffset = JSSHA1::offsetOfWrapped();
@@ -8532,7 +8201,7 @@ void JSSHA1::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSSHA1::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSSHA1Constructor::create(vm, globalObject, WebCore::JSSHA1Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA1Prototype*>(prototype));
+ return WebCore::JSSHA1Constructor::create(vm, globalObject, WebCore::JSSHA1Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA1Prototype*>(prototype));
}
JSObject* JSSHA1::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -8540,114 +8209,105 @@ JSObject* JSSHA1::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSSHA1Prototype::create(vm, globalObject, JSSHA1Prototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue SHA1__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSSHA1Structure();
- JSSHA1* instance = JSSHA1::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSSHA224Prototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSSHA224Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSSHA224Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA224Prototype>(vm)) JSSHA224Prototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSSHA224Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue SHA1__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSSHA1Structure();
+ JSSHA1* instance = JSSHA1::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSSHA224Prototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSSHA224Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSSHA224Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA224Prototype>(vm)) JSSHA224Prototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSSHA224Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSSHA224Constructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSSHA224Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA224Prototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA224Constructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA224Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA224Constructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA224Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA224Constructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSSHA224Constructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSSHA224Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA224Prototype* prototype);
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA224Constructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA224Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA224Constructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA224Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA224Constructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSSHA224Constructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype);
+};
extern "C" void* SHA224Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsSHA224Constructor);
extern "C" void SHA224Class__finalize(void*);
-
extern "C" JSC::EncodedJSValue SHA224Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SHA224Prototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue SHA224Prototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA224Prototype__digestCallback);
-
extern "C" EncodedJSValue SHA224Prototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA224Prototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA224Prototype, JSSHA224Prototype::Base);
-
- static const HashTableValue JSSHA224PrototypeTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA224Prototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA224Prototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA224Prototype__updateCallback, 1 } }
+static const HashTableValue JSSHA224PrototypeTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA224Prototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA224Prototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA224Prototype__updateCallback, 1 } }
};
-
-
const ClassInfo JSSHA224Prototype::s_info = { "SHA224"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA224Prototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsSHA224Constructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -8658,14 +8318,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA224Constructor, (JSGlobalObject * lexicalGlobalObj
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSSHA224Constructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SHA224Prototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSHA224* thisObject = jsCast<JSSHA224*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8673,41 +8331,38 @@ JSC_DEFINE_CUSTOM_GETTER(SHA224Prototype__byteLengthGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSSHA224* thisObject = jsDynamicCast<JSSHA224*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA224* thisObject = jsDynamicCast<JSSHA224*>(callFrame->thisValue());
- return SHA224Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSSHA224* thisObject = jsDynamicCast<JSSHA224*>(callFrame->thisValue());
+ return SHA224Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA224Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA224* thisObject = jsDynamicCast<JSSHA224*>(callFrame->thisValue());
- return SHA224Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return SHA224Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSSHA224Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -8719,12 +8374,11 @@ void JSSHA224Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalO
extern "C" JSC_DECLARE_CUSTOM_GETTER(SHA224Class__getByteLengthStatic);
extern "C" JSC_DECLARE_HOST_FUNCTION(SHA224Class__hash);
- static const HashTableValue JSSHA224ConstructorTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA224Class__getByteLengthStatic, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA224Class__hash, 2 } }
+static const HashTableValue JSSHA224ConstructorTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA224Class__getByteLengthStatic, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA224Class__hash, 2 } }
};
-
void JSSHA224Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype)
{
Base::finishCreation(vm, 0, "SHA224"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -8733,62 +8387,59 @@ void JSSHA224Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje
ASSERT(inherits(info()));
}
-JSSHA224Constructor::JSSHA224Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSSHA224Constructor::JSSHA224Constructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSSHA224Constructor* JSSHA224Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA224Prototype* prototype) {
+JSSHA224Constructor* JSSHA224Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA224Prototype* prototype)
+{
JSSHA224Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA224Constructor>(vm)) JSSHA224Constructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA224Constructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSSHA224Constructor();
Structure* structure = globalObject->JSSHA224Structure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSSHA224Structure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSSHA224Structure());
}
void* ptr = SHA224Class__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSSHA224* instance = JSSHA224::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSSHA224Constructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA224Prototype* prototype)
{
-
}
const ClassInfo JSSHA224Constructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA224Constructor) };
-
- extern "C" EncodedJSValue SHA224__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue SHA224__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSSHA224Constructor());
- }
+}
JSSHA224::~JSSHA224()
{
@@ -8800,7 +8451,7 @@ void JSSHA224::destroy(JSCell* cell)
{
static_cast<JSSHA224*>(cell)->JSSHA224::~JSSHA224();
}
-
+
const ClassInfo JSSHA224::s_info = { "SHA224"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA224) };
void JSSHA224::finishCreation(VM& vm)
@@ -8809,36 +8460,37 @@ void JSSHA224::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSSHA224* JSSHA224::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSSHA224* ptr = new (NotNull, JSC::allocateCell<JSSHA224>(vm)) JSSHA224(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSSHA224* JSSHA224::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSSHA224* ptr = new (NotNull, JSC::allocateCell<JSSHA224>(vm)) JSSHA224(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* SHA224__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* SHA224__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSSHA224* object = JSC::jsDynamicCast<JSSHA224*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSSHA224* object = JSC::jsDynamicCast<JSSHA224*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool SHA224__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSSHA224* object = JSC::jsDynamicCast<JSSHA224*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool SHA224__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSSHA224* object = JSC::jsDynamicCast<JSSHA224*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t SHA224__ptrOffset = JSSHA224::offsetOfWrapped();
@@ -8854,7 +8506,7 @@ void JSSHA224::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSSHA224::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSSHA224Constructor::create(vm, globalObject, WebCore::JSSHA224Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA224Prototype*>(prototype));
+ return WebCore::JSSHA224Constructor::create(vm, globalObject, WebCore::JSSHA224Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA224Prototype*>(prototype));
}
JSObject* JSSHA224::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -8862,114 +8514,105 @@ JSObject* JSSHA224::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSSHA224Prototype::create(vm, globalObject, JSSHA224Prototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue SHA224__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSSHA224Structure();
- JSSHA224* instance = JSSHA224::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSSHA256Prototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSSHA256Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSSHA256Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA256Prototype>(vm)) JSSHA256Prototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSSHA256Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue SHA224__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSSHA224Structure();
+ JSSHA224* instance = JSSHA224::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSSHA256Prototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSSHA256Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSSHA256Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA256Prototype>(vm)) JSSHA256Prototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSSHA256Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSSHA256Constructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSSHA256Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA256Prototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA256Constructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA256Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA256Constructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA256Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA256Constructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSSHA256Constructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSSHA256Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA256Prototype* prototype);
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA256Constructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA256Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA256Constructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA256Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA256Constructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSSHA256Constructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype);
+};
extern "C" void* SHA256Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsSHA256Constructor);
extern "C" void SHA256Class__finalize(void*);
-
extern "C" JSC::EncodedJSValue SHA256Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SHA256Prototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue SHA256Prototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA256Prototype__digestCallback);
-
extern "C" EncodedJSValue SHA256Prototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA256Prototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA256Prototype, JSSHA256Prototype::Base);
-
- static const HashTableValue JSSHA256PrototypeTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA256Prototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA256Prototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA256Prototype__updateCallback, 1 } }
+static const HashTableValue JSSHA256PrototypeTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA256Prototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA256Prototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA256Prototype__updateCallback, 1 } }
};
-
-
const ClassInfo JSSHA256Prototype::s_info = { "SHA256"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA256Prototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsSHA256Constructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -8980,14 +8623,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA256Constructor, (JSGlobalObject * lexicalGlobalObj
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSSHA256Constructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SHA256Prototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSHA256* thisObject = jsCast<JSSHA256*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -8995,41 +8636,38 @@ JSC_DEFINE_CUSTOM_GETTER(SHA256Prototype__byteLengthGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSSHA256* thisObject = jsDynamicCast<JSSHA256*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA256* thisObject = jsDynamicCast<JSSHA256*>(callFrame->thisValue());
- return SHA256Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSSHA256* thisObject = jsDynamicCast<JSSHA256*>(callFrame->thisValue());
+ return SHA256Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA256Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA256* thisObject = jsDynamicCast<JSSHA256*>(callFrame->thisValue());
- return SHA256Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return SHA256Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSSHA256Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -9041,12 +8679,11 @@ void JSSHA256Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalO
extern "C" JSC_DECLARE_CUSTOM_GETTER(SHA256Class__getByteLengthStatic);
extern "C" JSC_DECLARE_HOST_FUNCTION(SHA256Class__hash);
- static const HashTableValue JSSHA256ConstructorTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA256Class__getByteLengthStatic, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA256Class__hash, 2 } }
+static const HashTableValue JSSHA256ConstructorTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA256Class__getByteLengthStatic, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA256Class__hash, 2 } }
};
-
void JSSHA256Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype)
{
Base::finishCreation(vm, 0, "SHA256"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -9055,62 +8692,59 @@ void JSSHA256Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje
ASSERT(inherits(info()));
}
-JSSHA256Constructor::JSSHA256Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSSHA256Constructor::JSSHA256Constructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSSHA256Constructor* JSSHA256Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA256Prototype* prototype) {
+JSSHA256Constructor* JSSHA256Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA256Prototype* prototype)
+{
JSSHA256Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA256Constructor>(vm)) JSSHA256Constructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA256Constructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSSHA256Constructor();
Structure* structure = globalObject->JSSHA256Structure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSSHA256Structure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSSHA256Structure());
}
void* ptr = SHA256Class__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSSHA256* instance = JSSHA256::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSSHA256Constructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA256Prototype* prototype)
{
-
}
const ClassInfo JSSHA256Constructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA256Constructor) };
-
- extern "C" EncodedJSValue SHA256__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue SHA256__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSSHA256Constructor());
- }
+}
JSSHA256::~JSSHA256()
{
@@ -9122,7 +8756,7 @@ void JSSHA256::destroy(JSCell* cell)
{
static_cast<JSSHA256*>(cell)->JSSHA256::~JSSHA256();
}
-
+
const ClassInfo JSSHA256::s_info = { "SHA256"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA256) };
void JSSHA256::finishCreation(VM& vm)
@@ -9131,36 +8765,37 @@ void JSSHA256::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSSHA256* JSSHA256::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSSHA256* ptr = new (NotNull, JSC::allocateCell<JSSHA256>(vm)) JSSHA256(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSSHA256* JSSHA256::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSSHA256* ptr = new (NotNull, JSC::allocateCell<JSSHA256>(vm)) JSSHA256(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* SHA256__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* SHA256__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSSHA256* object = JSC::jsDynamicCast<JSSHA256*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSSHA256* object = JSC::jsDynamicCast<JSSHA256*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool SHA256__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSSHA256* object = JSC::jsDynamicCast<JSSHA256*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool SHA256__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSSHA256* object = JSC::jsDynamicCast<JSSHA256*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t SHA256__ptrOffset = JSSHA256::offsetOfWrapped();
@@ -9176,7 +8811,7 @@ void JSSHA256::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSSHA256::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSSHA256Constructor::create(vm, globalObject, WebCore::JSSHA256Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA256Prototype*>(prototype));
+ return WebCore::JSSHA256Constructor::create(vm, globalObject, WebCore::JSSHA256Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA256Prototype*>(prototype));
}
JSObject* JSSHA256::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -9184,114 +8819,105 @@ JSObject* JSSHA256::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSSHA256Prototype::create(vm, globalObject, JSSHA256Prototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue SHA256__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSSHA256Structure();
- JSSHA256* instance = JSSHA256::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSSHA384Prototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSSHA384Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSSHA384Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA384Prototype>(vm)) JSSHA384Prototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSSHA384Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue SHA256__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSSHA256Structure();
+ JSSHA256* instance = JSSHA256::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSSHA384Prototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSSHA384Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSSHA384Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA384Prototype>(vm)) JSSHA384Prototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSSHA384Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSSHA384Constructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSSHA384Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA384Prototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA384Constructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA384Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA384Constructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA384Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA384Constructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSSHA384Constructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSSHA384Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA384Prototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA384Constructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA384Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA384Constructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA384Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA384Constructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSSHA384Constructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype);
+};
extern "C" void* SHA384Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsSHA384Constructor);
extern "C" void SHA384Class__finalize(void*);
-
extern "C" JSC::EncodedJSValue SHA384Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SHA384Prototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue SHA384Prototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA384Prototype__digestCallback);
-
extern "C" EncodedJSValue SHA384Prototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA384Prototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA384Prototype, JSSHA384Prototype::Base);
-
- static const HashTableValue JSSHA384PrototypeTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA384Prototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA384Prototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA384Prototype__updateCallback, 1 } }
+static const HashTableValue JSSHA384PrototypeTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA384Prototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA384Prototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA384Prototype__updateCallback, 1 } }
};
-
-
const ClassInfo JSSHA384Prototype::s_info = { "SHA384"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA384Prototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsSHA384Constructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -9302,14 +8928,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA384Constructor, (JSGlobalObject * lexicalGlobalObj
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSSHA384Constructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SHA384Prototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSHA384* thisObject = jsCast<JSSHA384*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -9317,41 +8941,38 @@ JSC_DEFINE_CUSTOM_GETTER(SHA384Prototype__byteLengthGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSSHA384* thisObject = jsDynamicCast<JSSHA384*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA384* thisObject = jsDynamicCast<JSSHA384*>(callFrame->thisValue());
- return SHA384Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSSHA384* thisObject = jsDynamicCast<JSSHA384*>(callFrame->thisValue());
+ return SHA384Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA384Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA384* thisObject = jsDynamicCast<JSSHA384*>(callFrame->thisValue());
- return SHA384Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return SHA384Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSSHA384Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -9363,12 +8984,11 @@ void JSSHA384Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalO
extern "C" JSC_DECLARE_CUSTOM_GETTER(SHA384Class__getByteLengthStatic);
extern "C" JSC_DECLARE_HOST_FUNCTION(SHA384Class__hash);
- static const HashTableValue JSSHA384ConstructorTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA384Class__getByteLengthStatic, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA384Class__hash, 2 } }
+static const HashTableValue JSSHA384ConstructorTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA384Class__getByteLengthStatic, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA384Class__hash, 2 } }
};
-
void JSSHA384Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype)
{
Base::finishCreation(vm, 0, "SHA384"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -9377,62 +8997,59 @@ void JSSHA384Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje
ASSERT(inherits(info()));
}
-JSSHA384Constructor::JSSHA384Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSSHA384Constructor::JSSHA384Constructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSSHA384Constructor* JSSHA384Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA384Prototype* prototype) {
+JSSHA384Constructor* JSSHA384Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA384Prototype* prototype)
+{
JSSHA384Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA384Constructor>(vm)) JSSHA384Constructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA384Constructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSSHA384Constructor();
Structure* structure = globalObject->JSSHA384Structure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSSHA384Structure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSSHA384Structure());
}
void* ptr = SHA384Class__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSSHA384* instance = JSSHA384::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSSHA384Constructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA384Prototype* prototype)
{
-
}
const ClassInfo JSSHA384Constructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA384Constructor) };
-
- extern "C" EncodedJSValue SHA384__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue SHA384__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSSHA384Constructor());
- }
+}
JSSHA384::~JSSHA384()
{
@@ -9444,7 +9061,7 @@ void JSSHA384::destroy(JSCell* cell)
{
static_cast<JSSHA384*>(cell)->JSSHA384::~JSSHA384();
}
-
+
const ClassInfo JSSHA384::s_info = { "SHA384"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA384) };
void JSSHA384::finishCreation(VM& vm)
@@ -9453,36 +9070,37 @@ void JSSHA384::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSSHA384* JSSHA384::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSSHA384* ptr = new (NotNull, JSC::allocateCell<JSSHA384>(vm)) JSSHA384(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSSHA384* JSSHA384::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSSHA384* ptr = new (NotNull, JSC::allocateCell<JSSHA384>(vm)) JSSHA384(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* SHA384__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* SHA384__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSSHA384* object = JSC::jsDynamicCast<JSSHA384*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSSHA384* object = JSC::jsDynamicCast<JSSHA384*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool SHA384__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSSHA384* object = JSC::jsDynamicCast<JSSHA384*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool SHA384__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSSHA384* object = JSC::jsDynamicCast<JSSHA384*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t SHA384__ptrOffset = JSSHA384::offsetOfWrapped();
@@ -9498,7 +9116,7 @@ void JSSHA384::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSSHA384::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSSHA384Constructor::create(vm, globalObject, WebCore::JSSHA384Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA384Prototype*>(prototype));
+ return WebCore::JSSHA384Constructor::create(vm, globalObject, WebCore::JSSHA384Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA384Prototype*>(prototype));
}
JSObject* JSSHA384::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -9506,114 +9124,105 @@ JSObject* JSSHA384::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSSHA384Prototype::create(vm, globalObject, JSSHA384Prototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue SHA384__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSSHA384Structure();
- JSSHA384* instance = JSSHA384::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSSHA512Prototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSSHA512Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSSHA512Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA512Prototype>(vm)) JSSHA512Prototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSSHA512Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue SHA384__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSSHA384Structure();
+ JSSHA384* instance = JSSHA384::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSSHA512Prototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSSHA512Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSSHA512Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA512Prototype>(vm)) JSSHA512Prototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSSHA512Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSSHA512Constructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSSHA512Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512Prototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA512Constructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA512Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512Constructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA512Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512Constructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSSHA512Constructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSSHA512Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512Prototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA512Constructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA512Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512Constructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA512Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512Constructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSSHA512Constructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype);
+};
extern "C" void* SHA512Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsSHA512Constructor);
extern "C" void SHA512Class__finalize(void*);
-
extern "C" JSC::EncodedJSValue SHA512Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SHA512Prototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue SHA512Prototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA512Prototype__digestCallback);
-
extern "C" EncodedJSValue SHA512Prototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA512Prototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA512Prototype, JSSHA512Prototype::Base);
-
- static const HashTableValue JSSHA512PrototypeTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA512Prototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512Prototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512Prototype__updateCallback, 1 } }
+static const HashTableValue JSSHA512PrototypeTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA512Prototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512Prototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512Prototype__updateCallback, 1 } }
};
-
-
const ClassInfo JSSHA512Prototype::s_info = { "SHA512"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA512Prototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsSHA512Constructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -9624,14 +9233,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA512Constructor, (JSGlobalObject * lexicalGlobalObj
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSSHA512Constructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SHA512Prototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSHA512* thisObject = jsCast<JSSHA512*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -9639,41 +9246,38 @@ JSC_DEFINE_CUSTOM_GETTER(SHA512Prototype__byteLengthGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
- JSSHA512* thisObject = jsDynamicCast<JSSHA512*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA512* thisObject = jsDynamicCast<JSSHA512*>(callFrame->thisValue());
- return SHA512Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSSHA512* thisObject = jsDynamicCast<JSSHA512*>(callFrame->thisValue());
+ return SHA512Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA512Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA512* thisObject = jsDynamicCast<JSSHA512*>(callFrame->thisValue());
- return SHA512Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return SHA512Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSSHA512Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -9685,12 +9289,11 @@ void JSSHA512Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalO
extern "C" JSC_DECLARE_CUSTOM_GETTER(SHA512Class__getByteLengthStatic);
extern "C" JSC_DECLARE_HOST_FUNCTION(SHA512Class__hash);
- static const HashTableValue JSSHA512ConstructorTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA512Class__getByteLengthStatic, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512Class__hash, 2 } }
+static const HashTableValue JSSHA512ConstructorTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA512Class__getByteLengthStatic, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512Class__hash, 2 } }
};
-
void JSSHA512Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype)
{
Base::finishCreation(vm, 0, "SHA512"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -9699,62 +9302,59 @@ void JSSHA512Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObje
ASSERT(inherits(info()));
}
-JSSHA512Constructor::JSSHA512Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSSHA512Constructor::JSSHA512Constructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSSHA512Constructor* JSSHA512Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512Prototype* prototype) {
+JSSHA512Constructor* JSSHA512Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512Prototype* prototype)
+{
JSSHA512Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA512Constructor>(vm)) JSSHA512Constructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA512Constructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSSHA512Constructor();
Structure* structure = globalObject->JSSHA512Structure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSSHA512Structure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSSHA512Structure());
}
void* ptr = SHA512Class__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSSHA512* instance = JSSHA512::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSSHA512Constructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512Prototype* prototype)
{
-
}
const ClassInfo JSSHA512Constructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA512Constructor) };
-
- extern "C" EncodedJSValue SHA512__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue SHA512__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSSHA512Constructor());
- }
+}
JSSHA512::~JSSHA512()
{
@@ -9766,7 +9366,7 @@ void JSSHA512::destroy(JSCell* cell)
{
static_cast<JSSHA512*>(cell)->JSSHA512::~JSSHA512();
}
-
+
const ClassInfo JSSHA512::s_info = { "SHA512"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA512) };
void JSSHA512::finishCreation(VM& vm)
@@ -9775,36 +9375,37 @@ void JSSHA512::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSSHA512* JSSHA512::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSSHA512* ptr = new (NotNull, JSC::allocateCell<JSSHA512>(vm)) JSSHA512(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSSHA512* JSSHA512::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSSHA512* ptr = new (NotNull, JSC::allocateCell<JSSHA512>(vm)) JSSHA512(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* SHA512__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* SHA512__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSSHA512* object = JSC::jsDynamicCast<JSSHA512*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSSHA512* object = JSC::jsDynamicCast<JSSHA512*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool SHA512__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSSHA512* object = JSC::jsDynamicCast<JSSHA512*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool SHA512__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSSHA512* object = JSC::jsDynamicCast<JSSHA512*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t SHA512__ptrOffset = JSSHA512::offsetOfWrapped();
@@ -9820,7 +9421,7 @@ void JSSHA512::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSSHA512::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSSHA512Constructor::create(vm, globalObject, WebCore::JSSHA512Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA512Prototype*>(prototype));
+ return WebCore::JSSHA512Constructor::create(vm, globalObject, WebCore::JSSHA512Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA512Prototype*>(prototype));
}
JSObject* JSSHA512::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -9828,114 +9429,105 @@ JSObject* JSSHA512::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSSHA512Prototype::create(vm, globalObject, JSSHA512Prototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue SHA512__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSSHA512Structure();
- JSSHA512* instance = JSSHA512::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSSHA512_256Prototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSSHA512_256Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSSHA512_256Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256Prototype>(vm)) JSSHA512_256Prototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSSHA512_256Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue SHA512__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSSHA512Structure();
+ JSSHA512* instance = JSSHA512::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSSHA512_256Prototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSSHA512_256Prototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSSHA512_256Prototype* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256Prototype>(vm)) JSSHA512_256Prototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSSHA512_256Prototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSSHA512_256Constructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSSHA512_256Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512_256Prototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA512_256Constructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA512_256Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512_256Constructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA512_256Constructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512_256Constructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSSHA512_256Constructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSSHA512_256Constructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512_256Prototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA512_256Constructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA512_256Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512_256Constructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA512_256Constructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512_256Constructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSSHA512_256Constructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype);
+};
extern "C" void* SHA512_256Class__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsSHA512_256Constructor);
extern "C" void SHA512_256Class__finalize(void*);
-
extern "C" JSC::EncodedJSValue SHA512_256Prototype__getByteLength(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SHA512_256Prototype__byteLengthGetterWrap);
-
extern "C" EncodedJSValue SHA512_256Prototype__digest(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA512_256Prototype__digestCallback);
-
extern "C" EncodedJSValue SHA512_256Prototype__update(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SHA512_256Prototype__updateCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSHA512_256Prototype, JSSHA512_256Prototype::Base);
-
- static const HashTableValue JSSHA512_256PrototypeTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA512_256Prototype__byteLengthGetterWrap, 0 } } ,
-{ "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512_256Prototype__digestCallback, 0 } } ,
-{ "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512_256Prototype__updateCallback, 1 } }
+static const HashTableValue JSSHA512_256PrototypeTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA512_256Prototype__byteLengthGetterWrap, 0 } },
+ { "digest"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512_256Prototype__digestCallback, 0 } },
+ { "update"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512_256Prototype__updateCallback, 1 } }
};
-
-
const ClassInfo JSSHA512_256Prototype::s_info = { "SHA512_256"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA512_256Prototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsSHA512_256Constructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -9946,14 +9538,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsSHA512_256Constructor, (JSGlobalObject * lexicalGloba
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSSHA512_256Constructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SHA512_256Prototype__byteLengthGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSHA512_256* thisObject = jsCast<JSSHA512_256*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -9961,41 +9551,38 @@ JSC_DEFINE_CUSTOM_GETTER(SHA512_256Prototype__byteLengthGetterWrap, (JSGlobalObj
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
- JSSHA512_256* thisObject = jsDynamicCast<JSSHA512_256*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__digestCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA512_256* thisObject = jsDynamicCast<JSSHA512_256*>(callFrame->thisValue());
- return SHA512_256Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSSHA512_256* thisObject = jsDynamicCast<JSSHA512_256*>(callFrame->thisValue());
+ return SHA512_256Prototype__digest(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(SHA512_256Prototype__updateCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSSHA512_256* thisObject = jsDynamicCast<JSSHA512_256*>(callFrame->thisValue());
- return SHA512_256Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return SHA512_256Prototype__update(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSSHA512_256Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -10007,12 +9594,11 @@ void JSSHA512_256Prototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* glo
extern "C" JSC_DECLARE_CUSTOM_GETTER(SHA512_256Class__getByteLengthStatic);
extern "C" JSC_DECLARE_HOST_FUNCTION(SHA512_256Class__hash);
- static const HashTableValue JSSHA512_256ConstructorTableValues[] = {
-{ "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA512_256Class__getByteLengthStatic, 0 } } ,
-{ "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512_256Class__hash, 2 } }
+static const HashTableValue JSSHA512_256ConstructorTableValues[] = {
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SHA512_256Class__getByteLengthStatic, 0 } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SHA512_256Class__hash, 2 } }
};
-
void JSSHA512_256Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype)
{
Base::finishCreation(vm, 0, "SHA512_256"_s, PropertyAdditionMode::WithoutStructureTransition);
@@ -10021,62 +9607,59 @@ void JSSHA512_256Constructor::finishCreation(VM& vm, JSC::JSGlobalObject* global
ASSERT(inherits(info()));
}
-JSSHA512_256Constructor::JSSHA512_256Constructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSSHA512_256Constructor::JSSHA512_256Constructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSSHA512_256Constructor* JSSHA512_256Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512_256Prototype* prototype) {
+JSSHA512_256Constructor* JSSHA512_256Constructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSSHA512_256Prototype* prototype)
+{
JSSHA512_256Constructor* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256Constructor>(vm)) JSSHA512_256Constructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSSHA512_256Constructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSSHA512_256Constructor();
Structure* structure = globalObject->JSSHA512_256Structure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSSHA512_256Structure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSSHA512_256Structure());
}
void* ptr = SHA512_256Class__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSSHA512_256* instance = JSSHA512_256::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSSHA512_256Constructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSSHA512_256Prototype* prototype)
{
-
}
const ClassInfo JSSHA512_256Constructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA512_256Constructor) };
-
- extern "C" EncodedJSValue SHA512_256__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue SHA512_256__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSSHA512_256Constructor());
- }
+}
JSSHA512_256::~JSSHA512_256()
{
@@ -10088,7 +9671,7 @@ void JSSHA512_256::destroy(JSCell* cell)
{
static_cast<JSSHA512_256*>(cell)->JSSHA512_256::~JSSHA512_256();
}
-
+
const ClassInfo JSSHA512_256::s_info = { "SHA512_256"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSHA512_256) };
void JSSHA512_256::finishCreation(VM& vm)
@@ -10097,36 +9680,37 @@ void JSSHA512_256::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSSHA512_256* JSSHA512_256::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSSHA512_256* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256>(vm)) JSSHA512_256(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSSHA512_256* JSSHA512_256::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSSHA512_256* ptr = new (NotNull, JSC::allocateCell<JSSHA512_256>(vm)) JSSHA512_256(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* SHA512_256__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* SHA512_256__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
+
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSSHA512_256* object = JSC::jsDynamicCast<JSSHA512_256*>(cell);
- JSC::JSCell* cell = decodedValue.asCell();
- JSSHA512_256* object = JSC::jsDynamicCast<JSSHA512_256*>(cell);
+ if (!object)
+ return nullptr;
- if (!object)
- return nullptr;
-
- return object->wrapped();
+ return object->wrapped();
}
-extern "C" bool SHA512_256__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSSHA512_256* object = JSC::jsDynamicCast<JSSHA512_256*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
-}
+extern "C" bool SHA512_256__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSSHA512_256* object = JSC::jsDynamicCast<JSSHA512_256*>(JSValue::decode(value));
+ if (!object)
+ return false;
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t SHA512_256__ptrOffset = JSSHA512_256::offsetOfWrapped();
@@ -10142,7 +9726,7 @@ void JSSHA512_256::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSSHA512_256::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSSHA512_256Constructor::create(vm, globalObject, WebCore::JSSHA512_256Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA512_256Prototype*>(prototype));
+ return WebCore::JSSHA512_256Constructor::create(vm, globalObject, WebCore::JSSHA512_256Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSSHA512_256Prototype*>(prototype));
}
JSObject* JSSHA512_256::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -10150,134 +9734,123 @@ JSObject* JSSHA512_256::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSSHA512_256Prototype::create(vm, globalObject, JSSHA512_256Prototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue SHA512_256__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSSHA512_256Structure();
- JSSHA512_256* instance = JSSHA512_256::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSServerWebSocketPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSServerWebSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSServerWebSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocketPrototype>(vm)) JSServerWebSocketPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSServerWebSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue SHA512_256__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSSHA512_256Structure();
+ JSSHA512_256* instance = JSSHA512_256::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSServerWebSocketPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSServerWebSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSServerWebSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocketPrototype>(vm)) JSServerWebSocketPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSServerWebSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSServerWebSocketConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSServerWebSocketConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSServerWebSocketPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSServerWebSocketConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForServerWebSocketConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForServerWebSocketConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForServerWebSocketConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForServerWebSocketConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSServerWebSocketConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSServerWebSocketConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSServerWebSocketPrototype* prototype);
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSServerWebSocketConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForServerWebSocketConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForServerWebSocketConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForServerWebSocketConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForServerWebSocketConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSServerWebSocketConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype);
+};
extern "C" void* ServerWebSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsServerWebSocketConstructor);
extern "C" void ServerWebSocketClass__finalize(void*);
-
extern "C" JSC::EncodedJSValue ServerWebSocketPrototype__getBinaryType(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ServerWebSocketPrototype__binaryTypeGetterWrap);
-
extern "C" bool ServerWebSocketPrototype__setBinaryType(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::EncodedJSValue value);
JSC_DECLARE_CUSTOM_SETTER(ServerWebSocketPrototype__binaryTypeSetterWrap);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__close(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__closeCallback);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__cork(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__corkCallback);
-
extern "C" JSC::EncodedJSValue ServerWebSocketPrototype__getData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ServerWebSocketPrototype__dataGetterWrap);
-
extern "C" bool ServerWebSocketPrototype__setData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::EncodedJSValue value);
JSC_DECLARE_CUSTOM_SETTER(ServerWebSocketPrototype__dataSetterWrap);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__getBufferedAmount(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__getBufferedAmountCallback);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__isSubscribed(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__isSubscribedCallback);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__publish(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__publishCallback);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__publishBinary(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__publishBinaryCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(ServerWebSocketPrototype__publishBinaryWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSString* arg0, JSC::JSUint8Array* arg1));
- extern "C" EncodedJSValue ServerWebSocketPrototype__publishBinaryWithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject, JSC::JSString* arg0, JSC::JSUint8Array* arg1);
+extern "C" EncodedJSValue ServerWebSocketPrototype__publishBinaryWithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSString* arg0, JSC::JSUint8Array* arg1);
- static const JSC::DOMJIT::Signature DOMJITSignatureForServerWebSocketPrototype__publishBinary(ServerWebSocketPrototype__publishBinaryWithoutTypeChecksWrapper,
- JSServerWebSocket::info(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- JSC::SpecHeapTop, JSC::SpecString, JSC::SpecUint8Array);
+static const JSC::DOMJIT::Signature DOMJITSignatureForServerWebSocketPrototype__publishBinary(ServerWebSocketPrototype__publishBinaryWithoutTypeChecksWrapper,
+ JSServerWebSocket::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ JSC::SpecHeapTop, JSC::SpecString, JSC::SpecUint8Array);
JSC_DEFINE_JIT_OPERATION(ServerWebSocketPrototype__publishBinaryWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSString* arg0, JSC::JSUint8Array* arg1))
{
@@ -10292,14 +9865,13 @@ JSC_DEFINE_JIT_OPERATION(ServerWebSocketPrototype__publishBinaryWithoutTypeCheck
extern "C" EncodedJSValue ServerWebSocketPrototype__publishText(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__publishTextCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(ServerWebSocketPrototype__publishTextWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSString* arg0, JSC::JSString* arg1));
- extern "C" EncodedJSValue ServerWebSocketPrototype__publishTextWithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject, JSC::JSString* arg0, JSC::JSString* arg1);
+extern "C" EncodedJSValue ServerWebSocketPrototype__publishTextWithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSString* arg0, JSC::JSString* arg1);
- static const JSC::DOMJIT::Signature DOMJITSignatureForServerWebSocketPrototype__publishText(ServerWebSocketPrototype__publishTextWithoutTypeChecksWrapper,
- JSServerWebSocket::info(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- JSC::SpecHeapTop, JSC::SpecString, JSC::SpecString);
+static const JSC::DOMJIT::Signature DOMJITSignatureForServerWebSocketPrototype__publishText(ServerWebSocketPrototype__publishTextWithoutTypeChecksWrapper,
+ JSServerWebSocket::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ JSC::SpecHeapTop, JSC::SpecString, JSC::SpecString);
JSC_DEFINE_JIT_OPERATION(ServerWebSocketPrototype__publishTextWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSString* arg0, JSC::JSString* arg1))
{
@@ -10314,26 +9886,22 @@ JSC_DEFINE_JIT_OPERATION(ServerWebSocketPrototype__publishTextWithoutTypeChecksW
extern "C" JSC::EncodedJSValue ServerWebSocketPrototype__getReadyState(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ServerWebSocketPrototype__readyStateGetterWrap);
-
extern "C" JSC::EncodedJSValue ServerWebSocketPrototype__getRemoteAddress(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(ServerWebSocketPrototype__remoteAddressGetterWrap);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__send(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__sendCallback);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__sendBinary(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__sendBinaryCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(ServerWebSocketPrototype__sendBinaryWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg0, bool arg1));
- extern "C" EncodedJSValue ServerWebSocketPrototype__sendBinaryWithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject, JSC::JSUint8Array* arg0, bool arg1);
+extern "C" EncodedJSValue ServerWebSocketPrototype__sendBinaryWithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSUint8Array* arg0, bool arg1);
- static const JSC::DOMJIT::Signature DOMJITSignatureForServerWebSocketPrototype__sendBinary(ServerWebSocketPrototype__sendBinaryWithoutTypeChecksWrapper,
- JSServerWebSocket::info(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- JSC::SpecHeapTop, JSC::SpecUint8Array, JSC::SpecBoolean);
+static const JSC::DOMJIT::Signature DOMJITSignatureForServerWebSocketPrototype__sendBinary(ServerWebSocketPrototype__sendBinaryWithoutTypeChecksWrapper,
+ JSServerWebSocket::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ JSC::SpecHeapTop, JSC::SpecUint8Array, JSC::SpecBoolean);
JSC_DEFINE_JIT_OPERATION(ServerWebSocketPrototype__sendBinaryWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg0, bool arg1))
{
@@ -10348,14 +9916,13 @@ JSC_DEFINE_JIT_OPERATION(ServerWebSocketPrototype__sendBinaryWithoutTypeChecksWr
extern "C" EncodedJSValue ServerWebSocketPrototype__sendText(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__sendTextCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(ServerWebSocketPrototype__sendTextWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSString* arg0, bool arg1));
- extern "C" EncodedJSValue ServerWebSocketPrototype__sendTextWithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject, JSC::JSString* arg0, bool arg1);
+extern "C" EncodedJSValue ServerWebSocketPrototype__sendTextWithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSString* arg0, bool arg1);
- static const JSC::DOMJIT::Signature DOMJITSignatureForServerWebSocketPrototype__sendText(ServerWebSocketPrototype__sendTextWithoutTypeChecksWrapper,
- JSServerWebSocket::info(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- JSC::SpecHeapTop, JSC::SpecString, JSC::SpecBoolean);
+static const JSC::DOMJIT::Signature DOMJITSignatureForServerWebSocketPrototype__sendText(ServerWebSocketPrototype__sendTextWithoutTypeChecksWrapper,
+ JSServerWebSocket::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ JSC::SpecHeapTop, JSC::SpecString, JSC::SpecBoolean);
JSC_DEFINE_JIT_OPERATION(ServerWebSocketPrototype__sendTextWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSString* arg0, bool arg1))
{
@@ -10370,39 +9937,32 @@ JSC_DEFINE_JIT_OPERATION(ServerWebSocketPrototype__sendTextWithoutTypeChecksWrap
extern "C" EncodedJSValue ServerWebSocketPrototype__subscribe(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__subscribeCallback);
-
extern "C" EncodedJSValue ServerWebSocketPrototype__unsubscribe(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(ServerWebSocketPrototype__unsubscribeCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSServerWebSocketPrototype, JSServerWebSocketPrototype::Base);
-
- static const HashTableValue JSServerWebSocketPrototypeTableValues[] = {
-{ "binaryType"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ServerWebSocketPrototype__binaryTypeGetterWrap, ServerWebSocketPrototype__binaryTypeSetterWrap } } ,
-{ "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__closeCallback, 1 } } ,
-{ "cork"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__corkCallback, 1 } } ,
-{ "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ServerWebSocketPrototype__dataGetterWrap, ServerWebSocketPrototype__dataSetterWrap } } ,
-{ "getBufferedAmount"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__getBufferedAmountCallback, 0 } } ,
-{ "isSubscribed"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__isSubscribedCallback, 1 } } ,
-{ "publish"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__publishCallback, 3 } } ,
-{ "publishBinary"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ServerWebSocketPrototype__publishBinaryCallback, &DOMJITSignatureForServerWebSocketPrototype__publishBinary } } ,
-{ "publishText"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ServerWebSocketPrototype__publishTextCallback, &DOMJITSignatureForServerWebSocketPrototype__publishText } } ,
-{ "readyState"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ServerWebSocketPrototype__readyStateGetterWrap, 0 } } ,
-{ "remoteAddress"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ServerWebSocketPrototype__remoteAddressGetterWrap, 0 } } ,
-{ "send"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__sendCallback, 2 } } ,
-{ "sendBinary"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ServerWebSocketPrototype__sendBinaryCallback, &DOMJITSignatureForServerWebSocketPrototype__sendBinary } } ,
-{ "sendText"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ServerWebSocketPrototype__sendTextCallback, &DOMJITSignatureForServerWebSocketPrototype__sendText } } ,
-{ "subscribe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__subscribeCallback, 1 } } ,
-{ "unsubscribe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__unsubscribeCallback, 1 } }
+static const HashTableValue JSServerWebSocketPrototypeTableValues[] = {
+ { "binaryType"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ServerWebSocketPrototype__binaryTypeGetterWrap, ServerWebSocketPrototype__binaryTypeSetterWrap } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__closeCallback, 1 } },
+ { "cork"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__corkCallback, 1 } },
+ { "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ServerWebSocketPrototype__dataGetterWrap, ServerWebSocketPrototype__dataSetterWrap } },
+ { "getBufferedAmount"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__getBufferedAmountCallback, 0 } },
+ { "isSubscribed"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__isSubscribedCallback, 1 } },
+ { "publish"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__publishCallback, 3 } },
+ { "publishBinary"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ServerWebSocketPrototype__publishBinaryCallback, &DOMJITSignatureForServerWebSocketPrototype__publishBinary } },
+ { "publishText"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ServerWebSocketPrototype__publishTextCallback, &DOMJITSignatureForServerWebSocketPrototype__publishText } },
+ { "readyState"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ServerWebSocketPrototype__readyStateGetterWrap, 0 } },
+ { "remoteAddress"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, ServerWebSocketPrototype__remoteAddressGetterWrap, 0 } },
+ { "send"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__sendCallback, 2 } },
+ { "sendBinary"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ServerWebSocketPrototype__sendBinaryCallback, &DOMJITSignatureForServerWebSocketPrototype__sendBinary } },
+ { "sendText"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ServerWebSocketPrototype__sendTextCallback, &DOMJITSignatureForServerWebSocketPrototype__sendText } },
+ { "subscribe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__subscribeCallback, 1 } },
+ { "unsubscribe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, ServerWebSocketPrototype__unsubscribeCallback, 1 } }
};
-
-
const ClassInfo JSServerWebSocketPrototype::s_info = { "ServerWebSocket"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSServerWebSocketPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsServerWebSocketConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -10413,14 +9973,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsServerWebSocketConstructor, (JSGlobalObject * lexical
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSServerWebSocketConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__binaryTypeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSServerWebSocket* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10428,7 +9986,6 @@ JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__binaryTypeGetterWrap, (JSGlob
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_SETTER(ServerWebSocketPrototype__binaryTypeSetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName))
{
@@ -10441,75 +9998,68 @@ JSC_DEFINE_CUSTOM_SETTER(ServerWebSocketPrototype__binaryTypeSetterWrap, (JSGlob
RELEASE_AND_RETURN(throwScope, result);
}
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__closeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
-
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__close(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__corkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__close(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__corkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__cork(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ServerWebSocketPrototype__cork(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__dataGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSServerWebSocket* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_data.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- ServerWebSocketPrototype__getData(thisObject->wrapped(), globalObject)
- );
+ ServerWebSocketPrototype__getData(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_data.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void ServerWebSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
+ thisObject->m_data.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ServerWebSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
- thisObject->m_data.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ServerWebSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ServerWebSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_data.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_SETTER(ServerWebSocketPrototype__dataSetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName))
{
@@ -10522,96 +10072,90 @@ JSC_DEFINE_CUSTOM_SETTER(ServerWebSocketPrototype__dataSetterWrap, (JSGlobalObje
RELEASE_AND_RETURN(throwScope, result);
}
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__getBufferedAmountCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__getBufferedAmountCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
-
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__getBufferedAmount(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__isSubscribedCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__getBufferedAmount(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__isSubscribedCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__isSubscribed(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__isSubscribed(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__publish(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishBinaryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__publish(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishBinaryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__publishBinary(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishTextCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__publishBinary(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__publishTextCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__publishText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ServerWebSocketPrototype__publishText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__readyStateGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSServerWebSocket* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -10619,127 +10163,117 @@ JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__readyStateGetterWrap, (JSGlob
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(ServerWebSocketPrototype__remoteAddressGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSServerWebSocket* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_remoteAddress.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- ServerWebSocketPrototype__getRemoteAddress(thisObject->wrapped(), globalObject)
- );
+ ServerWebSocketPrototype__getRemoteAddress(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_remoteAddress.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void ServerWebSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
+ thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void ServerWebSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
- thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue ServerWebSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue ServerWebSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSServerWebSocket*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_remoteAddress.get());
- }
-
-
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__send(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendBinaryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__send(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendBinaryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__sendBinary(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendTextCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__sendBinary(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__sendTextCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__sendText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__subscribeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__sendText(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__subscribeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__subscribe(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__unsubscribeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
+ return ServerWebSocketPrototype__subscribe(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(ServerWebSocketPrototype__unsubscribeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSServerWebSocket* thisObject = jsDynamicCast<JSServerWebSocket*>(callFrame->thisValue());
- return ServerWebSocketPrototype__unsubscribe(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return ServerWebSocketPrototype__unsubscribe(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSServerWebSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -10751,67 +10285,64 @@ void JSServerWebSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject
void JSServerWebSocketConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype)
{
Base::finishCreation(vm, 0, "ServerWebSocket"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSServerWebSocketConstructor::JSServerWebSocketConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSServerWebSocketConstructor::JSServerWebSocketConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSServerWebSocketConstructor* JSServerWebSocketConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSServerWebSocketPrototype* prototype) {
+JSServerWebSocketConstructor* JSServerWebSocketConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSServerWebSocketPrototype* prototype)
+{
JSServerWebSocketConstructor* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocketConstructor>(vm)) JSServerWebSocketConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSServerWebSocketConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSServerWebSocketConstructor();
Structure* structure = globalObject->JSServerWebSocketStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSServerWebSocketStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSServerWebSocketStructure());
}
void* ptr = ServerWebSocketClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSServerWebSocket* instance = JSServerWebSocket::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSServerWebSocketConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSServerWebSocketPrototype* prototype)
{
-
}
const ClassInfo JSServerWebSocketConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSServerWebSocketConstructor) };
-
- extern "C" EncodedJSValue ServerWebSocket__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue ServerWebSocket__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSServerWebSocketConstructor());
- }
+}
JSServerWebSocket::~JSServerWebSocket()
{
@@ -10823,7 +10354,7 @@ void JSServerWebSocket::destroy(JSCell* cell)
{
static_cast<JSServerWebSocket*>(cell)->JSServerWebSocket::~JSServerWebSocket();
}
-
+
const ClassInfo JSServerWebSocket::s_info = { "ServerWebSocket"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSServerWebSocket) };
void JSServerWebSocket::finishCreation(VM& vm)
@@ -10832,36 +10363,37 @@ void JSServerWebSocket::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSServerWebSocket* JSServerWebSocket::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSServerWebSocket* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocket>(vm)) JSServerWebSocket(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSServerWebSocket* JSServerWebSocket::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSServerWebSocket* ptr = new (NotNull, JSC::allocateCell<JSServerWebSocket>(vm)) JSServerWebSocket(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* ServerWebSocket__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* ServerWebSocket__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSServerWebSocket* object = JSC::jsDynamicCast<JSServerWebSocket*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSServerWebSocket* object = JSC::jsDynamicCast<JSServerWebSocket*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool ServerWebSocket__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSServerWebSocket* object = JSC::jsDynamicCast<JSServerWebSocket*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool ServerWebSocket__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSServerWebSocket* object = JSC::jsDynamicCast<JSServerWebSocket*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t ServerWebSocket__ptrOffset = JSServerWebSocket::offsetOfWrapped();
@@ -10877,7 +10409,7 @@ void JSServerWebSocket::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSServerWebSocket::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSServerWebSocketConstructor::create(vm, globalObject, WebCore::JSServerWebSocketConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSServerWebSocketPrototype*>(prototype));
+ return WebCore::JSServerWebSocketConstructor::create(vm, globalObject, WebCore::JSServerWebSocketConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSServerWebSocketPrototype*>(prototype));
}
JSObject* JSServerWebSocket::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -10885,12 +10417,13 @@ JSObject* JSServerWebSocket::createPrototype(VM& vm, JSDOMGlobalObject* globalOb
return JSServerWebSocketPrototype::create(vm, globalObject, JSServerWebSocketPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue ServerWebSocket__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSServerWebSocketStructure();
- JSServerWebSocket* instance = JSServerWebSocket::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue ServerWebSocket__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSServerWebSocketStructure();
+ JSServerWebSocket* instance = JSServerWebSocket::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -10899,11 +10432,9 @@ void JSServerWebSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSServerWebSocket* thisObject = jsCast<JSServerWebSocket*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_data);
visitor.append(thisObject->m_remoteAddress);
-
}
DEFINE_VISIT_CHILDREN(JSServerWebSocket);
@@ -10911,10 +10442,10 @@ DEFINE_VISIT_CHILDREN(JSServerWebSocket);
template<typename Visitor>
void JSServerWebSocket::visitAdditionalChildren(Visitor& visitor)
{
- JSServerWebSocket* thisObject = this;
+ JSServerWebSocket* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_data);
+
+ visitor.append(thisObject->m_data);
visitor.append(thisObject->m_remoteAddress);
;
}
@@ -10922,7 +10453,7 @@ void JSServerWebSocket::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSServerWebSocket);
template<typename Visitor>
-void JSServerWebSocket::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSServerWebSocket::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSServerWebSocket* thisObject = jsCast<JSServerWebSocket*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -10930,135 +10461,121 @@ void JSServerWebSocket::visitOutputConstraintsImpl(JSCell *cell, Visitor& visito
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSServerWebSocket);
- class JSStatsPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSStatsPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSStatsPrototype* ptr = new (NotNull, JSC::allocateCell<JSStatsPrototype>(vm)) JSStatsPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSStatsPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSStatsPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSStatsPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSStatsPrototype* ptr = new (NotNull, JSC::allocateCell<JSStatsPrototype>(vm)) JSStatsPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSStatsPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSStatsConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSStatsConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSStatsPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSStatsConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForStatsConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForStatsConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForStatsConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForStatsConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSStatsPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSStatsConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSStatsPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSStatsConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSStatsPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSStatsConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForStatsConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForStatsConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForStatsConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForStatsConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSStatsPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSStatsConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSStatsPrototype* prototype);
+};
extern "C" void* StatsClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsStatsConstructor);
extern "C" void StatsClass__finalize(void*);
-
extern "C" JSC::EncodedJSValue StatsPrototype__atime(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__atimeGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__atimeMs(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__atimeMsGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__birthtime(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__birthtimeGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__birthtimeMs(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__birthtimeMsGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__blksize(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__blksizeGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__blocks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__blocksGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__ctime(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__ctimeGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__ctimeMs(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__ctimeMsGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__dev(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__devGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__gid(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__gidGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__ino(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__inoGetterWrap);
-
extern "C" EncodedJSValue StatsPrototype__isBlockDevice_(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(StatsPrototype__isBlockDeviceCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(StatsPrototype__isBlockDeviceWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
- extern "C" EncodedJSValue StatsPrototype__isBlockDevice_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject);
+extern "C" EncodedJSValue StatsPrototype__isBlockDevice_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
- static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isBlockDevice(StatsPrototype__isBlockDeviceWithoutTypeChecksWrapper,
- JSStats::info(),
- JSC::DOMJIT::Effect::forPure(),
- JSC::SpecHeapTop);
+static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isBlockDevice(StatsPrototype__isBlockDeviceWithoutTypeChecksWrapper,
+ JSStats::info(),
+ JSC::DOMJIT::Effect::forPure(),
+ JSC::SpecHeapTop);
JSC_DEFINE_JIT_OPERATION(StatsPrototype__isBlockDeviceWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
{
@@ -11073,14 +10590,13 @@ JSC_DEFINE_JIT_OPERATION(StatsPrototype__isBlockDeviceWithoutTypeChecksWrapper,
extern "C" EncodedJSValue StatsPrototype__isCharacterDevice_(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(StatsPrototype__isCharacterDeviceCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(StatsPrototype__isCharacterDeviceWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
- extern "C" EncodedJSValue StatsPrototype__isCharacterDevice_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject);
+extern "C" EncodedJSValue StatsPrototype__isCharacterDevice_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
- static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isCharacterDevice(StatsPrototype__isCharacterDeviceWithoutTypeChecksWrapper,
- JSStats::info(),
- JSC::DOMJIT::Effect::forPure(),
- JSC::SpecHeapTop);
+static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isCharacterDevice(StatsPrototype__isCharacterDeviceWithoutTypeChecksWrapper,
+ JSStats::info(),
+ JSC::DOMJIT::Effect::forPure(),
+ JSC::SpecHeapTop);
JSC_DEFINE_JIT_OPERATION(StatsPrototype__isCharacterDeviceWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
{
@@ -11095,14 +10611,13 @@ JSC_DEFINE_JIT_OPERATION(StatsPrototype__isCharacterDeviceWithoutTypeChecksWrapp
extern "C" EncodedJSValue StatsPrototype__isDirectory_(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(StatsPrototype__isDirectoryCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(StatsPrototype__isDirectoryWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
- extern "C" EncodedJSValue StatsPrototype__isDirectory_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject);
+extern "C" EncodedJSValue StatsPrototype__isDirectory_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
- static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isDirectory(StatsPrototype__isDirectoryWithoutTypeChecksWrapper,
- JSStats::info(),
- JSC::DOMJIT::Effect::forPure(),
- JSC::SpecHeapTop);
+static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isDirectory(StatsPrototype__isDirectoryWithoutTypeChecksWrapper,
+ JSStats::info(),
+ JSC::DOMJIT::Effect::forPure(),
+ JSC::SpecHeapTop);
JSC_DEFINE_JIT_OPERATION(StatsPrototype__isDirectoryWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
{
@@ -11117,14 +10632,13 @@ JSC_DEFINE_JIT_OPERATION(StatsPrototype__isDirectoryWithoutTypeChecksWrapper, En
extern "C" EncodedJSValue StatsPrototype__isFIFO_(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(StatsPrototype__isFIFOCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(StatsPrototype__isFIFOWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
- extern "C" EncodedJSValue StatsPrototype__isFIFO_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject);
+extern "C" EncodedJSValue StatsPrototype__isFIFO_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
- static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isFIFO(StatsPrototype__isFIFOWithoutTypeChecksWrapper,
- JSStats::info(),
- JSC::DOMJIT::Effect::forPure(),
- JSC::SpecHeapTop);
+static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isFIFO(StatsPrototype__isFIFOWithoutTypeChecksWrapper,
+ JSStats::info(),
+ JSC::DOMJIT::Effect::forPure(),
+ JSC::SpecHeapTop);
JSC_DEFINE_JIT_OPERATION(StatsPrototype__isFIFOWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
{
@@ -11139,14 +10653,13 @@ JSC_DEFINE_JIT_OPERATION(StatsPrototype__isFIFOWithoutTypeChecksWrapper, Encoded
extern "C" EncodedJSValue StatsPrototype__isFile_(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(StatsPrototype__isFileCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(StatsPrototype__isFileWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
- extern "C" EncodedJSValue StatsPrototype__isFile_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject);
+extern "C" EncodedJSValue StatsPrototype__isFile_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
- static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isFile(StatsPrototype__isFileWithoutTypeChecksWrapper,
- JSStats::info(),
- JSC::DOMJIT::Effect::forPure(),
- JSC::SpecHeapTop);
+static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isFile(StatsPrototype__isFileWithoutTypeChecksWrapper,
+ JSStats::info(),
+ JSC::DOMJIT::Effect::forPure(),
+ JSC::SpecHeapTop);
JSC_DEFINE_JIT_OPERATION(StatsPrototype__isFileWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
{
@@ -11161,14 +10674,13 @@ JSC_DEFINE_JIT_OPERATION(StatsPrototype__isFileWithoutTypeChecksWrapper, Encoded
extern "C" EncodedJSValue StatsPrototype__isSocket_(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(StatsPrototype__isSocketCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(StatsPrototype__isSocketWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
- extern "C" EncodedJSValue StatsPrototype__isSocket_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject);
+extern "C" EncodedJSValue StatsPrototype__isSocket_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
- static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isSocket(StatsPrototype__isSocketWithoutTypeChecksWrapper,
- JSStats::info(),
- JSC::DOMJIT::Effect::forPure(),
- JSC::SpecHeapTop);
+static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isSocket(StatsPrototype__isSocketWithoutTypeChecksWrapper,
+ JSStats::info(),
+ JSC::DOMJIT::Effect::forPure(),
+ JSC::SpecHeapTop);
JSC_DEFINE_JIT_OPERATION(StatsPrototype__isSocketWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
{
@@ -11183,14 +10695,13 @@ JSC_DEFINE_JIT_OPERATION(StatsPrototype__isSocketWithoutTypeChecksWrapper, Encod
extern "C" EncodedJSValue StatsPrototype__isSymbolicLink_(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(StatsPrototype__isSymbolicLinkCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(StatsPrototype__isSymbolicLinkWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue));
- extern "C" EncodedJSValue StatsPrototype__isSymbolicLink_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject);
+extern "C" EncodedJSValue StatsPrototype__isSymbolicLink_WithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
- static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isSymbolicLink(StatsPrototype__isSymbolicLinkWithoutTypeChecksWrapper,
- JSStats::info(),
- JSC::DOMJIT::Effect::forPure(),
- JSC::SpecHeapTop);
+static const JSC::DOMJIT::Signature DOMJITSignatureForStatsPrototype__isSymbolicLink(StatsPrototype__isSymbolicLinkWithoutTypeChecksWrapper,
+ JSStats::info(),
+ JSC::DOMJIT::Effect::forPure(),
+ JSC::SpecHeapTop);
JSC_DEFINE_JIT_OPERATION(StatsPrototype__isSymbolicLinkWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue))
{
@@ -11205,68 +10716,56 @@ JSC_DEFINE_JIT_OPERATION(StatsPrototype__isSymbolicLinkWithoutTypeChecksWrapper,
extern "C" JSC::EncodedJSValue StatsPrototype__mode(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__modeGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__mtime(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__mtimeGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__mtimeMs(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__mtimeMsGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__nlink(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__nlinkGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__rdev(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__rdevGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__size(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__sizeGetterWrap);
-
extern "C" JSC::EncodedJSValue StatsPrototype__uid(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(StatsPrototype__uidGetterWrap);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSStatsPrototype, JSStatsPrototype::Base);
-
- static const HashTableValue JSStatsPrototypeTableValues[] = {
-{ "atime"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__atimeGetterWrap, 0 } } ,
-{ "atimeMs"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__atimeMsGetterWrap, 0 } } ,
-{ "birthtime"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__birthtimeGetterWrap, 0 } } ,
-{ "birthtimeMs"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__birthtimeMsGetterWrap, 0 } } ,
-{ "blksize"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__blksizeGetterWrap, 0 } } ,
-{ "blocks"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__blocksGetterWrap, 0 } } ,
-{ "ctime"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__ctimeGetterWrap, 0 } } ,
-{ "ctimeMs"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__ctimeMsGetterWrap, 0 } } ,
-{ "dev"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__devGetterWrap, 0 } } ,
-{ "gid"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__gidGetterWrap, 0 } } ,
-{ "ino"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__inoGetterWrap, 0 } } ,
-{ "isBlockDevice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isBlockDeviceCallback, &DOMJITSignatureForStatsPrototype__isBlockDevice } } ,
-{ "isCharacterDevice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isCharacterDeviceCallback, &DOMJITSignatureForStatsPrototype__isCharacterDevice } } ,
-{ "isDirectory"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isDirectoryCallback, &DOMJITSignatureForStatsPrototype__isDirectory } } ,
-{ "isFIFO"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isFIFOCallback, &DOMJITSignatureForStatsPrototype__isFIFO } } ,
-{ "isFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isFileCallback, &DOMJITSignatureForStatsPrototype__isFile } } ,
-{ "isSocket"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isSocketCallback, &DOMJITSignatureForStatsPrototype__isSocket } } ,
-{ "isSymbolicLink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isSymbolicLinkCallback, &DOMJITSignatureForStatsPrototype__isSymbolicLink } } ,
-{ "mode"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__modeGetterWrap, 0 } } ,
-{ "mtime"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__mtimeGetterWrap, 0 } } ,
-{ "mtimeMs"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__mtimeMsGetterWrap, 0 } } ,
-{ "nlink"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__nlinkGetterWrap, 0 } } ,
-{ "rdev"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__rdevGetterWrap, 0 } } ,
-{ "size"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__sizeGetterWrap, 0 } } ,
-{ "uid"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__uidGetterWrap, 0 } }
+static const HashTableValue JSStatsPrototypeTableValues[] = {
+ { "atime"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__atimeGetterWrap, 0 } },
+ { "atimeMs"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__atimeMsGetterWrap, 0 } },
+ { "birthtime"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__birthtimeGetterWrap, 0 } },
+ { "birthtimeMs"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__birthtimeMsGetterWrap, 0 } },
+ { "blksize"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__blksizeGetterWrap, 0 } },
+ { "blocks"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__blocksGetterWrap, 0 } },
+ { "ctime"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__ctimeGetterWrap, 0 } },
+ { "ctimeMs"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__ctimeMsGetterWrap, 0 } },
+ { "dev"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__devGetterWrap, 0 } },
+ { "gid"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__gidGetterWrap, 0 } },
+ { "ino"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__inoGetterWrap, 0 } },
+ { "isBlockDevice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isBlockDeviceCallback, &DOMJITSignatureForStatsPrototype__isBlockDevice } },
+ { "isCharacterDevice"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isCharacterDeviceCallback, &DOMJITSignatureForStatsPrototype__isCharacterDevice } },
+ { "isDirectory"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isDirectoryCallback, &DOMJITSignatureForStatsPrototype__isDirectory } },
+ { "isFIFO"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isFIFOCallback, &DOMJITSignatureForStatsPrototype__isFIFO } },
+ { "isFile"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isFileCallback, &DOMJITSignatureForStatsPrototype__isFile } },
+ { "isSocket"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isSocketCallback, &DOMJITSignatureForStatsPrototype__isSocket } },
+ { "isSymbolicLink"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, StatsPrototype__isSymbolicLinkCallback, &DOMJITSignatureForStatsPrototype__isSymbolicLink } },
+ { "mode"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__modeGetterWrap, 0 } },
+ { "mtime"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__mtimeGetterWrap, 0 } },
+ { "mtimeMs"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__mtimeMsGetterWrap, 0 } },
+ { "nlink"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__nlinkGetterWrap, 0 } },
+ { "rdev"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__rdevGetterWrap, 0 } },
+ { "size"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__sizeGetterWrap, 0 } },
+ { "uid"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, StatsPrototype__uidGetterWrap, 0 } }
};
-
-
const ClassInfo JSStatsPrototype::s_info = { "Stats"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStatsPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsStatsConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -11277,49 +10776,43 @@ JSC_DEFINE_CUSTOM_GETTER(jsStatsConstructor, (JSGlobalObject * lexicalGlobalObje
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSStatsConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__atimeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_atime.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- StatsPrototype__atime(thisObject->wrapped(), globalObject)
- );
+ StatsPrototype__atime(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_atime.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void StatsPrototype__atimeSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
+ thisObject->m_atime.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void StatsPrototype__atimeSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
- thisObject->m_atime.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue StatsPrototype__atimeGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue StatsPrototype__atimeGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_atime.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__atimeMsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11327,12 +10820,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__atimeMsGetterWrap, (JSGlobalObject * le
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__birthtimeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11340,12 +10832,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__birthtimeGetterWrap, (JSGlobalObject *
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__birthtimeMsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11353,12 +10844,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__birthtimeMsGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__blksizeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11366,12 +10856,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__blksizeGetterWrap, (JSGlobalObject * le
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__blocksGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11379,47 +10868,42 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__blocksGetterWrap, (JSGlobalObject * lex
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__ctimeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_ctime.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- StatsPrototype__ctime(thisObject->wrapped(), globalObject)
- );
+ StatsPrototype__ctime(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_ctime.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void StatsPrototype__ctimeSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
+ thisObject->m_ctime.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void StatsPrototype__ctimeSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
- thisObject->m_ctime.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue StatsPrototype__ctimeGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue StatsPrototype__ctimeGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_ctime.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__ctimeMsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11427,12 +10911,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__ctimeMsGetterWrap, (JSGlobalObject * le
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__devGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11440,12 +10923,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__devGetterWrap, (JSGlobalObject * lexica
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__gidGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11453,12 +10935,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__gidGetterWrap, (JSGlobalObject * lexica
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__inoGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11466,131 +10947,123 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__inoGetterWrap, (JSGlobalObject * lexica
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
-
- JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isBlockDeviceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isBlockDeviceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
- return StatsPrototype__isBlockDevice_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isCharacterDeviceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
+ return StatsPrototype__isBlockDevice_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isCharacterDeviceCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
- return StatsPrototype__isCharacterDevice_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isDirectoryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
+ return StatsPrototype__isCharacterDevice_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isDirectoryCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
- return StatsPrototype__isDirectory_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isFIFOCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
+ return StatsPrototype__isDirectory_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isFIFOCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
- return StatsPrototype__isFIFO_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
+ return StatsPrototype__isFIFO_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isFileCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
- return StatsPrototype__isFile_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isSocketCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
+ return StatsPrototype__isFile_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isSocketCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
- return StatsPrototype__isSocket_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isSymbolicLinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
+ return StatsPrototype__isSocket_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(StatsPrototype__isSymbolicLinkCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSStats* thisObject = jsDynamicCast<JSStats*>(callFrame->thisValue());
- return StatsPrototype__isSymbolicLink_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return StatsPrototype__isSymbolicLink_(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__modeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11598,47 +11071,42 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__modeGetterWrap, (JSGlobalObject * lexic
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__mtimeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_mtime.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- StatsPrototype__mtime(thisObject->wrapped(), globalObject)
- );
+ StatsPrototype__mtime(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_mtime.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void StatsPrototype__mtimeSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
+ thisObject->m_mtime.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void StatsPrototype__mtimeSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
- thisObject->m_mtime.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue StatsPrototype__mtimeGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue StatsPrototype__mtimeGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_mtime.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__mtimeMsGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11646,12 +11114,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__mtimeMsGetterWrap, (JSGlobalObject * le
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__nlinkGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11659,12 +11126,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__nlinkGetterWrap, (JSGlobalObject * lexi
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__rdevGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11672,12 +11138,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__rdevGetterWrap, (JSGlobalObject * lexic
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__sizeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11685,12 +11150,11 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__sizeGetterWrap, (JSGlobalObject * lexic
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__uidGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSStats* thisObject = jsCast<JSStats*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -11698,7 +11162,6 @@ JSC_DEFINE_CUSTOM_GETTER(StatsPrototype__uidGetterWrap, (JSGlobalObject * lexica
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
void JSStatsPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -11710,67 +11173,64 @@ void JSStatsPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalOb
void JSStatsConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSStatsPrototype* prototype)
{
Base::finishCreation(vm, 0, "Stats"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSStatsConstructor::JSStatsConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSStatsConstructor::JSStatsConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSStatsConstructor* JSStatsConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSStatsPrototype* prototype) {
+JSStatsConstructor* JSStatsConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSStatsPrototype* prototype)
+{
JSStatsConstructor* ptr = new (NotNull, JSC::allocateCell<JSStatsConstructor>(vm)) JSStatsConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSStatsConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSStatsConstructor();
Structure* structure = globalObject->JSStatsStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSStatsStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSStatsStructure());
}
void* ptr = StatsClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSStats* instance = JSStats::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSStatsConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSStatsPrototype* prototype)
{
-
}
const ClassInfo JSStatsConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStatsConstructor) };
-
- extern "C" EncodedJSValue Stats__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue Stats__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSStatsConstructor());
- }
+}
JSStats::~JSStats()
{
@@ -11782,7 +11242,7 @@ void JSStats::destroy(JSCell* cell)
{
static_cast<JSStats*>(cell)->JSStats::~JSStats();
}
-
+
const ClassInfo JSStats::s_info = { "Stats"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStats) };
void JSStats::finishCreation(VM& vm)
@@ -11791,36 +11251,37 @@ void JSStats::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSStats* JSStats::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSStats* ptr = new (NotNull, JSC::allocateCell<JSStats>(vm)) JSStats(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSStats* JSStats::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSStats* ptr = new (NotNull, JSC::allocateCell<JSStats>(vm)) JSStats(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Stats__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Stats__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSStats* object = JSC::jsDynamicCast<JSStats*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSStats* object = JSC::jsDynamicCast<JSStats*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Stats__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSStats* object = JSC::jsDynamicCast<JSStats*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Stats__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSStats* object = JSC::jsDynamicCast<JSStats*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Stats__ptrOffset = JSStats::offsetOfWrapped();
@@ -11836,7 +11297,7 @@ void JSStats::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSStats::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSStatsConstructor::create(vm, globalObject, WebCore::JSStatsConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSStatsPrototype*>(prototype));
+ return WebCore::JSStatsConstructor::create(vm, globalObject, WebCore::JSStatsConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSStatsPrototype*>(prototype));
}
JSObject* JSStats::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -11844,12 +11305,13 @@ JSObject* JSStats::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSStatsPrototype::create(vm, globalObject, JSStatsPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Stats__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSStatsStructure();
- JSStats* instance = JSStats::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue Stats__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSStatsStructure();
+ JSStats* instance = JSStats::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -11858,12 +11320,10 @@ void JSStats::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSStats* thisObject = jsCast<JSStats*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_atime);
visitor.append(thisObject->m_ctime);
visitor.append(thisObject->m_mtime);
-
}
DEFINE_VISIT_CHILDREN(JSStats);
@@ -11871,10 +11331,10 @@ DEFINE_VISIT_CHILDREN(JSStats);
template<typename Visitor>
void JSStats::visitAdditionalChildren(Visitor& visitor)
{
- JSStats* thisObject = this;
+ JSStats* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_atime);
+
+ visitor.append(thisObject->m_atime);
visitor.append(thisObject->m_ctime);
visitor.append(thisObject->m_mtime);
;
@@ -11883,7 +11343,7 @@ void JSStats::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSStats);
template<typename Visitor>
-void JSStats::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSStats::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSStats* thisObject = jsCast<JSStats*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -11891,119 +11351,100 @@ void JSStats::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSStats);
- class JSSubprocessPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSSubprocessPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSSubprocessPrototype* ptr = new (NotNull, JSC::allocateCell<JSSubprocessPrototype>(vm)) JSSubprocessPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSSubprocessPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSSubprocessPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSSubprocessPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSSubprocessPrototype* ptr = new (NotNull, JSC::allocateCell<JSSubprocessPrototype>(vm)) JSSubprocessPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSSubprocessPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
extern "C" void* SubprocessClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsSubprocessConstructor);
extern "C" void SubprocessClass__finalize(void*);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getExitCode(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__exitCodeGetterWrap);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getExited(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__exitedGetterWrap);
-
extern "C" EncodedJSValue SubprocessPrototype__kill(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SubprocessPrototype__killCallback);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getKilled(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__killedGetterWrap);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getPid(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__pidGetterWrap);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getStdout(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__readableGetterWrap);
-
extern "C" EncodedJSValue SubprocessPrototype__doRef(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SubprocessPrototype__refCallback);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getSignalCode(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__signalCodeGetterWrap);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getStderr(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__stderrGetterWrap);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getStdin(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__stdinGetterWrap);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getStdout(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__stdoutGetterWrap);
-
extern "C" EncodedJSValue SubprocessPrototype__doUnref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(SubprocessPrototype__unrefCallback);
-
extern "C" JSC::EncodedJSValue SubprocessPrototype__getStdin(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(SubprocessPrototype__writableGetterWrap);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSSubprocessPrototype, JSSubprocessPrototype::Base);
-
- static const HashTableValue JSSubprocessPrototypeTableValues[] = {
-{ "exitCode"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__exitCodeGetterWrap, 0 } } ,
-{ "exited"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__exitedGetterWrap, 0 } } ,
-{ "kill"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SubprocessPrototype__killCallback, 1 } } ,
-{ "killed"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__killedGetterWrap, 0 } } ,
-{ "pid"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__pidGetterWrap, 0 } } ,
-{ "readable"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__readableGetterWrap, 0 } } ,
-{ "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SubprocessPrototype__refCallback, 0 } } ,
-{ "signalCode"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__signalCodeGetterWrap, 0 } } ,
-{ "stderr"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__stderrGetterWrap, 0 } } ,
-{ "stdin"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__stdinGetterWrap, 0 } } ,
-{ "stdout"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__stdoutGetterWrap, 0 } } ,
-{ "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SubprocessPrototype__unrefCallback, 0 } } ,
-{ "writable"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__writableGetterWrap, 0 } }
+static const HashTableValue JSSubprocessPrototypeTableValues[] = {
+ { "exitCode"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__exitCodeGetterWrap, 0 } },
+ { "exited"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__exitedGetterWrap, 0 } },
+ { "kill"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SubprocessPrototype__killCallback, 1 } },
+ { "killed"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__killedGetterWrap, 0 } },
+ { "pid"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__pidGetterWrap, 0 } },
+ { "readable"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__readableGetterWrap, 0 } },
+ { "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SubprocessPrototype__refCallback, 0 } },
+ { "signalCode"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__signalCodeGetterWrap, 0 } },
+ { "stderr"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__stderrGetterWrap, 0 } },
+ { "stdin"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__stdinGetterWrap, 0 } },
+ { "stdout"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__stdoutGetterWrap, 0 } },
+ { "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, SubprocessPrototype__unrefCallback, 0 } },
+ { "writable"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, SubprocessPrototype__writableGetterWrap, 0 } }
};
-
-
const ClassInfo JSSubprocessPrototype::s_info = { "Subprocess"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSubprocessPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsSubprocessConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -12014,14 +11455,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsSubprocessConstructor, (JSGlobalObject * lexicalGloba
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSSubprocessConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__exitCodeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12029,12 +11468,11 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__exitCodeGetterWrap, (JSGlobalObjec
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__exitedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12042,29 +11480,27 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__exitedGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__killCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__killCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue());
+ JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return SubprocessPrototype__kill(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return SubprocessPrototype__kill(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__killedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12072,12 +11508,11 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__killedGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__pidGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12085,64 +11520,58 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__pidGetterWrap, (JSGlobalObject * l
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__readableGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_stdout.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- SubprocessPrototype__getStdout(thisObject->wrapped(), globalObject)
- );
+ SubprocessPrototype__getStdout(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_stdout.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void SubprocessPrototype__readableSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
+ thisObject->m_stdout.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void SubprocessPrototype__readableSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- thisObject->m_stdout.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue SubprocessPrototype__readableGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue SubprocessPrototype__readableGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_stdout.get());
- }
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue());
+ JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return SubprocessPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return SubprocessPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__signalCodeGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12150,164 +11579,146 @@ JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__signalCodeGetterWrap, (JSGlobalObj
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stderrGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_stderr.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- SubprocessPrototype__getStderr(thisObject->wrapped(), globalObject)
- );
+ SubprocessPrototype__getStderr(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_stderr.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void SubprocessPrototype__stderrSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
+ thisObject->m_stderr.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void SubprocessPrototype__stderrSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- thisObject->m_stderr.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue SubprocessPrototype__stderrGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue SubprocessPrototype__stderrGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_stderr.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stdinGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_stdin.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- SubprocessPrototype__getStdin(thisObject->wrapped(), globalObject)
- );
+ SubprocessPrototype__getStdin(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_stdin.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void SubprocessPrototype__stdinSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
+ thisObject->m_stdin.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void SubprocessPrototype__stdinSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- thisObject->m_stdin.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue SubprocessPrototype__stdinGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue SubprocessPrototype__stdinGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_stdin.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__stdoutGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_stdout.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- SubprocessPrototype__getStdout(thisObject->wrapped(), globalObject)
- );
+ SubprocessPrototype__getStdout(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_stdout.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void SubprocessPrototype__stdoutSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
+ thisObject->m_stdout.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void SubprocessPrototype__stdoutSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- thisObject->m_stdout.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue SubprocessPrototype__stdoutGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue SubprocessPrototype__stdoutGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_stdout.get());
- }
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(SubprocessPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue());
+ JSSubprocess* thisObject = jsDynamicCast<JSSubprocess*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return SubprocessPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return SubprocessPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(SubprocessPrototype__writableGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSubprocess* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_stdin.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- SubprocessPrototype__getStdin(thisObject->wrapped(), globalObject)
- );
+ SubprocessPrototype__getStdin(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_stdin.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void SubprocessPrototype__writableSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
+ thisObject->m_stdin.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void SubprocessPrototype__writableSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
- thisObject->m_stdin.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue SubprocessPrototype__writableGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue SubprocessPrototype__writableGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSSubprocess*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_stdin.get());
- }
-
-
+}
void JSSubprocessPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -12317,9 +11728,10 @@ void JSSubprocessPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* glo
}
extern "C" bool Subprocess__hasPendingActivity(void* ptr);
- bool JSSubprocess::hasPendingActivity(void* ctx) {
- return Subprocess__hasPendingActivity(ctx);
- }
+bool JSSubprocess::hasPendingActivity(void* ctx)
+{
+ return Subprocess__hasPendingActivity(ctx);
+}
JSSubprocess::~JSSubprocess()
{
@@ -12331,7 +11743,7 @@ void JSSubprocess::destroy(JSCell* cell)
{
static_cast<JSSubprocess*>(cell)->JSSubprocess::~JSSubprocess();
}
-
+
const ClassInfo JSSubprocess::s_info = { "Subprocess"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSubprocess) };
void JSSubprocess::finishCreation(VM& vm)
@@ -12340,36 +11752,37 @@ void JSSubprocess::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSSubprocess* JSSubprocess::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSSubprocess* ptr = new (NotNull, JSC::allocateCell<JSSubprocess>(vm)) JSSubprocess(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSSubprocess* JSSubprocess::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSSubprocess* ptr = new (NotNull, JSC::allocateCell<JSSubprocess>(vm)) JSSubprocess(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Subprocess__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Subprocess__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSSubprocess* object = JSC::jsDynamicCast<JSSubprocess*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSSubprocess* object = JSC::jsDynamicCast<JSSubprocess*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Subprocess__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSSubprocess* object = JSC::jsDynamicCast<JSSubprocess*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Subprocess__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSSubprocess* object = JSC::jsDynamicCast<JSSubprocess*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Subprocess__ptrOffset = JSSubprocess::offsetOfWrapped();
@@ -12383,19 +11796,18 @@ void JSSubprocess::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
Base::analyzeHeap(cell, analyzer);
}
-
-
JSObject* JSSubprocess::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
{
return JSSubprocessPrototype::create(vm, globalObject, JSSubprocessPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Subprocess__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSSubprocessStructure();
- JSSubprocess* instance = JSSubprocess::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue Subprocess__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSSubprocessStructure();
+ JSSubprocess* instance = JSSubprocess::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -12404,12 +11816,11 @@ void JSSubprocess::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSSubprocess* thisObject = jsCast<JSSubprocess*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_stderr);
visitor.append(thisObject->m_stdin);
visitor.append(thisObject->m_stdout);
-visitor.addOpaqueRoot(thisObject->wrapped());
+ visitor.addOpaqueRoot(thisObject->wrapped());
}
DEFINE_VISIT_CHILDREN(JSSubprocess);
@@ -12417,10 +11828,10 @@ DEFINE_VISIT_CHILDREN(JSSubprocess);
template<typename Visitor>
void JSSubprocess::visitAdditionalChildren(Visitor& visitor)
{
- JSSubprocess* thisObject = this;
+ JSSubprocess* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_stderr);
+
+ visitor.append(thisObject->m_stderr);
visitor.append(thisObject->m_stdin);
visitor.append(thisObject->m_stdout);
visitor.addOpaqueRoot(this->wrapped());
@@ -12429,7 +11840,7 @@ void JSSubprocess::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSSubprocess);
template<typename Visitor>
-void JSSubprocess::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSSubprocess::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSSubprocess* thisObject = jsCast<JSSubprocess*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -12437,133 +11848,111 @@ void JSSubprocess::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSSubprocess);
- class JSTCPSocketPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSTCPSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSTCPSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSTCPSocketPrototype>(vm)) JSTCPSocketPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSTCPSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSTCPSocketPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSTCPSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSTCPSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSTCPSocketPrototype>(vm)) JSTCPSocketPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSTCPSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
extern "C" void* TCPSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsTCPSocketConstructor);
extern "C" void TCPSocketClass__finalize(void*);
-
extern "C" JSC::EncodedJSValue TCPSocketPrototype__getAuthorized(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__authorizedGetterWrap);
-
extern "C" JSC::EncodedJSValue TCPSocketPrototype__getData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__dataGetterWrap);
-
extern "C" bool TCPSocketPrototype__setData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::EncodedJSValue value);
JSC_DECLARE_CUSTOM_SETTER(TCPSocketPrototype__dataSetterWrap);
-
extern "C" EncodedJSValue TCPSocketPrototype__end(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__endCallback);
-
extern "C" EncodedJSValue TCPSocketPrototype__flush(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__flushCallback);
-
extern "C" EncodedJSValue TCPSocketPrototype__getAuthorizationError(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__getAuthorizationErrorCallback);
-
extern "C" JSC::EncodedJSValue TCPSocketPrototype__getListener(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__listenerGetterWrap);
-
extern "C" JSC::EncodedJSValue TCPSocketPrototype__getLocalPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__localPortGetterWrap);
-
extern "C" JSC::EncodedJSValue TCPSocketPrototype__getReadyState(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__readyStateGetterWrap);
-
extern "C" EncodedJSValue TCPSocketPrototype__ref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__refCallback);
-
extern "C" EncodedJSValue TCPSocketPrototype__reload(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__reloadCallback);
-
extern "C" JSC::EncodedJSValue TCPSocketPrototype__getRemoteAddress(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TCPSocketPrototype__remoteAddressGetterWrap);
-
extern "C" EncodedJSValue TCPSocketPrototype__shutdown(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__shutdownCallback);
-
extern "C" EncodedJSValue TCPSocketPrototype__timeout(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__timeoutCallback);
-
extern "C" EncodedJSValue TCPSocketPrototype__unref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback);
-
extern "C" EncodedJSValue TCPSocketPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TCPSocketPrototype__writeCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTCPSocketPrototype, JSTCPSocketPrototype::Base);
-
- static const HashTableValue JSTCPSocketPrototypeTableValues[] = {
-{ "authorized"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__authorizedGetterWrap, 0 } } ,
-{ "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__dataGetterWrap, TCPSocketPrototype__dataSetterWrap } } ,
-{ "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__endCallback, 3 } } ,
-{ "flush"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__flushCallback, 0 } } ,
-{ "getAuthorizationError"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__getAuthorizationErrorCallback, 0 } } ,
-{ "listener"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__listenerGetterWrap, 0 } } ,
-{ "localPort"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__localPortGetterWrap, 0 } } ,
-{ "readyState"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__readyStateGetterWrap, 0 } } ,
-{ "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__refCallback, 0 } } ,
-{ "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__reloadCallback, 1 } } ,
-{ "remoteAddress"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__remoteAddressGetterWrap, 0 } } ,
-{ "shutdown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__shutdownCallback, 1 } } ,
-{ "timeout"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__timeoutCallback, 1 } } ,
-{ "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__unrefCallback, 0 } } ,
-{ "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__writeCallback, 3 } }
+static const HashTableValue JSTCPSocketPrototypeTableValues[] = {
+ { "authorized"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__authorizedGetterWrap, 0 } },
+ { "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__dataGetterWrap, TCPSocketPrototype__dataSetterWrap } },
+ { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__endCallback, 3 } },
+ { "flush"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__flushCallback, 0 } },
+ { "getAuthorizationError"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__getAuthorizationErrorCallback, 0 } },
+ { "listener"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__listenerGetterWrap, 0 } },
+ { "localPort"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__localPortGetterWrap, 0 } },
+ { "readyState"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__readyStateGetterWrap, 0 } },
+ { "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__refCallback, 0 } },
+ { "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__reloadCallback, 1 } },
+ { "remoteAddress"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TCPSocketPrototype__remoteAddressGetterWrap, 0 } },
+ { "shutdown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__shutdownCallback, 1 } },
+ { "timeout"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__timeoutCallback, 1 } },
+ { "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__unrefCallback, 0 } },
+ { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TCPSocketPrototype__writeCallback, 3 } }
};
-
-
const ClassInfo JSTCPSocketPrototype::s_info = { "TCPSocket"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTCPSocketPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsTCPSocketConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -12574,14 +11963,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsTCPSocketConstructor, (JSGlobalObject * lexicalGlobal
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSTCPSocketConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__authorizedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12589,42 +11976,37 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__authorizedGetterWrap, (JSGlobalObje
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__dataGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_data.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- TCPSocketPrototype__getData(thisObject->wrapped(), globalObject)
- );
+ TCPSocketPrototype__getData(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_data.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void TCPSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
+ thisObject->m_data.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void TCPSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
- thisObject->m_data.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue TCPSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue TCPSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_data.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_SETTER(TCPSocketPrototype__dataSetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName))
{
@@ -12637,62 +12019,58 @@ JSC_DEFINE_CUSTOM_SETTER(TCPSocketPrototype__dataSetterWrap, (JSGlobalObject * l
RELEASE_AND_RETURN(throwScope, result);
}
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__endCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__endCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
-
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__end(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
+ return TCPSocketPrototype__end(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__flush(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getAuthorizationErrorCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
+ return TCPSocketPrototype__flush(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__getAuthorizationErrorCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__getAuthorizationError(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TCPSocketPrototype__getAuthorizationError(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__listenerGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12700,12 +12078,11 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__listenerGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__localPortGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12713,12 +12090,11 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__localPortGetterWrap, (JSGlobalObjec
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__readyStateGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -12726,144 +12102,133 @@ JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__readyStateGetterWrap, (JSGlobalObje
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
+ return TCPSocketPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TCPSocketPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(TCPSocketPrototype__remoteAddressGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_remoteAddress.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- TCPSocketPrototype__getRemoteAddress(thisObject->wrapped(), globalObject)
- );
+ TCPSocketPrototype__getRemoteAddress(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_remoteAddress.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void TCPSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
+ thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void TCPSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
- thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue TCPSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue TCPSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSTCPSocket*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_remoteAddress.get());
- }
-
-
-
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__shutdown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__timeoutCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
+ return TCPSocketPrototype__shutdown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__timeoutCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__timeout(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
+ return TCPSocketPrototype__timeout(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
+ return TCPSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TCPSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTCPSocket* thisObject = jsDynamicCast<JSTCPSocket*>(callFrame->thisValue());
- return TCPSocketPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TCPSocketPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSTCPSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -12873,9 +12238,10 @@ void JSTCPSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* glob
}
extern "C" bool TCPSocket__hasPendingActivity(void* ptr);
- bool JSTCPSocket::hasPendingActivity(void* ctx) {
- return TCPSocket__hasPendingActivity(ctx);
- }
+bool JSTCPSocket::hasPendingActivity(void* ctx)
+{
+ return TCPSocket__hasPendingActivity(ctx);
+}
JSTCPSocket::~JSTCPSocket()
{
@@ -12887,7 +12253,7 @@ void JSTCPSocket::destroy(JSCell* cell)
{
static_cast<JSTCPSocket*>(cell)->JSTCPSocket::~JSTCPSocket();
}
-
+
const ClassInfo JSTCPSocket::s_info = { "TCPSocket"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTCPSocket) };
void JSTCPSocket::finishCreation(VM& vm)
@@ -12896,36 +12262,37 @@ void JSTCPSocket::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSTCPSocket* JSTCPSocket::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSTCPSocket* ptr = new (NotNull, JSC::allocateCell<JSTCPSocket>(vm)) JSTCPSocket(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSTCPSocket* JSTCPSocket::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSTCPSocket* ptr = new (NotNull, JSC::allocateCell<JSTCPSocket>(vm)) JSTCPSocket(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* TCPSocket__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* TCPSocket__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSTCPSocket* object = JSC::jsDynamicCast<JSTCPSocket*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSTCPSocket* object = JSC::jsDynamicCast<JSTCPSocket*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool TCPSocket__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSTCPSocket* object = JSC::jsDynamicCast<JSTCPSocket*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool TCPSocket__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSTCPSocket* object = JSC::jsDynamicCast<JSTCPSocket*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t TCPSocket__ptrOffset = JSTCPSocket::offsetOfWrapped();
@@ -12939,19 +12306,18 @@ void JSTCPSocket::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
Base::analyzeHeap(cell, analyzer);
}
-
-
JSObject* JSTCPSocket::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
{
return JSTCPSocketPrototype::create(vm, globalObject, JSTCPSocketPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue TCPSocket__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSTCPSocketStructure();
- JSTCPSocket* instance = JSTCPSocket::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue TCPSocket__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSTCPSocketStructure();
+ JSTCPSocket* instance = JSTCPSocket::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -12960,11 +12326,10 @@ void JSTCPSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_data);
visitor.append(thisObject->m_remoteAddress);
-visitor.addOpaqueRoot(thisObject->wrapped());
+ visitor.addOpaqueRoot(thisObject->wrapped());
}
DEFINE_VISIT_CHILDREN(JSTCPSocket);
@@ -12972,10 +12337,10 @@ DEFINE_VISIT_CHILDREN(JSTCPSocket);
template<typename Visitor>
void JSTCPSocket::visitAdditionalChildren(Visitor& visitor)
{
- JSTCPSocket* thisObject = this;
+ JSTCPSocket* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_data);
+
+ visitor.append(thisObject->m_data);
visitor.append(thisObject->m_remoteAddress);
visitor.addOpaqueRoot(this->wrapped());
}
@@ -12983,7 +12348,7 @@ void JSTCPSocket::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSTCPSocket);
template<typename Visitor>
-void JSTCPSocket::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSTCPSocket::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -12991,133 +12356,111 @@ void JSTCPSocket::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSTCPSocket);
- class JSTLSSocketPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSTLSSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSTLSSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSTLSSocketPrototype>(vm)) JSTLSSocketPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSTLSSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSTLSSocketPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSTLSSocketPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSTLSSocketPrototype* ptr = new (NotNull, JSC::allocateCell<JSTLSSocketPrototype>(vm)) JSTLSSocketPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSTLSSocketPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
extern "C" void* TLSSocketClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsTLSSocketConstructor);
extern "C" void TLSSocketClass__finalize(void*);
-
extern "C" JSC::EncodedJSValue TLSSocketPrototype__getAuthorized(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__authorizedGetterWrap);
-
extern "C" JSC::EncodedJSValue TLSSocketPrototype__getData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__dataGetterWrap);
-
extern "C" bool TLSSocketPrototype__setData(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::EncodedJSValue value);
JSC_DECLARE_CUSTOM_SETTER(TLSSocketPrototype__dataSetterWrap);
-
extern "C" EncodedJSValue TLSSocketPrototype__end(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__endCallback);
-
extern "C" EncodedJSValue TLSSocketPrototype__flush(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__flushCallback);
-
extern "C" EncodedJSValue TLSSocketPrototype__getAuthorizationError(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__getAuthorizationErrorCallback);
-
extern "C" JSC::EncodedJSValue TLSSocketPrototype__getListener(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__listenerGetterWrap);
-
extern "C" JSC::EncodedJSValue TLSSocketPrototype__getLocalPort(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__localPortGetterWrap);
-
extern "C" JSC::EncodedJSValue TLSSocketPrototype__getReadyState(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__readyStateGetterWrap);
-
extern "C" EncodedJSValue TLSSocketPrototype__ref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__refCallback);
-
extern "C" EncodedJSValue TLSSocketPrototype__reload(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__reloadCallback);
-
extern "C" JSC::EncodedJSValue TLSSocketPrototype__getRemoteAddress(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TLSSocketPrototype__remoteAddressGetterWrap);
-
extern "C" EncodedJSValue TLSSocketPrototype__shutdown(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__shutdownCallback);
-
extern "C" EncodedJSValue TLSSocketPrototype__timeout(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__timeoutCallback);
-
extern "C" EncodedJSValue TLSSocketPrototype__unref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback);
-
extern "C" EncodedJSValue TLSSocketPrototype__write(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TLSSocketPrototype__writeCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTLSSocketPrototype, JSTLSSocketPrototype::Base);
-
- static const HashTableValue JSTLSSocketPrototypeTableValues[] = {
-{ "authorized"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__authorizedGetterWrap, 0 } } ,
-{ "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__dataGetterWrap, TLSSocketPrototype__dataSetterWrap } } ,
-{ "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__endCallback, 3 } } ,
-{ "flush"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__flushCallback, 0 } } ,
-{ "getAuthorizationError"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__getAuthorizationErrorCallback, 0 } } ,
-{ "listener"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__listenerGetterWrap, 0 } } ,
-{ "localPort"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__localPortGetterWrap, 0 } } ,
-{ "readyState"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__readyStateGetterWrap, 0 } } ,
-{ "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__refCallback, 0 } } ,
-{ "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__reloadCallback, 1 } } ,
-{ "remoteAddress"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__remoteAddressGetterWrap, 0 } } ,
-{ "shutdown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__shutdownCallback, 1 } } ,
-{ "timeout"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__timeoutCallback, 1 } } ,
-{ "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__unrefCallback, 0 } } ,
-{ "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__writeCallback, 3 } }
+static const HashTableValue JSTLSSocketPrototypeTableValues[] = {
+ { "authorized"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__authorizedGetterWrap, 0 } },
+ { "data"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__dataGetterWrap, TLSSocketPrototype__dataSetterWrap } },
+ { "end"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__endCallback, 3 } },
+ { "flush"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__flushCallback, 0 } },
+ { "getAuthorizationError"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__getAuthorizationErrorCallback, 0 } },
+ { "listener"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__listenerGetterWrap, 0 } },
+ { "localPort"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__localPortGetterWrap, 0 } },
+ { "readyState"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__readyStateGetterWrap, 0 } },
+ { "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__refCallback, 0 } },
+ { "reload"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__reloadCallback, 1 } },
+ { "remoteAddress"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TLSSocketPrototype__remoteAddressGetterWrap, 0 } },
+ { "shutdown"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__shutdownCallback, 1 } },
+ { "timeout"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__timeoutCallback, 1 } },
+ { "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__unrefCallback, 0 } },
+ { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TLSSocketPrototype__writeCallback, 3 } }
};
-
-
const ClassInfo JSTLSSocketPrototype::s_info = { "TLSSocket"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTLSSocketPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsTLSSocketConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -13128,14 +12471,12 @@ JSC_DEFINE_CUSTOM_GETTER(jsTLSSocketConstructor, (JSGlobalObject * lexicalGlobal
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSTLSSocketConstructor());
-}
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__authorizedGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13143,42 +12484,37 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__authorizedGetterWrap, (JSGlobalObje
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__dataGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_data.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- TLSSocketPrototype__getData(thisObject->wrapped(), globalObject)
- );
+ TLSSocketPrototype__getData(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_data.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void TLSSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
+ thisObject->m_data.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void TLSSocketPrototype__dataSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
- thisObject->m_data.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue TLSSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue TLSSocketPrototype__dataGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_data.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_SETTER(TLSSocketPrototype__dataSetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName))
{
@@ -13191,62 +12527,58 @@ JSC_DEFINE_CUSTOM_SETTER(TLSSocketPrototype__dataSetterWrap, (JSGlobalObject * l
RELEASE_AND_RETURN(throwScope, result);
}
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__endCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__endCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
-
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__end(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
+ return TLSSocketPrototype__end(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__flushCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__flush(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getAuthorizationErrorCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
+ return TLSSocketPrototype__flush(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__getAuthorizationErrorCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__getAuthorizationError(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TLSSocketPrototype__getAuthorizationError(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__listenerGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13254,12 +12586,11 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__listenerGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__localPortGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13267,12 +12598,11 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__localPortGetterWrap, (JSGlobalObjec
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__readyStateGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13280,144 +12610,133 @@ JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__readyStateGetterWrap, (JSGlobalObje
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
+ return TLSSocketPrototype__ref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__reloadCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TLSSocketPrototype__reload(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(TLSSocketPrototype__remoteAddressGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_remoteAddress.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- TLSSocketPrototype__getRemoteAddress(thisObject->wrapped(), globalObject)
- );
+ TLSSocketPrototype__getRemoteAddress(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_remoteAddress.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void TLSSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
+ thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void TLSSocketPrototype__remoteAddressSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
- thisObject->m_remoteAddress.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue TLSSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue TLSSocketPrototype__remoteAddressGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSTLSSocket*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_remoteAddress.get());
- }
-
-
-
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__shutdownCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__shutdown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__timeoutCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
+ return TLSSocketPrototype__shutdown(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__timeoutCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__timeout(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
+ return TLSSocketPrototype__timeout(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
+ return TLSSocketPrototype__unref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TLSSocketPrototype__writeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTLSSocket* thisObject = jsDynamicCast<JSTLSSocket*>(callFrame->thisValue());
- return TLSSocketPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TLSSocketPrototype__write(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSTLSSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -13427,9 +12746,10 @@ void JSTLSSocketPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* glob
}
extern "C" bool TLSSocket__hasPendingActivity(void* ptr);
- bool JSTLSSocket::hasPendingActivity(void* ctx) {
- return TLSSocket__hasPendingActivity(ctx);
- }
+bool JSTLSSocket::hasPendingActivity(void* ctx)
+{
+ return TLSSocket__hasPendingActivity(ctx);
+}
JSTLSSocket::~JSTLSSocket()
{
@@ -13441,7 +12761,7 @@ void JSTLSSocket::destroy(JSCell* cell)
{
static_cast<JSTLSSocket*>(cell)->JSTLSSocket::~JSTLSSocket();
}
-
+
const ClassInfo JSTLSSocket::s_info = { "TLSSocket"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTLSSocket) };
void JSTLSSocket::finishCreation(VM& vm)
@@ -13450,36 +12770,37 @@ void JSTLSSocket::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSTLSSocket* JSTLSSocket::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSTLSSocket* ptr = new (NotNull, JSC::allocateCell<JSTLSSocket>(vm)) JSTLSSocket(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSTLSSocket* JSTLSSocket::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSTLSSocket* ptr = new (NotNull, JSC::allocateCell<JSTLSSocket>(vm)) JSTLSSocket(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* TLSSocket__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* TLSSocket__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSTLSSocket* object = JSC::jsDynamicCast<JSTLSSocket*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSTLSSocket* object = JSC::jsDynamicCast<JSTLSSocket*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool TLSSocket__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSTLSSocket* object = JSC::jsDynamicCast<JSTLSSocket*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool TLSSocket__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSTLSSocket* object = JSC::jsDynamicCast<JSTLSSocket*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t TLSSocket__ptrOffset = JSTLSSocket::offsetOfWrapped();
@@ -13493,19 +12814,18 @@ void JSTLSSocket::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
Base::analyzeHeap(cell, analyzer);
}
-
-
JSObject* JSTLSSocket::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
{
return JSTLSSocketPrototype::create(vm, globalObject, JSTLSSocketPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue TLSSocket__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSTLSSocketStructure();
- JSTLSSocket* instance = JSTLSSocket::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue TLSSocket__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSTLSSocketStructure();
+ JSTLSSocket* instance = JSTLSSocket::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -13514,11 +12834,10 @@ void JSTLSSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
+
visitor.append(thisObject->m_data);
visitor.append(thisObject->m_remoteAddress);
-visitor.addOpaqueRoot(thisObject->wrapped());
+ visitor.addOpaqueRoot(thisObject->wrapped());
}
DEFINE_VISIT_CHILDREN(JSTLSSocket);
@@ -13526,10 +12845,10 @@ DEFINE_VISIT_CHILDREN(JSTLSSocket);
template<typename Visitor>
void JSTLSSocket::visitAdditionalChildren(Visitor& visitor)
{
- JSTLSSocket* thisObject = this;
+ JSTLSSocket* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_data);
+
+ visitor.append(thisObject->m_data);
visitor.append(thisObject->m_remoteAddress);
visitor.addOpaqueRoot(this->wrapped());
}
@@ -13537,7 +12856,7 @@ void JSTLSSocket::visitAdditionalChildren(Visitor& visitor)
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSTLSSocket);
template<typename Visitor>
-void JSTLSSocket::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSTLSSocket::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -13545,91 +12864,88 @@ void JSTLSSocket::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSTLSSocket);
- class JSTextDecoderPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSTextDecoderPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSTextDecoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextDecoderPrototype>(vm)) JSTextDecoderPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSTextDecoderPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSTextDecoderPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSTextDecoderPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSTextDecoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextDecoderPrototype>(vm)) JSTextDecoderPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSTextDecoderPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSTextDecoderConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSTextDecoderConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTextDecoderPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSTextDecoderConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForTextDecoderConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextDecoderConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForTextDecoderConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForTextDecoderConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSTextDecoderConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSTextDecoderConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTextDecoderPrototype* prototype);
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSTextDecoderConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForTextDecoderConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextDecoderConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForTextDecoderConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForTextDecoderConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSTextDecoderConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype);
+};
extern "C" void* TextDecoderClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsTextDecoderConstructor);
extern "C" void TextDecoderClass__finalize(void*);
-
extern "C" EncodedJSValue TextDecoderPrototype__decode(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TextDecoderPrototype__decodeCallback);
-
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(TextDecoderPrototype__decodeWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg0));
- extern "C" EncodedJSValue TextDecoderPrototype__decodeWithoutTypeChecks(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject, JSC::JSUint8Array* arg0);
+extern "C" EncodedJSValue TextDecoderPrototype__decodeWithoutTypeChecks(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSUint8Array* arg0);
- static const JSC::DOMJIT::Signature DOMJITSignatureForTextDecoderPrototype__decode(TextDecoderPrototype__decodeWithoutTypeChecksWrapper,
- JSTextDecoder::info(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- JSC::SpecString, JSC::SpecUint8Array);
+static const JSC::DOMJIT::Signature DOMJITSignatureForTextDecoderPrototype__decode(TextDecoderPrototype__decodeWithoutTypeChecksWrapper,
+ JSTextDecoder::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ JSC::SpecString, JSC::SpecUint8Array);
JSC_DEFINE_JIT_OPERATION(TextDecoderPrototype__decodeWithoutTypeChecksWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg0))
{
@@ -13644,26 +12960,19 @@ JSC_DEFINE_JIT_OPERATION(TextDecoderPrototype__decodeWithoutTypeChecksWrapper, E
extern "C" JSC::EncodedJSValue TextDecoderPrototype__getEncoding(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TextDecoderPrototype__encodingGetterWrap);
-
extern "C" JSC::EncodedJSValue TextDecoderPrototype__getFatal(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject);
JSC_DECLARE_CUSTOM_GETTER(TextDecoderPrototype__fatalGetterWrap);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTextDecoderPrototype, JSTextDecoderPrototype::Base);
-
- static const HashTableValue JSTextDecoderPrototypeTableValues[] = {
-{ "decode"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, TextDecoderPrototype__decodeCallback, &DOMJITSignatureForTextDecoderPrototype__decode } } ,
-{ "encoding"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TextDecoderPrototype__encodingGetterWrap, 0 } } ,
-{ "fatal"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TextDecoderPrototype__fatalGetterWrap, 0 } }
+static const HashTableValue JSTextDecoderPrototypeTableValues[] = {
+ { "decode"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::DOMJITFunctionType, TextDecoderPrototype__decodeCallback, &DOMJITSignatureForTextDecoderPrototype__decode } },
+ { "encoding"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TextDecoderPrototype__encodingGetterWrap, 0 } },
+ { "fatal"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::GetterSetterType, TextDecoderPrototype__fatalGetterWrap, 0 } }
};
-
-
const ClassInfo JSTextDecoderPrototype::s_info = { "TextDecoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextDecoderPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsTextDecoderConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -13674,66 +12983,59 @@ JSC_DEFINE_CUSTOM_GETTER(jsTextDecoderConstructor, (JSGlobalObject * lexicalGlob
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSTextDecoderConstructor());
-}
-
-
+}
- JSC_DEFINE_HOST_FUNCTION(TextDecoderPrototype__decodeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+JSC_DEFINE_HOST_FUNCTION(TextDecoderPrototype__decodeCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSTextDecoder* thisObject = jsDynamicCast<JSTextDecoder*>(callFrame->thisValue());
+ JSTextDecoder* thisObject = jsDynamicCast<JSTextDecoder*>(callFrame->thisValue());
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- return TextDecoderPrototype__decode(thisObject->wrapped(), lexicalGlobalObject, callFrame);
- }
-
+ return TextDecoderPrototype__decode(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
JSC_DEFINE_CUSTOM_GETTER(TextDecoderPrototype__encodingGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTextDecoder* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(thisValue));
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
-
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
if (JSValue cachedValue = thisObject->m_encoding.get())
return JSValue::encode(cachedValue);
-
+
JSC::JSValue result = JSC::JSValue::decode(
- TextDecoderPrototype__getEncoding(thisObject->wrapped(), globalObject)
- );
+ TextDecoderPrototype__getEncoding(thisObject->wrapped(), globalObject));
RETURN_IF_EXCEPTION(throwScope, {});
thisObject->m_encoding.set(vm, thisObject, result);
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
}
+extern "C" void TextDecoderPrototype__encodingSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(thisValue));
+ thisObject->m_encoding.set(vm, thisObject, JSValue::decode(value));
+}
- extern "C" void TextDecoderPrototype__encodingSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value)
- {
- auto& vm = globalObject->vm();
- auto* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(thisValue));
- thisObject->m_encoding.set(vm, thisObject, JSValue::decode(value));
- }
-
- extern "C" EncodedJSValue TextDecoderPrototype__encodingGetCachedValue(JSC::EncodedJSValue thisValue)
- {
+extern "C" EncodedJSValue TextDecoderPrototype__encodingGetCachedValue(JSC::EncodedJSValue thisValue)
+{
auto* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(thisValue));
return JSValue::encode(thisObject->m_encoding.get());
- }
-
-
+}
JSC_DEFINE_CUSTOM_GETTER(TextDecoderPrototype__fatalGetterWrap, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
{
auto& vm = lexicalGlobalObject->vm();
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSTextDecoder* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(thisValue));
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
@@ -13741,7 +13043,6 @@ JSC_DEFINE_CUSTOM_GETTER(TextDecoderPrototype__fatalGetterWrap, (JSGlobalObject
RETURN_IF_EXCEPTION(throwScope, {});
RELEASE_AND_RETURN(throwScope, result);
}
-
void JSTextDecoderPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -13753,67 +13054,64 @@ void JSTextDecoderPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* gl
void JSTextDecoderConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype)
{
Base::finishCreation(vm, 0, "TextDecoder"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSTextDecoderConstructor::JSTextDecoderConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSTextDecoderConstructor::JSTextDecoderConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSTextDecoderConstructor* JSTextDecoderConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTextDecoderPrototype* prototype) {
+JSTextDecoderConstructor* JSTextDecoderConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTextDecoderPrototype* prototype)
+{
JSTextDecoderConstructor* ptr = new (NotNull, JSC::allocateCell<JSTextDecoderConstructor>(vm)) JSTextDecoderConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSTextDecoderConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSTextDecoderConstructor();
Structure* structure = globalObject->JSTextDecoderStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSTextDecoderStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSTextDecoderStructure());
}
void* ptr = TextDecoderClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSTextDecoder* instance = JSTextDecoder::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSTextDecoderConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype)
{
-
}
const ClassInfo JSTextDecoderConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextDecoderConstructor) };
-
- extern "C" EncodedJSValue TextDecoder__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue TextDecoder__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSTextDecoderConstructor());
- }
+}
JSTextDecoder::~JSTextDecoder()
{
@@ -13825,7 +13123,7 @@ void JSTextDecoder::destroy(JSCell* cell)
{
static_cast<JSTextDecoder*>(cell)->JSTextDecoder::~JSTextDecoder();
}
-
+
const ClassInfo JSTextDecoder::s_info = { "TextDecoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextDecoder) };
void JSTextDecoder::finishCreation(VM& vm)
@@ -13834,36 +13132,37 @@ void JSTextDecoder::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSTextDecoder* JSTextDecoder::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSTextDecoder* ptr = new (NotNull, JSC::allocateCell<JSTextDecoder>(vm)) JSTextDecoder(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSTextDecoder* JSTextDecoder::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSTextDecoder* ptr = new (NotNull, JSC::allocateCell<JSTextDecoder>(vm)) JSTextDecoder(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* TextDecoder__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* TextDecoder__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSTextDecoder* object = JSC::jsDynamicCast<JSTextDecoder*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSTextDecoder* object = JSC::jsDynamicCast<JSTextDecoder*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool TextDecoder__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSTextDecoder* object = JSC::jsDynamicCast<JSTextDecoder*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool TextDecoder__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSTextDecoder* object = JSC::jsDynamicCast<JSTextDecoder*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t TextDecoder__ptrOffset = JSTextDecoder::offsetOfWrapped();
@@ -13879,7 +13178,7 @@ void JSTextDecoder::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSTextDecoder::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSTextDecoderConstructor::create(vm, globalObject, WebCore::JSTextDecoderConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSTextDecoderPrototype*>(prototype));
+ return WebCore::JSTextDecoderConstructor::create(vm, globalObject, WebCore::JSTextDecoderConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSTextDecoderPrototype*>(prototype));
}
JSObject* JSTextDecoder::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -13887,12 +13186,13 @@ JSObject* JSTextDecoder::createPrototype(VM& vm, JSDOMGlobalObject* globalObject
return JSTextDecoderPrototype::create(vm, globalObject, JSTextDecoderPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue TextDecoder__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSTextDecoderStructure();
- JSTextDecoder* instance = JSTextDecoder::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue TextDecoder__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSTextDecoderStructure();
+ JSTextDecoder* instance = JSTextDecoder::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
template<typename Visitor>
@@ -13901,10 +13201,8 @@ void JSTextDecoder::visitChildrenImpl(JSCell* cell, Visitor& visitor)
JSTextDecoder* thisObject = jsCast<JSTextDecoder*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
-
-
- visitor.append(thisObject->m_encoding);
+ visitor.append(thisObject->m_encoding);
}
DEFINE_VISIT_CHILDREN(JSTextDecoder);
@@ -13912,17 +13210,17 @@ DEFINE_VISIT_CHILDREN(JSTextDecoder);
template<typename Visitor>
void JSTextDecoder::visitAdditionalChildren(Visitor& visitor)
{
- JSTextDecoder* thisObject = this;
+ JSTextDecoder* thisObject = this;
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
- visitor.append(thisObject->m_encoding);
+
+ visitor.append(thisObject->m_encoding);
;
}
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSTextDecoder);
template<typename Visitor>
-void JSTextDecoder::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
+void JSTextDecoder::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
{
JSTextDecoder* thisObject = jsCast<JSTextDecoder*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
@@ -13930,137 +13228,124 @@ void JSTextDecoder::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
}
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSTextDecoder);
- class JSTimeoutPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSTimeoutPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSTimeoutPrototype* ptr = new (NotNull, JSC::allocateCell<JSTimeoutPrototype>(vm)) JSTimeoutPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSTimeoutPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+class JSTimeoutPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
-extern "C" void TimeoutClass__finalize(void*);
+ static JSTimeoutPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSTimeoutPrototype* ptr = new (NotNull, JSC::allocateCell<JSTimeoutPrototype>(vm)) JSTimeoutPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+private:
+ JSTimeoutPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
+
+extern "C" void TimeoutClass__finalize(void*);
extern "C" EncodedJSValue TimeoutPrototype__toPrimitive(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TimeoutPrototype__toPrimitiveCallback);
-
extern "C" EncodedJSValue TimeoutPrototype__hasRef(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TimeoutPrototype__hasRefCallback);
-
extern "C" EncodedJSValue TimeoutPrototype__doRef(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TimeoutPrototype__refCallback);
-
extern "C" EncodedJSValue TimeoutPrototype__doUnref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TimeoutPrototype__unrefCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTimeoutPrototype, JSTimeoutPrototype::Base);
-
- static const HashTableValue JSTimeoutPrototypeTableValues[] = {
-{ "hasRef"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__hasRefCallback, 0 } } ,
-{ "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__refCallback, 0 } } ,
-{ "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__unrefCallback, 0 } }
+static const HashTableValue JSTimeoutPrototypeTableValues[] = {
+ { "hasRef"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__hasRefCallback, 0 } },
+ { "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__refCallback, 0 } },
+ { "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__unrefCallback, 0 } }
};
-
-
const ClassInfo JSTimeoutPrototype::s_info = { "Timeout"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTimeoutPrototype) };
+JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__toPrimitiveCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__toPrimitiveCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
-
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
-
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
- return TimeoutPrototype__toPrimitive(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__hasRefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
+ return TimeoutPrototype__toPrimitive(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__hasRefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
- return TimeoutPrototype__hasRef(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
+ return TimeoutPrototype__hasRef(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__refCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
- return TimeoutPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
+ return TimeoutPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
- return TimeoutPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TimeoutPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSTimeoutPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -14080,7 +13365,7 @@ void JSTimeout::destroy(JSCell* cell)
{
static_cast<JSTimeout*>(cell)->JSTimeout::~JSTimeout();
}
-
+
const ClassInfo JSTimeout::s_info = { "Timeout"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTimeout) };
void JSTimeout::finishCreation(VM& vm)
@@ -14089,36 +13374,37 @@ void JSTimeout::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSTimeout* JSTimeout::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSTimeout* ptr = new (NotNull, JSC::allocateCell<JSTimeout>(vm)) JSTimeout(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSTimeout* JSTimeout::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSTimeout* ptr = new (NotNull, JSC::allocateCell<JSTimeout>(vm)) JSTimeout(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Timeout__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Timeout__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSTimeout* object = JSC::jsDynamicCast<JSTimeout*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSTimeout* object = JSC::jsDynamicCast<JSTimeout*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Timeout__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSTimeout* object = JSC::jsDynamicCast<JSTimeout*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Timeout__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSTimeout* object = JSC::jsDynamicCast<JSTimeout*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Timeout__ptrOffset = JSTimeout::offsetOfWrapped();
@@ -14132,126 +13418,114 @@ void JSTimeout::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
Base::analyzeHeap(cell, analyzer);
}
-
-
JSObject* JSTimeout::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
{
return JSTimeoutPrototype::create(vm, globalObject, JSTimeoutPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Timeout__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSTimeoutStructure();
- JSTimeout* instance = JSTimeout::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
-}
- class JSTranspilerPrototype final : public JSC::JSNonFinalObject {
- public:
- using Base = JSC::JSNonFinalObject;
-
- static JSTranspilerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
- {
- JSTranspilerPrototype* ptr = new (NotNull, JSC::allocateCell<JSTranspilerPrototype>(vm)) JSTranspilerPrototype(vm, globalObject, structure);
- ptr->finishCreation(vm, globalObject);
- return ptr;
- }
-
- DECLARE_INFO;
- template<typename CellType, JSC::SubspaceAccess>
- static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- return &vm.plainObjectSpace();
- }
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
- }
-
- private:
- JSTranspilerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
- : Base(vm, structure)
- {
- }
-
- void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
- };
+extern "C" EncodedJSValue Timeout__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSTimeoutStructure();
+ JSTimeout* instance = JSTimeout::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
+}
+class JSTranspilerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+
+ static JSTranspilerPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSTranspilerPrototype* ptr = new (NotNull, JSC::allocateCell<JSTranspilerPrototype>(vm)) JSTranspilerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm, globalObject);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSTranspilerPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject*);
+};
class JSTranspilerConstructor final : public JSC::InternalFunction {
- public:
- using Base = JSC::InternalFunction;
- static JSTranspilerConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTranspilerPrototype* prototype);
-
- static constexpr unsigned StructureFlags = Base::StructureFlags;
- static constexpr bool needsDestruction = false;
-
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
- }
-
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSTranspilerConstructor, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForTranspilerConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTranspilerConstructor = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForTranspilerConstructor.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForTranspilerConstructor = std::forward<decltype(space)>(space); });
- }
-
-
- void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTranspilerPrototype* prototype);
-
- // Must be defined for each specialization class.
- static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
-
- DECLARE_EXPORT_INFO;
- private:
- JSTranspilerConstructor(JSC::VM& vm, JSC::Structure* structure);
- void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTranspilerPrototype* prototype);
- };
+public:
+ using Base = JSC::InternalFunction;
+ static JSTranspilerConstructor* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTranspilerPrototype* prototype);
+
+ static constexpr unsigned StructureFlags = Base::StructureFlags;
+ static constexpr bool needsDestruction = false;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSTranspilerConstructor, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForTranspilerConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTranspilerConstructor = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForTranspilerConstructor.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForTranspilerConstructor = std::forward<decltype(space)>(space); });
+ }
+
+ void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSTranspilerPrototype* prototype);
+
+ // Must be defined for each specialization class.
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+ DECLARE_EXPORT_INFO;
+
+private:
+ JSTranspilerConstructor(JSC::VM& vm, JSC::Structure* structure);
+ void finishCreation(JSC::VM&, JSC::JSGlobalObject* globalObject, JSTranspilerPrototype* prototype);
+};
extern "C" void* TranspilerClass__construct(JSC::JSGlobalObject*, JSC::CallFrame*);
JSC_DECLARE_CUSTOM_GETTER(jsTranspilerConstructor);
extern "C" void TranspilerClass__finalize(void*);
-
extern "C" EncodedJSValue TranspilerPrototype__scan(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TranspilerPrototype__scanCallback);
-
extern "C" EncodedJSValue TranspilerPrototype__scanImports(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TranspilerPrototype__scanImportsCallback);
-
extern "C" EncodedJSValue TranspilerPrototype__transform(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TranspilerPrototype__transformCallback);
-
extern "C" EncodedJSValue TranspilerPrototype__transformSync(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TranspilerPrototype__transformSyncCallback);
-
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTranspilerPrototype, JSTranspilerPrototype::Base);
-
- static const HashTableValue JSTranspilerPrototypeTableValues[] = {
-{ "scan"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TranspilerPrototype__scanCallback, 2 } } ,
-{ "scanImports"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TranspilerPrototype__scanImportsCallback, 2 } } ,
-{ "transform"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TranspilerPrototype__transformCallback, 2 } } ,
-{ "transformSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TranspilerPrototype__transformSyncCallback, 2 } }
+static const HashTableValue JSTranspilerPrototypeTableValues[] = {
+ { "scan"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TranspilerPrototype__scanCallback, 2 } },
+ { "scanImports"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TranspilerPrototype__scanImportsCallback, 2 } },
+ { "transform"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TranspilerPrototype__transformCallback, 2 } },
+ { "transformSync"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TranspilerPrototype__transformSyncCallback, 2 } }
};
-
-
const ClassInfo JSTranspilerPrototype::s_info = { "Transpiler"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTranspilerPrototype) };
-
-
JSC_DEFINE_CUSTOM_GETTER(jsTranspilerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
{
VM& vm = JSC::getVM(lexicalGlobalObject);
@@ -14262,77 +13536,71 @@ JSC_DEFINE_CUSTOM_GETTER(jsTranspilerConstructor, (JSGlobalObject * lexicalGloba
if (UNLIKELY(!prototype))
return throwVMTypeError(lexicalGlobalObject, throwScope);
return JSValue::encode(globalObject->JSTranspilerConstructor());
-}
-
-
-
- JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__scanCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
-
- JSTranspiler* thisObject = jsDynamicCast<JSTranspiler*>(callFrame->thisValue());
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__scanCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTranspiler* thisObject = jsDynamicCast<JSTranspiler*>(callFrame->thisValue());
- return TranspilerPrototype__scan(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__scanImportsCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTranspiler* thisObject = jsDynamicCast<JSTranspiler*>(callFrame->thisValue());
+ return TranspilerPrototype__scan(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__scanImportsCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTranspiler* thisObject = jsDynamicCast<JSTranspiler*>(callFrame->thisValue());
- return TranspilerPrototype__scanImports(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__transformCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTranspiler* thisObject = jsDynamicCast<JSTranspiler*>(callFrame->thisValue());
+ return TranspilerPrototype__scanImports(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__transformCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTranspiler* thisObject = jsDynamicCast<JSTranspiler*>(callFrame->thisValue());
- return TranspilerPrototype__transform(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
- JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__transformSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
- {
- auto& vm = lexicalGlobalObject->vm();
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
- JSTranspiler* thisObject = jsDynamicCast<JSTranspiler*>(callFrame->thisValue());
+ return TranspilerPrototype__transform(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
- if (UNLIKELY(!thisObject)) {
- auto throwScope = DECLARE_THROW_SCOPE(vm);
- return throwVMTypeError(lexicalGlobalObject, throwScope);
- }
+JSC_DEFINE_HOST_FUNCTION(TranspilerPrototype__transformSyncCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
- JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+ JSTranspiler* thisObject = jsDynamicCast<JSTranspiler*>(callFrame->thisValue());
- return TranspilerPrototype__transformSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
}
-
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TranspilerPrototype__transformSync(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
void JSTranspilerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
@@ -14344,69 +13612,64 @@ void JSTranspilerPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* glo
void JSTranspilerConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSTranspilerPrototype* prototype)
{
Base::finishCreation(vm, 0, "Transpiler"_s, PropertyAdditionMode::WithoutStructureTransition);
-
+
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
ASSERT(inherits(info()));
}
-JSTranspilerConstructor::JSTranspilerConstructor(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure, construct, construct) {
-
- }
+JSTranspilerConstructor::JSTranspilerConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct, construct)
+{
+}
-JSTranspilerConstructor* JSTranspilerConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTranspilerPrototype* prototype) {
+JSTranspilerConstructor* JSTranspilerConstructor::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, JSTranspilerPrototype* prototype)
+{
JSTranspilerConstructor* ptr = new (NotNull, JSC::allocateCell<JSTranspilerConstructor>(vm)) JSTranspilerConstructor(vm, structure);
ptr->finishCreation(vm, globalObject, prototype);
return ptr;
}
-
JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSTranspilerConstructor::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
{
- Zig::GlobalObject *globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
- JSC::VM &vm = globalObject->vm();
+ Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
+ JSC::VM& vm = globalObject->vm();
JSObject* newTarget = asObject(callFrame->newTarget());
auto* constructor = globalObject->JSTranspilerConstructor();
Structure* structure = globalObject->JSTranspilerStructure();
if (constructor != newTarget) {
- auto scope = DECLARE_THROW_SCOPE(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
- auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
- // ShadowRealm functions belong to a different global object.
- getFunctionRealm(globalObject, newTarget)
- );
- RETURN_IF_EXCEPTION(scope, {});
- structure = InternalFunction::createSubclassStructure(
- globalObject,
- newTarget,
- functionGlobalObject->JSTranspilerStructure()
- );
+ auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(
+ // ShadowRealm functions belong to a different global object.
+ getFunctionRealm(globalObject, newTarget));
+ RETURN_IF_EXCEPTION(scope, {});
+ structure = InternalFunction::createSubclassStructure(
+ globalObject,
+ newTarget,
+ functionGlobalObject->JSTranspilerStructure());
}
void* ptr = TranspilerClass__construct(globalObject, callFrame);
if (UNLIKELY(!ptr)) {
- return JSValue::encode(JSC::jsUndefined());
+ return JSValue::encode(JSC::jsUndefined());
}
JSTranspiler* instance = JSTranspiler::create(vm, globalObject, structure, ptr);
-
return JSValue::encode(instance);
}
void JSTranspilerConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSTranspilerPrototype* prototype)
{
-
}
const ClassInfo JSTranspilerConstructor::s_info = { "Function"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTranspilerConstructor) };
-
- extern "C" EncodedJSValue Transpiler__getConstructor(Zig::GlobalObject* globalObject) {
+extern "C" EncodedJSValue Transpiler__getConstructor(Zig::GlobalObject* globalObject)
+{
return JSValue::encode(globalObject->JSTranspilerConstructor());
- }
-
-#include "JSTranspiler+BunPlugin-impl.h";
+}
JSTranspiler::~JSTranspiler()
{
@@ -14418,7 +13681,7 @@ void JSTranspiler::destroy(JSCell* cell)
{
static_cast<JSTranspiler*>(cell)->JSTranspiler::~JSTranspiler();
}
-
+
const ClassInfo JSTranspiler::s_info = { "Transpiler"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTranspiler) };
void JSTranspiler::finishCreation(VM& vm)
@@ -14427,36 +13690,37 @@ void JSTranspiler::finishCreation(VM& vm)
ASSERT(inherits(info()));
}
-
-JSTranspiler* JSTranspiler::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx) {
- JSTranspiler* ptr = new (NotNull, JSC::allocateCell<JSTranspiler>(vm)) JSTranspiler(vm, structure, ctx);
- ptr->finishCreation(vm);
- return ptr;
+JSTranspiler* JSTranspiler::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx)
+{
+ JSTranspiler* ptr = new (NotNull, JSC::allocateCell<JSTranspiler>(vm)) JSTranspiler(vm, structure, ctx);
+ ptr->finishCreation(vm);
+ return ptr;
}
-extern "C" void* Transpiler__fromJS(JSC::EncodedJSValue value) {
- JSC::JSValue decodedValue = JSC::JSValue::decode(value);
- if (decodedValue.isEmpty() || !decodedValue.isCell())
- return nullptr;
+extern "C" void* Transpiler__fromJS(JSC::EncodedJSValue value)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(value);
+ if (decodedValue.isEmpty() || !decodedValue.isCell())
+ return nullptr;
- JSC::JSCell* cell = decodedValue.asCell();
- JSTranspiler* object = JSC::jsDynamicCast<JSTranspiler*>(cell);
+ JSC::JSCell* cell = decodedValue.asCell();
+ JSTranspiler* object = JSC::jsDynamicCast<JSTranspiler*>(cell);
- if (!object)
- return nullptr;
-
- return object->wrapped();
-}
+ if (!object)
+ return nullptr;
-extern "C" bool Transpiler__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr) {
- JSTranspiler* object = JSC::jsDynamicCast<JSTranspiler*>(JSValue::decode(value));
- if (!object)
- return false;
-
- object->m_ctx = ptr;
- return true;
+ return object->wrapped();
}
+extern "C" bool Transpiler__dangerouslySetPtr(JSC::EncodedJSValue value, void* ptr)
+{
+ JSTranspiler* object = JSC::jsDynamicCast<JSTranspiler*>(JSValue::decode(value));
+ if (!object)
+ return false;
+
+ object->m_ctx = ptr;
+ return true;
+}
extern "C" const size_t Transpiler__ptrOffset = JSTranspiler::offsetOfWrapped();
@@ -14472,7 +13736,7 @@ void JSTranspiler::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
JSObject* JSTranspiler::createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
- return WebCore::JSTranspilerConstructor::create(vm, globalObject, WebCore::JSTranspilerConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSTranspilerPrototype*>(prototype));
+ return WebCore::JSTranspilerConstructor::create(vm, globalObject, WebCore::JSTranspilerConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<WebCore::JSTranspilerPrototype*>(prototype));
}
JSObject* JSTranspiler::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
@@ -14480,13 +13744,13 @@ JSObject* JSTranspiler::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
return JSTranspilerPrototype::create(vm, globalObject, JSTranspilerPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
-extern "C" EncodedJSValue Transpiler__create(Zig::GlobalObject* globalObject, void* ptr) {
- auto &vm = globalObject->vm();
- JSC::Structure* structure = globalObject->JSTranspilerStructure();
- JSTranspiler* instance = JSTranspiler::create(vm, globalObject, structure, ptr);
-
- return JSValue::encode(instance);
+extern "C" EncodedJSValue Transpiler__create(Zig::GlobalObject* globalObject, void* ptr)
+{
+ auto& vm = globalObject->vm();
+ JSC::Structure* structure = globalObject->JSTranspilerStructure();
+ JSTranspiler* instance = JSTranspiler::create(vm, globalObject, structure, ptr);
+
+ return JSValue::encode(instance);
}
} // namespace WebCore
-
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index ed0532ce3..b1b59451f 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -10,1784 +10,1635 @@ namespace Zig {
#include "JSDOMWrapper.h"
#include <wtf/NeverDestroyed.h>
-#include "BunPlugin.h";
-
namespace WebCore {
using namespace Zig;
using namespace JSC;
class JSBlob final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSBlob* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSBlob, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForBlob.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBlob = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForBlob.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForBlob = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSBlob();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSBlob, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSBlob(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSBlob* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSBlob, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForBlob.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBlob = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForBlob.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForBlob = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSBlob();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSBlob, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSBlob(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSBundler final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSBundler* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSBundler, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForBundler.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBundler = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForBundler.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForBundler = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSBundler();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSBundler, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSBundler(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ m_weakThis = JSC::Weak<JSBundler>(this, getOwner());
+ }
+
+ void finishCreation(JSC::VM&);
+
+ JSC::Weak<JSBundler> m_weakThis;
-
-
-
- };
+ static bool hasPendingActivity(void* ctx);
-class JSCryptoHasher final : public JSC::JSDestructibleObject {
+ class Owner final : public JSC::WeakHandleOwner {
public:
- using Base = JSC::JSDestructibleObject;
- static JSCryptoHasher* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSCryptoHasher, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForCryptoHasher.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCryptoHasher = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForCryptoHasher.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForCryptoHasher = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSCryptoHasher();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
+ bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
{
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSCryptoHasher, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSCryptoHasher(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
+ auto* controller = JSC::jsCast<JSBundler*>(handle.slot()->asCell());
+ if (JSBundler::hasPendingActivity(controller->wrapped())) {
+ if (UNLIKELY(reason))
+ *reason = "has pending activity";
+ return true;
+ }
-
+ return visitor.containsOpaqueRoot(context);
+ }
+ void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
+ };
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+ static JSC::WeakHandleOwner* getOwner()
+ {
+ static NeverDestroyed<Owner> m_owner;
+ return &m_owner.get();
+ }
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+};
- mutable JSC::WriteBarrier<JSC::Unknown> m_algorithms;
-mutable JSC::WriteBarrier<JSC::Unknown> m_algorithm;
- };
+class JSCryptoHasher final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSCryptoHasher* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSCryptoHasher, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForCryptoHasher.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForCryptoHasher = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForCryptoHasher.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForCryptoHasher = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSCryptoHasher();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSCryptoHasher, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSCryptoHasher(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_algorithms;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_algorithm;
+};
class JSDirent final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSDirent* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSDirent, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForDirent.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForDirent = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForDirent.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForDirent = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSDirent();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSDirent, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSDirent(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSDirent* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSDirent, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForDirent.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForDirent = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForDirent.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForDirent = std::forward<decltype(space)>(space); });
+ }
-
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
+ }
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+ ~JSDirent();
- mutable JSC::WriteBarrier<JSC::Unknown> m_name;
- };
-
-class JSExpect final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSExpect* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSExpect, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForExpect.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForExpect = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForExpect.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForExpect = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSExpect();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSExpect, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSExpect(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
+ void* wrapped() const { return m_ctx; }
-
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
-
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSDirent, m_ctx); }
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+ void* m_ctx { nullptr };
+ JSDirent(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
- mutable JSC::WriteBarrier<JSC::Unknown> m_capturedValue;
-mutable JSC::WriteBarrier<JSC::Unknown> m_resultValue;
- };
+ void finishCreation(JSC::VM&);
-class JSExpectAny final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSExpectAny* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSExpectAny, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForExpectAny.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForExpectAny = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForExpectAny.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForExpectAny = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- ;
-
- ~JSExpectAny();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSExpectAny, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSExpectAny(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
-
+ mutable JSC::WriteBarrier<JSC::Unknown> m_name;
+};
-
+class JSExpect final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSExpect* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSExpect, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForExpect.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForExpect = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForExpect.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForExpect = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSExpect();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSExpect, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSExpect(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_capturedValue;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_resultValue;
+};
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+class JSExpectAny final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSExpectAny* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSExpectAny, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForExpectAny.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForExpectAny = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForExpectAny.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForExpectAny = std::forward<decltype(space)>(space); });
+ }
- mutable JSC::WriteBarrier<JSC::Unknown> m_constructorValue;
- };
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
-class JSFileSystemRouter final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSFileSystemRouter* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSFileSystemRouter, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForFileSystemRouter.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForFileSystemRouter = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForFileSystemRouter.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForFileSystemRouter = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSFileSystemRouter();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSFileSystemRouter, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSFileSystemRouter(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
-
+ ~JSExpectAny();
-
+ void* wrapped() const { return m_ctx; }
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSExpectAny, m_ctx); }
- mutable JSC::WriteBarrier<JSC::Unknown> m_origin;
-mutable JSC::WriteBarrier<JSC::Unknown> m_routes;
-mutable JSC::WriteBarrier<JSC::Unknown> m_style;
- };
+ void* m_ctx { nullptr };
-class JSListener final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSListener* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSListener, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForListener.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForListener = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForListener.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForListener = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- ;
-
- ~JSListener();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSListener, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSListener(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
+ JSExpectAny(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
-
+ void finishCreation(JSC::VM&);
-
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_constructorValue;
+};
+class JSFileSystemRouter final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSFileSystemRouter* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSFileSystemRouter, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForFileSystemRouter.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForFileSystemRouter = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForFileSystemRouter.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForFileSystemRouter = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSFileSystemRouter();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSFileSystemRouter, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSFileSystemRouter(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_origin;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_routes;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_style;
+};
- mutable JSC::WriteBarrier<JSC::Unknown> m_hostname;
-mutable JSC::WriteBarrier<JSC::Unknown> m_unix;
- };
+class JSListener final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSListener* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSListener, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForListener.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForListener = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForListener.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForListener = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSListener();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSListener, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSListener(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_hostname;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_unix;
+};
class JSMD4 final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSMD4* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSMD4, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForMD4.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD4 = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForMD4.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForMD4 = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSMD4();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSMD4, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSMD4(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSMD4* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSMD4, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForMD4.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD4 = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForMD4.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForMD4 = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSMD4();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSMD4, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSMD4(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSMD5 final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSMD5* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSMD5, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForMD5.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD5 = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForMD5.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForMD5 = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSMD5();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSMD5, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSMD5(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSMD5* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSMD5, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForMD5.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMD5 = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForMD5.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForMD5 = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSMD5();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSMD5, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSMD5(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSMatchedRoute final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSMatchedRoute* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSMatchedRoute, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForMatchedRoute.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMatchedRoute = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForMatchedRoute.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForMatchedRoute = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- ;
-
- ~JSMatchedRoute();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSMatchedRoute, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSMatchedRoute(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
-
-
- mutable JSC::WriteBarrier<JSC::Unknown> m_filePath;
-mutable JSC::WriteBarrier<JSC::Unknown> m_kind;
-mutable JSC::WriteBarrier<JSC::Unknown> m_name;
-mutable JSC::WriteBarrier<JSC::Unknown> m_params;
-mutable JSC::WriteBarrier<JSC::Unknown> m_pathname;
-mutable JSC::WriteBarrier<JSC::Unknown> m_query;
-mutable JSC::WriteBarrier<JSC::Unknown> m_scriptSrc;
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSMatchedRoute* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSMatchedRoute, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForMatchedRoute.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForMatchedRoute = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForMatchedRoute.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForMatchedRoute = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSMatchedRoute();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSMatchedRoute, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSMatchedRoute(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_filePath;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_kind;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_name;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_params;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_pathname;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_query;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_scriptSrc;
+};
class JSNodeJSFS final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSNodeJSFS* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSNodeJSFS, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForNodeJSFS.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForNodeJSFS = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForNodeJSFS.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForNodeJSFS = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSNodeJSFS();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSNodeJSFS, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSNodeJSFS(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSNodeJSFS* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSNodeJSFS, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForNodeJSFS.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForNodeJSFS = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForNodeJSFS.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForNodeJSFS = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(ObjectType), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSNodeJSFS();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSNodeJSFS, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSNodeJSFS(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSRequest final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSRequest* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSRequest, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForRequest.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequest = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForRequest.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForRequest = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSRequest();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSRequest, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSRequest(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
-
-
- mutable JSC::WriteBarrier<JSC::Unknown> m_body;
-mutable JSC::WriteBarrier<JSC::Unknown> m_headers;
-mutable JSC::WriteBarrier<JSC::Unknown> m_signal;
-mutable JSC::WriteBarrier<JSC::Unknown> m_url;
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSRequest* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSRequest, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForRequest.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForRequest = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForRequest.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForRequest = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSRequest();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSRequest, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSRequest(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_body;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_headers;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_signal;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_url;
+};
class JSResponse final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSResponse* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSResponse, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForResponse.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResponse = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForResponse.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForResponse = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSResponse();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSResponse, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSResponse(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
-
-
- mutable JSC::WriteBarrier<JSC::Unknown> m_body;
-mutable JSC::WriteBarrier<JSC::Unknown> m_headers;
-mutable JSC::WriteBarrier<JSC::Unknown> m_statusText;
-mutable JSC::WriteBarrier<JSC::Unknown> m_url;
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSResponse* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSResponse, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForResponse.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForResponse = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForResponse.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForResponse = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSResponse();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSResponse, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSResponse(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_body;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_headers;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_statusText;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_url;
+};
class JSSHA1 final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSSHA1* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA1, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA1.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA1 = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA1.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA1 = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSSHA1();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA1, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSSHA1(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSSHA1* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA1, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA1.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA1 = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA1.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA1 = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSSHA1();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA1, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSSHA1(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSSHA224 final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSSHA224* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA224, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA224.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA224 = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA224.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA224 = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSSHA224();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA224, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSSHA224(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSSHA224* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA224, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA224.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA224 = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA224.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA224 = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSSHA224();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA224, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSSHA224(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSSHA256 final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSSHA256* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA256, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA256.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA256 = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA256.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA256 = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSSHA256();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA256, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSSHA256(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSSHA256* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA256, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA256.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA256 = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA256.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA256 = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSSHA256();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA256, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSSHA256(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSSHA384 final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSSHA384* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA384, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA384.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA384 = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA384.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA384 = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSSHA384();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA384, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSSHA384(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSSHA384* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA384, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA384.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA384 = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA384.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA384 = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSSHA384();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA384, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSSHA384(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSSHA512 final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSSHA512* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA512, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA512.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512 = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA512.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512 = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSSHA512();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA512, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSSHA512(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSSHA512* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA512, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA512.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512 = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA512.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512 = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSSHA512();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA512, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSSHA512(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSSHA512_256 final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSSHA512_256* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSHA512_256, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSHA512_256.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512_256 = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSHA512_256.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512_256 = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSSHA512_256();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA512_256, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSSHA512_256(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
-
-
-
-
- };
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSSHA512_256* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSHA512_256, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSHA512_256.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSHA512_256 = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSHA512_256.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSHA512_256 = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSSHA512_256();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSHA512_256, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSSHA512_256(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
class JSServerWebSocket final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSServerWebSocket* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSServerWebSocket, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForServerWebSocket.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForServerWebSocket = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForServerWebSocket.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForServerWebSocket = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSServerWebSocket();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSServerWebSocket, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSServerWebSocket(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSServerWebSocket* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSServerWebSocket, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForServerWebSocket.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForServerWebSocket = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForServerWebSocket.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForServerWebSocket = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSServerWebSocket();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSServerWebSocket, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSServerWebSocket(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_data;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
+};
-
+class JSStats final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSStats* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSStats, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForStats.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForStats = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForStats.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForStats = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSStats();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSStats, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSStats(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_atime;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_ctime;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_mtime;
+};
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+class JSSubprocess final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSSubprocess* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSSubprocess, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForSubprocess.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSubprocess = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForSubprocess.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForSubprocess = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSSubprocess();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSubprocess, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSSubprocess(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ m_weakThis = JSC::Weak<JSSubprocess>(this, getOwner());
+ }
+
+ void finishCreation(JSC::VM&);
+ JSC::Weak<JSSubprocess> m_weakThis;
- mutable JSC::WriteBarrier<JSC::Unknown> m_data;
-mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
- };
+ static bool hasPendingActivity(void* ctx);
-class JSStats final : public JSC::JSDestructibleObject {
+ class Owner final : public JSC::WeakHandleOwner {
public:
- using Base = JSC::JSDestructibleObject;
- static JSStats* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSStats, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForStats.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForStats = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForStats.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForStats = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSStats();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
+ bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
{
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSStats, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSStats(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
-
-
-
-
+ auto* controller = JSC::jsCast<JSSubprocess*>(handle.slot()->asCell());
+ if (JSSubprocess::hasPendingActivity(controller->wrapped())) {
+ if (UNLIKELY(reason))
+ *reason = "has pending activity";
+ return true;
+ }
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+ return visitor.containsOpaqueRoot(context);
+ }
+ void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
+ };
+ static JSC::WeakHandleOwner* getOwner()
+ {
+ static NeverDestroyed<Owner> m_owner;
+ return &m_owner.get();
+ }
- mutable JSC::WriteBarrier<JSC::Unknown> m_atime;
-mutable JSC::WriteBarrier<JSC::Unknown> m_ctime;
-mutable JSC::WriteBarrier<JSC::Unknown> m_mtime;
- };
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
-class JSSubprocess final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSSubprocess* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSSubprocess, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForSubprocess.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForSubprocess = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForSubprocess.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForSubprocess = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- ;
-
- ~JSSubprocess();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSSubprocess, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSSubprocess(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
- m_weakThis = JSC::Weak<JSSubprocess>(this, getOwner());
- }
-
- void finishCreation(JSC::VM&);
+ mutable JSC::WriteBarrier<JSC::Unknown> m_stderr;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_stdin;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_stdout;
+};
-
+class JSTCPSocket final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSTCPSocket* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSTCPSocket, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForTCPSocket.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTCPSocket = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForTCPSocket.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForTCPSocket = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSTCPSocket();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTCPSocket, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSTCPSocket(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ m_weakThis = JSC::Weak<JSTCPSocket>(this, getOwner());
+ }
+
+ void finishCreation(JSC::VM&);
-
- JSC::Weak<JSSubprocess> m_weakThis;
-
+ JSC::Weak<JSTCPSocket> m_weakThis;
static bool hasPendingActivity(void* ctx);
class Owner final : public JSC::WeakHandleOwner {
- public:
- bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
- {
- auto* controller = JSC::jsCast<JSSubprocess*>(handle.slot()->asCell());
- if (JSSubprocess::hasPendingActivity(controller->wrapped())) {
- if (UNLIKELY(reason))
- *reason = "has pending activity";
- return true;
- }
-
- return visitor.containsOpaqueRoot(context);
- }
- void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
- };
-
- static JSC::WeakHandleOwner* getOwner()
- {
- static NeverDestroyed<Owner> m_owner;
- return &m_owner.get();
- }
-
-
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
-
-
- mutable JSC::WriteBarrier<JSC::Unknown> m_stderr;
-mutable JSC::WriteBarrier<JSC::Unknown> m_stdin;
-mutable JSC::WriteBarrier<JSC::Unknown> m_stdout;
- };
-
-class JSTCPSocket final : public JSC::JSDestructibleObject {
public:
- using Base = JSC::JSDestructibleObject;
- static JSTCPSocket* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSTCPSocket, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForTCPSocket.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTCPSocket = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForTCPSocket.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForTCPSocket = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- ;
-
- ~JSTCPSocket();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
+ bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
{
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTCPSocket, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSTCPSocket(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
- m_weakThis = JSC::Weak<JSTCPSocket>(this, getOwner());
+ auto* controller = JSC::jsCast<JSTCPSocket*>(handle.slot()->asCell());
+ if (JSTCPSocket::hasPendingActivity(controller->wrapped())) {
+ if (UNLIKELY(reason))
+ *reason = "has pending activity";
+ return true;
+ }
+
+ return visitor.containsOpaqueRoot(context);
}
-
- void finishCreation(JSC::VM&);
+ void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
+ };
-
+ static JSC::WeakHandleOwner* getOwner()
+ {
+ static NeverDestroyed<Owner> m_owner;
+ return &m_owner.get();
+ }
-
- JSC::Weak<JSTCPSocket> m_weakThis;
-
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
- static bool hasPendingActivity(void* ctx);
-
- class Owner final : public JSC::WeakHandleOwner {
- public:
- bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
- {
- auto* controller = JSC::jsCast<JSTCPSocket*>(handle.slot()->asCell());
- if (JSTCPSocket::hasPendingActivity(controller->wrapped())) {
- if (UNLIKELY(reason))
- *reason = "has pending activity";
- return true;
- }
-
- return visitor.containsOpaqueRoot(context);
- }
- void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
- };
-
- static JSC::WeakHandleOwner* getOwner()
- {
- static NeverDestroyed<Owner> m_owner;
- return &m_owner.get();
- }
-
-
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
-
-
- mutable JSC::WriteBarrier<JSC::Unknown> m_data;
-mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
- };
+ mutable JSC::WriteBarrier<JSC::Unknown> m_data;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
+};
class JSTLSSocket final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSTLSSocket* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSTLSSocket, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForTLSSocket.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTLSSocket = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForTLSSocket.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForTLSSocket = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- ;
-
- ~JSTLSSocket();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTLSSocket, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSTLSSocket(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
- m_weakThis = JSC::Weak<JSTLSSocket>(this, getOwner());
- }
-
- void finishCreation(JSC::VM&);
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSTLSSocket* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSTLSSocket, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForTLSSocket.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTLSSocket = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForTLSSocket.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForTLSSocket = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSTLSSocket();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTLSSocket, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSTLSSocket(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ m_weakThis = JSC::Weak<JSTLSSocket>(this, getOwner());
+ }
+
+ void finishCreation(JSC::VM&);
-
-
-
JSC::Weak<JSTLSSocket> m_weakThis;
-
static bool hasPendingActivity(void* ctx);
class Owner final : public JSC::WeakHandleOwner {
- public:
- bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
- {
- auto* controller = JSC::jsCast<JSTLSSocket*>(handle.slot()->asCell());
- if (JSTLSSocket::hasPendingActivity(controller->wrapped())) {
- if (UNLIKELY(reason))
- *reason = "has pending activity";
- return true;
- }
-
- return visitor.containsOpaqueRoot(context);
- }
- void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
- };
-
- static JSC::WeakHandleOwner* getOwner()
- {
- static NeverDestroyed<Owner> m_owner;
- return &m_owner.get();
- }
-
-
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
-
-
- mutable JSC::WriteBarrier<JSC::Unknown> m_data;
-mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
- };
-
-class JSTextDecoder final : public JSC::JSDestructibleObject {
public:
- using Base = JSC::JSDestructibleObject;
- static JSTextDecoder* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSTextDecoder, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForTextDecoder.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextDecoder = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForTextDecoder.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForTextDecoder = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSTextDecoder();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
+ bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
{
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTextDecoder, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSTextDecoder(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
+ auto* controller = JSC::jsCast<JSTLSSocket*>(handle.slot()->asCell());
+ if (JSTLSSocket::hasPendingActivity(controller->wrapped())) {
+ if (UNLIKELY(reason))
+ *reason = "has pending activity";
+ return true;
+ }
+
+ return visitor.containsOpaqueRoot(context);
}
-
- void finishCreation(JSC::VM&);
+ void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
+ };
-
+ static JSC::WeakHandleOwner* getOwner()
+ {
+ static NeverDestroyed<Owner> m_owner;
+ return &m_owner.get();
+ }
-
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
- DECLARE_VISIT_CHILDREN;
-template<typename Visitor> void visitAdditionalChildren(Visitor&);
-DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_data;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
+};
+class JSTextDecoder final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSTextDecoder* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
- mutable JSC::WriteBarrier<JSC::Unknown> m_encoding;
- };
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSTextDecoder, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForTextDecoder.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextDecoder = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForTextDecoder.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForTextDecoder = std::forward<decltype(space)>(space); });
+ }
-class JSTimeout final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSTimeout* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSTimeout, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForTimeout.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTimeout = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForTimeout.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForTimeout = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- ;
-
- ~JSTimeout();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTimeout, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSTimeout(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
-
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
+ ~JSTextDecoder();
-
+ void* wrapped() const { return m_ctx; }
-
- };
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
-class JSTranspiler final : public JSC::JSDestructibleObject {
- public:
- using Base = JSC::JSDestructibleObject;
- static JSTranspiler* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
-
- DECLARE_EXPORT_INFO;
- template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
- {
- if constexpr (mode == JSC::SubspaceAccess::Concurrently)
- return nullptr;
- return WebCore::subspaceForImpl<JSTranspiler, WebCore::UseCustomHeapCellType::No>(
- vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForTranspiler.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTranspiler = std::forward<decltype(space)>(space); },
- [](auto& spaces) { return spaces.m_subspaceForTranspiler.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForTranspiler = std::forward<decltype(space)>(space); });
- }
-
- static void destroy(JSC::JSCell*);
- static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
- {
- return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
- }
-
- static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
- static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
-
- ~JSTranspiler();
-
- void* wrapped() const { return m_ctx; }
-
- void detach()
- {
- m_ctx = nullptr;
- }
-
- static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
- static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTranspiler, m_ctx); }
-
- void* m_ctx { nullptr };
-
-
- JSTranspiler(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
- : Base(vm, structure)
- {
- m_ctx = sinkPtr;
-
- }
-
- void finishCreation(JSC::VM&);
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTextDecoder, m_ctx); }
- WTF::Vector<std::unique_ptr<BunPlugin::OnLoad>> onLoadPlugins;
-WTF::Vector<std::unique_ptr<BunPlugin::OnResolve>> onResolvePlugins;
+ void* m_ctx { nullptr };
-
+ JSTextDecoder(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
-
+ void finishCreation(JSC::VM&);
-
- };
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_encoding;
+};
-}
+class JSTimeout final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSTimeout* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSTimeout, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForTimeout.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTimeout = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForTimeout.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForTimeout = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ ;
+
+ ~JSTimeout();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTimeout, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSTimeout(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
+class JSTranspiler final : public JSC::JSDestructibleObject {
+public:
+ using Base = JSC::JSDestructibleObject;
+ static JSTranspiler* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, void* ctx);
+
+ DECLARE_EXPORT_INFO;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return WebCore::subspaceForImpl<JSTranspiler, WebCore::UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForTranspiler.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTranspiler = std::forward<decltype(space)>(space); },
+ [](auto& spaces) { return spaces.m_subspaceForTranspiler.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForTranspiler = std::forward<decltype(space)>(space); });
+ }
+
+ static void destroy(JSC::JSCell*);
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast<JSC::JSType>(0b11101110), StructureFlags), info());
+ }
+
+ static JSObject* createPrototype(VM& vm, JSDOMGlobalObject* globalObject);
+ static JSObject* createConstructor(VM& vm, JSGlobalObject* globalObject, JSValue prototype);
+
+ ~JSTranspiler();
+
+ void* wrapped() const { return m_ctx; }
+
+ void detach()
+ {
+ m_ctx = nullptr;
+ }
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+ static ptrdiff_t offsetOfWrapped() { return OBJECT_OFFSETOF(JSTranspiler, m_ctx); }
+
+ void* m_ctx { nullptr };
+
+ JSTranspiler(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr)
+ : Base(vm, structure)
+ {
+ m_ctx = sinkPtr;
+ }
+
+ void finishCreation(JSC::VM&);
+};
+
+}
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index 0ef81f487..d4da19f68 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -3960,6 +3960,133 @@ pub const JSValue = enum(JSValueReprInt) {
return null;
}
+ pub fn toEnumWithMapField(
+ this: JSValue,
+ globalThis: *JSGlobalObject,
+ comptime property_name: []const u8,
+ comptime Enum: type,
+ comptime map_name: []const u8,
+ ) !Enum {
+ if (!this.isString()) {
+ globalThis.throwInvalidArguments(property_name ++ " must be a string", .{});
+ return error.JSError;
+ }
+
+ const target_str = this.getZigString(globalThis);
+ return @field(Enum, map_name).getWithEql(target_str, ZigString.eqlComptime) orelse {
+ const one_of = struct {
+ pub const list = brk: {
+ var str = "'";
+ const field_names = std.meta.fieldNames(Enum);
+ for (field_names, 0..) |entry, i| {
+ str = str ++ entry.key ++ "'";
+ if (i < field_names.len - 2) {
+ str = str ++ ", '";
+ } else if (i == field_names.len - 2) {
+ str = str ++ " or '";
+ }
+ }
+ break :brk str;
+ };
+
+ pub const label = property_name ++ " must be one of " ++ list;
+ }.label;
+ globalThis.throwInvalidArguments(one_of, .{});
+ return error.JSError;
+ };
+ }
+
+ pub fn toEnum(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8, comptime Enum: type) !Enum {
+ return toEnumWithMapField(this, globalThis, property_name, Enum, "Map");
+ }
+
+ pub fn toOptionalEnum(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8, comptime Enum: type) !?Enum {
+ if (this.isEmptyOrUndefinedOrNull())
+ return null;
+
+ return toEnum(this, globalThis, property_name, Enum);
+ }
+
+ pub fn getOptionalEnum(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8, comptime Enum: type) !?Enum {
+ if (get(this, globalThis, property_name)) |prop| {
+ return toEnum(prop, globalThis, property_name, Enum);
+ }
+ }
+
+ pub fn getArray(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8) !?JSValue {
+ if (getTruthy(this, globalThis, property_name)) |prop| {
+ if (!prop.jsTypeLoose().isArray()) {
+ globalThis.throwInvalidArguments(property_name ++ " must be an array", .{});
+ return error.JSError;
+ }
+
+ if (prop.getLengthOfArray(globalThis) == 0) {
+ return null;
+ }
+
+ return prop;
+ }
+
+ return null;
+ }
+
+ pub fn getObject(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8) !?JSValue {
+ if (getTruthy(this, globalThis, property_name)) |prop| {
+ if (!prop.jsTypeLoose().isObject()) {
+ globalThis.throwInvalidArguments(property_name ++ " must be an object", .{});
+ return error.JSError;
+ }
+
+ return prop;
+ }
+
+ return null;
+ }
+
+ pub fn getFunction(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8) !?JSValue {
+ if (getTruthy(this, globalThis, property_name)) |prop| {
+ if (!prop.isCell() or !prop.isCallable(globalThis.vm())) {
+ globalThis.throwInvalidArguments(property_name ++ " must be a function", .{});
+ return error.JSError;
+ }
+
+ return prop;
+ }
+
+ return null;
+ }
+
+ pub fn getOptional(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8, comptime T: type) !?T {
+ if (getTruthy(this, globalThis, property_name)) |prop| {
+ switch (comptime T) {
+ bool => {
+ if (prop.isBoolean()) {
+ return prop.toBoolean();
+ }
+
+ if (prop.isNumber()) {
+ return prop.toNumber() != 0;
+ }
+
+ globalThis.throwInvalidArguments(property_name ++ " must be a boolean", .{});
+ return error.JSError;
+ },
+ ZigString.Slice => {
+ if (prop.isString()) {
+ if (return prop.toSliceOrNull(globalThis)) |str| {
+ return str;
+ }
+ }
+
+ globalThis.throwInvalidArguments(property_name ++ " must be a string", .{});
+ return error.JSError;
+ },
+ }
+ }
+
+ return null;
+ }
+
/// Alias for getIfPropertyExists
pub const getIfPropertyExists = get;
diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig
index 191f6c0d4..3538960d7 100644
--- a/src/bun.js/bindings/generated_classes.zig
+++ b/src/bun.js/bindings/generated_classes.zig
@@ -1,4 +1,3 @@
-
/// Generated code! To regenerate, run:
///
/// make codegen
@@ -13,25 +12,23 @@
/// - Add it to generated_classes_list.zig
/// - pub usingnamespace JSC.Codegen.JSMyClassName;
/// 5. make clean-bindings && make bindings -j10
-///
+///
const JSC = @import("bun").JSC;
const Classes = @import("./generated_classes_list.zig").Classes;
const Environment = @import("../../env.zig");
const std = @import("std");
-pub const StaticGetterType = fn(*JSC.JSGlobalObject, JSC.JSValue, JSC.JSValue) callconv(.C) JSC.JSValue;
-pub const StaticSetterType = fn(*JSC.JSGlobalObject, JSC.JSValue, JSC.JSValue, JSC.JSValue) callconv(.C) bool;
-pub const StaticCallbackType = fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
-
-
+pub const StaticGetterType = fn (*JSC.JSGlobalObject, JSC.JSValue, JSC.JSValue) callconv(.C) JSC.JSValue;
+pub const StaticSetterType = fn (*JSC.JSGlobalObject, JSC.JSValue, JSC.JSValue, JSC.JSValue) callconv(.C) bool;
+pub const StaticCallbackType = fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
pub const JSBlob = struct {
const Blob = Classes.Blob;
- const GetterType = fn(*Blob, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Blob, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Blob, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Blob, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Blob, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Blob, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Blob, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Blob, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Blob, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Blob, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -40,16 +37,13 @@ pub const JSBlob = struct {
return Blob__fromJS(value);
}
-
-
-
/// Get the Blob constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return Blob__getConstructor(globalObject);
}
-
+
/// Create a new instance of Blob
pub fn toJS(this: *Blob, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -64,14 +58,14 @@ pub const JSBlob = struct {
/// Modify the internal ptr to point to a new instance of Blob.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Blob) bool {
- JSC.markBinding(@src());
- return Blob__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Blob__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Blob, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Blob__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Blob__dangerouslySetPtr(value, null));
}
extern fn Blob__fromJS(JSC.JSValue) ?*Blob;
@@ -82,81 +76,135 @@ pub const JSBlob = struct {
extern fn Blob__dangerouslySetPtr(JSC.JSValue, ?*Blob) bool;
comptime {
-
- if (@TypeOf(Blob.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Blob)) {
- @compileLog("Blob.constructor is not a constructor");
+ if (@TypeOf(Blob.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Blob)) {
+ @compileLog("Blob.constructor is not a constructor");
}
-
- if (@TypeOf(Blob.finalize) != (fn(*Blob) callconv(.C) void)) {
- @compileLog("Blob.finalize is not a finalizer");
+
+ if (@TypeOf(Blob.finalize) != (fn (*Blob) callconv(.C) void)) {
+ @compileLog("Blob.finalize is not a finalizer");
}
-
- if (@TypeOf(Blob.getArrayBuffer) != CallbackType)
- @compileLog(
- "Expected Blob.getArrayBuffer to be a callback but received " ++ @typeName(@TypeOf(Blob.getArrayBuffer))
- );
- if (@TypeOf(Blob.getFormData) != CallbackType)
- @compileLog(
- "Expected Blob.getFormData to be a callback but received " ++ @typeName(@TypeOf(Blob.getFormData))
- );
- if (@TypeOf(Blob.getJSON) != CallbackType)
- @compileLog(
- "Expected Blob.getJSON to be a callback but received " ++ @typeName(@TypeOf(Blob.getJSON))
- );
- if (@TypeOf(Blob.getLastModified) != GetterType)
- @compileLog(
- "Expected Blob.getLastModified to be a getter"
- );
-
- if (@TypeOf(Blob.getSize) != GetterType)
- @compileLog(
- "Expected Blob.getSize to be a getter"
- );
-
- if (@TypeOf(Blob.getSlice) != CallbackType)
- @compileLog(
- "Expected Blob.getSlice to be a callback but received " ++ @typeName(@TypeOf(Blob.getSlice))
- );
- if (@TypeOf(Blob.getStream) != CallbackType)
- @compileLog(
- "Expected Blob.getStream to be a callback but received " ++ @typeName(@TypeOf(Blob.getStream))
- );
- if (@TypeOf(Blob.getText) != CallbackType)
- @compileLog(
- "Expected Blob.getText to be a callback but received " ++ @typeName(@TypeOf(Blob.getText))
- );
- if (@TypeOf(Blob.getType) != GetterType)
- @compileLog(
- "Expected Blob.getType to be a getter"
- );
-
- if (@TypeOf(Blob.getWriter) != CallbackType)
- @compileLog(
- "Expected Blob.getWriter to be a callback but received " ++ @typeName(@TypeOf(Blob.getWriter))
- );
+
+ if (@TypeOf(Blob.getArrayBuffer) != CallbackType)
+ @compileLog("Expected Blob.getArrayBuffer to be a callback but received " ++ @typeName(@TypeOf(Blob.getArrayBuffer)));
+ if (@TypeOf(Blob.getFormData) != CallbackType)
+ @compileLog("Expected Blob.getFormData to be a callback but received " ++ @typeName(@TypeOf(Blob.getFormData)));
+ if (@TypeOf(Blob.getJSON) != CallbackType)
+ @compileLog("Expected Blob.getJSON to be a callback but received " ++ @typeName(@TypeOf(Blob.getJSON)));
+ if (@TypeOf(Blob.getLastModified) != GetterType)
+ @compileLog("Expected Blob.getLastModified to be a getter");
+
+ if (@TypeOf(Blob.getSize) != GetterType)
+ @compileLog("Expected Blob.getSize to be a getter");
+
+ if (@TypeOf(Blob.getSlice) != CallbackType)
+ @compileLog("Expected Blob.getSlice to be a callback but received " ++ @typeName(@TypeOf(Blob.getSlice)));
+ if (@TypeOf(Blob.getStream) != CallbackType)
+ @compileLog("Expected Blob.getStream to be a callback but received " ++ @typeName(@TypeOf(Blob.getStream)));
+ if (@TypeOf(Blob.getText) != CallbackType)
+ @compileLog("Expected Blob.getText to be a callback but received " ++ @typeName(@TypeOf(Blob.getText)));
+ if (@TypeOf(Blob.getType) != GetterType)
+ @compileLog("Expected Blob.getType to be a getter");
+
+ if (@TypeOf(Blob.getWriter) != CallbackType)
+ @compileLog("Expected Blob.getWriter to be a callback but received " ++ @typeName(@TypeOf(Blob.getWriter)));
if (!JSC.is_bindgen) {
-@export(Blob.constructor, .{.name = "BlobClass__construct"});
- @export(Blob.finalize, .{.name = "BlobClass__finalize"});
- @export(Blob.getArrayBuffer, .{.name = "BlobPrototype__getArrayBuffer"});
- @export(Blob.getFormData, .{.name = "BlobPrototype__getFormData"});
- @export(Blob.getJSON, .{.name = "BlobPrototype__getJSON"});
- @export(Blob.getLastModified, .{.name = "BlobPrototype__getLastModified"});
- @export(Blob.getSize, .{.name = "BlobPrototype__getSize"});
- @export(Blob.getSlice, .{.name = "BlobPrototype__getSlice"});
- @export(Blob.getStream, .{.name = "BlobPrototype__getStream"});
- @export(Blob.getText, .{.name = "BlobPrototype__getText"});
- @export(Blob.getType, .{.name = "BlobPrototype__getType"});
- @export(Blob.getWriter, .{.name = "BlobPrototype__getWriter"});
+ @export(Blob.constructor, .{ .name = "BlobClass__construct" });
+ @export(Blob.finalize, .{ .name = "BlobClass__finalize" });
+ @export(Blob.getArrayBuffer, .{ .name = "BlobPrototype__getArrayBuffer" });
+ @export(Blob.getFormData, .{ .name = "BlobPrototype__getFormData" });
+ @export(Blob.getJSON, .{ .name = "BlobPrototype__getJSON" });
+ @export(Blob.getLastModified, .{ .name = "BlobPrototype__getLastModified" });
+ @export(Blob.getSize, .{ .name = "BlobPrototype__getSize" });
+ @export(Blob.getSlice, .{ .name = "BlobPrototype__getSlice" });
+ @export(Blob.getStream, .{ .name = "BlobPrototype__getStream" });
+ @export(Blob.getText, .{ .name = "BlobPrototype__getText" });
+ @export(Blob.getType, .{ .name = "BlobPrototype__getType" });
+ @export(Blob.getWriter, .{ .name = "BlobPrototype__getWriter" });
+ }
+ }
+};
+pub const JSBundler = struct {
+ const Bundler = Classes.Bundler;
+ const GetterType = fn (*Bundler, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Bundler, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Bundler, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Bundler, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Bundler, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+
+ /// Return the pointer to the wrapped object.
+ /// If the object does not match the type, return null.
+ pub fn fromJS(value: JSC.JSValue) ?*Bundler {
+ JSC.markBinding(@src());
+ return Bundler__fromJS(value);
+ }
+
+ /// Get the Bundler constructor value.
+ /// This loads lazily from the global object.
+ pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ return Bundler__getConstructor(globalObject);
+ }
+
+ /// Create a new instance of Bundler
+ pub fn toJS(this: *Bundler, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
+ JSC.markBinding(@src());
+ if (comptime Environment.allow_assert) {
+ const value__ = Bundler__create(globalObject, this);
+ std.debug.assert(value__.as(Bundler).? == this); // If this fails, likely a C ABI issue.
+ return value__;
+ } else {
+ return Bundler__create(globalObject, this);
+ }
+ }
+
+ /// Modify the internal ptr to point to a new instance of Bundler.
+ pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Bundler) bool {
+ JSC.markBinding(@src());
+ return Bundler__dangerouslySetPtr(value, ptr);
+ }
+
+ /// Detach the ptr from the thisValue
+ pub fn detachPtr(_: *Bundler, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ std.debug.assert(Bundler__dangerouslySetPtr(value, null));
+ }
+
+ extern fn Bundler__fromJS(JSC.JSValue) ?*Bundler;
+ extern fn Bundler__getConstructor(*JSC.JSGlobalObject) JSC.JSValue;
+
+ extern fn Bundler__create(globalObject: *JSC.JSGlobalObject, ptr: ?*Bundler) JSC.JSValue;
+
+ extern fn Bundler__dangerouslySetPtr(JSC.JSValue, ?*Bundler) bool;
+
+ comptime {
+ if (@TypeOf(Bundler.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Bundler)) {
+ @compileLog("Bundler.constructor is not a constructor");
+ }
+
+ if (@TypeOf(Bundler.finalize) != (fn (*Bundler) callconv(.C) void)) {
+ @compileLog("Bundler.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(Bundler.handleRequest) != CallbackType)
+ @compileLog("Expected Bundler.handleRequest to be a callback but received " ++ @typeName(@TypeOf(Bundler.handleRequest)));
+ if (@TypeOf(Bundler.write) != CallbackType)
+ @compileLog("Expected Bundler.write to be a callback but received " ++ @typeName(@TypeOf(Bundler.write)));
+ if (!JSC.is_bindgen) {
+ @export(Bundler.constructor, .{ .name = "BundlerClass__construct" });
+ @export(Bundler.finalize, .{ .name = "BundlerClass__finalize" });
+ @export(Bundler.handleRequest, .{ .name = "BundlerPrototype__handleRequest" });
+ @export(Bundler.hasPendingActivity, .{ .name = "Bundler__hasPendingActivity" });
+ @export(Bundler.write, .{ .name = "BundlerPrototype__write" });
}
}
};
pub const JSCryptoHasher = struct {
const CryptoHasher = Classes.CryptoHasher;
- const GetterType = fn(*CryptoHasher, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*CryptoHasher, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*CryptoHasher, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*CryptoHasher, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*CryptoHasher, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*CryptoHasher, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*CryptoHasher, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*CryptoHasher, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*CryptoHasher, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*CryptoHasher, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -167,35 +215,33 @@ pub const JSCryptoHasher = struct {
extern fn CryptoHasherPrototype__algorithmSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn CryptoHasherPrototype__algorithmGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `CryptoHasher.algorithm` setter
- /// This value will be visited by the garbage collector.
- pub fn algorithmSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- CryptoHasherPrototype__algorithmSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn CryptoHasherPrototype__algorithmGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `CryptoHasher.algorithm` getter
- /// This value will be visited by the garbage collector.
- pub fn algorithmGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = CryptoHasherPrototype__algorithmGetCachedValue(thisValue);
- if (result == .zero)
+ /// `CryptoHasher.algorithm` setter
+ /// This value will be visited by the garbage collector.
+ pub fn algorithmSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ CryptoHasherPrototype__algorithmSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `CryptoHasher.algorithm` getter
+ /// This value will be visited by the garbage collector.
+ pub fn algorithmGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = CryptoHasherPrototype__algorithmGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the CryptoHasher constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return CryptoHasher__getConstructor(globalObject);
}
-
+
/// Create a new instance of CryptoHasher
pub fn toJS(this: *CryptoHasher, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -210,14 +256,14 @@ pub const JSCryptoHasher = struct {
/// Modify the internal ptr to point to a new instance of CryptoHasher.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*CryptoHasher) bool {
- JSC.markBinding(@src());
- return CryptoHasher__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return CryptoHasher__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *CryptoHasher, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(CryptoHasher__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(CryptoHasher__dangerouslySetPtr(value, null));
}
extern fn CryptoHasher__fromJS(JSC.JSValue) ?*CryptoHasher;
@@ -228,61 +274,48 @@ pub const JSCryptoHasher = struct {
extern fn CryptoHasher__dangerouslySetPtr(JSC.JSValue, ?*CryptoHasher) bool;
comptime {
-
- if (@TypeOf(CryptoHasher.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*CryptoHasher)) {
- @compileLog("CryptoHasher.constructor is not a constructor");
+ if (@TypeOf(CryptoHasher.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*CryptoHasher)) {
+ @compileLog("CryptoHasher.constructor is not a constructor");
}
-
- if (@TypeOf(CryptoHasher.finalize) != (fn(*CryptoHasher) callconv(.C) void)) {
- @compileLog("CryptoHasher.finalize is not a finalizer");
+
+ if (@TypeOf(CryptoHasher.finalize) != (fn (*CryptoHasher) callconv(.C) void)) {
+ @compileLog("CryptoHasher.finalize is not a finalizer");
}
-
- if (@TypeOf(CryptoHasher.getAlgorithm) != GetterType)
- @compileLog(
- "Expected CryptoHasher.getAlgorithm to be a getter"
- );
-
- if (@TypeOf(CryptoHasher.getByteLength) != GetterType)
- @compileLog(
- "Expected CryptoHasher.getByteLength to be a getter"
- );
-
- if (@TypeOf(CryptoHasher.digest) != CallbackType)
- @compileLog(
- "Expected CryptoHasher.digest to be a callback but received " ++ @typeName(@TypeOf(CryptoHasher.digest))
- );
- if (@TypeOf(CryptoHasher.update) != CallbackType)
- @compileLog(
- "Expected CryptoHasher.update to be a callback but received " ++ @typeName(@TypeOf(CryptoHasher.update))
- );
- if (@TypeOf(CryptoHasher.getAlgorithms) != StaticGetterType)
- @compileLog(
- "Expected CryptoHasher.getAlgorithms to be a static getter"
- );
-
- if (@TypeOf(CryptoHasher.hash) != StaticCallbackType)
- @compileLog(
- "Expected CryptoHasher.hash to be a static callback"
- );
+
+ if (@TypeOf(CryptoHasher.getAlgorithm) != GetterType)
+ @compileLog("Expected CryptoHasher.getAlgorithm to be a getter");
+
+ if (@TypeOf(CryptoHasher.getByteLength) != GetterType)
+ @compileLog("Expected CryptoHasher.getByteLength to be a getter");
+
+ if (@TypeOf(CryptoHasher.digest) != CallbackType)
+ @compileLog("Expected CryptoHasher.digest to be a callback but received " ++ @typeName(@TypeOf(CryptoHasher.digest)));
+ if (@TypeOf(CryptoHasher.update) != CallbackType)
+ @compileLog("Expected CryptoHasher.update to be a callback but received " ++ @typeName(@TypeOf(CryptoHasher.update)));
+ if (@TypeOf(CryptoHasher.getAlgorithms) != StaticGetterType)
+ @compileLog("Expected CryptoHasher.getAlgorithms to be a static getter");
+
+ if (@TypeOf(CryptoHasher.hash) != StaticCallbackType)
+ @compileLog("Expected CryptoHasher.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(CryptoHasher.constructor, .{.name = "CryptoHasherClass__construct"});
- @export(CryptoHasher.digest, .{.name = "CryptoHasherPrototype__digest"});
- @export(CryptoHasher.finalize, .{.name = "CryptoHasherClass__finalize"});
- @export(CryptoHasher.getAlgorithm, .{.name = "CryptoHasherPrototype__getAlgorithm"});
- @export(CryptoHasher.getAlgorithms, .{.name = "CryptoHasherClass__getAlgorithms"});
- @export(CryptoHasher.getByteLength, .{.name = "CryptoHasherPrototype__getByteLength"});
- @export(CryptoHasher.hash, .{.name = "CryptoHasherClass__hash"});
- @export(CryptoHasher.update, .{.name = "CryptoHasherPrototype__update"});
+ @export(CryptoHasher.constructor, .{ .name = "CryptoHasherClass__construct" });
+ @export(CryptoHasher.digest, .{ .name = "CryptoHasherPrototype__digest" });
+ @export(CryptoHasher.finalize, .{ .name = "CryptoHasherClass__finalize" });
+ @export(CryptoHasher.getAlgorithm, .{ .name = "CryptoHasherPrototype__getAlgorithm" });
+ @export(CryptoHasher.getAlgorithms, .{ .name = "CryptoHasherClass__getAlgorithms" });
+ @export(CryptoHasher.getByteLength, .{ .name = "CryptoHasherPrototype__getByteLength" });
+ @export(CryptoHasher.hash, .{ .name = "CryptoHasherClass__hash" });
+ @export(CryptoHasher.update, .{ .name = "CryptoHasherPrototype__update" });
}
}
};
pub const JSDirent = struct {
const Dirent = Classes.Dirent;
- const GetterType = fn(*Dirent, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Dirent, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Dirent, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Dirent, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Dirent, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Dirent, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Dirent, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Dirent, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Dirent, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Dirent, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -293,35 +326,33 @@ pub const JSDirent = struct {
extern fn DirentPrototype__nameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn DirentPrototype__nameGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Dirent.name` setter
- /// This value will be visited by the garbage collector.
- pub fn nameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- DirentPrototype__nameSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn DirentPrototype__nameGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `Dirent.name` getter
- /// This value will be visited by the garbage collector.
- pub fn nameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = DirentPrototype__nameGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Dirent.name` setter
+ /// This value will be visited by the garbage collector.
+ pub fn nameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ DirentPrototype__nameSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Dirent.name` getter
+ /// This value will be visited by the garbage collector.
+ pub fn nameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = DirentPrototype__nameGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the Dirent constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return Dirent__getConstructor(globalObject);
}
-
+
/// Create a new instance of Dirent
pub fn toJS(this: *Dirent, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -336,14 +367,14 @@ pub const JSDirent = struct {
/// Modify the internal ptr to point to a new instance of Dirent.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Dirent) bool {
- JSC.markBinding(@src());
- return Dirent__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Dirent__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Dirent, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Dirent__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Dirent__dangerouslySetPtr(value, null));
}
extern fn Dirent__fromJS(JSC.JSValue) ?*Dirent;
@@ -354,69 +385,52 @@ pub const JSDirent = struct {
extern fn Dirent__dangerouslySetPtr(JSC.JSValue, ?*Dirent) bool;
comptime {
-
- if (@TypeOf(Dirent.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Dirent)) {
- @compileLog("Dirent.constructor is not a constructor");
- }
-
- if (@TypeOf(Dirent.finalize) != (fn(*Dirent) callconv(.C) void)) {
- @compileLog("Dirent.finalize is not a finalizer");
- }
-
- if (@TypeOf(Dirent.isBlockDevice) != CallbackType)
- @compileLog(
- "Expected Dirent.isBlockDevice to be a callback but received " ++ @typeName(@TypeOf(Dirent.isBlockDevice))
- );
- if (@TypeOf(Dirent.isCharacterDevice) != CallbackType)
- @compileLog(
- "Expected Dirent.isCharacterDevice to be a callback but received " ++ @typeName(@TypeOf(Dirent.isCharacterDevice))
- );
- if (@TypeOf(Dirent.isDirectory) != CallbackType)
- @compileLog(
- "Expected Dirent.isDirectory to be a callback but received " ++ @typeName(@TypeOf(Dirent.isDirectory))
- );
- if (@TypeOf(Dirent.isFIFO) != CallbackType)
- @compileLog(
- "Expected Dirent.isFIFO to be a callback but received " ++ @typeName(@TypeOf(Dirent.isFIFO))
- );
- if (@TypeOf(Dirent.isFile) != CallbackType)
- @compileLog(
- "Expected Dirent.isFile to be a callback but received " ++ @typeName(@TypeOf(Dirent.isFile))
- );
- if (@TypeOf(Dirent.isSocket) != CallbackType)
- @compileLog(
- "Expected Dirent.isSocket to be a callback but received " ++ @typeName(@TypeOf(Dirent.isSocket))
- );
- if (@TypeOf(Dirent.isSymbolicLink) != CallbackType)
- @compileLog(
- "Expected Dirent.isSymbolicLink to be a callback but received " ++ @typeName(@TypeOf(Dirent.isSymbolicLink))
- );
- if (@TypeOf(Dirent.getName) != GetterType)
- @compileLog(
- "Expected Dirent.getName to be a getter"
- );
+ if (@TypeOf(Dirent.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Dirent)) {
+ @compileLog("Dirent.constructor is not a constructor");
+ }
+
+ if (@TypeOf(Dirent.finalize) != (fn (*Dirent) callconv(.C) void)) {
+ @compileLog("Dirent.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(Dirent.isBlockDevice) != CallbackType)
+ @compileLog("Expected Dirent.isBlockDevice to be a callback but received " ++ @typeName(@TypeOf(Dirent.isBlockDevice)));
+ if (@TypeOf(Dirent.isCharacterDevice) != CallbackType)
+ @compileLog("Expected Dirent.isCharacterDevice to be a callback but received " ++ @typeName(@TypeOf(Dirent.isCharacterDevice)));
+ if (@TypeOf(Dirent.isDirectory) != CallbackType)
+ @compileLog("Expected Dirent.isDirectory to be a callback but received " ++ @typeName(@TypeOf(Dirent.isDirectory)));
+ if (@TypeOf(Dirent.isFIFO) != CallbackType)
+ @compileLog("Expected Dirent.isFIFO to be a callback but received " ++ @typeName(@TypeOf(Dirent.isFIFO)));
+ if (@TypeOf(Dirent.isFile) != CallbackType)
+ @compileLog("Expected Dirent.isFile to be a callback but received " ++ @typeName(@TypeOf(Dirent.isFile)));
+ if (@TypeOf(Dirent.isSocket) != CallbackType)
+ @compileLog("Expected Dirent.isSocket to be a callback but received " ++ @typeName(@TypeOf(Dirent.isSocket)));
+ if (@TypeOf(Dirent.isSymbolicLink) != CallbackType)
+ @compileLog("Expected Dirent.isSymbolicLink to be a callback but received " ++ @typeName(@TypeOf(Dirent.isSymbolicLink)));
+ if (@TypeOf(Dirent.getName) != GetterType)
+ @compileLog("Expected Dirent.getName to be a getter");
if (!JSC.is_bindgen) {
-@export(Dirent.constructor, .{.name = "DirentClass__construct"});
- @export(Dirent.finalize, .{.name = "DirentClass__finalize"});
- @export(Dirent.getName, .{.name = "DirentPrototype__getName"});
- @export(Dirent.isBlockDevice, .{.name = "DirentPrototype__isBlockDevice"});
- @export(Dirent.isCharacterDevice, .{.name = "DirentPrototype__isCharacterDevice"});
- @export(Dirent.isDirectory, .{.name = "DirentPrototype__isDirectory"});
- @export(Dirent.isFIFO, .{.name = "DirentPrototype__isFIFO"});
- @export(Dirent.isFile, .{.name = "DirentPrototype__isFile"});
- @export(Dirent.isSocket, .{.name = "DirentPrototype__isSocket"});
- @export(Dirent.isSymbolicLink, .{.name = "DirentPrototype__isSymbolicLink"});
+ @export(Dirent.constructor, .{ .name = "DirentClass__construct" });
+ @export(Dirent.finalize, .{ .name = "DirentClass__finalize" });
+ @export(Dirent.getName, .{ .name = "DirentPrototype__getName" });
+ @export(Dirent.isBlockDevice, .{ .name = "DirentPrototype__isBlockDevice" });
+ @export(Dirent.isCharacterDevice, .{ .name = "DirentPrototype__isCharacterDevice" });
+ @export(Dirent.isDirectory, .{ .name = "DirentPrototype__isDirectory" });
+ @export(Dirent.isFIFO, .{ .name = "DirentPrototype__isFIFO" });
+ @export(Dirent.isFile, .{ .name = "DirentPrototype__isFile" });
+ @export(Dirent.isSocket, .{ .name = "DirentPrototype__isSocket" });
+ @export(Dirent.isSymbolicLink, .{ .name = "DirentPrototype__isSymbolicLink" });
}
}
};
pub const JSExpect = struct {
const Expect = Classes.Expect;
- const GetterType = fn(*Expect, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Expect, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Expect, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Expect, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Expect, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Expect, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Expect, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Expect, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Expect, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Expect, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -427,57 +441,55 @@ pub const JSExpect = struct {
extern fn ExpectPrototype__capturedValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn ExpectPrototype__capturedValueGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Expect.capturedValue` setter
- /// This value will be visited by the garbage collector.
- pub fn capturedValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ExpectPrototype__capturedValueSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ExpectPrototype__capturedValueGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Expect.capturedValue` setter
+ /// This value will be visited by the garbage collector.
+ pub fn capturedValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ExpectPrototype__capturedValueSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Expect.capturedValue` getter
- /// This value will be visited by the garbage collector.
- pub fn capturedValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ExpectPrototype__capturedValueGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Expect.capturedValue` getter
+ /// This value will be visited by the garbage collector.
+ pub fn capturedValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ExpectPrototype__capturedValueGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn ExpectPrototype__resultValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn ExpectPrototype__resultValueGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Expect.resultValue` setter
- /// This value will be visited by the garbage collector.
- pub fn resultValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ExpectPrototype__resultValueSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ExpectPrototype__resultValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ExpectPrototype__resultValueGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Expect.resultValue` setter
+ /// This value will be visited by the garbage collector.
+ pub fn resultValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ExpectPrototype__resultValueSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Expect.resultValue` getter
- /// This value will be visited by the garbage collector.
- pub fn resultValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ExpectPrototype__resultValueGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Expect.resultValue` getter
+ /// This value will be visited by the garbage collector.
+ pub fn resultValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ExpectPrototype__resultValueGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the Expect constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return Expect__getConstructor(globalObject);
}
-
+
/// Create a new instance of Expect
pub fn toJS(this: *Expect, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -492,14 +504,14 @@ extern fn ExpectPrototype__resultValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalO
/// Modify the internal ptr to point to a new instance of Expect.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Expect) bool {
- JSC.markBinding(@src());
- return Expect__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Expect__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Expect, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Expect__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Expect__dangerouslySetPtr(value, null));
}
extern fn Expect__fromJS(JSC.JSValue) ?*Expect;
@@ -510,280 +522,183 @@ extern fn ExpectPrototype__resultValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalO
extern fn Expect__dangerouslySetPtr(JSC.JSValue, ?*Expect) bool;
comptime {
-
- if (@TypeOf(Expect.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Expect)) {
- @compileLog("Expect.constructor is not a constructor");
- }
-
- if (@TypeOf(Expect.finalize) != (fn(*Expect) callconv(.C) void)) {
- @compileLog("Expect.finalize is not a finalizer");
- }
-
- if (@TypeOf(Expect.getNot) != GetterTypeWithThisValue)
- @compileLog("Expected Expect.getNot to be a getter with thisValue");
- if (@TypeOf(Expect.getRejects) != GetterTypeWithThisValue)
- @compileLog("Expected Expect.getRejects to be a getter with thisValue");
- if (@TypeOf(Expect.getResolves) != GetterTypeWithThisValue)
- @compileLog("Expected Expect.getResolves to be a getter with thisValue");
- if (@TypeOf(Expect.toBe) != CallbackType)
- @compileLog(
- "Expected Expect.toBe to be a callback but received " ++ @typeName(@TypeOf(Expect.toBe))
- );
- if (@TypeOf(Expect.toBeCloseTo) != CallbackType)
- @compileLog(
- "Expected Expect.toBeCloseTo to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeCloseTo))
- );
- if (@TypeOf(Expect.toBeDefined) != CallbackType)
- @compileLog(
- "Expected Expect.toBeDefined to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeDefined))
- );
- if (@TypeOf(Expect.toBeFalsy) != CallbackType)
- @compileLog(
- "Expected Expect.toBeFalsy to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeFalsy))
- );
- if (@TypeOf(Expect.toBeGreaterThan) != CallbackType)
- @compileLog(
- "Expected Expect.toBeGreaterThan to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeGreaterThan))
- );
- if (@TypeOf(Expect.toBeGreaterThanOrEqual) != CallbackType)
- @compileLog(
- "Expected Expect.toBeGreaterThanOrEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeGreaterThanOrEqual))
- );
- if (@TypeOf(Expect.toBeInstanceOf) != CallbackType)
- @compileLog(
- "Expected Expect.toBeInstanceOf to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeInstanceOf))
- );
- if (@TypeOf(Expect.toBeLessThan) != CallbackType)
- @compileLog(
- "Expected Expect.toBeLessThan to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeLessThan))
- );
- if (@TypeOf(Expect.toBeLessThanOrEqual) != CallbackType)
- @compileLog(
- "Expected Expect.toBeLessThanOrEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeLessThanOrEqual))
- );
- if (@TypeOf(Expect.toBeNaN) != CallbackType)
- @compileLog(
- "Expected Expect.toBeNaN to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeNaN))
- );
- if (@TypeOf(Expect.toBeNull) != CallbackType)
- @compileLog(
- "Expected Expect.toBeNull to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeNull))
- );
- if (@TypeOf(Expect.toBeTruthy) != CallbackType)
- @compileLog(
- "Expected Expect.toBeTruthy to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeTruthy))
- );
- if (@TypeOf(Expect.toBeUndefined) != CallbackType)
- @compileLog(
- "Expected Expect.toBeUndefined to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeUndefined))
- );
- if (@TypeOf(Expect.toContain) != CallbackType)
- @compileLog(
- "Expected Expect.toContain to be a callback but received " ++ @typeName(@TypeOf(Expect.toContain))
- );
- if (@TypeOf(Expect.toContainEqual) != CallbackType)
- @compileLog(
- "Expected Expect.toContainEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toContainEqual))
- );
- if (@TypeOf(Expect.toEqual) != CallbackType)
- @compileLog(
- "Expected Expect.toEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toEqual))
- );
- if (@TypeOf(Expect.toHaveBeenCalledTimes) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveBeenCalledTimes to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveBeenCalledTimes))
- );
- if (@TypeOf(Expect.toHaveBeenCalledWith) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveBeenCalledWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveBeenCalledWith))
- );
- if (@TypeOf(Expect.toHaveBeenLastCalledWith) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveBeenLastCalledWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveBeenLastCalledWith))
- );
- if (@TypeOf(Expect.toHaveBeenNthCalledWith) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveBeenNthCalledWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveBeenNthCalledWith))
- );
- if (@TypeOf(Expect.toHaveLastReturnedWith) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveLastReturnedWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveLastReturnedWith))
- );
- if (@TypeOf(Expect.toHaveLength) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveLength to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveLength))
- );
- if (@TypeOf(Expect.toHaveNthReturnedWith) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveNthReturnedWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveNthReturnedWith))
- );
- if (@TypeOf(Expect.toHaveProperty) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveProperty to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveProperty))
- );
- if (@TypeOf(Expect.toHaveReturnedTimes) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveReturnedTimes to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveReturnedTimes))
- );
- if (@TypeOf(Expect.toHaveReturnedWith) != CallbackType)
- @compileLog(
- "Expected Expect.toHaveReturnedWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveReturnedWith))
- );
- if (@TypeOf(Expect.toMatch) != CallbackType)
- @compileLog(
- "Expected Expect.toMatch to be a callback but received " ++ @typeName(@TypeOf(Expect.toMatch))
- );
- if (@TypeOf(Expect.toMatchInlineSnapshot) != CallbackType)
- @compileLog(
- "Expected Expect.toMatchInlineSnapshot to be a callback but received " ++ @typeName(@TypeOf(Expect.toMatchInlineSnapshot))
- );
- if (@TypeOf(Expect.toMatchObject) != CallbackType)
- @compileLog(
- "Expected Expect.toMatchObject to be a callback but received " ++ @typeName(@TypeOf(Expect.toMatchObject))
- );
- if (@TypeOf(Expect.toMatchSnapshot) != CallbackType)
- @compileLog(
- "Expected Expect.toMatchSnapshot to be a callback but received " ++ @typeName(@TypeOf(Expect.toMatchSnapshot))
- );
- if (@TypeOf(Expect.toStrictEqual) != CallbackType)
- @compileLog(
- "Expected Expect.toStrictEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toStrictEqual))
- );
- if (@TypeOf(Expect.toThrow) != CallbackType)
- @compileLog(
- "Expected Expect.toThrow to be a callback but received " ++ @typeName(@TypeOf(Expect.toThrow))
- );
- if (@TypeOf(Expect.toThrowErrorMatchingInlineSnapshot) != CallbackType)
- @compileLog(
- "Expected Expect.toThrowErrorMatchingInlineSnapshot to be a callback but received " ++ @typeName(@TypeOf(Expect.toThrowErrorMatchingInlineSnapshot))
- );
- if (@TypeOf(Expect.toThrowErrorMatchingSnapshot) != CallbackType)
- @compileLog(
- "Expected Expect.toThrowErrorMatchingSnapshot to be a callback but received " ++ @typeName(@TypeOf(Expect.toThrowErrorMatchingSnapshot))
- );
- if (@TypeOf(Expect.addSnapshotSerializer) != StaticCallbackType)
- @compileLog(
- "Expected Expect.addSnapshotSerializer to be a static callback"
- );
- if (@TypeOf(Expect.any) != StaticCallbackType)
- @compileLog(
- "Expected Expect.any to be a static callback"
- );
- if (@TypeOf(Expect.anything) != StaticCallbackType)
- @compileLog(
- "Expected Expect.anything to be a static callback"
- );
- if (@TypeOf(Expect.arrayContaining) != StaticCallbackType)
- @compileLog(
- "Expected Expect.arrayContaining to be a static callback"
- );
- if (@TypeOf(Expect.assertions) != StaticCallbackType)
- @compileLog(
- "Expected Expect.assertions to be a static callback"
- );
- if (@TypeOf(Expect.extend) != StaticCallbackType)
- @compileLog(
- "Expected Expect.extend to be a static callback"
- );
- if (@TypeOf(Expect.hasAssertions) != StaticCallbackType)
- @compileLog(
- "Expected Expect.hasAssertions to be a static callback"
- );
- if (@TypeOf(Expect.getStaticNot) != StaticGetterType)
- @compileLog(
- "Expected Expect.getStaticNot to be a static getter"
- );
-
- if (@TypeOf(Expect.objectContaining) != StaticCallbackType)
- @compileLog(
- "Expected Expect.objectContaining to be a static callback"
- );
- if (@TypeOf(Expect.getStaticRejects) != StaticGetterType)
- @compileLog(
- "Expected Expect.getStaticRejects to be a static getter"
- );
-
- if (@TypeOf(Expect.getStaticResolves) != StaticGetterType)
- @compileLog(
- "Expected Expect.getStaticResolves to be a static getter"
- );
-
- if (@TypeOf(Expect.stringContaining) != StaticCallbackType)
- @compileLog(
- "Expected Expect.stringContaining to be a static callback"
- );
- if (@TypeOf(Expect.stringMatching) != StaticCallbackType)
- @compileLog(
- "Expected Expect.stringMatching to be a static callback"
- );
- if (@TypeOf(Expect.call) != StaticCallbackType)
- @compileLog(
- "Expected Expect.call to be a static callback"
- );
+ if (@TypeOf(Expect.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Expect)) {
+ @compileLog("Expect.constructor is not a constructor");
+ }
+
+ if (@TypeOf(Expect.finalize) != (fn (*Expect) callconv(.C) void)) {
+ @compileLog("Expect.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(Expect.getNot) != GetterTypeWithThisValue)
+ @compileLog("Expected Expect.getNot to be a getter with thisValue");
+ if (@TypeOf(Expect.getRejects) != GetterTypeWithThisValue)
+ @compileLog("Expected Expect.getRejects to be a getter with thisValue");
+ if (@TypeOf(Expect.getResolves) != GetterTypeWithThisValue)
+ @compileLog("Expected Expect.getResolves to be a getter with thisValue");
+ if (@TypeOf(Expect.toBe) != CallbackType)
+ @compileLog("Expected Expect.toBe to be a callback but received " ++ @typeName(@TypeOf(Expect.toBe)));
+ if (@TypeOf(Expect.toBeCloseTo) != CallbackType)
+ @compileLog("Expected Expect.toBeCloseTo to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeCloseTo)));
+ if (@TypeOf(Expect.toBeDefined) != CallbackType)
+ @compileLog("Expected Expect.toBeDefined to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeDefined)));
+ if (@TypeOf(Expect.toBeFalsy) != CallbackType)
+ @compileLog("Expected Expect.toBeFalsy to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeFalsy)));
+ if (@TypeOf(Expect.toBeGreaterThan) != CallbackType)
+ @compileLog("Expected Expect.toBeGreaterThan to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeGreaterThan)));
+ if (@TypeOf(Expect.toBeGreaterThanOrEqual) != CallbackType)
+ @compileLog("Expected Expect.toBeGreaterThanOrEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeGreaterThanOrEqual)));
+ if (@TypeOf(Expect.toBeInstanceOf) != CallbackType)
+ @compileLog("Expected Expect.toBeInstanceOf to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeInstanceOf)));
+ if (@TypeOf(Expect.toBeLessThan) != CallbackType)
+ @compileLog("Expected Expect.toBeLessThan to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeLessThan)));
+ if (@TypeOf(Expect.toBeLessThanOrEqual) != CallbackType)
+ @compileLog("Expected Expect.toBeLessThanOrEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeLessThanOrEqual)));
+ if (@TypeOf(Expect.toBeNaN) != CallbackType)
+ @compileLog("Expected Expect.toBeNaN to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeNaN)));
+ if (@TypeOf(Expect.toBeNull) != CallbackType)
+ @compileLog("Expected Expect.toBeNull to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeNull)));
+ if (@TypeOf(Expect.toBeTruthy) != CallbackType)
+ @compileLog("Expected Expect.toBeTruthy to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeTruthy)));
+ if (@TypeOf(Expect.toBeUndefined) != CallbackType)
+ @compileLog("Expected Expect.toBeUndefined to be a callback but received " ++ @typeName(@TypeOf(Expect.toBeUndefined)));
+ if (@TypeOf(Expect.toContain) != CallbackType)
+ @compileLog("Expected Expect.toContain to be a callback but received " ++ @typeName(@TypeOf(Expect.toContain)));
+ if (@TypeOf(Expect.toContainEqual) != CallbackType)
+ @compileLog("Expected Expect.toContainEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toContainEqual)));
+ if (@TypeOf(Expect.toEqual) != CallbackType)
+ @compileLog("Expected Expect.toEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toEqual)));
+ if (@TypeOf(Expect.toHaveBeenCalledTimes) != CallbackType)
+ @compileLog("Expected Expect.toHaveBeenCalledTimes to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveBeenCalledTimes)));
+ if (@TypeOf(Expect.toHaveBeenCalledWith) != CallbackType)
+ @compileLog("Expected Expect.toHaveBeenCalledWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveBeenCalledWith)));
+ if (@TypeOf(Expect.toHaveBeenLastCalledWith) != CallbackType)
+ @compileLog("Expected Expect.toHaveBeenLastCalledWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveBeenLastCalledWith)));
+ if (@TypeOf(Expect.toHaveBeenNthCalledWith) != CallbackType)
+ @compileLog("Expected Expect.toHaveBeenNthCalledWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveBeenNthCalledWith)));
+ if (@TypeOf(Expect.toHaveLastReturnedWith) != CallbackType)
+ @compileLog("Expected Expect.toHaveLastReturnedWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveLastReturnedWith)));
+ if (@TypeOf(Expect.toHaveLength) != CallbackType)
+ @compileLog("Expected Expect.toHaveLength to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveLength)));
+ if (@TypeOf(Expect.toHaveNthReturnedWith) != CallbackType)
+ @compileLog("Expected Expect.toHaveNthReturnedWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveNthReturnedWith)));
+ if (@TypeOf(Expect.toHaveProperty) != CallbackType)
+ @compileLog("Expected Expect.toHaveProperty to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveProperty)));
+ if (@TypeOf(Expect.toHaveReturnedTimes) != CallbackType)
+ @compileLog("Expected Expect.toHaveReturnedTimes to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveReturnedTimes)));
+ if (@TypeOf(Expect.toHaveReturnedWith) != CallbackType)
+ @compileLog("Expected Expect.toHaveReturnedWith to be a callback but received " ++ @typeName(@TypeOf(Expect.toHaveReturnedWith)));
+ if (@TypeOf(Expect.toMatch) != CallbackType)
+ @compileLog("Expected Expect.toMatch to be a callback but received " ++ @typeName(@TypeOf(Expect.toMatch)));
+ if (@TypeOf(Expect.toMatchInlineSnapshot) != CallbackType)
+ @compileLog("Expected Expect.toMatchInlineSnapshot to be a callback but received " ++ @typeName(@TypeOf(Expect.toMatchInlineSnapshot)));
+ if (@TypeOf(Expect.toMatchObject) != CallbackType)
+ @compileLog("Expected Expect.toMatchObject to be a callback but received " ++ @typeName(@TypeOf(Expect.toMatchObject)));
+ if (@TypeOf(Expect.toMatchSnapshot) != CallbackType)
+ @compileLog("Expected Expect.toMatchSnapshot to be a callback but received " ++ @typeName(@TypeOf(Expect.toMatchSnapshot)));
+ if (@TypeOf(Expect.toStrictEqual) != CallbackType)
+ @compileLog("Expected Expect.toStrictEqual to be a callback but received " ++ @typeName(@TypeOf(Expect.toStrictEqual)));
+ if (@TypeOf(Expect.toThrow) != CallbackType)
+ @compileLog("Expected Expect.toThrow to be a callback but received " ++ @typeName(@TypeOf(Expect.toThrow)));
+ if (@TypeOf(Expect.toThrowErrorMatchingInlineSnapshot) != CallbackType)
+ @compileLog("Expected Expect.toThrowErrorMatchingInlineSnapshot to be a callback but received " ++ @typeName(@TypeOf(Expect.toThrowErrorMatchingInlineSnapshot)));
+ if (@TypeOf(Expect.toThrowErrorMatchingSnapshot) != CallbackType)
+ @compileLog("Expected Expect.toThrowErrorMatchingSnapshot to be a callback but received " ++ @typeName(@TypeOf(Expect.toThrowErrorMatchingSnapshot)));
+ if (@TypeOf(Expect.addSnapshotSerializer) != StaticCallbackType)
+ @compileLog("Expected Expect.addSnapshotSerializer to be a static callback");
+ if (@TypeOf(Expect.any) != StaticCallbackType)
+ @compileLog("Expected Expect.any to be a static callback");
+ if (@TypeOf(Expect.anything) != StaticCallbackType)
+ @compileLog("Expected Expect.anything to be a static callback");
+ if (@TypeOf(Expect.arrayContaining) != StaticCallbackType)
+ @compileLog("Expected Expect.arrayContaining to be a static callback");
+ if (@TypeOf(Expect.assertions) != StaticCallbackType)
+ @compileLog("Expected Expect.assertions to be a static callback");
+ if (@TypeOf(Expect.extend) != StaticCallbackType)
+ @compileLog("Expected Expect.extend to be a static callback");
+ if (@TypeOf(Expect.hasAssertions) != StaticCallbackType)
+ @compileLog("Expected Expect.hasAssertions to be a static callback");
+ if (@TypeOf(Expect.getStaticNot) != StaticGetterType)
+ @compileLog("Expected Expect.getStaticNot to be a static getter");
+
+ if (@TypeOf(Expect.objectContaining) != StaticCallbackType)
+ @compileLog("Expected Expect.objectContaining to be a static callback");
+ if (@TypeOf(Expect.getStaticRejects) != StaticGetterType)
+ @compileLog("Expected Expect.getStaticRejects to be a static getter");
+
+ if (@TypeOf(Expect.getStaticResolves) != StaticGetterType)
+ @compileLog("Expected Expect.getStaticResolves to be a static getter");
+
+ if (@TypeOf(Expect.stringContaining) != StaticCallbackType)
+ @compileLog("Expected Expect.stringContaining to be a static callback");
+ if (@TypeOf(Expect.stringMatching) != StaticCallbackType)
+ @compileLog("Expected Expect.stringMatching to be a static callback");
+ if (@TypeOf(Expect.call) != StaticCallbackType)
+ @compileLog("Expected Expect.call to be a static callback");
if (!JSC.is_bindgen) {
-@export(Expect.addSnapshotSerializer, .{.name = "ExpectClass__addSnapshotSerializer"});
- @export(Expect.any, .{.name = "ExpectClass__any"});
- @export(Expect.anything, .{.name = "ExpectClass__anything"});
- @export(Expect.arrayContaining, .{.name = "ExpectClass__arrayContaining"});
- @export(Expect.assertions, .{.name = "ExpectClass__assertions"});
- @export(Expect.call, .{.name = "ExpectClass__call"});
- @export(Expect.constructor, .{.name = "ExpectClass__construct"});
- @export(Expect.extend, .{.name = "ExpectClass__extend"});
- @export(Expect.finalize, .{.name = "ExpectClass__finalize"});
- @export(Expect.getNot, .{.name = "ExpectPrototype__getNot"});
- @export(Expect.getRejects, .{.name = "ExpectPrototype__getRejects"});
- @export(Expect.getResolves, .{.name = "ExpectPrototype__getResolves"});
- @export(Expect.getStaticNot, .{.name = "ExpectClass__getStaticNot"});
- @export(Expect.getStaticRejects, .{.name = "ExpectClass__getStaticRejects"});
- @export(Expect.getStaticResolves, .{.name = "ExpectClass__getStaticResolves"});
- @export(Expect.hasAssertions, .{.name = "ExpectClass__hasAssertions"});
- @export(Expect.objectContaining, .{.name = "ExpectClass__objectContaining"});
- @export(Expect.stringContaining, .{.name = "ExpectClass__stringContaining"});
- @export(Expect.stringMatching, .{.name = "ExpectClass__stringMatching"});
- @export(Expect.toBe, .{.name = "ExpectPrototype__toBe"});
- @export(Expect.toBeCloseTo, .{.name = "ExpectPrototype__toBeCloseTo"});
- @export(Expect.toBeDefined, .{.name = "ExpectPrototype__toBeDefined"});
- @export(Expect.toBeFalsy, .{.name = "ExpectPrototype__toBeFalsy"});
- @export(Expect.toBeGreaterThan, .{.name = "ExpectPrototype__toBeGreaterThan"});
- @export(Expect.toBeGreaterThanOrEqual, .{.name = "ExpectPrototype__toBeGreaterThanOrEqual"});
- @export(Expect.toBeInstanceOf, .{.name = "ExpectPrototype__toBeInstanceOf"});
- @export(Expect.toBeLessThan, .{.name = "ExpectPrototype__toBeLessThan"});
- @export(Expect.toBeLessThanOrEqual, .{.name = "ExpectPrototype__toBeLessThanOrEqual"});
- @export(Expect.toBeNaN, .{.name = "ExpectPrototype__toBeNaN"});
- @export(Expect.toBeNull, .{.name = "ExpectPrototype__toBeNull"});
- @export(Expect.toBeTruthy, .{.name = "ExpectPrototype__toBeTruthy"});
- @export(Expect.toBeUndefined, .{.name = "ExpectPrototype__toBeUndefined"});
- @export(Expect.toContain, .{.name = "ExpectPrototype__toContain"});
- @export(Expect.toContainEqual, .{.name = "ExpectPrototype__toContainEqual"});
- @export(Expect.toEqual, .{.name = "ExpectPrototype__toEqual"});
- @export(Expect.toHaveBeenCalledTimes, .{.name = "ExpectPrototype__toHaveBeenCalledTimes"});
- @export(Expect.toHaveBeenCalledWith, .{.name = "ExpectPrototype__toHaveBeenCalledWith"});
- @export(Expect.toHaveBeenLastCalledWith, .{.name = "ExpectPrototype__toHaveBeenLastCalledWith"});
- @export(Expect.toHaveBeenNthCalledWith, .{.name = "ExpectPrototype__toHaveBeenNthCalledWith"});
- @export(Expect.toHaveLastReturnedWith, .{.name = "ExpectPrototype__toHaveLastReturnedWith"});
- @export(Expect.toHaveLength, .{.name = "ExpectPrototype__toHaveLength"});
- @export(Expect.toHaveNthReturnedWith, .{.name = "ExpectPrototype__toHaveNthReturnedWith"});
- @export(Expect.toHaveProperty, .{.name = "ExpectPrototype__toHaveProperty"});
- @export(Expect.toHaveReturnedTimes, .{.name = "ExpectPrototype__toHaveReturnedTimes"});
- @export(Expect.toHaveReturnedWith, .{.name = "ExpectPrototype__toHaveReturnedWith"});
- @export(Expect.toMatch, .{.name = "ExpectPrototype__toMatch"});
- @export(Expect.toMatchInlineSnapshot, .{.name = "ExpectPrototype__toMatchInlineSnapshot"});
- @export(Expect.toMatchObject, .{.name = "ExpectPrototype__toMatchObject"});
- @export(Expect.toMatchSnapshot, .{.name = "ExpectPrototype__toMatchSnapshot"});
- @export(Expect.toStrictEqual, .{.name = "ExpectPrototype__toStrictEqual"});
- @export(Expect.toThrow, .{.name = "ExpectPrototype__toThrow"});
- @export(Expect.toThrowErrorMatchingInlineSnapshot, .{.name = "ExpectPrototype__toThrowErrorMatchingInlineSnapshot"});
- @export(Expect.toThrowErrorMatchingSnapshot, .{.name = "ExpectPrototype__toThrowErrorMatchingSnapshot"});
+ @export(Expect.addSnapshotSerializer, .{ .name = "ExpectClass__addSnapshotSerializer" });
+ @export(Expect.any, .{ .name = "ExpectClass__any" });
+ @export(Expect.anything, .{ .name = "ExpectClass__anything" });
+ @export(Expect.arrayContaining, .{ .name = "ExpectClass__arrayContaining" });
+ @export(Expect.assertions, .{ .name = "ExpectClass__assertions" });
+ @export(Expect.call, .{ .name = "ExpectClass__call" });
+ @export(Expect.constructor, .{ .name = "ExpectClass__construct" });
+ @export(Expect.extend, .{ .name = "ExpectClass__extend" });
+ @export(Expect.finalize, .{ .name = "ExpectClass__finalize" });
+ @export(Expect.getNot, .{ .name = "ExpectPrototype__getNot" });
+ @export(Expect.getRejects, .{ .name = "ExpectPrototype__getRejects" });
+ @export(Expect.getResolves, .{ .name = "ExpectPrototype__getResolves" });
+ @export(Expect.getStaticNot, .{ .name = "ExpectClass__getStaticNot" });
+ @export(Expect.getStaticRejects, .{ .name = "ExpectClass__getStaticRejects" });
+ @export(Expect.getStaticResolves, .{ .name = "ExpectClass__getStaticResolves" });
+ @export(Expect.hasAssertions, .{ .name = "ExpectClass__hasAssertions" });
+ @export(Expect.objectContaining, .{ .name = "ExpectClass__objectContaining" });
+ @export(Expect.stringContaining, .{ .name = "ExpectClass__stringContaining" });
+ @export(Expect.stringMatching, .{ .name = "ExpectClass__stringMatching" });
+ @export(Expect.toBe, .{ .name = "ExpectPrototype__toBe" });
+ @export(Expect.toBeCloseTo, .{ .name = "ExpectPrototype__toBeCloseTo" });
+ @export(Expect.toBeDefined, .{ .name = "ExpectPrototype__toBeDefined" });
+ @export(Expect.toBeFalsy, .{ .name = "ExpectPrototype__toBeFalsy" });
+ @export(Expect.toBeGreaterThan, .{ .name = "ExpectPrototype__toBeGreaterThan" });
+ @export(Expect.toBeGreaterThanOrEqual, .{ .name = "ExpectPrototype__toBeGreaterThanOrEqual" });
+ @export(Expect.toBeInstanceOf, .{ .name = "ExpectPrototype__toBeInstanceOf" });
+ @export(Expect.toBeLessThan, .{ .name = "ExpectPrototype__toBeLessThan" });
+ @export(Expect.toBeLessThanOrEqual, .{ .name = "ExpectPrototype__toBeLessThanOrEqual" });
+ @export(Expect.toBeNaN, .{ .name = "ExpectPrototype__toBeNaN" });
+ @export(Expect.toBeNull, .{ .name = "ExpectPrototype__toBeNull" });
+ @export(Expect.toBeTruthy, .{ .name = "ExpectPrototype__toBeTruthy" });
+ @export(Expect.toBeUndefined, .{ .name = "ExpectPrototype__toBeUndefined" });
+ @export(Expect.toContain, .{ .name = "ExpectPrototype__toContain" });
+ @export(Expect.toContainEqual, .{ .name = "ExpectPrototype__toContainEqual" });
+ @export(Expect.toEqual, .{ .name = "ExpectPrototype__toEqual" });
+ @export(Expect.toHaveBeenCalledTimes, .{ .name = "ExpectPrototype__toHaveBeenCalledTimes" });
+ @export(Expect.toHaveBeenCalledWith, .{ .name = "ExpectPrototype__toHaveBeenCalledWith" });
+ @export(Expect.toHaveBeenLastCalledWith, .{ .name = "ExpectPrototype__toHaveBeenLastCalledWith" });
+ @export(Expect.toHaveBeenNthCalledWith, .{ .name = "ExpectPrototype__toHaveBeenNthCalledWith" });
+ @export(Expect.toHaveLastReturnedWith, .{ .name = "ExpectPrototype__toHaveLastReturnedWith" });
+ @export(Expect.toHaveLength, .{ .name = "ExpectPrototype__toHaveLength" });
+ @export(Expect.toHaveNthReturnedWith, .{ .name = "ExpectPrototype__toHaveNthReturnedWith" });
+ @export(Expect.toHaveProperty, .{ .name = "ExpectPrototype__toHaveProperty" });
+ @export(Expect.toHaveReturnedTimes, .{ .name = "ExpectPrototype__toHaveReturnedTimes" });
+ @export(Expect.toHaveReturnedWith, .{ .name = "ExpectPrototype__toHaveReturnedWith" });
+ @export(Expect.toMatch, .{ .name = "ExpectPrototype__toMatch" });
+ @export(Expect.toMatchInlineSnapshot, .{ .name = "ExpectPrototype__toMatchInlineSnapshot" });
+ @export(Expect.toMatchObject, .{ .name = "ExpectPrototype__toMatchObject" });
+ @export(Expect.toMatchSnapshot, .{ .name = "ExpectPrototype__toMatchSnapshot" });
+ @export(Expect.toStrictEqual, .{ .name = "ExpectPrototype__toStrictEqual" });
+ @export(Expect.toThrow, .{ .name = "ExpectPrototype__toThrow" });
+ @export(Expect.toThrowErrorMatchingInlineSnapshot, .{ .name = "ExpectPrototype__toThrowErrorMatchingInlineSnapshot" });
+ @export(Expect.toThrowErrorMatchingSnapshot, .{ .name = "ExpectPrototype__toThrowErrorMatchingSnapshot" });
}
}
};
pub const JSExpectAny = struct {
const ExpectAny = Classes.ExpectAny;
- const GetterType = fn(*ExpectAny, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*ExpectAny, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*ExpectAny, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*ExpectAny, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*ExpectAny, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*ExpectAny, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*ExpectAny, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*ExpectAny, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*ExpectAny, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*ExpectAny, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -794,28 +709,26 @@ pub const JSExpectAny = struct {
extern fn ExpectAnyPrototype__constructorValueSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn ExpectAnyPrototype__constructorValueGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `ExpectAny.constructorValue` setter
- /// This value will be visited by the garbage collector.
- pub fn constructorValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ExpectAnyPrototype__constructorValueSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ExpectAnyPrototype__constructorValueGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ExpectAny.constructorValue` setter
+ /// This value will be visited by the garbage collector.
+ pub fn constructorValueSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ExpectAnyPrototype__constructorValueSetCachedValue(thisValue, globalObject, value);
+ }
- /// `ExpectAny.constructorValue` getter
- /// This value will be visited by the garbage collector.
- pub fn constructorValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ExpectAnyPrototype__constructorValueGetCachedValue(thisValue);
- if (result == .zero)
+ /// `ExpectAny.constructorValue` getter
+ /// This value will be visited by the garbage collector.
+ pub fn constructorValueGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ExpectAnyPrototype__constructorValueGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Create a new instance of ExpectAny
pub fn toJS(this: *ExpectAny, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -830,14 +743,14 @@ pub const JSExpectAny = struct {
/// Modify the internal ptr to point to a new instance of ExpectAny.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*ExpectAny) bool {
- JSC.markBinding(@src());
- return ExpectAny__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return ExpectAny__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *ExpectAny, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(ExpectAny__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(ExpectAny__dangerouslySetPtr(value, null));
}
extern fn ExpectAny__fromJS(JSC.JSValue) ?*ExpectAny;
@@ -848,28 +761,25 @@ pub const JSExpectAny = struct {
extern fn ExpectAny__dangerouslySetPtr(JSC.JSValue, ?*ExpectAny) bool;
comptime {
-
- if (@TypeOf(ExpectAny.finalize) != (fn(*ExpectAny) callconv(.C) void)) {
- @compileLog("ExpectAny.finalize is not a finalizer");
+ if (@TypeOf(ExpectAny.finalize) != (fn (*ExpectAny) callconv(.C) void)) {
+ @compileLog("ExpectAny.finalize is not a finalizer");
}
-
- if (@TypeOf(ExpectAny.call) != StaticCallbackType)
- @compileLog(
- "Expected ExpectAny.call to be a static callback"
- );
+
+ if (@TypeOf(ExpectAny.call) != StaticCallbackType)
+ @compileLog("Expected ExpectAny.call to be a static callback");
if (!JSC.is_bindgen) {
-@export(ExpectAny.call, .{.name = "ExpectAnyClass__call"});
- @export(ExpectAny.finalize, .{.name = "ExpectAnyClass__finalize"});
+ @export(ExpectAny.call, .{ .name = "ExpectAnyClass__call" });
+ @export(ExpectAny.finalize, .{ .name = "ExpectAnyClass__finalize" });
}
}
};
pub const JSFileSystemRouter = struct {
const FileSystemRouter = Classes.FileSystemRouter;
- const GetterType = fn(*FileSystemRouter, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*FileSystemRouter, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*FileSystemRouter, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*FileSystemRouter, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*FileSystemRouter, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*FileSystemRouter, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*FileSystemRouter, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*FileSystemRouter, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*FileSystemRouter, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*FileSystemRouter, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -880,79 +790,77 @@ pub const JSFileSystemRouter = struct {
extern fn FileSystemRouterPrototype__originSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn FileSystemRouterPrototype__originGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `FileSystemRouter.origin` setter
- /// This value will be visited by the garbage collector.
- pub fn originSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- FileSystemRouterPrototype__originSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn FileSystemRouterPrototype__originGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `FileSystemRouter.origin` getter
- /// This value will be visited by the garbage collector.
- pub fn originGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = FileSystemRouterPrototype__originGetCachedValue(thisValue);
- if (result == .zero)
+ /// `FileSystemRouter.origin` setter
+ /// This value will be visited by the garbage collector.
+ pub fn originSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ FileSystemRouterPrototype__originSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `FileSystemRouter.origin` getter
+ /// This value will be visited by the garbage collector.
+ pub fn originGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = FileSystemRouterPrototype__originGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn FileSystemRouterPrototype__routesSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn FileSystemRouterPrototype__routesGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `FileSystemRouter.routes` setter
- /// This value will be visited by the garbage collector.
- pub fn routesSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- FileSystemRouterPrototype__routesSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn FileSystemRouterPrototype__routesSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- /// `FileSystemRouter.routes` getter
- /// This value will be visited by the garbage collector.
- pub fn routesGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = FileSystemRouterPrototype__routesGetCachedValue(thisValue);
- if (result == .zero)
+ extern fn FileSystemRouterPrototype__routesGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `FileSystemRouter.routes` setter
+ /// This value will be visited by the garbage collector.
+ pub fn routesSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ FileSystemRouterPrototype__routesSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `FileSystemRouter.routes` getter
+ /// This value will be visited by the garbage collector.
+ pub fn routesGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = FileSystemRouterPrototype__routesGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn FileSystemRouterPrototype__styleSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn FileSystemRouterPrototype__styleGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `FileSystemRouter.style` setter
- /// This value will be visited by the garbage collector.
- pub fn styleSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- FileSystemRouterPrototype__styleSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn FileSystemRouterPrototype__styleSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn FileSystemRouterPrototype__styleGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `FileSystemRouter.style` setter
+ /// This value will be visited by the garbage collector.
+ pub fn styleSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ FileSystemRouterPrototype__styleSetCachedValue(thisValue, globalObject, value);
+ }
- /// `FileSystemRouter.style` getter
- /// This value will be visited by the garbage collector.
- pub fn styleGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = FileSystemRouterPrototype__styleGetCachedValue(thisValue);
- if (result == .zero)
+ /// `FileSystemRouter.style` getter
+ /// This value will be visited by the garbage collector.
+ pub fn styleGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = FileSystemRouterPrototype__styleGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the FileSystemRouter constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return FileSystemRouter__getConstructor(globalObject);
}
-
+
/// Create a new instance of FileSystemRouter
pub fn toJS(this: *FileSystemRouter, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -967,14 +875,14 @@ extern fn FileSystemRouterPrototype__styleSetCachedValue(JSC.JSValue, *JSC.JSGlo
/// Modify the internal ptr to point to a new instance of FileSystemRouter.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*FileSystemRouter) bool {
- JSC.markBinding(@src());
- return FileSystemRouter__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return FileSystemRouter__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *FileSystemRouter, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(FileSystemRouter__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(FileSystemRouter__dangerouslySetPtr(value, null));
}
extern fn FileSystemRouter__fromJS(JSC.JSValue) ?*FileSystemRouter;
@@ -985,56 +893,45 @@ extern fn FileSystemRouterPrototype__styleSetCachedValue(JSC.JSValue, *JSC.JSGlo
extern fn FileSystemRouter__dangerouslySetPtr(JSC.JSValue, ?*FileSystemRouter) bool;
comptime {
-
- if (@TypeOf(FileSystemRouter.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*FileSystemRouter)) {
- @compileLog("FileSystemRouter.constructor is not a constructor");
+ if (@TypeOf(FileSystemRouter.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*FileSystemRouter)) {
+ @compileLog("FileSystemRouter.constructor is not a constructor");
}
-
- if (@TypeOf(FileSystemRouter.finalize) != (fn(*FileSystemRouter) callconv(.C) void)) {
- @compileLog("FileSystemRouter.finalize is not a finalizer");
+
+ if (@TypeOf(FileSystemRouter.finalize) != (fn (*FileSystemRouter) callconv(.C) void)) {
+ @compileLog("FileSystemRouter.finalize is not a finalizer");
}
-
- if (@TypeOf(FileSystemRouter.match) != CallbackType)
- @compileLog(
- "Expected FileSystemRouter.match to be a callback but received " ++ @typeName(@TypeOf(FileSystemRouter.match))
- );
- if (@TypeOf(FileSystemRouter.getOrigin) != GetterType)
- @compileLog(
- "Expected FileSystemRouter.getOrigin to be a getter"
- );
-
- if (@TypeOf(FileSystemRouter.reload) != CallbackType)
- @compileLog(
- "Expected FileSystemRouter.reload to be a callback but received " ++ @typeName(@TypeOf(FileSystemRouter.reload))
- );
- if (@TypeOf(FileSystemRouter.getRoutes) != GetterType)
- @compileLog(
- "Expected FileSystemRouter.getRoutes to be a getter"
- );
-
- if (@TypeOf(FileSystemRouter.getStyle) != GetterType)
- @compileLog(
- "Expected FileSystemRouter.getStyle to be a getter"
- );
+
+ if (@TypeOf(FileSystemRouter.match) != CallbackType)
+ @compileLog("Expected FileSystemRouter.match to be a callback but received " ++ @typeName(@TypeOf(FileSystemRouter.match)));
+ if (@TypeOf(FileSystemRouter.getOrigin) != GetterType)
+ @compileLog("Expected FileSystemRouter.getOrigin to be a getter");
+
+ if (@TypeOf(FileSystemRouter.reload) != CallbackType)
+ @compileLog("Expected FileSystemRouter.reload to be a callback but received " ++ @typeName(@TypeOf(FileSystemRouter.reload)));
+ if (@TypeOf(FileSystemRouter.getRoutes) != GetterType)
+ @compileLog("Expected FileSystemRouter.getRoutes to be a getter");
+
+ if (@TypeOf(FileSystemRouter.getStyle) != GetterType)
+ @compileLog("Expected FileSystemRouter.getStyle to be a getter");
if (!JSC.is_bindgen) {
-@export(FileSystemRouter.constructor, .{.name = "FileSystemRouterClass__construct"});
- @export(FileSystemRouter.finalize, .{.name = "FileSystemRouterClass__finalize"});
- @export(FileSystemRouter.getOrigin, .{.name = "FileSystemRouterPrototype__getOrigin"});
- @export(FileSystemRouter.getRoutes, .{.name = "FileSystemRouterPrototype__getRoutes"});
- @export(FileSystemRouter.getStyle, .{.name = "FileSystemRouterPrototype__getStyle"});
- @export(FileSystemRouter.match, .{.name = "FileSystemRouterPrototype__match"});
- @export(FileSystemRouter.reload, .{.name = "FileSystemRouterPrototype__reload"});
+ @export(FileSystemRouter.constructor, .{ .name = "FileSystemRouterClass__construct" });
+ @export(FileSystemRouter.finalize, .{ .name = "FileSystemRouterClass__finalize" });
+ @export(FileSystemRouter.getOrigin, .{ .name = "FileSystemRouterPrototype__getOrigin" });
+ @export(FileSystemRouter.getRoutes, .{ .name = "FileSystemRouterPrototype__getRoutes" });
+ @export(FileSystemRouter.getStyle, .{ .name = "FileSystemRouterPrototype__getStyle" });
+ @export(FileSystemRouter.match, .{ .name = "FileSystemRouterPrototype__match" });
+ @export(FileSystemRouter.reload, .{ .name = "FileSystemRouterPrototype__reload" });
}
}
};
pub const JSListener = struct {
const Listener = Classes.Listener;
- const GetterType = fn(*Listener, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Listener, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Listener, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Listener, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Listener, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Listener, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Listener, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Listener, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Listener, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Listener, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -1045,50 +942,48 @@ pub const JSListener = struct {
extern fn ListenerPrototype__hostnameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn ListenerPrototype__hostnameGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Listener.hostname` setter
- /// This value will be visited by the garbage collector.
- pub fn hostnameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ListenerPrototype__hostnameSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ListenerPrototype__hostnameGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `Listener.hostname` getter
- /// This value will be visited by the garbage collector.
- pub fn hostnameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ListenerPrototype__hostnameGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Listener.hostname` setter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ListenerPrototype__hostnameSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Listener.hostname` getter
+ /// This value will be visited by the garbage collector.
+ pub fn hostnameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ListenerPrototype__hostnameGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn ListenerPrototype__unixSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
+
+ extern fn ListenerPrototype__unixSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn ListenerPrototype__unixGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Listener.unix` setter
- /// This value will be visited by the garbage collector.
- pub fn unixSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ListenerPrototype__unixSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ListenerPrototype__unixGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `Listener.unix` getter
- /// This value will be visited by the garbage collector.
- pub fn unixGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ListenerPrototype__unixGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Listener.unix` setter
+ /// This value will be visited by the garbage collector.
+ pub fn unixSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ListenerPrototype__unixSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Listener.unix` getter
+ /// This value will be visited by the garbage collector.
+ pub fn unixGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ListenerPrototype__unixGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Create a new instance of Listener
pub fn toJS(this: *Listener, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -1103,14 +998,14 @@ extern fn ListenerPrototype__unixSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject
/// Modify the internal ptr to point to a new instance of Listener.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Listener) bool {
- JSC.markBinding(@src());
- return Listener__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Listener__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Listener, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Listener__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Listener__dangerouslySetPtr(value, null));
}
extern fn Listener__fromJS(JSC.JSValue) ?*Listener;
@@ -1121,72 +1016,53 @@ extern fn ListenerPrototype__unixSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject
extern fn Listener__dangerouslySetPtr(JSC.JSValue, ?*Listener) bool;
comptime {
-
- if (@TypeOf(Listener.finalize) != (fn(*Listener) callconv(.C) void)) {
- @compileLog("Listener.finalize is not a finalizer");
+ if (@TypeOf(Listener.finalize) != (fn (*Listener) callconv(.C) void)) {
+ @compileLog("Listener.finalize is not a finalizer");
}
-
- if (@TypeOf(Listener.getData) != GetterType)
- @compileLog(
- "Expected Listener.getData to be a getter"
- );
-
- if (@TypeOf(Listener.setData) != SetterType)
- @compileLog(
- "Expected Listener.setData to be a setter"
- );
- if (@TypeOf(Listener.getHostname) != GetterType)
- @compileLog(
- "Expected Listener.getHostname to be a getter"
- );
-
- if (@TypeOf(Listener.getPort) != GetterType)
- @compileLog(
- "Expected Listener.getPort to be a getter"
- );
-
- if (@TypeOf(Listener.ref) != CallbackType)
- @compileLog(
- "Expected Listener.ref to be a callback but received " ++ @typeName(@TypeOf(Listener.ref))
- );
- if (@TypeOf(Listener.reload) != CallbackType)
- @compileLog(
- "Expected Listener.reload to be a callback but received " ++ @typeName(@TypeOf(Listener.reload))
- );
- if (@TypeOf(Listener.stop) != CallbackType)
- @compileLog(
- "Expected Listener.stop to be a callback but received " ++ @typeName(@TypeOf(Listener.stop))
- );
- if (@TypeOf(Listener.getUnix) != GetterType)
- @compileLog(
- "Expected Listener.getUnix to be a getter"
- );
-
- if (@TypeOf(Listener.unref) != CallbackType)
- @compileLog(
- "Expected Listener.unref to be a callback but received " ++ @typeName(@TypeOf(Listener.unref))
- );
+
+ if (@TypeOf(Listener.getData) != GetterType)
+ @compileLog("Expected Listener.getData to be a getter");
+
+ if (@TypeOf(Listener.setData) != SetterType)
+ @compileLog("Expected Listener.setData to be a setter");
+ if (@TypeOf(Listener.getHostname) != GetterType)
+ @compileLog("Expected Listener.getHostname to be a getter");
+
+ if (@TypeOf(Listener.getPort) != GetterType)
+ @compileLog("Expected Listener.getPort to be a getter");
+
+ if (@TypeOf(Listener.ref) != CallbackType)
+ @compileLog("Expected Listener.ref to be a callback but received " ++ @typeName(@TypeOf(Listener.ref)));
+ if (@TypeOf(Listener.reload) != CallbackType)
+ @compileLog("Expected Listener.reload to be a callback but received " ++ @typeName(@TypeOf(Listener.reload)));
+ if (@TypeOf(Listener.stop) != CallbackType)
+ @compileLog("Expected Listener.stop to be a callback but received " ++ @typeName(@TypeOf(Listener.stop)));
+ if (@TypeOf(Listener.getUnix) != GetterType)
+ @compileLog("Expected Listener.getUnix to be a getter");
+
+ if (@TypeOf(Listener.unref) != CallbackType)
+ @compileLog("Expected Listener.unref to be a callback but received " ++ @typeName(@TypeOf(Listener.unref)));
if (!JSC.is_bindgen) {
-@export(Listener.finalize, .{.name = "ListenerClass__finalize"});
- @export(Listener.getData, .{.name = "ListenerPrototype__getData"});
- @export(Listener.getHostname, .{.name = "ListenerPrototype__getHostname"});
- @export(Listener.getPort, .{.name = "ListenerPrototype__getPort"});
- @export(Listener.getUnix, .{.name = "ListenerPrototype__getUnix"});
- @export(Listener.ref, .{.name = "ListenerPrototype__ref"});
- @export(Listener.reload, .{.name = "ListenerPrototype__reload"});
- @export(Listener.setData, .{.name = "ListenerPrototype__setData"});
- @export(Listener.stop, .{.name = "ListenerPrototype__stop"});
- @export(Listener.unref, .{.name = "ListenerPrototype__unref"});
+ @export(Listener.finalize, .{ .name = "ListenerClass__finalize" });
+ @export(Listener.getData, .{ .name = "ListenerPrototype__getData" });
+ @export(Listener.getHostname, .{ .name = "ListenerPrototype__getHostname" });
+ @export(Listener.getPort, .{ .name = "ListenerPrototype__getPort" });
+ @export(Listener.getUnix, .{ .name = "ListenerPrototype__getUnix" });
+ @export(Listener.ref, .{ .name = "ListenerPrototype__ref" });
+ @export(Listener.reload, .{ .name = "ListenerPrototype__reload" });
+ @export(Listener.setData, .{ .name = "ListenerPrototype__setData" });
+ @export(Listener.stop, .{ .name = "ListenerPrototype__stop" });
+ @export(Listener.unref, .{ .name = "ListenerPrototype__unref" });
}
}
};
pub const JSMD4 = struct {
const MD4 = Classes.MD4;
- const GetterType = fn(*MD4, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*MD4, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*MD4, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*MD4, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*MD4, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*MD4, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*MD4, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*MD4, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*MD4, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*MD4, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -1195,16 +1071,13 @@ pub const JSMD4 = struct {
return MD4__fromJS(value);
}
-
-
-
/// Get the MD4 constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return MD4__getConstructor(globalObject);
}
-
+
/// Create a new instance of MD4
pub fn toJS(this: *MD4, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -1219,14 +1092,14 @@ pub const JSMD4 = struct {
/// Modify the internal ptr to point to a new instance of MD4.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*MD4) bool {
- JSC.markBinding(@src());
- return MD4__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return MD4__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *MD4, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(MD4__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(MD4__dangerouslySetPtr(value, null));
}
extern fn MD4__fromJS(JSC.JSValue) ?*MD4;
@@ -1237,55 +1110,44 @@ pub const JSMD4 = struct {
extern fn MD4__dangerouslySetPtr(JSC.JSValue, ?*MD4) bool;
comptime {
-
- if (@TypeOf(MD4.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*MD4)) {
- @compileLog("MD4.constructor is not a constructor");
+ if (@TypeOf(MD4.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*MD4)) {
+ @compileLog("MD4.constructor is not a constructor");
}
-
- if (@TypeOf(MD4.finalize) != (fn(*MD4) callconv(.C) void)) {
- @compileLog("MD4.finalize is not a finalizer");
+
+ if (@TypeOf(MD4.finalize) != (fn (*MD4) callconv(.C) void)) {
+ @compileLog("MD4.finalize is not a finalizer");
}
-
- if (@TypeOf(MD4.getByteLength) != GetterType)
- @compileLog(
- "Expected MD4.getByteLength to be a getter"
- );
-
- if (@TypeOf(MD4.digest) != CallbackType)
- @compileLog(
- "Expected MD4.digest to be a callback but received " ++ @typeName(@TypeOf(MD4.digest))
- );
- if (@TypeOf(MD4.update) != CallbackType)
- @compileLog(
- "Expected MD4.update to be a callback but received " ++ @typeName(@TypeOf(MD4.update))
- );
- if (@TypeOf(MD4.getByteLengthStatic) != StaticGetterType)
- @compileLog(
- "Expected MD4.getByteLengthStatic to be a static getter"
- );
-
- if (@TypeOf(MD4.hash) != StaticCallbackType)
- @compileLog(
- "Expected MD4.hash to be a static callback"
- );
+
+ if (@TypeOf(MD4.getByteLength) != GetterType)
+ @compileLog("Expected MD4.getByteLength to be a getter");
+
+ if (@TypeOf(MD4.digest) != CallbackType)
+ @compileLog("Expected MD4.digest to be a callback but received " ++ @typeName(@TypeOf(MD4.digest)));
+ if (@TypeOf(MD4.update) != CallbackType)
+ @compileLog("Expected MD4.update to be a callback but received " ++ @typeName(@TypeOf(MD4.update)));
+ if (@TypeOf(MD4.getByteLengthStatic) != StaticGetterType)
+ @compileLog("Expected MD4.getByteLengthStatic to be a static getter");
+
+ if (@TypeOf(MD4.hash) != StaticCallbackType)
+ @compileLog("Expected MD4.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(MD4.constructor, .{.name = "MD4Class__construct"});
- @export(MD4.digest, .{.name = "MD4Prototype__digest"});
- @export(MD4.finalize, .{.name = "MD4Class__finalize"});
- @export(MD4.getByteLength, .{.name = "MD4Prototype__getByteLength"});
- @export(MD4.getByteLengthStatic, .{.name = "MD4Class__getByteLengthStatic"});
- @export(MD4.hash, .{.name = "MD4Class__hash"});
- @export(MD4.update, .{.name = "MD4Prototype__update"});
+ @export(MD4.constructor, .{ .name = "MD4Class__construct" });
+ @export(MD4.digest, .{ .name = "MD4Prototype__digest" });
+ @export(MD4.finalize, .{ .name = "MD4Class__finalize" });
+ @export(MD4.getByteLength, .{ .name = "MD4Prototype__getByteLength" });
+ @export(MD4.getByteLengthStatic, .{ .name = "MD4Class__getByteLengthStatic" });
+ @export(MD4.hash, .{ .name = "MD4Class__hash" });
+ @export(MD4.update, .{ .name = "MD4Prototype__update" });
}
}
};
pub const JSMD5 = struct {
const MD5 = Classes.MD5;
- const GetterType = fn(*MD5, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*MD5, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*MD5, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*MD5, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*MD5, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*MD5, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*MD5, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*MD5, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*MD5, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*MD5, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -1294,16 +1156,13 @@ pub const JSMD5 = struct {
return MD5__fromJS(value);
}
-
-
-
/// Get the MD5 constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return MD5__getConstructor(globalObject);
}
-
+
/// Create a new instance of MD5
pub fn toJS(this: *MD5, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -1318,14 +1177,14 @@ pub const JSMD5 = struct {
/// Modify the internal ptr to point to a new instance of MD5.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*MD5) bool {
- JSC.markBinding(@src());
- return MD5__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return MD5__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *MD5, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(MD5__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(MD5__dangerouslySetPtr(value, null));
}
extern fn MD5__fromJS(JSC.JSValue) ?*MD5;
@@ -1336,55 +1195,44 @@ pub const JSMD5 = struct {
extern fn MD5__dangerouslySetPtr(JSC.JSValue, ?*MD5) bool;
comptime {
-
- if (@TypeOf(MD5.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*MD5)) {
- @compileLog("MD5.constructor is not a constructor");
+ if (@TypeOf(MD5.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*MD5)) {
+ @compileLog("MD5.constructor is not a constructor");
}
-
- if (@TypeOf(MD5.finalize) != (fn(*MD5) callconv(.C) void)) {
- @compileLog("MD5.finalize is not a finalizer");
+
+ if (@TypeOf(MD5.finalize) != (fn (*MD5) callconv(.C) void)) {
+ @compileLog("MD5.finalize is not a finalizer");
}
-
- if (@TypeOf(MD5.getByteLength) != GetterType)
- @compileLog(
- "Expected MD5.getByteLength to be a getter"
- );
-
- if (@TypeOf(MD5.digest) != CallbackType)
- @compileLog(
- "Expected MD5.digest to be a callback but received " ++ @typeName(@TypeOf(MD5.digest))
- );
- if (@TypeOf(MD5.update) != CallbackType)
- @compileLog(
- "Expected MD5.update to be a callback but received " ++ @typeName(@TypeOf(MD5.update))
- );
- if (@TypeOf(MD5.getByteLengthStatic) != StaticGetterType)
- @compileLog(
- "Expected MD5.getByteLengthStatic to be a static getter"
- );
-
- if (@TypeOf(MD5.hash) != StaticCallbackType)
- @compileLog(
- "Expected MD5.hash to be a static callback"
- );
+
+ if (@TypeOf(MD5.getByteLength) != GetterType)
+ @compileLog("Expected MD5.getByteLength to be a getter");
+
+ if (@TypeOf(MD5.digest) != CallbackType)
+ @compileLog("Expected MD5.digest to be a callback but received " ++ @typeName(@TypeOf(MD5.digest)));
+ if (@TypeOf(MD5.update) != CallbackType)
+ @compileLog("Expected MD5.update to be a callback but received " ++ @typeName(@TypeOf(MD5.update)));
+ if (@TypeOf(MD5.getByteLengthStatic) != StaticGetterType)
+ @compileLog("Expected MD5.getByteLengthStatic to be a static getter");
+
+ if (@TypeOf(MD5.hash) != StaticCallbackType)
+ @compileLog("Expected MD5.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(MD5.constructor, .{.name = "MD5Class__construct"});
- @export(MD5.digest, .{.name = "MD5Prototype__digest"});
- @export(MD5.finalize, .{.name = "MD5Class__finalize"});
- @export(MD5.getByteLength, .{.name = "MD5Prototype__getByteLength"});
- @export(MD5.getByteLengthStatic, .{.name = "MD5Class__getByteLengthStatic"});
- @export(MD5.hash, .{.name = "MD5Class__hash"});
- @export(MD5.update, .{.name = "MD5Prototype__update"});
+ @export(MD5.constructor, .{ .name = "MD5Class__construct" });
+ @export(MD5.digest, .{ .name = "MD5Prototype__digest" });
+ @export(MD5.finalize, .{ .name = "MD5Class__finalize" });
+ @export(MD5.getByteLength, .{ .name = "MD5Prototype__getByteLength" });
+ @export(MD5.getByteLengthStatic, .{ .name = "MD5Class__getByteLengthStatic" });
+ @export(MD5.hash, .{ .name = "MD5Class__hash" });
+ @export(MD5.update, .{ .name = "MD5Prototype__update" });
}
}
};
pub const JSMatchedRoute = struct {
const MatchedRoute = Classes.MatchedRoute;
- const GetterType = fn(*MatchedRoute, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*MatchedRoute, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*MatchedRoute, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*MatchedRoute, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*MatchedRoute, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*MatchedRoute, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*MatchedRoute, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*MatchedRoute, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*MatchedRoute, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*MatchedRoute, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -1395,160 +1243,158 @@ pub const JSMatchedRoute = struct {
extern fn MatchedRoutePrototype__filePathSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn MatchedRoutePrototype__filePathGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `MatchedRoute.filePath` setter
- /// This value will be visited by the garbage collector.
- pub fn filePathSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- MatchedRoutePrototype__filePathSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn MatchedRoutePrototype__filePathGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `MatchedRoute.filePath` getter
- /// This value will be visited by the garbage collector.
- pub fn filePathGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = MatchedRoutePrototype__filePathGetCachedValue(thisValue);
- if (result == .zero)
+ /// `MatchedRoute.filePath` setter
+ /// This value will be visited by the garbage collector.
+ pub fn filePathSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ MatchedRoutePrototype__filePathSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `MatchedRoute.filePath` getter
+ /// This value will be visited by the garbage collector.
+ pub fn filePathGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = MatchedRoutePrototype__filePathGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn MatchedRoutePrototype__kindSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
+
+ extern fn MatchedRoutePrototype__kindSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn MatchedRoutePrototype__kindGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `MatchedRoute.kind` setter
- /// This value will be visited by the garbage collector.
- pub fn kindSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- MatchedRoutePrototype__kindSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn MatchedRoutePrototype__kindGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `MatchedRoute.kind` getter
- /// This value will be visited by the garbage collector.
- pub fn kindGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = MatchedRoutePrototype__kindGetCachedValue(thisValue);
- if (result == .zero)
+ /// `MatchedRoute.kind` setter
+ /// This value will be visited by the garbage collector.
+ pub fn kindSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ MatchedRoutePrototype__kindSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `MatchedRoute.kind` getter
+ /// This value will be visited by the garbage collector.
+ pub fn kindGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = MatchedRoutePrototype__kindGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn MatchedRoutePrototype__nameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
+
+ extern fn MatchedRoutePrototype__nameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn MatchedRoutePrototype__nameGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `MatchedRoute.name` setter
- /// This value will be visited by the garbage collector.
- pub fn nameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- MatchedRoutePrototype__nameSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn MatchedRoutePrototype__nameGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `MatchedRoute.name` getter
- /// This value will be visited by the garbage collector.
- pub fn nameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = MatchedRoutePrototype__nameGetCachedValue(thisValue);
- if (result == .zero)
+ /// `MatchedRoute.name` setter
+ /// This value will be visited by the garbage collector.
+ pub fn nameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ MatchedRoutePrototype__nameSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `MatchedRoute.name` getter
+ /// This value will be visited by the garbage collector.
+ pub fn nameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = MatchedRoutePrototype__nameGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn MatchedRoutePrototype__paramsSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
+
+ extern fn MatchedRoutePrototype__paramsSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn MatchedRoutePrototype__paramsGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `MatchedRoute.params` setter
- /// This value will be visited by the garbage collector.
- pub fn paramsSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- MatchedRoutePrototype__paramsSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn MatchedRoutePrototype__paramsGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `MatchedRoute.params` getter
- /// This value will be visited by the garbage collector.
- pub fn paramsGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = MatchedRoutePrototype__paramsGetCachedValue(thisValue);
- if (result == .zero)
+ /// `MatchedRoute.params` setter
+ /// This value will be visited by the garbage collector.
+ pub fn paramsSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ MatchedRoutePrototype__paramsSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `MatchedRoute.params` getter
+ /// This value will be visited by the garbage collector.
+ pub fn paramsGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = MatchedRoutePrototype__paramsGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn MatchedRoutePrototype__pathnameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn MatchedRoutePrototype__pathnameGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `MatchedRoute.pathname` setter
- /// This value will be visited by the garbage collector.
- pub fn pathnameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- MatchedRoutePrototype__pathnameSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn MatchedRoutePrototype__pathnameSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- /// `MatchedRoute.pathname` getter
- /// This value will be visited by the garbage collector.
- pub fn pathnameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = MatchedRoutePrototype__pathnameGetCachedValue(thisValue);
- if (result == .zero)
+ extern fn MatchedRoutePrototype__pathnameGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `MatchedRoute.pathname` setter
+ /// This value will be visited by the garbage collector.
+ pub fn pathnameSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ MatchedRoutePrototype__pathnameSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `MatchedRoute.pathname` getter
+ /// This value will be visited by the garbage collector.
+ pub fn pathnameGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = MatchedRoutePrototype__pathnameGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn MatchedRoutePrototype__querySetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn MatchedRoutePrototype__queryGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `MatchedRoute.query` setter
- /// This value will be visited by the garbage collector.
- pub fn querySetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- MatchedRoutePrototype__querySetCachedValue(thisValue, globalObject, value);
- }
+ extern fn MatchedRoutePrototype__querySetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- /// `MatchedRoute.query` getter
- /// This value will be visited by the garbage collector.
- pub fn queryGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = MatchedRoutePrototype__queryGetCachedValue(thisValue);
- if (result == .zero)
+ extern fn MatchedRoutePrototype__queryGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `MatchedRoute.query` setter
+ /// This value will be visited by the garbage collector.
+ pub fn querySetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ MatchedRoutePrototype__querySetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `MatchedRoute.query` getter
+ /// This value will be visited by the garbage collector.
+ pub fn queryGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = MatchedRoutePrototype__queryGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn MatchedRoutePrototype__scriptSrcSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn MatchedRoutePrototype__scriptSrcGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `MatchedRoute.scriptSrc` setter
- /// This value will be visited by the garbage collector.
- pub fn scriptSrcSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- MatchedRoutePrototype__scriptSrcSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn MatchedRoutePrototype__scriptSrcSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn MatchedRoutePrototype__scriptSrcGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `MatchedRoute.scriptSrc` setter
+ /// This value will be visited by the garbage collector.
+ pub fn scriptSrcSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ MatchedRoutePrototype__scriptSrcSetCachedValue(thisValue, globalObject, value);
+ }
- /// `MatchedRoute.scriptSrc` getter
- /// This value will be visited by the garbage collector.
- pub fn scriptSrcGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = MatchedRoutePrototype__scriptSrcGetCachedValue(thisValue);
- if (result == .zero)
+ /// `MatchedRoute.scriptSrc` getter
+ /// This value will be visited by the garbage collector.
+ pub fn scriptSrcGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = MatchedRoutePrototype__scriptSrcGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Create a new instance of MatchedRoute
pub fn toJS(this: *MatchedRoute, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -1563,14 +1409,14 @@ extern fn MatchedRoutePrototype__scriptSrcSetCachedValue(JSC.JSValue, *JSC.JSGlo
/// Modify the internal ptr to point to a new instance of MatchedRoute.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*MatchedRoute) bool {
- JSC.markBinding(@src());
- return MatchedRoute__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return MatchedRoute__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *MatchedRoute, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(MatchedRoute__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(MatchedRoute__dangerouslySetPtr(value, null));
}
extern fn MatchedRoute__fromJS(JSC.JSValue) ?*MatchedRoute;
@@ -1581,70 +1427,53 @@ extern fn MatchedRoutePrototype__scriptSrcSetCachedValue(JSC.JSValue, *JSC.JSGlo
extern fn MatchedRoute__dangerouslySetPtr(JSC.JSValue, ?*MatchedRoute) bool;
comptime {
-
- if (@TypeOf(MatchedRoute.finalize) != (fn(*MatchedRoute) callconv(.C) void)) {
- @compileLog("MatchedRoute.finalize is not a finalizer");
+ if (@TypeOf(MatchedRoute.finalize) != (fn (*MatchedRoute) callconv(.C) void)) {
+ @compileLog("MatchedRoute.finalize is not a finalizer");
}
-
- if (@TypeOf(MatchedRoute.getFilePath) != GetterType)
- @compileLog(
- "Expected MatchedRoute.getFilePath to be a getter"
- );
-
- if (@TypeOf(MatchedRoute.getKind) != GetterType)
- @compileLog(
- "Expected MatchedRoute.getKind to be a getter"
- );
-
- if (@TypeOf(MatchedRoute.getName) != GetterType)
- @compileLog(
- "Expected MatchedRoute.getName to be a getter"
- );
-
- if (@TypeOf(MatchedRoute.getParams) != GetterType)
- @compileLog(
- "Expected MatchedRoute.getParams to be a getter"
- );
-
- if (@TypeOf(MatchedRoute.getPathname) != GetterType)
- @compileLog(
- "Expected MatchedRoute.getPathname to be a getter"
- );
-
- if (@TypeOf(MatchedRoute.getQuery) != GetterType)
- @compileLog(
- "Expected MatchedRoute.getQuery to be a getter"
- );
-
- if (@TypeOf(MatchedRoute.getScriptSrc) != GetterType)
- @compileLog(
- "Expected MatchedRoute.getScriptSrc to be a getter"
- );
-
- if (@TypeOf(MatchedRoute.getScriptSrc) != GetterType)
- @compileLog(
- "Expected MatchedRoute.getScriptSrc to be a getter"
- );
+
+ if (@TypeOf(MatchedRoute.getFilePath) != GetterType)
+ @compileLog("Expected MatchedRoute.getFilePath to be a getter");
+
+ if (@TypeOf(MatchedRoute.getKind) != GetterType)
+ @compileLog("Expected MatchedRoute.getKind to be a getter");
+
+ if (@TypeOf(MatchedRoute.getName) != GetterType)
+ @compileLog("Expected MatchedRoute.getName to be a getter");
+
+ if (@TypeOf(MatchedRoute.getParams) != GetterType)
+ @compileLog("Expected MatchedRoute.getParams to be a getter");
+
+ if (@TypeOf(MatchedRoute.getPathname) != GetterType)
+ @compileLog("Expected MatchedRoute.getPathname to be a getter");
+
+ if (@TypeOf(MatchedRoute.getQuery) != GetterType)
+ @compileLog("Expected MatchedRoute.getQuery to be a getter");
+
+ if (@TypeOf(MatchedRoute.getScriptSrc) != GetterType)
+ @compileLog("Expected MatchedRoute.getScriptSrc to be a getter");
+
+ if (@TypeOf(MatchedRoute.getScriptSrc) != GetterType)
+ @compileLog("Expected MatchedRoute.getScriptSrc to be a getter");
if (!JSC.is_bindgen) {
-@export(MatchedRoute.finalize, .{.name = "MatchedRouteClass__finalize"});
- @export(MatchedRoute.getFilePath, .{.name = "MatchedRoutePrototype__getFilePath"});
- @export(MatchedRoute.getKind, .{.name = "MatchedRoutePrototype__getKind"});
- @export(MatchedRoute.getName, .{.name = "MatchedRoutePrototype__getName"});
- @export(MatchedRoute.getParams, .{.name = "MatchedRoutePrototype__getParams"});
- @export(MatchedRoute.getPathname, .{.name = "MatchedRoutePrototype__getPathname"});
- @export(MatchedRoute.getQuery, .{.name = "MatchedRoutePrototype__getQuery"});
- @export(MatchedRoute.getScriptSrc, .{.name = "MatchedRoutePrototype__getScriptSrc"});
+ @export(MatchedRoute.finalize, .{ .name = "MatchedRouteClass__finalize" });
+ @export(MatchedRoute.getFilePath, .{ .name = "MatchedRoutePrototype__getFilePath" });
+ @export(MatchedRoute.getKind, .{ .name = "MatchedRoutePrototype__getKind" });
+ @export(MatchedRoute.getName, .{ .name = "MatchedRoutePrototype__getName" });
+ @export(MatchedRoute.getParams, .{ .name = "MatchedRoutePrototype__getParams" });
+ @export(MatchedRoute.getPathname, .{ .name = "MatchedRoutePrototype__getPathname" });
+ @export(MatchedRoute.getQuery, .{ .name = "MatchedRoutePrototype__getQuery" });
+ @export(MatchedRoute.getScriptSrc, .{ .name = "MatchedRoutePrototype__getScriptSrc" });
}
}
};
pub const JSNodeJSFS = struct {
const NodeJSFS = Classes.NodeJSFS;
- const GetterType = fn(*NodeJSFS, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*NodeJSFS, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*NodeJSFS, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*NodeJSFS, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*NodeJSFS, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*NodeJSFS, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*NodeJSFS, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*NodeJSFS, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*NodeJSFS, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*NodeJSFS, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -1653,16 +1482,13 @@ pub const JSNodeJSFS = struct {
return NodeJSFS__fromJS(value);
}
-
-
-
/// Get the NodeJSFS constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return NodeJSFS__getConstructor(globalObject);
}
-
+
/// Create a new instance of NodeJSFS
pub fn toJS(this: *NodeJSFS, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -1677,14 +1503,14 @@ pub const JSNodeJSFS = struct {
/// Modify the internal ptr to point to a new instance of NodeJSFS.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*NodeJSFS) bool {
- JSC.markBinding(@src());
- return NodeJSFS__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return NodeJSFS__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *NodeJSFS, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(NodeJSFS__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(NodeJSFS__dangerouslySetPtr(value, null));
}
extern fn NodeJSFS__fromJS(JSC.JSValue) ?*NodeJSFS;
@@ -1695,435 +1521,270 @@ pub const JSNodeJSFS = struct {
extern fn NodeJSFS__dangerouslySetPtr(JSC.JSValue, ?*NodeJSFS) bool;
comptime {
-
- if (@TypeOf(NodeJSFS.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*NodeJSFS)) {
- @compileLog("NodeJSFS.constructor is not a constructor");
- }
-
- if (@TypeOf(NodeJSFS.access) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.access to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.access))
- );
- if (@TypeOf(NodeJSFS.accessSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.accessSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.accessSync))
- );
- if (@TypeOf(NodeJSFS.appendFile) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.appendFile to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.appendFile))
- );
- if (@TypeOf(NodeJSFS.appendFileSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.appendFileSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.appendFileSync))
- );
- if (@TypeOf(NodeJSFS.chmod) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.chmod to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.chmod))
- );
- if (@TypeOf(NodeJSFS.chmodSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.chmodSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.chmodSync))
- );
- if (@TypeOf(NodeJSFS.chown) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.chown to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.chown))
- );
- if (@TypeOf(NodeJSFS.chownSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.chownSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.chownSync))
- );
- if (@TypeOf(NodeJSFS.close) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.close to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.close))
- );
- if (@TypeOf(NodeJSFS.closeSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.closeSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.closeSync))
- );
- if (@TypeOf(NodeJSFS.copyFile) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.copyFile to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.copyFile))
- );
- if (@TypeOf(NodeJSFS.copyFileSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.copyFileSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.copyFileSync))
- );
- if (@TypeOf(NodeJSFS.getDirent) != GetterType)
- @compileLog(
- "Expected NodeJSFS.getDirent to be a getter"
- );
-
- if (@TypeOf(NodeJSFS.exists) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.exists to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.exists))
- );
- if (@TypeOf(NodeJSFS.existsSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.existsSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.existsSync))
- );
- if (@TypeOf(NodeJSFS.fchmod) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fchmod to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fchmod))
- );
- if (@TypeOf(NodeJSFS.fchmodSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fchmodSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fchmodSync))
- );
- if (@TypeOf(NodeJSFS.fchown) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fchown to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fchown))
- );
- if (@TypeOf(NodeJSFS.fchownSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fchownSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fchownSync))
- );
- if (@TypeOf(NodeJSFS.fdatasync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fdatasync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fdatasync))
- );
- if (@TypeOf(NodeJSFS.fdatasyncSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fdatasyncSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fdatasyncSync))
- );
- if (@TypeOf(NodeJSFS.fstat) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fstat to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fstat))
- );
- if (@TypeOf(NodeJSFS.fstatSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fstatSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fstatSync))
- );
- if (@TypeOf(NodeJSFS.fsync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fsync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fsync))
- );
- if (@TypeOf(NodeJSFS.fsyncSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.fsyncSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fsyncSync))
- );
- if (@TypeOf(NodeJSFS.ftruncate) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.ftruncate to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.ftruncate))
- );
- if (@TypeOf(NodeJSFS.ftruncateSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.ftruncateSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.ftruncateSync))
- );
- if (@TypeOf(NodeJSFS.futimes) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.futimes to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.futimes))
- );
- if (@TypeOf(NodeJSFS.futimesSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.futimesSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.futimesSync))
- );
- if (@TypeOf(NodeJSFS.lchmod) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.lchmod to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lchmod))
- );
- if (@TypeOf(NodeJSFS.lchmodSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.lchmodSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lchmodSync))
- );
- if (@TypeOf(NodeJSFS.lchown) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.lchown to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lchown))
- );
- if (@TypeOf(NodeJSFS.lchownSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.lchownSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lchownSync))
- );
- if (@TypeOf(NodeJSFS.link) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.link to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.link))
- );
- if (@TypeOf(NodeJSFS.linkSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.linkSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.linkSync))
- );
- if (@TypeOf(NodeJSFS.lstat) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.lstat to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lstat))
- );
- if (@TypeOf(NodeJSFS.lstatSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.lstatSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lstatSync))
- );
- if (@TypeOf(NodeJSFS.lutimes) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.lutimes to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lutimes))
- );
- if (@TypeOf(NodeJSFS.lutimesSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.lutimesSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lutimesSync))
- );
- if (@TypeOf(NodeJSFS.mkdir) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.mkdir to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.mkdir))
- );
- if (@TypeOf(NodeJSFS.mkdirSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.mkdirSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.mkdirSync))
- );
- if (@TypeOf(NodeJSFS.mkdtemp) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.mkdtemp to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.mkdtemp))
- );
- if (@TypeOf(NodeJSFS.mkdtempSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.mkdtempSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.mkdtempSync))
- );
- if (@TypeOf(NodeJSFS.open) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.open to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.open))
- );
- if (@TypeOf(NodeJSFS.opendir) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.opendir to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.opendir))
- );
- if (@TypeOf(NodeJSFS.opendirSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.opendirSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.opendirSync))
- );
- if (@TypeOf(NodeJSFS.openSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.openSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.openSync))
- );
- if (@TypeOf(NodeJSFS.read) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.read to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.read))
- );
- if (@TypeOf(NodeJSFS.readdir) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readdir to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readdir))
- );
- if (@TypeOf(NodeJSFS.readdirSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readdirSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readdirSync))
- );
- if (@TypeOf(NodeJSFS.readFile) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readFile to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readFile))
- );
- if (@TypeOf(NodeJSFS.readFileSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readFileSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readFileSync))
- );
- if (@TypeOf(NodeJSFS.readlink) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readlink to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readlink))
- );
- if (@TypeOf(NodeJSFS.readlinkSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readlinkSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readlinkSync))
- );
- if (@TypeOf(NodeJSFS.readSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readSync))
- );
- if (@TypeOf(NodeJSFS.readv) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readv to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readv))
- );
- if (@TypeOf(NodeJSFS.readvSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.readvSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readvSync))
- );
- if (@TypeOf(NodeJSFS.realpath) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.realpath to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.realpath))
- );
- if (@TypeOf(NodeJSFS.realpathSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.realpathSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.realpathSync))
- );
- if (@TypeOf(NodeJSFS.rename) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.rename to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rename))
- );
- if (@TypeOf(NodeJSFS.renameSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.renameSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.renameSync))
- );
- if (@TypeOf(NodeJSFS.rm) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.rm to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rm))
- );
- if (@TypeOf(NodeJSFS.rmdir) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.rmdir to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rmdir))
- );
- if (@TypeOf(NodeJSFS.rmdirSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.rmdirSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rmdirSync))
- );
- if (@TypeOf(NodeJSFS.rmSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.rmSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rmSync))
- );
- if (@TypeOf(NodeJSFS.stat) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.stat to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.stat))
- );
- if (@TypeOf(NodeJSFS.getStats) != GetterType)
- @compileLog(
- "Expected NodeJSFS.getStats to be a getter"
- );
-
- if (@TypeOf(NodeJSFS.statSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.statSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.statSync))
- );
- if (@TypeOf(NodeJSFS.symlink) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.symlink to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.symlink))
- );
- if (@TypeOf(NodeJSFS.symlinkSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.symlinkSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.symlinkSync))
- );
- if (@TypeOf(NodeJSFS.truncate) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.truncate to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.truncate))
- );
- if (@TypeOf(NodeJSFS.truncateSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.truncateSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.truncateSync))
- );
- if (@TypeOf(NodeJSFS.unlink) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.unlink to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.unlink))
- );
- if (@TypeOf(NodeJSFS.unlinkSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.unlinkSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.unlinkSync))
- );
- if (@TypeOf(NodeJSFS.utimes) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.utimes to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.utimes))
- );
- if (@TypeOf(NodeJSFS.utimesSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.utimesSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.utimesSync))
- );
- if (@TypeOf(NodeJSFS.write) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.write to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.write))
- );
- if (@TypeOf(NodeJSFS.writeFile) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.writeFile to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writeFile))
- );
- if (@TypeOf(NodeJSFS.writeFileSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.writeFileSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writeFileSync))
- );
- if (@TypeOf(NodeJSFS.writeSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.writeSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writeSync))
- );
- if (@TypeOf(NodeJSFS.writev) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.writev to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writev))
- );
- if (@TypeOf(NodeJSFS.writevSync) != CallbackType)
- @compileLog(
- "Expected NodeJSFS.writevSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writevSync))
- );
+ if (@TypeOf(NodeJSFS.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*NodeJSFS)) {
+ @compileLog("NodeJSFS.constructor is not a constructor");
+ }
+
+ if (@TypeOf(NodeJSFS.access) != CallbackType)
+ @compileLog("Expected NodeJSFS.access to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.access)));
+ if (@TypeOf(NodeJSFS.accessSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.accessSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.accessSync)));
+ if (@TypeOf(NodeJSFS.appendFile) != CallbackType)
+ @compileLog("Expected NodeJSFS.appendFile to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.appendFile)));
+ if (@TypeOf(NodeJSFS.appendFileSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.appendFileSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.appendFileSync)));
+ if (@TypeOf(NodeJSFS.chmod) != CallbackType)
+ @compileLog("Expected NodeJSFS.chmod to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.chmod)));
+ if (@TypeOf(NodeJSFS.chmodSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.chmodSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.chmodSync)));
+ if (@TypeOf(NodeJSFS.chown) != CallbackType)
+ @compileLog("Expected NodeJSFS.chown to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.chown)));
+ if (@TypeOf(NodeJSFS.chownSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.chownSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.chownSync)));
+ if (@TypeOf(NodeJSFS.close) != CallbackType)
+ @compileLog("Expected NodeJSFS.close to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.close)));
+ if (@TypeOf(NodeJSFS.closeSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.closeSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.closeSync)));
+ if (@TypeOf(NodeJSFS.copyFile) != CallbackType)
+ @compileLog("Expected NodeJSFS.copyFile to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.copyFile)));
+ if (@TypeOf(NodeJSFS.copyFileSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.copyFileSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.copyFileSync)));
+ if (@TypeOf(NodeJSFS.getDirent) != GetterType)
+ @compileLog("Expected NodeJSFS.getDirent to be a getter");
+
+ if (@TypeOf(NodeJSFS.exists) != CallbackType)
+ @compileLog("Expected NodeJSFS.exists to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.exists)));
+ if (@TypeOf(NodeJSFS.existsSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.existsSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.existsSync)));
+ if (@TypeOf(NodeJSFS.fchmod) != CallbackType)
+ @compileLog("Expected NodeJSFS.fchmod to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fchmod)));
+ if (@TypeOf(NodeJSFS.fchmodSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.fchmodSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fchmodSync)));
+ if (@TypeOf(NodeJSFS.fchown) != CallbackType)
+ @compileLog("Expected NodeJSFS.fchown to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fchown)));
+ if (@TypeOf(NodeJSFS.fchownSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.fchownSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fchownSync)));
+ if (@TypeOf(NodeJSFS.fdatasync) != CallbackType)
+ @compileLog("Expected NodeJSFS.fdatasync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fdatasync)));
+ if (@TypeOf(NodeJSFS.fdatasyncSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.fdatasyncSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fdatasyncSync)));
+ if (@TypeOf(NodeJSFS.fstat) != CallbackType)
+ @compileLog("Expected NodeJSFS.fstat to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fstat)));
+ if (@TypeOf(NodeJSFS.fstatSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.fstatSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fstatSync)));
+ if (@TypeOf(NodeJSFS.fsync) != CallbackType)
+ @compileLog("Expected NodeJSFS.fsync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fsync)));
+ if (@TypeOf(NodeJSFS.fsyncSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.fsyncSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.fsyncSync)));
+ if (@TypeOf(NodeJSFS.ftruncate) != CallbackType)
+ @compileLog("Expected NodeJSFS.ftruncate to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.ftruncate)));
+ if (@TypeOf(NodeJSFS.ftruncateSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.ftruncateSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.ftruncateSync)));
+ if (@TypeOf(NodeJSFS.futimes) != CallbackType)
+ @compileLog("Expected NodeJSFS.futimes to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.futimes)));
+ if (@TypeOf(NodeJSFS.futimesSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.futimesSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.futimesSync)));
+ if (@TypeOf(NodeJSFS.lchmod) != CallbackType)
+ @compileLog("Expected NodeJSFS.lchmod to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lchmod)));
+ if (@TypeOf(NodeJSFS.lchmodSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.lchmodSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lchmodSync)));
+ if (@TypeOf(NodeJSFS.lchown) != CallbackType)
+ @compileLog("Expected NodeJSFS.lchown to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lchown)));
+ if (@TypeOf(NodeJSFS.lchownSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.lchownSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lchownSync)));
+ if (@TypeOf(NodeJSFS.link) != CallbackType)
+ @compileLog("Expected NodeJSFS.link to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.link)));
+ if (@TypeOf(NodeJSFS.linkSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.linkSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.linkSync)));
+ if (@TypeOf(NodeJSFS.lstat) != CallbackType)
+ @compileLog("Expected NodeJSFS.lstat to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lstat)));
+ if (@TypeOf(NodeJSFS.lstatSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.lstatSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lstatSync)));
+ if (@TypeOf(NodeJSFS.lutimes) != CallbackType)
+ @compileLog("Expected NodeJSFS.lutimes to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lutimes)));
+ if (@TypeOf(NodeJSFS.lutimesSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.lutimesSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.lutimesSync)));
+ if (@TypeOf(NodeJSFS.mkdir) != CallbackType)
+ @compileLog("Expected NodeJSFS.mkdir to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.mkdir)));
+ if (@TypeOf(NodeJSFS.mkdirSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.mkdirSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.mkdirSync)));
+ if (@TypeOf(NodeJSFS.mkdtemp) != CallbackType)
+ @compileLog("Expected NodeJSFS.mkdtemp to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.mkdtemp)));
+ if (@TypeOf(NodeJSFS.mkdtempSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.mkdtempSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.mkdtempSync)));
+ if (@TypeOf(NodeJSFS.open) != CallbackType)
+ @compileLog("Expected NodeJSFS.open to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.open)));
+ if (@TypeOf(NodeJSFS.opendir) != CallbackType)
+ @compileLog("Expected NodeJSFS.opendir to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.opendir)));
+ if (@TypeOf(NodeJSFS.opendirSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.opendirSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.opendirSync)));
+ if (@TypeOf(NodeJSFS.openSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.openSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.openSync)));
+ if (@TypeOf(NodeJSFS.read) != CallbackType)
+ @compileLog("Expected NodeJSFS.read to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.read)));
+ if (@TypeOf(NodeJSFS.readdir) != CallbackType)
+ @compileLog("Expected NodeJSFS.readdir to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readdir)));
+ if (@TypeOf(NodeJSFS.readdirSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.readdirSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readdirSync)));
+ if (@TypeOf(NodeJSFS.readFile) != CallbackType)
+ @compileLog("Expected NodeJSFS.readFile to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readFile)));
+ if (@TypeOf(NodeJSFS.readFileSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.readFileSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readFileSync)));
+ if (@TypeOf(NodeJSFS.readlink) != CallbackType)
+ @compileLog("Expected NodeJSFS.readlink to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readlink)));
+ if (@TypeOf(NodeJSFS.readlinkSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.readlinkSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readlinkSync)));
+ if (@TypeOf(NodeJSFS.readSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.readSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readSync)));
+ if (@TypeOf(NodeJSFS.readv) != CallbackType)
+ @compileLog("Expected NodeJSFS.readv to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readv)));
+ if (@TypeOf(NodeJSFS.readvSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.readvSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.readvSync)));
+ if (@TypeOf(NodeJSFS.realpath) != CallbackType)
+ @compileLog("Expected NodeJSFS.realpath to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.realpath)));
+ if (@TypeOf(NodeJSFS.realpathSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.realpathSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.realpathSync)));
+ if (@TypeOf(NodeJSFS.rename) != CallbackType)
+ @compileLog("Expected NodeJSFS.rename to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rename)));
+ if (@TypeOf(NodeJSFS.renameSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.renameSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.renameSync)));
+ if (@TypeOf(NodeJSFS.rm) != CallbackType)
+ @compileLog("Expected NodeJSFS.rm to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rm)));
+ if (@TypeOf(NodeJSFS.rmdir) != CallbackType)
+ @compileLog("Expected NodeJSFS.rmdir to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rmdir)));
+ if (@TypeOf(NodeJSFS.rmdirSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.rmdirSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rmdirSync)));
+ if (@TypeOf(NodeJSFS.rmSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.rmSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.rmSync)));
+ if (@TypeOf(NodeJSFS.stat) != CallbackType)
+ @compileLog("Expected NodeJSFS.stat to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.stat)));
+ if (@TypeOf(NodeJSFS.getStats) != GetterType)
+ @compileLog("Expected NodeJSFS.getStats to be a getter");
+
+ if (@TypeOf(NodeJSFS.statSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.statSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.statSync)));
+ if (@TypeOf(NodeJSFS.symlink) != CallbackType)
+ @compileLog("Expected NodeJSFS.symlink to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.symlink)));
+ if (@TypeOf(NodeJSFS.symlinkSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.symlinkSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.symlinkSync)));
+ if (@TypeOf(NodeJSFS.truncate) != CallbackType)
+ @compileLog("Expected NodeJSFS.truncate to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.truncate)));
+ if (@TypeOf(NodeJSFS.truncateSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.truncateSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.truncateSync)));
+ if (@TypeOf(NodeJSFS.unlink) != CallbackType)
+ @compileLog("Expected NodeJSFS.unlink to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.unlink)));
+ if (@TypeOf(NodeJSFS.unlinkSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.unlinkSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.unlinkSync)));
+ if (@TypeOf(NodeJSFS.utimes) != CallbackType)
+ @compileLog("Expected NodeJSFS.utimes to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.utimes)));
+ if (@TypeOf(NodeJSFS.utimesSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.utimesSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.utimesSync)));
+ if (@TypeOf(NodeJSFS.write) != CallbackType)
+ @compileLog("Expected NodeJSFS.write to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.write)));
+ if (@TypeOf(NodeJSFS.writeFile) != CallbackType)
+ @compileLog("Expected NodeJSFS.writeFile to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writeFile)));
+ if (@TypeOf(NodeJSFS.writeFileSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.writeFileSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writeFileSync)));
+ if (@TypeOf(NodeJSFS.writeSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.writeSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writeSync)));
+ if (@TypeOf(NodeJSFS.writev) != CallbackType)
+ @compileLog("Expected NodeJSFS.writev to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writev)));
+ if (@TypeOf(NodeJSFS.writevSync) != CallbackType)
+ @compileLog("Expected NodeJSFS.writevSync to be a callback but received " ++ @typeName(@TypeOf(NodeJSFS.writevSync)));
if (!JSC.is_bindgen) {
-@export(NodeJSFS.access, .{.name = "NodeJSFSPrototype__access"});
- @export(NodeJSFS.accessSync, .{.name = "NodeJSFSPrototype__accessSync"});
- @export(NodeJSFS.appendFile, .{.name = "NodeJSFSPrototype__appendFile"});
- @export(NodeJSFS.appendFileSync, .{.name = "NodeJSFSPrototype__appendFileSync"});
- @export(NodeJSFS.chmod, .{.name = "NodeJSFSPrototype__chmod"});
- @export(NodeJSFS.chmodSync, .{.name = "NodeJSFSPrototype__chmodSync"});
- @export(NodeJSFS.chown, .{.name = "NodeJSFSPrototype__chown"});
- @export(NodeJSFS.chownSync, .{.name = "NodeJSFSPrototype__chownSync"});
- @export(NodeJSFS.close, .{.name = "NodeJSFSPrototype__close"});
- @export(NodeJSFS.closeSync, .{.name = "NodeJSFSPrototype__closeSync"});
- @export(NodeJSFS.constructor, .{.name = "NodeJSFSClass__construct"});
- @export(NodeJSFS.copyFile, .{.name = "NodeJSFSPrototype__copyFile"});
- @export(NodeJSFS.copyFileSync, .{.name = "NodeJSFSPrototype__copyFileSync"});
- @export(NodeJSFS.exists, .{.name = "NodeJSFSPrototype__exists"});
- @export(NodeJSFS.existsSync, .{.name = "NodeJSFSPrototype__existsSync"});
- @export(NodeJSFS.fchmod, .{.name = "NodeJSFSPrototype__fchmod"});
- @export(NodeJSFS.fchmodSync, .{.name = "NodeJSFSPrototype__fchmodSync"});
- @export(NodeJSFS.fchown, .{.name = "NodeJSFSPrototype__fchown"});
- @export(NodeJSFS.fchownSync, .{.name = "NodeJSFSPrototype__fchownSync"});
- @export(NodeJSFS.fdatasync, .{.name = "NodeJSFSPrototype__fdatasync"});
- @export(NodeJSFS.fdatasyncSync, .{.name = "NodeJSFSPrototype__fdatasyncSync"});
- @export(NodeJSFS.fstat, .{.name = "NodeJSFSPrototype__fstat"});
- @export(NodeJSFS.fstatSync, .{.name = "NodeJSFSPrototype__fstatSync"});
- @export(NodeJSFS.fsync, .{.name = "NodeJSFSPrototype__fsync"});
- @export(NodeJSFS.fsyncSync, .{.name = "NodeJSFSPrototype__fsyncSync"});
- @export(NodeJSFS.ftruncate, .{.name = "NodeJSFSPrototype__ftruncate"});
- @export(NodeJSFS.ftruncateSync, .{.name = "NodeJSFSPrototype__ftruncateSync"});
- @export(NodeJSFS.futimes, .{.name = "NodeJSFSPrototype__futimes"});
- @export(NodeJSFS.futimesSync, .{.name = "NodeJSFSPrototype__futimesSync"});
- @export(NodeJSFS.getDirent, .{.name = "NodeJSFSPrototype__getDirent"});
- @export(NodeJSFS.getStats, .{.name = "NodeJSFSPrototype__getStats"});
- @export(NodeJSFS.lchmod, .{.name = "NodeJSFSPrototype__lchmod"});
- @export(NodeJSFS.lchmodSync, .{.name = "NodeJSFSPrototype__lchmodSync"});
- @export(NodeJSFS.lchown, .{.name = "NodeJSFSPrototype__lchown"});
- @export(NodeJSFS.lchownSync, .{.name = "NodeJSFSPrototype__lchownSync"});
- @export(NodeJSFS.link, .{.name = "NodeJSFSPrototype__link"});
- @export(NodeJSFS.linkSync, .{.name = "NodeJSFSPrototype__linkSync"});
- @export(NodeJSFS.lstat, .{.name = "NodeJSFSPrototype__lstat"});
- @export(NodeJSFS.lstatSync, .{.name = "NodeJSFSPrototype__lstatSync"});
- @export(NodeJSFS.lutimes, .{.name = "NodeJSFSPrototype__lutimes"});
- @export(NodeJSFS.lutimesSync, .{.name = "NodeJSFSPrototype__lutimesSync"});
- @export(NodeJSFS.mkdir, .{.name = "NodeJSFSPrototype__mkdir"});
- @export(NodeJSFS.mkdirSync, .{.name = "NodeJSFSPrototype__mkdirSync"});
- @export(NodeJSFS.mkdtemp, .{.name = "NodeJSFSPrototype__mkdtemp"});
- @export(NodeJSFS.mkdtempSync, .{.name = "NodeJSFSPrototype__mkdtempSync"});
- @export(NodeJSFS.open, .{.name = "NodeJSFSPrototype__open"});
- @export(NodeJSFS.opendir, .{.name = "NodeJSFSPrototype__opendir"});
- @export(NodeJSFS.opendirSync, .{.name = "NodeJSFSPrototype__opendirSync"});
- @export(NodeJSFS.openSync, .{.name = "NodeJSFSPrototype__openSync"});
- @export(NodeJSFS.read, .{.name = "NodeJSFSPrototype__read"});
- @export(NodeJSFS.readdir, .{.name = "NodeJSFSPrototype__readdir"});
- @export(NodeJSFS.readdirSync, .{.name = "NodeJSFSPrototype__readdirSync"});
- @export(NodeJSFS.readFile, .{.name = "NodeJSFSPrototype__readFile"});
- @export(NodeJSFS.readFileSync, .{.name = "NodeJSFSPrototype__readFileSync"});
- @export(NodeJSFS.readlink, .{.name = "NodeJSFSPrototype__readlink"});
- @export(NodeJSFS.readlinkSync, .{.name = "NodeJSFSPrototype__readlinkSync"});
- @export(NodeJSFS.readSync, .{.name = "NodeJSFSPrototype__readSync"});
- @export(NodeJSFS.readv, .{.name = "NodeJSFSPrototype__readv"});
- @export(NodeJSFS.readvSync, .{.name = "NodeJSFSPrototype__readvSync"});
- @export(NodeJSFS.realpath, .{.name = "NodeJSFSPrototype__realpath"});
- @export(NodeJSFS.realpathSync, .{.name = "NodeJSFSPrototype__realpathSync"});
- @export(NodeJSFS.rename, .{.name = "NodeJSFSPrototype__rename"});
- @export(NodeJSFS.renameSync, .{.name = "NodeJSFSPrototype__renameSync"});
- @export(NodeJSFS.rm, .{.name = "NodeJSFSPrototype__rm"});
- @export(NodeJSFS.rmdir, .{.name = "NodeJSFSPrototype__rmdir"});
- @export(NodeJSFS.rmdirSync, .{.name = "NodeJSFSPrototype__rmdirSync"});
- @export(NodeJSFS.rmSync, .{.name = "NodeJSFSPrototype__rmSync"});
- @export(NodeJSFS.stat, .{.name = "NodeJSFSPrototype__stat"});
- @export(NodeJSFS.statSync, .{.name = "NodeJSFSPrototype__statSync"});
- @export(NodeJSFS.symlink, .{.name = "NodeJSFSPrototype__symlink"});
- @export(NodeJSFS.symlinkSync, .{.name = "NodeJSFSPrototype__symlinkSync"});
- @export(NodeJSFS.truncate, .{.name = "NodeJSFSPrototype__truncate"});
- @export(NodeJSFS.truncateSync, .{.name = "NodeJSFSPrototype__truncateSync"});
- @export(NodeJSFS.unlink, .{.name = "NodeJSFSPrototype__unlink"});
- @export(NodeJSFS.unlinkSync, .{.name = "NodeJSFSPrototype__unlinkSync"});
- @export(NodeJSFS.utimes, .{.name = "NodeJSFSPrototype__utimes"});
- @export(NodeJSFS.utimesSync, .{.name = "NodeJSFSPrototype__utimesSync"});
- @export(NodeJSFS.write, .{.name = "NodeJSFSPrototype__write"});
- @export(NodeJSFS.writeFile, .{.name = "NodeJSFSPrototype__writeFile"});
- @export(NodeJSFS.writeFileSync, .{.name = "NodeJSFSPrototype__writeFileSync"});
- @export(NodeJSFS.writeSync, .{.name = "NodeJSFSPrototype__writeSync"});
- @export(NodeJSFS.writev, .{.name = "NodeJSFSPrototype__writev"});
- @export(NodeJSFS.writevSync, .{.name = "NodeJSFSPrototype__writevSync"});
+ @export(NodeJSFS.access, .{ .name = "NodeJSFSPrototype__access" });
+ @export(NodeJSFS.accessSync, .{ .name = "NodeJSFSPrototype__accessSync" });
+ @export(NodeJSFS.appendFile, .{ .name = "NodeJSFSPrototype__appendFile" });
+ @export(NodeJSFS.appendFileSync, .{ .name = "NodeJSFSPrototype__appendFileSync" });
+ @export(NodeJSFS.chmod, .{ .name = "NodeJSFSPrototype__chmod" });
+ @export(NodeJSFS.chmodSync, .{ .name = "NodeJSFSPrototype__chmodSync" });
+ @export(NodeJSFS.chown, .{ .name = "NodeJSFSPrototype__chown" });
+ @export(NodeJSFS.chownSync, .{ .name = "NodeJSFSPrototype__chownSync" });
+ @export(NodeJSFS.close, .{ .name = "NodeJSFSPrototype__close" });
+ @export(NodeJSFS.closeSync, .{ .name = "NodeJSFSPrototype__closeSync" });
+ @export(NodeJSFS.constructor, .{ .name = "NodeJSFSClass__construct" });
+ @export(NodeJSFS.copyFile, .{ .name = "NodeJSFSPrototype__copyFile" });
+ @export(NodeJSFS.copyFileSync, .{ .name = "NodeJSFSPrototype__copyFileSync" });
+ @export(NodeJSFS.exists, .{ .name = "NodeJSFSPrototype__exists" });
+ @export(NodeJSFS.existsSync, .{ .name = "NodeJSFSPrototype__existsSync" });
+ @export(NodeJSFS.fchmod, .{ .name = "NodeJSFSPrototype__fchmod" });
+ @export(NodeJSFS.fchmodSync, .{ .name = "NodeJSFSPrototype__fchmodSync" });
+ @export(NodeJSFS.fchown, .{ .name = "NodeJSFSPrototype__fchown" });
+ @export(NodeJSFS.fchownSync, .{ .name = "NodeJSFSPrototype__fchownSync" });
+ @export(NodeJSFS.fdatasync, .{ .name = "NodeJSFSPrototype__fdatasync" });
+ @export(NodeJSFS.fdatasyncSync, .{ .name = "NodeJSFSPrototype__fdatasyncSync" });
+ @export(NodeJSFS.fstat, .{ .name = "NodeJSFSPrototype__fstat" });
+ @export(NodeJSFS.fstatSync, .{ .name = "NodeJSFSPrototype__fstatSync" });
+ @export(NodeJSFS.fsync, .{ .name = "NodeJSFSPrototype__fsync" });
+ @export(NodeJSFS.fsyncSync, .{ .name = "NodeJSFSPrototype__fsyncSync" });
+ @export(NodeJSFS.ftruncate, .{ .name = "NodeJSFSPrototype__ftruncate" });
+ @export(NodeJSFS.ftruncateSync, .{ .name = "NodeJSFSPrototype__ftruncateSync" });
+ @export(NodeJSFS.futimes, .{ .name = "NodeJSFSPrototype__futimes" });
+ @export(NodeJSFS.futimesSync, .{ .name = "NodeJSFSPrototype__futimesSync" });
+ @export(NodeJSFS.getDirent, .{ .name = "NodeJSFSPrototype__getDirent" });
+ @export(NodeJSFS.getStats, .{ .name = "NodeJSFSPrototype__getStats" });
+ @export(NodeJSFS.lchmod, .{ .name = "NodeJSFSPrototype__lchmod" });
+ @export(NodeJSFS.lchmodSync, .{ .name = "NodeJSFSPrototype__lchmodSync" });
+ @export(NodeJSFS.lchown, .{ .name = "NodeJSFSPrototype__lchown" });
+ @export(NodeJSFS.lchownSync, .{ .name = "NodeJSFSPrototype__lchownSync" });
+ @export(NodeJSFS.link, .{ .name = "NodeJSFSPrototype__link" });
+ @export(NodeJSFS.linkSync, .{ .name = "NodeJSFSPrototype__linkSync" });
+ @export(NodeJSFS.lstat, .{ .name = "NodeJSFSPrototype__lstat" });
+ @export(NodeJSFS.lstatSync, .{ .name = "NodeJSFSPrototype__lstatSync" });
+ @export(NodeJSFS.lutimes, .{ .name = "NodeJSFSPrototype__lutimes" });
+ @export(NodeJSFS.lutimesSync, .{ .name = "NodeJSFSPrototype__lutimesSync" });
+ @export(NodeJSFS.mkdir, .{ .name = "NodeJSFSPrototype__mkdir" });
+ @export(NodeJSFS.mkdirSync, .{ .name = "NodeJSFSPrototype__mkdirSync" });
+ @export(NodeJSFS.mkdtemp, .{ .name = "NodeJSFSPrototype__mkdtemp" });
+ @export(NodeJSFS.mkdtempSync, .{ .name = "NodeJSFSPrototype__mkdtempSync" });
+ @export(NodeJSFS.open, .{ .name = "NodeJSFSPrototype__open" });
+ @export(NodeJSFS.opendir, .{ .name = "NodeJSFSPrototype__opendir" });
+ @export(NodeJSFS.opendirSync, .{ .name = "NodeJSFSPrototype__opendirSync" });
+ @export(NodeJSFS.openSync, .{ .name = "NodeJSFSPrototype__openSync" });
+ @export(NodeJSFS.read, .{ .name = "NodeJSFSPrototype__read" });
+ @export(NodeJSFS.readdir, .{ .name = "NodeJSFSPrototype__readdir" });
+ @export(NodeJSFS.readdirSync, .{ .name = "NodeJSFSPrototype__readdirSync" });
+ @export(NodeJSFS.readFile, .{ .name = "NodeJSFSPrototype__readFile" });
+ @export(NodeJSFS.readFileSync, .{ .name = "NodeJSFSPrototype__readFileSync" });
+ @export(NodeJSFS.readlink, .{ .name = "NodeJSFSPrototype__readlink" });
+ @export(NodeJSFS.readlinkSync, .{ .name = "NodeJSFSPrototype__readlinkSync" });
+ @export(NodeJSFS.readSync, .{ .name = "NodeJSFSPrototype__readSync" });
+ @export(NodeJSFS.readv, .{ .name = "NodeJSFSPrototype__readv" });
+ @export(NodeJSFS.readvSync, .{ .name = "NodeJSFSPrototype__readvSync" });
+ @export(NodeJSFS.realpath, .{ .name = "NodeJSFSPrototype__realpath" });
+ @export(NodeJSFS.realpathSync, .{ .name = "NodeJSFSPrototype__realpathSync" });
+ @export(NodeJSFS.rename, .{ .name = "NodeJSFSPrototype__rename" });
+ @export(NodeJSFS.renameSync, .{ .name = "NodeJSFSPrototype__renameSync" });
+ @export(NodeJSFS.rm, .{ .name = "NodeJSFSPrototype__rm" });
+ @export(NodeJSFS.rmdir, .{ .name = "NodeJSFSPrototype__rmdir" });
+ @export(NodeJSFS.rmdirSync, .{ .name = "NodeJSFSPrototype__rmdirSync" });
+ @export(NodeJSFS.rmSync, .{ .name = "NodeJSFSPrototype__rmSync" });
+ @export(NodeJSFS.stat, .{ .name = "NodeJSFSPrototype__stat" });
+ @export(NodeJSFS.statSync, .{ .name = "NodeJSFSPrototype__statSync" });
+ @export(NodeJSFS.symlink, .{ .name = "NodeJSFSPrototype__symlink" });
+ @export(NodeJSFS.symlinkSync, .{ .name = "NodeJSFSPrototype__symlinkSync" });
+ @export(NodeJSFS.truncate, .{ .name = "NodeJSFSPrototype__truncate" });
+ @export(NodeJSFS.truncateSync, .{ .name = "NodeJSFSPrototype__truncateSync" });
+ @export(NodeJSFS.unlink, .{ .name = "NodeJSFSPrototype__unlink" });
+ @export(NodeJSFS.unlinkSync, .{ .name = "NodeJSFSPrototype__unlinkSync" });
+ @export(NodeJSFS.utimes, .{ .name = "NodeJSFSPrototype__utimes" });
+ @export(NodeJSFS.utimesSync, .{ .name = "NodeJSFSPrototype__utimesSync" });
+ @export(NodeJSFS.write, .{ .name = "NodeJSFSPrototype__write" });
+ @export(NodeJSFS.writeFile, .{ .name = "NodeJSFSPrototype__writeFile" });
+ @export(NodeJSFS.writeFileSync, .{ .name = "NodeJSFSPrototype__writeFileSync" });
+ @export(NodeJSFS.writeSync, .{ .name = "NodeJSFSPrototype__writeSync" });
+ @export(NodeJSFS.writev, .{ .name = "NodeJSFSPrototype__writev" });
+ @export(NodeJSFS.writevSync, .{ .name = "NodeJSFSPrototype__writevSync" });
}
}
};
pub const JSRequest = struct {
const Request = Classes.Request;
- const GetterType = fn(*Request, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Request, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Request, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Request, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Request, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Request, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Request, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Request, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Request, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Request, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -2134,101 +1795,99 @@ pub const JSRequest = struct {
extern fn RequestPrototype__bodySetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn RequestPrototype__bodyGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Request.body` setter
- /// This value will be visited by the garbage collector.
- pub fn bodySetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- RequestPrototype__bodySetCachedValue(thisValue, globalObject, value);
- }
+ extern fn RequestPrototype__bodyGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `Request.body` getter
- /// This value will be visited by the garbage collector.
- pub fn bodyGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = RequestPrototype__bodyGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Request.body` setter
+ /// This value will be visited by the garbage collector.
+ pub fn bodySetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ RequestPrototype__bodySetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Request.body` getter
+ /// This value will be visited by the garbage collector.
+ pub fn bodyGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = RequestPrototype__bodyGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn RequestPrototype__headersSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
+
+ extern fn RequestPrototype__headersSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn RequestPrototype__headersGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Request.headers` setter
- /// This value will be visited by the garbage collector.
- pub fn headersSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- RequestPrototype__headersSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn RequestPrototype__headersGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `Request.headers` getter
- /// This value will be visited by the garbage collector.
- pub fn headersGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = RequestPrototype__headersGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Request.headers` setter
+ /// This value will be visited by the garbage collector.
+ pub fn headersSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ RequestPrototype__headersSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Request.headers` getter
+ /// This value will be visited by the garbage collector.
+ pub fn headersGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = RequestPrototype__headersGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn RequestPrototype__signalSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
+
+ extern fn RequestPrototype__signalSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn RequestPrototype__signalGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Request.signal` setter
- /// This value will be visited by the garbage collector.
- pub fn signalSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- RequestPrototype__signalSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn RequestPrototype__signalGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `Request.signal` getter
- /// This value will be visited by the garbage collector.
- pub fn signalGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = RequestPrototype__signalGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Request.signal` setter
+ /// This value will be visited by the garbage collector.
+ pub fn signalSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ RequestPrototype__signalSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Request.signal` getter
+ /// This value will be visited by the garbage collector.
+ pub fn signalGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = RequestPrototype__signalGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn RequestPrototype__urlSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn RequestPrototype__urlGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Request.url` setter
- /// This value will be visited by the garbage collector.
- pub fn urlSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- RequestPrototype__urlSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn RequestPrototype__urlSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- /// `Request.url` getter
- /// This value will be visited by the garbage collector.
- pub fn urlGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = RequestPrototype__urlGetCachedValue(thisValue);
- if (result == .zero)
+ extern fn RequestPrototype__urlGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Request.url` setter
+ /// This value will be visited by the garbage collector.
+ pub fn urlSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ RequestPrototype__urlSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Request.url` getter
+ /// This value will be visited by the garbage collector.
+ pub fn urlGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = RequestPrototype__urlGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the Request constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return Request__getConstructor(globalObject);
}
-
+
/// Create a new instance of Request
pub fn toJS(this: *Request, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -2243,14 +1902,14 @@ extern fn RequestPrototype__urlSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject,
/// Modify the internal ptr to point to a new instance of Request.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Request) bool {
- JSC.markBinding(@src());
- return Request__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Request__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Request, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Request__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Request__dangerouslySetPtr(value, null));
}
extern fn Request__fromJS(JSC.JSValue) ?*Request;
@@ -2261,147 +1920,106 @@ extern fn RequestPrototype__urlSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject,
extern fn Request__dangerouslySetPtr(JSC.JSValue, ?*Request) bool;
comptime {
-
- if (@TypeOf(Request.estimatedSize) != (fn(*Request) callconv(.C) usize)) {
- @compileLog("Request.estimatedSize is not a size function");
+ if (@TypeOf(Request.estimatedSize) != (fn (*Request) callconv(.C) usize)) {
+ @compileLog("Request.estimatedSize is not a size function");
}
-
- if (@TypeOf(Request.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Request)) {
- @compileLog("Request.constructor is not a constructor");
+
+ if (@TypeOf(Request.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Request)) {
+ @compileLog("Request.constructor is not a constructor");
}
-
- if (@TypeOf(Request.finalize) != (fn(*Request) callconv(.C) void)) {
- @compileLog("Request.finalize is not a finalizer");
+
+ if (@TypeOf(Request.finalize) != (fn (*Request) callconv(.C) void)) {
+ @compileLog("Request.finalize is not a finalizer");
}
-
- if (@TypeOf(Request.getArrayBuffer) != CallbackType)
- @compileLog(
- "Expected Request.getArrayBuffer to be a callback but received " ++ @typeName(@TypeOf(Request.getArrayBuffer))
- );
- if (@TypeOf(Request.getBlob) != CallbackType)
- @compileLog(
- "Expected Request.getBlob to be a callback but received " ++ @typeName(@TypeOf(Request.getBlob))
- );
- if (@TypeOf(Request.getBody) != GetterType)
- @compileLog(
- "Expected Request.getBody to be a getter"
- );
-
- if (@TypeOf(Request.getBodyUsed) != GetterType)
- @compileLog(
- "Expected Request.getBodyUsed to be a getter"
- );
-
- if (@TypeOf(Request.getCache) != GetterType)
- @compileLog(
- "Expected Request.getCache to be a getter"
- );
-
- if (@TypeOf(Request.doClone) != CallbackType)
- @compileLog(
- "Expected Request.doClone to be a callback but received " ++ @typeName(@TypeOf(Request.doClone))
- );
- if (@TypeOf(Request.getCredentials) != GetterType)
- @compileLog(
- "Expected Request.getCredentials to be a getter"
- );
-
- if (@TypeOf(Request.getDestination) != GetterType)
- @compileLog(
- "Expected Request.getDestination to be a getter"
- );
-
- if (@TypeOf(Request.getFormData) != CallbackType)
- @compileLog(
- "Expected Request.getFormData to be a callback but received " ++ @typeName(@TypeOf(Request.getFormData))
- );
- if (@TypeOf(Request.getHeaders) != GetterType)
- @compileLog(
- "Expected Request.getHeaders to be a getter"
- );
-
- if (@TypeOf(Request.getIntegrity) != GetterType)
- @compileLog(
- "Expected Request.getIntegrity to be a getter"
- );
-
- if (@TypeOf(Request.getJSON) != CallbackType)
- @compileLog(
- "Expected Request.getJSON to be a callback but received " ++ @typeName(@TypeOf(Request.getJSON))
- );
- if (@TypeOf(Request.getMethod) != GetterType)
- @compileLog(
- "Expected Request.getMethod to be a getter"
- );
-
- if (@TypeOf(Request.getMode) != GetterType)
- @compileLog(
- "Expected Request.getMode to be a getter"
- );
-
- if (@TypeOf(Request.getRedirect) != GetterType)
- @compileLog(
- "Expected Request.getRedirect to be a getter"
- );
-
- if (@TypeOf(Request.getReferrer) != GetterType)
- @compileLog(
- "Expected Request.getReferrer to be a getter"
- );
-
- if (@TypeOf(Request.getReferrerPolicy) != GetterType)
- @compileLog(
- "Expected Request.getReferrerPolicy to be a getter"
- );
-
- if (@TypeOf(Request.getSignal) != GetterType)
- @compileLog(
- "Expected Request.getSignal to be a getter"
- );
-
- if (@TypeOf(Request.getText) != CallbackType)
- @compileLog(
- "Expected Request.getText to be a callback but received " ++ @typeName(@TypeOf(Request.getText))
- );
- if (@TypeOf(Request.getUrl) != GetterType)
- @compileLog(
- "Expected Request.getUrl to be a getter"
- );
+
+ if (@TypeOf(Request.getArrayBuffer) != CallbackType)
+ @compileLog("Expected Request.getArrayBuffer to be a callback but received " ++ @typeName(@TypeOf(Request.getArrayBuffer)));
+ if (@TypeOf(Request.getBlob) != CallbackType)
+ @compileLog("Expected Request.getBlob to be a callback but received " ++ @typeName(@TypeOf(Request.getBlob)));
+ if (@TypeOf(Request.getBody) != GetterType)
+ @compileLog("Expected Request.getBody to be a getter");
+
+ if (@TypeOf(Request.getBodyUsed) != GetterType)
+ @compileLog("Expected Request.getBodyUsed to be a getter");
+
+ if (@TypeOf(Request.getCache) != GetterType)
+ @compileLog("Expected Request.getCache to be a getter");
+
+ if (@TypeOf(Request.doClone) != CallbackType)
+ @compileLog("Expected Request.doClone to be a callback but received " ++ @typeName(@TypeOf(Request.doClone)));
+ if (@TypeOf(Request.getCredentials) != GetterType)
+ @compileLog("Expected Request.getCredentials to be a getter");
+
+ if (@TypeOf(Request.getDestination) != GetterType)
+ @compileLog("Expected Request.getDestination to be a getter");
+
+ if (@TypeOf(Request.getFormData) != CallbackType)
+ @compileLog("Expected Request.getFormData to be a callback but received " ++ @typeName(@TypeOf(Request.getFormData)));
+ if (@TypeOf(Request.getHeaders) != GetterType)
+ @compileLog("Expected Request.getHeaders to be a getter");
+
+ if (@TypeOf(Request.getIntegrity) != GetterType)
+ @compileLog("Expected Request.getIntegrity to be a getter");
+
+ if (@TypeOf(Request.getJSON) != CallbackType)
+ @compileLog("Expected Request.getJSON to be a callback but received " ++ @typeName(@TypeOf(Request.getJSON)));
+ if (@TypeOf(Request.getMethod) != GetterType)
+ @compileLog("Expected Request.getMethod to be a getter");
+
+ if (@TypeOf(Request.getMode) != GetterType)
+ @compileLog("Expected Request.getMode to be a getter");
+
+ if (@TypeOf(Request.getRedirect) != GetterType)
+ @compileLog("Expected Request.getRedirect to be a getter");
+
+ if (@TypeOf(Request.getReferrer) != GetterType)
+ @compileLog("Expected Request.getReferrer to be a getter");
+
+ if (@TypeOf(Request.getReferrerPolicy) != GetterType)
+ @compileLog("Expected Request.getReferrerPolicy to be a getter");
+
+ if (@TypeOf(Request.getSignal) != GetterType)
+ @compileLog("Expected Request.getSignal to be a getter");
+
+ if (@TypeOf(Request.getText) != CallbackType)
+ @compileLog("Expected Request.getText to be a callback but received " ++ @typeName(@TypeOf(Request.getText)));
+ if (@TypeOf(Request.getUrl) != GetterType)
+ @compileLog("Expected Request.getUrl to be a getter");
if (!JSC.is_bindgen) {
-@export(Request.constructor, .{.name = "RequestClass__construct"});
- @export(Request.doClone, .{.name = "RequestPrototype__doClone"});
- @export(Request.estimatedSize, .{.name = "Request__estimatedSize"});
- @export(Request.finalize, .{.name = "RequestClass__finalize"});
- @export(Request.getArrayBuffer, .{.name = "RequestPrototype__getArrayBuffer"});
- @export(Request.getBlob, .{.name = "RequestPrototype__getBlob"});
- @export(Request.getBody, .{.name = "RequestPrototype__getBody"});
- @export(Request.getBodyUsed, .{.name = "RequestPrototype__getBodyUsed"});
- @export(Request.getCache, .{.name = "RequestPrototype__getCache"});
- @export(Request.getCredentials, .{.name = "RequestPrototype__getCredentials"});
- @export(Request.getDestination, .{.name = "RequestPrototype__getDestination"});
- @export(Request.getFormData, .{.name = "RequestPrototype__getFormData"});
- @export(Request.getHeaders, .{.name = "RequestPrototype__getHeaders"});
- @export(Request.getIntegrity, .{.name = "RequestPrototype__getIntegrity"});
- @export(Request.getJSON, .{.name = "RequestPrototype__getJSON"});
- @export(Request.getMethod, .{.name = "RequestPrototype__getMethod"});
- @export(Request.getMode, .{.name = "RequestPrototype__getMode"});
- @export(Request.getRedirect, .{.name = "RequestPrototype__getRedirect"});
- @export(Request.getReferrer, .{.name = "RequestPrototype__getReferrer"});
- @export(Request.getReferrerPolicy, .{.name = "RequestPrototype__getReferrerPolicy"});
- @export(Request.getSignal, .{.name = "RequestPrototype__getSignal"});
- @export(Request.getText, .{.name = "RequestPrototype__getText"});
- @export(Request.getUrl, .{.name = "RequestPrototype__getUrl"});
+ @export(Request.constructor, .{ .name = "RequestClass__construct" });
+ @export(Request.doClone, .{ .name = "RequestPrototype__doClone" });
+ @export(Request.estimatedSize, .{ .name = "Request__estimatedSize" });
+ @export(Request.finalize, .{ .name = "RequestClass__finalize" });
+ @export(Request.getArrayBuffer, .{ .name = "RequestPrototype__getArrayBuffer" });
+ @export(Request.getBlob, .{ .name = "RequestPrototype__getBlob" });
+ @export(Request.getBody, .{ .name = "RequestPrototype__getBody" });
+ @export(Request.getBodyUsed, .{ .name = "RequestPrototype__getBodyUsed" });
+ @export(Request.getCache, .{ .name = "RequestPrototype__getCache" });
+ @export(Request.getCredentials, .{ .name = "RequestPrototype__getCredentials" });
+ @export(Request.getDestination, .{ .name = "RequestPrototype__getDestination" });
+ @export(Request.getFormData, .{ .name = "RequestPrototype__getFormData" });
+ @export(Request.getHeaders, .{ .name = "RequestPrototype__getHeaders" });
+ @export(Request.getIntegrity, .{ .name = "RequestPrototype__getIntegrity" });
+ @export(Request.getJSON, .{ .name = "RequestPrototype__getJSON" });
+ @export(Request.getMethod, .{ .name = "RequestPrototype__getMethod" });
+ @export(Request.getMode, .{ .name = "RequestPrototype__getMode" });
+ @export(Request.getRedirect, .{ .name = "RequestPrototype__getRedirect" });
+ @export(Request.getReferrer, .{ .name = "RequestPrototype__getReferrer" });
+ @export(Request.getReferrerPolicy, .{ .name = "RequestPrototype__getReferrerPolicy" });
+ @export(Request.getSignal, .{ .name = "RequestPrototype__getSignal" });
+ @export(Request.getText, .{ .name = "RequestPrototype__getText" });
+ @export(Request.getUrl, .{ .name = "RequestPrototype__getUrl" });
}
}
};
pub const JSResponse = struct {
const Response = Classes.Response;
- const GetterType = fn(*Response, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Response, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Response, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Response, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Response, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Response, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Response, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Response, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Response, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Response, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -2412,101 +2030,99 @@ pub const JSResponse = struct {
extern fn ResponsePrototype__bodySetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn ResponsePrototype__bodyGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Response.body` setter
- /// This value will be visited by the garbage collector.
- pub fn bodySetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ResponsePrototype__bodySetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ResponsePrototype__bodyGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `Response.body` getter
- /// This value will be visited by the garbage collector.
- pub fn bodyGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ResponsePrototype__bodyGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Response.body` setter
+ /// This value will be visited by the garbage collector.
+ pub fn bodySetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResponsePrototype__bodySetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Response.body` getter
+ /// This value will be visited by the garbage collector.
+ pub fn bodyGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResponsePrototype__bodyGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn ResponsePrototype__headersSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn ResponsePrototype__headersGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Response.headers` setter
- /// This value will be visited by the garbage collector.
- pub fn headersSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ResponsePrototype__headersSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ResponsePrototype__headersSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- /// `Response.headers` getter
- /// This value will be visited by the garbage collector.
- pub fn headersGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ResponsePrototype__headersGetCachedValue(thisValue);
- if (result == .zero)
+ extern fn ResponsePrototype__headersGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Response.headers` setter
+ /// This value will be visited by the garbage collector.
+ pub fn headersSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResponsePrototype__headersSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Response.headers` getter
+ /// This value will be visited by the garbage collector.
+ pub fn headersGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResponsePrototype__headersGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn ResponsePrototype__statusTextSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn ResponsePrototype__statusTextGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Response.statusText` setter
- /// This value will be visited by the garbage collector.
- pub fn statusTextSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ResponsePrototype__statusTextSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ResponsePrototype__statusTextSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ResponsePrototype__statusTextGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Response.statusText` setter
+ /// This value will be visited by the garbage collector.
+ pub fn statusTextSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResponsePrototype__statusTextSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Response.statusText` getter
- /// This value will be visited by the garbage collector.
- pub fn statusTextGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ResponsePrototype__statusTextGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Response.statusText` getter
+ /// This value will be visited by the garbage collector.
+ pub fn statusTextGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResponsePrototype__statusTextGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn ResponsePrototype__urlSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn ResponsePrototype__urlGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Response.url` setter
- /// This value will be visited by the garbage collector.
- pub fn urlSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ResponsePrototype__urlSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ResponsePrototype__urlSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn ResponsePrototype__urlGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Response.url` setter
+ /// This value will be visited by the garbage collector.
+ pub fn urlSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ResponsePrototype__urlSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Response.url` getter
- /// This value will be visited by the garbage collector.
- pub fn urlGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ResponsePrototype__urlGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Response.url` getter
+ /// This value will be visited by the garbage collector.
+ pub fn urlGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ResponsePrototype__urlGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the Response constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return Response__getConstructor(globalObject);
}
-
+
/// Create a new instance of Response
pub fn toJS(this: *Response, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -2521,14 +2137,14 @@ extern fn ResponsePrototype__urlSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject,
/// Modify the internal ptr to point to a new instance of Response.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Response) bool {
- JSC.markBinding(@src());
- return Response__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Response__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Response, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Response__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Response__dangerouslySetPtr(value, null));
}
extern fn Response__fromJS(JSC.JSValue) ?*Response;
@@ -2539,132 +2155,95 @@ extern fn ResponsePrototype__urlSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject,
extern fn Response__dangerouslySetPtr(JSC.JSValue, ?*Response) bool;
comptime {
-
- if (@TypeOf(Response.estimatedSize) != (fn(*Response) callconv(.C) usize)) {
- @compileLog("Response.estimatedSize is not a size function");
+ if (@TypeOf(Response.estimatedSize) != (fn (*Response) callconv(.C) usize)) {
+ @compileLog("Response.estimatedSize is not a size function");
}
-
- if (@TypeOf(Response.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Response)) {
- @compileLog("Response.constructor is not a constructor");
+
+ if (@TypeOf(Response.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Response)) {
+ @compileLog("Response.constructor is not a constructor");
}
-
- if (@TypeOf(Response.finalize) != (fn(*Response) callconv(.C) void)) {
- @compileLog("Response.finalize is not a finalizer");
+
+ if (@TypeOf(Response.finalize) != (fn (*Response) callconv(.C) void)) {
+ @compileLog("Response.finalize is not a finalizer");
}
-
- if (@TypeOf(Response.getArrayBuffer) != CallbackType)
- @compileLog(
- "Expected Response.getArrayBuffer to be a callback but received " ++ @typeName(@TypeOf(Response.getArrayBuffer))
- );
- if (@TypeOf(Response.getBlob) != CallbackType)
- @compileLog(
- "Expected Response.getBlob to be a callback but received " ++ @typeName(@TypeOf(Response.getBlob))
- );
- if (@TypeOf(Response.getBody) != GetterType)
- @compileLog(
- "Expected Response.getBody to be a getter"
- );
-
- if (@TypeOf(Response.getBodyUsed) != GetterType)
- @compileLog(
- "Expected Response.getBodyUsed to be a getter"
- );
-
- if (@TypeOf(Response.doClone) != CallbackType)
- @compileLog(
- "Expected Response.doClone to be a callback but received " ++ @typeName(@TypeOf(Response.doClone))
- );
- if (@TypeOf(Response.getFormData) != CallbackType)
- @compileLog(
- "Expected Response.getFormData to be a callback but received " ++ @typeName(@TypeOf(Response.getFormData))
- );
- if (@TypeOf(Response.getHeaders) != GetterType)
- @compileLog(
- "Expected Response.getHeaders to be a getter"
- );
-
- if (@TypeOf(Response.getJSON) != CallbackType)
- @compileLog(
- "Expected Response.getJSON to be a callback but received " ++ @typeName(@TypeOf(Response.getJSON))
- );
- if (@TypeOf(Response.getOK) != GetterType)
- @compileLog(
- "Expected Response.getOK to be a getter"
- );
-
- if (@TypeOf(Response.getRedirected) != GetterType)
- @compileLog(
- "Expected Response.getRedirected to be a getter"
- );
-
- if (@TypeOf(Response.getStatus) != GetterType)
- @compileLog(
- "Expected Response.getStatus to be a getter"
- );
-
- if (@TypeOf(Response.getStatusText) != GetterType)
- @compileLog(
- "Expected Response.getStatusText to be a getter"
- );
-
- if (@TypeOf(Response.getText) != CallbackType)
- @compileLog(
- "Expected Response.getText to be a callback but received " ++ @typeName(@TypeOf(Response.getText))
- );
- if (@TypeOf(Response.getResponseType) != GetterType)
- @compileLog(
- "Expected Response.getResponseType to be a getter"
- );
-
- if (@TypeOf(Response.getURL) != GetterType)
- @compileLog(
- "Expected Response.getURL to be a getter"
- );
-
- if (@TypeOf(Response.constructError) != StaticCallbackType)
- @compileLog(
- "Expected Response.constructError to be a static callback"
- );
- if (@TypeOf(Response.constructJSON) != StaticCallbackType)
- @compileLog(
- "Expected Response.constructJSON to be a static callback"
- );
- if (@TypeOf(Response.constructRedirect) != StaticCallbackType)
- @compileLog(
- "Expected Response.constructRedirect to be a static callback"
- );
+
+ if (@TypeOf(Response.getArrayBuffer) != CallbackType)
+ @compileLog("Expected Response.getArrayBuffer to be a callback but received " ++ @typeName(@TypeOf(Response.getArrayBuffer)));
+ if (@TypeOf(Response.getBlob) != CallbackType)
+ @compileLog("Expected Response.getBlob to be a callback but received " ++ @typeName(@TypeOf(Response.getBlob)));
+ if (@TypeOf(Response.getBody) != GetterType)
+ @compileLog("Expected Response.getBody to be a getter");
+
+ if (@TypeOf(Response.getBodyUsed) != GetterType)
+ @compileLog("Expected Response.getBodyUsed to be a getter");
+
+ if (@TypeOf(Response.doClone) != CallbackType)
+ @compileLog("Expected Response.doClone to be a callback but received " ++ @typeName(@TypeOf(Response.doClone)));
+ if (@TypeOf(Response.getFormData) != CallbackType)
+ @compileLog("Expected Response.getFormData to be a callback but received " ++ @typeName(@TypeOf(Response.getFormData)));
+ if (@TypeOf(Response.getHeaders) != GetterType)
+ @compileLog("Expected Response.getHeaders to be a getter");
+
+ if (@TypeOf(Response.getJSON) != CallbackType)
+ @compileLog("Expected Response.getJSON to be a callback but received " ++ @typeName(@TypeOf(Response.getJSON)));
+ if (@TypeOf(Response.getOK) != GetterType)
+ @compileLog("Expected Response.getOK to be a getter");
+
+ if (@TypeOf(Response.getRedirected) != GetterType)
+ @compileLog("Expected Response.getRedirected to be a getter");
+
+ if (@TypeOf(Response.getStatus) != GetterType)
+ @compileLog("Expected Response.getStatus to be a getter");
+
+ if (@TypeOf(Response.getStatusText) != GetterType)
+ @compileLog("Expected Response.getStatusText to be a getter");
+
+ if (@TypeOf(Response.getText) != CallbackType)
+ @compileLog("Expected Response.getText to be a callback but received " ++ @typeName(@TypeOf(Response.getText)));
+ if (@TypeOf(Response.getResponseType) != GetterType)
+ @compileLog("Expected Response.getResponseType to be a getter");
+
+ if (@TypeOf(Response.getURL) != GetterType)
+ @compileLog("Expected Response.getURL to be a getter");
+
+ if (@TypeOf(Response.constructError) != StaticCallbackType)
+ @compileLog("Expected Response.constructError to be a static callback");
+ if (@TypeOf(Response.constructJSON) != StaticCallbackType)
+ @compileLog("Expected Response.constructJSON to be a static callback");
+ if (@TypeOf(Response.constructRedirect) != StaticCallbackType)
+ @compileLog("Expected Response.constructRedirect to be a static callback");
if (!JSC.is_bindgen) {
-@export(Response.constructError, .{.name = "ResponseClass__constructError"});
- @export(Response.constructJSON, .{.name = "ResponseClass__constructJSON"});
- @export(Response.constructor, .{.name = "ResponseClass__construct"});
- @export(Response.constructRedirect, .{.name = "ResponseClass__constructRedirect"});
- @export(Response.doClone, .{.name = "ResponsePrototype__doClone"});
- @export(Response.estimatedSize, .{.name = "Response__estimatedSize"});
- @export(Response.finalize, .{.name = "ResponseClass__finalize"});
- @export(Response.getArrayBuffer, .{.name = "ResponsePrototype__getArrayBuffer"});
- @export(Response.getBlob, .{.name = "ResponsePrototype__getBlob"});
- @export(Response.getBody, .{.name = "ResponsePrototype__getBody"});
- @export(Response.getBodyUsed, .{.name = "ResponsePrototype__getBodyUsed"});
- @export(Response.getFormData, .{.name = "ResponsePrototype__getFormData"});
- @export(Response.getHeaders, .{.name = "ResponsePrototype__getHeaders"});
- @export(Response.getJSON, .{.name = "ResponsePrototype__getJSON"});
- @export(Response.getOK, .{.name = "ResponsePrototype__getOK"});
- @export(Response.getRedirected, .{.name = "ResponsePrototype__getRedirected"});
- @export(Response.getResponseType, .{.name = "ResponsePrototype__getResponseType"});
- @export(Response.getStatus, .{.name = "ResponsePrototype__getStatus"});
- @export(Response.getStatusText, .{.name = "ResponsePrototype__getStatusText"});
- @export(Response.getText, .{.name = "ResponsePrototype__getText"});
- @export(Response.getURL, .{.name = "ResponsePrototype__getURL"});
+ @export(Response.constructError, .{ .name = "ResponseClass__constructError" });
+ @export(Response.constructJSON, .{ .name = "ResponseClass__constructJSON" });
+ @export(Response.constructor, .{ .name = "ResponseClass__construct" });
+ @export(Response.constructRedirect, .{ .name = "ResponseClass__constructRedirect" });
+ @export(Response.doClone, .{ .name = "ResponsePrototype__doClone" });
+ @export(Response.estimatedSize, .{ .name = "Response__estimatedSize" });
+ @export(Response.finalize, .{ .name = "ResponseClass__finalize" });
+ @export(Response.getArrayBuffer, .{ .name = "ResponsePrototype__getArrayBuffer" });
+ @export(Response.getBlob, .{ .name = "ResponsePrototype__getBlob" });
+ @export(Response.getBody, .{ .name = "ResponsePrototype__getBody" });
+ @export(Response.getBodyUsed, .{ .name = "ResponsePrototype__getBodyUsed" });
+ @export(Response.getFormData, .{ .name = "ResponsePrototype__getFormData" });
+ @export(Response.getHeaders, .{ .name = "ResponsePrototype__getHeaders" });
+ @export(Response.getJSON, .{ .name = "ResponsePrototype__getJSON" });
+ @export(Response.getOK, .{ .name = "ResponsePrototype__getOK" });
+ @export(Response.getRedirected, .{ .name = "ResponsePrototype__getRedirected" });
+ @export(Response.getResponseType, .{ .name = "ResponsePrototype__getResponseType" });
+ @export(Response.getStatus, .{ .name = "ResponsePrototype__getStatus" });
+ @export(Response.getStatusText, .{ .name = "ResponsePrototype__getStatusText" });
+ @export(Response.getText, .{ .name = "ResponsePrototype__getText" });
+ @export(Response.getURL, .{ .name = "ResponsePrototype__getURL" });
}
}
};
pub const JSSHA1 = struct {
const SHA1 = Classes.SHA1;
- const GetterType = fn(*SHA1, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*SHA1, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*SHA1, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*SHA1, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*SHA1, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*SHA1, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*SHA1, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*SHA1, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*SHA1, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*SHA1, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -2673,16 +2252,13 @@ pub const JSSHA1 = struct {
return SHA1__fromJS(value);
}
-
-
-
/// Get the SHA1 constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return SHA1__getConstructor(globalObject);
}
-
+
/// Create a new instance of SHA1
pub fn toJS(this: *SHA1, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -2697,14 +2273,14 @@ pub const JSSHA1 = struct {
/// Modify the internal ptr to point to a new instance of SHA1.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*SHA1) bool {
- JSC.markBinding(@src());
- return SHA1__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return SHA1__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *SHA1, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(SHA1__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(SHA1__dangerouslySetPtr(value, null));
}
extern fn SHA1__fromJS(JSC.JSValue) ?*SHA1;
@@ -2715,55 +2291,44 @@ pub const JSSHA1 = struct {
extern fn SHA1__dangerouslySetPtr(JSC.JSValue, ?*SHA1) bool;
comptime {
-
- if (@TypeOf(SHA1.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA1)) {
- @compileLog("SHA1.constructor is not a constructor");
+ if (@TypeOf(SHA1.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA1)) {
+ @compileLog("SHA1.constructor is not a constructor");
}
-
- if (@TypeOf(SHA1.finalize) != (fn(*SHA1) callconv(.C) void)) {
- @compileLog("SHA1.finalize is not a finalizer");
+
+ if (@TypeOf(SHA1.finalize) != (fn (*SHA1) callconv(.C) void)) {
+ @compileLog("SHA1.finalize is not a finalizer");
}
-
- if (@TypeOf(SHA1.getByteLength) != GetterType)
- @compileLog(
- "Expected SHA1.getByteLength to be a getter"
- );
-
- if (@TypeOf(SHA1.digest) != CallbackType)
- @compileLog(
- "Expected SHA1.digest to be a callback but received " ++ @typeName(@TypeOf(SHA1.digest))
- );
- if (@TypeOf(SHA1.update) != CallbackType)
- @compileLog(
- "Expected SHA1.update to be a callback but received " ++ @typeName(@TypeOf(SHA1.update))
- );
- if (@TypeOf(SHA1.getByteLengthStatic) != StaticGetterType)
- @compileLog(
- "Expected SHA1.getByteLengthStatic to be a static getter"
- );
-
- if (@TypeOf(SHA1.hash) != StaticCallbackType)
- @compileLog(
- "Expected SHA1.hash to be a static callback"
- );
+
+ if (@TypeOf(SHA1.getByteLength) != GetterType)
+ @compileLog("Expected SHA1.getByteLength to be a getter");
+
+ if (@TypeOf(SHA1.digest) != CallbackType)
+ @compileLog("Expected SHA1.digest to be a callback but received " ++ @typeName(@TypeOf(SHA1.digest)));
+ if (@TypeOf(SHA1.update) != CallbackType)
+ @compileLog("Expected SHA1.update to be a callback but received " ++ @typeName(@TypeOf(SHA1.update)));
+ if (@TypeOf(SHA1.getByteLengthStatic) != StaticGetterType)
+ @compileLog("Expected SHA1.getByteLengthStatic to be a static getter");
+
+ if (@TypeOf(SHA1.hash) != StaticCallbackType)
+ @compileLog("Expected SHA1.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(SHA1.constructor, .{.name = "SHA1Class__construct"});
- @export(SHA1.digest, .{.name = "SHA1Prototype__digest"});
- @export(SHA1.finalize, .{.name = "SHA1Class__finalize"});
- @export(SHA1.getByteLength, .{.name = "SHA1Prototype__getByteLength"});
- @export(SHA1.getByteLengthStatic, .{.name = "SHA1Class__getByteLengthStatic"});
- @export(SHA1.hash, .{.name = "SHA1Class__hash"});
- @export(SHA1.update, .{.name = "SHA1Prototype__update"});
+ @export(SHA1.constructor, .{ .name = "SHA1Class__construct" });
+ @export(SHA1.digest, .{ .name = "SHA1Prototype__digest" });
+ @export(SHA1.finalize, .{ .name = "SHA1Class__finalize" });
+ @export(SHA1.getByteLength, .{ .name = "SHA1Prototype__getByteLength" });
+ @export(SHA1.getByteLengthStatic, .{ .name = "SHA1Class__getByteLengthStatic" });
+ @export(SHA1.hash, .{ .name = "SHA1Class__hash" });
+ @export(SHA1.update, .{ .name = "SHA1Prototype__update" });
}
}
};
pub const JSSHA224 = struct {
const SHA224 = Classes.SHA224;
- const GetterType = fn(*SHA224, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*SHA224, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*SHA224, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*SHA224, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*SHA224, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*SHA224, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*SHA224, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*SHA224, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*SHA224, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*SHA224, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -2772,16 +2337,13 @@ pub const JSSHA224 = struct {
return SHA224__fromJS(value);
}
-
-
-
/// Get the SHA224 constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return SHA224__getConstructor(globalObject);
}
-
+
/// Create a new instance of SHA224
pub fn toJS(this: *SHA224, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -2796,14 +2358,14 @@ pub const JSSHA224 = struct {
/// Modify the internal ptr to point to a new instance of SHA224.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*SHA224) bool {
- JSC.markBinding(@src());
- return SHA224__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return SHA224__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *SHA224, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(SHA224__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(SHA224__dangerouslySetPtr(value, null));
}
extern fn SHA224__fromJS(JSC.JSValue) ?*SHA224;
@@ -2814,55 +2376,44 @@ pub const JSSHA224 = struct {
extern fn SHA224__dangerouslySetPtr(JSC.JSValue, ?*SHA224) bool;
comptime {
-
- if (@TypeOf(SHA224.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA224)) {
- @compileLog("SHA224.constructor is not a constructor");
+ if (@TypeOf(SHA224.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA224)) {
+ @compileLog("SHA224.constructor is not a constructor");
}
-
- if (@TypeOf(SHA224.finalize) != (fn(*SHA224) callconv(.C) void)) {
- @compileLog("SHA224.finalize is not a finalizer");
+
+ if (@TypeOf(SHA224.finalize) != (fn (*SHA224) callconv(.C) void)) {
+ @compileLog("SHA224.finalize is not a finalizer");
}
-
- if (@TypeOf(SHA224.getByteLength) != GetterType)
- @compileLog(
- "Expected SHA224.getByteLength to be a getter"
- );
-
- if (@TypeOf(SHA224.digest) != CallbackType)
- @compileLog(
- "Expected SHA224.digest to be a callback but received " ++ @typeName(@TypeOf(SHA224.digest))
- );
- if (@TypeOf(SHA224.update) != CallbackType)
- @compileLog(
- "Expected SHA224.update to be a callback but received " ++ @typeName(@TypeOf(SHA224.update))
- );
- if (@TypeOf(SHA224.getByteLengthStatic) != StaticGetterType)
- @compileLog(
- "Expected SHA224.getByteLengthStatic to be a static getter"
- );
-
- if (@TypeOf(SHA224.hash) != StaticCallbackType)
- @compileLog(
- "Expected SHA224.hash to be a static callback"
- );
+
+ if (@TypeOf(SHA224.getByteLength) != GetterType)
+ @compileLog("Expected SHA224.getByteLength to be a getter");
+
+ if (@TypeOf(SHA224.digest) != CallbackType)
+ @compileLog("Expected SHA224.digest to be a callback but received " ++ @typeName(@TypeOf(SHA224.digest)));
+ if (@TypeOf(SHA224.update) != CallbackType)
+ @compileLog("Expected SHA224.update to be a callback but received " ++ @typeName(@TypeOf(SHA224.update)));
+ if (@TypeOf(SHA224.getByteLengthStatic) != StaticGetterType)
+ @compileLog("Expected SHA224.getByteLengthStatic to be a static getter");
+
+ if (@TypeOf(SHA224.hash) != StaticCallbackType)
+ @compileLog("Expected SHA224.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(SHA224.constructor, .{.name = "SHA224Class__construct"});
- @export(SHA224.digest, .{.name = "SHA224Prototype__digest"});
- @export(SHA224.finalize, .{.name = "SHA224Class__finalize"});
- @export(SHA224.getByteLength, .{.name = "SHA224Prototype__getByteLength"});
- @export(SHA224.getByteLengthStatic, .{.name = "SHA224Class__getByteLengthStatic"});
- @export(SHA224.hash, .{.name = "SHA224Class__hash"});
- @export(SHA224.update, .{.name = "SHA224Prototype__update"});
+ @export(SHA224.constructor, .{ .name = "SHA224Class__construct" });
+ @export(SHA224.digest, .{ .name = "SHA224Prototype__digest" });
+ @export(SHA224.finalize, .{ .name = "SHA224Class__finalize" });
+ @export(SHA224.getByteLength, .{ .name = "SHA224Prototype__getByteLength" });
+ @export(SHA224.getByteLengthStatic, .{ .name = "SHA224Class__getByteLengthStatic" });
+ @export(SHA224.hash, .{ .name = "SHA224Class__hash" });
+ @export(SHA224.update, .{ .name = "SHA224Prototype__update" });
}
}
};
pub const JSSHA256 = struct {
const SHA256 = Classes.SHA256;
- const GetterType = fn(*SHA256, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*SHA256, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*SHA256, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*SHA256, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*SHA256, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*SHA256, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*SHA256, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*SHA256, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*SHA256, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*SHA256, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -2871,16 +2422,13 @@ pub const JSSHA256 = struct {
return SHA256__fromJS(value);
}
-
-
-
/// Get the SHA256 constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return SHA256__getConstructor(globalObject);
}
-
+
/// Create a new instance of SHA256
pub fn toJS(this: *SHA256, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -2895,14 +2443,14 @@ pub const JSSHA256 = struct {
/// Modify the internal ptr to point to a new instance of SHA256.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*SHA256) bool {
- JSC.markBinding(@src());
- return SHA256__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return SHA256__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *SHA256, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(SHA256__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(SHA256__dangerouslySetPtr(value, null));
}
extern fn SHA256__fromJS(JSC.JSValue) ?*SHA256;
@@ -2913,55 +2461,44 @@ pub const JSSHA256 = struct {
extern fn SHA256__dangerouslySetPtr(JSC.JSValue, ?*SHA256) bool;
comptime {
-
- if (@TypeOf(SHA256.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA256)) {
- @compileLog("SHA256.constructor is not a constructor");
+ if (@TypeOf(SHA256.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA256)) {
+ @compileLog("SHA256.constructor is not a constructor");
}
-
- if (@TypeOf(SHA256.finalize) != (fn(*SHA256) callconv(.C) void)) {
- @compileLog("SHA256.finalize is not a finalizer");
+
+ if (@TypeOf(SHA256.finalize) != (fn (*SHA256) callconv(.C) void)) {
+ @compileLog("SHA256.finalize is not a finalizer");
}
-
- if (@TypeOf(SHA256.getByteLength) != GetterType)
- @compileLog(
- "Expected SHA256.getByteLength to be a getter"
- );
-
- if (@TypeOf(SHA256.digest) != CallbackType)
- @compileLog(
- "Expected SHA256.digest to be a callback but received " ++ @typeName(@TypeOf(SHA256.digest))
- );
- if (@TypeOf(SHA256.update) != CallbackType)
- @compileLog(
- "Expected SHA256.update to be a callback but received " ++ @typeName(@TypeOf(SHA256.update))
- );
- if (@TypeOf(SHA256.getByteLengthStatic) != StaticGetterType)
- @compileLog(
- "Expected SHA256.getByteLengthStatic to be a static getter"
- );
-
- if (@TypeOf(SHA256.hash) != StaticCallbackType)
- @compileLog(
- "Expected SHA256.hash to be a static callback"
- );
+
+ if (@TypeOf(SHA256.getByteLength) != GetterType)
+ @compileLog("Expected SHA256.getByteLength to be a getter");
+
+ if (@TypeOf(SHA256.digest) != CallbackType)
+ @compileLog("Expected SHA256.digest to be a callback but received " ++ @typeName(@TypeOf(SHA256.digest)));
+ if (@TypeOf(SHA256.update) != CallbackType)
+ @compileLog("Expected SHA256.update to be a callback but received " ++ @typeName(@TypeOf(SHA256.update)));
+ if (@TypeOf(SHA256.getByteLengthStatic) != StaticGetterType)
+ @compileLog("Expected SHA256.getByteLengthStatic to be a static getter");
+
+ if (@TypeOf(SHA256.hash) != StaticCallbackType)
+ @compileLog("Expected SHA256.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(SHA256.constructor, .{.name = "SHA256Class__construct"});
- @export(SHA256.digest, .{.name = "SHA256Prototype__digest"});
- @export(SHA256.finalize, .{.name = "SHA256Class__finalize"});
- @export(SHA256.getByteLength, .{.name = "SHA256Prototype__getByteLength"});
- @export(SHA256.getByteLengthStatic, .{.name = "SHA256Class__getByteLengthStatic"});
- @export(SHA256.hash, .{.name = "SHA256Class__hash"});
- @export(SHA256.update, .{.name = "SHA256Prototype__update"});
+ @export(SHA256.constructor, .{ .name = "SHA256Class__construct" });
+ @export(SHA256.digest, .{ .name = "SHA256Prototype__digest" });
+ @export(SHA256.finalize, .{ .name = "SHA256Class__finalize" });
+ @export(SHA256.getByteLength, .{ .name = "SHA256Prototype__getByteLength" });
+ @export(SHA256.getByteLengthStatic, .{ .name = "SHA256Class__getByteLengthStatic" });
+ @export(SHA256.hash, .{ .name = "SHA256Class__hash" });
+ @export(SHA256.update, .{ .name = "SHA256Prototype__update" });
}
}
};
pub const JSSHA384 = struct {
const SHA384 = Classes.SHA384;
- const GetterType = fn(*SHA384, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*SHA384, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*SHA384, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*SHA384, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*SHA384, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*SHA384, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*SHA384, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*SHA384, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*SHA384, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*SHA384, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -2970,16 +2507,13 @@ pub const JSSHA384 = struct {
return SHA384__fromJS(value);
}
-
-
-
/// Get the SHA384 constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return SHA384__getConstructor(globalObject);
}
-
+
/// Create a new instance of SHA384
pub fn toJS(this: *SHA384, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -2994,14 +2528,14 @@ pub const JSSHA384 = struct {
/// Modify the internal ptr to point to a new instance of SHA384.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*SHA384) bool {
- JSC.markBinding(@src());
- return SHA384__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return SHA384__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *SHA384, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(SHA384__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(SHA384__dangerouslySetPtr(value, null));
}
extern fn SHA384__fromJS(JSC.JSValue) ?*SHA384;
@@ -3012,55 +2546,44 @@ pub const JSSHA384 = struct {
extern fn SHA384__dangerouslySetPtr(JSC.JSValue, ?*SHA384) bool;
comptime {
-
- if (@TypeOf(SHA384.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA384)) {
- @compileLog("SHA384.constructor is not a constructor");
+ if (@TypeOf(SHA384.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA384)) {
+ @compileLog("SHA384.constructor is not a constructor");
}
-
- if (@TypeOf(SHA384.finalize) != (fn(*SHA384) callconv(.C) void)) {
- @compileLog("SHA384.finalize is not a finalizer");
+
+ if (@TypeOf(SHA384.finalize) != (fn (*SHA384) callconv(.C) void)) {
+ @compileLog("SHA384.finalize is not a finalizer");
}
-
- if (@TypeOf(SHA384.getByteLength) != GetterType)
- @compileLog(
- "Expected SHA384.getByteLength to be a getter"
- );
-
- if (@TypeOf(SHA384.digest) != CallbackType)
- @compileLog(
- "Expected SHA384.digest to be a callback but received " ++ @typeName(@TypeOf(SHA384.digest))
- );
- if (@TypeOf(SHA384.update) != CallbackType)
- @compileLog(
- "Expected SHA384.update to be a callback but received " ++ @typeName(@TypeOf(SHA384.update))
- );
- if (@TypeOf(SHA384.getByteLengthStatic) != StaticGetterType)
- @compileLog(
- "Expected SHA384.getByteLengthStatic to be a static getter"
- );
-
- if (@TypeOf(SHA384.hash) != StaticCallbackType)
- @compileLog(
- "Expected SHA384.hash to be a static callback"
- );
+
+ if (@TypeOf(SHA384.getByteLength) != GetterType)
+ @compileLog("Expected SHA384.getByteLength to be a getter");
+
+ if (@TypeOf(SHA384.digest) != CallbackType)
+ @compileLog("Expected SHA384.digest to be a callback but received " ++ @typeName(@TypeOf(SHA384.digest)));
+ if (@TypeOf(SHA384.update) != CallbackType)
+ @compileLog("Expected SHA384.update to be a callback but received " ++ @typeName(@TypeOf(SHA384.update)));
+ if (@TypeOf(SHA384.getByteLengthStatic) != StaticGetterType)
+ @compileLog("Expected SHA384.getByteLengthStatic to be a static getter");
+
+ if (@TypeOf(SHA384.hash) != StaticCallbackType)
+ @compileLog("Expected SHA384.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(SHA384.constructor, .{.name = "SHA384Class__construct"});
- @export(SHA384.digest, .{.name = "SHA384Prototype__digest"});
- @export(SHA384.finalize, .{.name = "SHA384Class__finalize"});
- @export(SHA384.getByteLength, .{.name = "SHA384Prototype__getByteLength"});
- @export(SHA384.getByteLengthStatic, .{.name = "SHA384Class__getByteLengthStatic"});
- @export(SHA384.hash, .{.name = "SHA384Class__hash"});
- @export(SHA384.update, .{.name = "SHA384Prototype__update"});
+ @export(SHA384.constructor, .{ .name = "SHA384Class__construct" });
+ @export(SHA384.digest, .{ .name = "SHA384Prototype__digest" });
+ @export(SHA384.finalize, .{ .name = "SHA384Class__finalize" });
+ @export(SHA384.getByteLength, .{ .name = "SHA384Prototype__getByteLength" });
+ @export(SHA384.getByteLengthStatic, .{ .name = "SHA384Class__getByteLengthStatic" });
+ @export(SHA384.hash, .{ .name = "SHA384Class__hash" });
+ @export(SHA384.update, .{ .name = "SHA384Prototype__update" });
}
}
};
pub const JSSHA512 = struct {
const SHA512 = Classes.SHA512;
- const GetterType = fn(*SHA512, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*SHA512, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*SHA512, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*SHA512, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*SHA512, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*SHA512, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*SHA512, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*SHA512, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*SHA512, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*SHA512, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -3069,16 +2592,13 @@ pub const JSSHA512 = struct {
return SHA512__fromJS(value);
}
-
-
-
/// Get the SHA512 constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return SHA512__getConstructor(globalObject);
}
-
+
/// Create a new instance of SHA512
pub fn toJS(this: *SHA512, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -3093,14 +2613,14 @@ pub const JSSHA512 = struct {
/// Modify the internal ptr to point to a new instance of SHA512.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*SHA512) bool {
- JSC.markBinding(@src());
- return SHA512__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return SHA512__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *SHA512, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(SHA512__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(SHA512__dangerouslySetPtr(value, null));
}
extern fn SHA512__fromJS(JSC.JSValue) ?*SHA512;
@@ -3111,55 +2631,44 @@ pub const JSSHA512 = struct {
extern fn SHA512__dangerouslySetPtr(JSC.JSValue, ?*SHA512) bool;
comptime {
-
- if (@TypeOf(SHA512.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA512)) {
- @compileLog("SHA512.constructor is not a constructor");
+ if (@TypeOf(SHA512.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA512)) {
+ @compileLog("SHA512.constructor is not a constructor");
}
-
- if (@TypeOf(SHA512.finalize) != (fn(*SHA512) callconv(.C) void)) {
- @compileLog("SHA512.finalize is not a finalizer");
+
+ if (@TypeOf(SHA512.finalize) != (fn (*SHA512) callconv(.C) void)) {
+ @compileLog("SHA512.finalize is not a finalizer");
}
-
- if (@TypeOf(SHA512.getByteLength) != GetterType)
- @compileLog(
- "Expected SHA512.getByteLength to be a getter"
- );
-
- if (@TypeOf(SHA512.digest) != CallbackType)
- @compileLog(
- "Expected SHA512.digest to be a callback but received " ++ @typeName(@TypeOf(SHA512.digest))
- );
- if (@TypeOf(SHA512.update) != CallbackType)
- @compileLog(
- "Expected SHA512.update to be a callback but received " ++ @typeName(@TypeOf(SHA512.update))
- );
- if (@TypeOf(SHA512.getByteLengthStatic) != StaticGetterType)
- @compileLog(
- "Expected SHA512.getByteLengthStatic to be a static getter"
- );
-
- if (@TypeOf(SHA512.hash) != StaticCallbackType)
- @compileLog(
- "Expected SHA512.hash to be a static callback"
- );
+
+ if (@TypeOf(SHA512.getByteLength) != GetterType)
+ @compileLog("Expected SHA512.getByteLength to be a getter");
+
+ if (@TypeOf(SHA512.digest) != CallbackType)
+ @compileLog("Expected SHA512.digest to be a callback but received " ++ @typeName(@TypeOf(SHA512.digest)));
+ if (@TypeOf(SHA512.update) != CallbackType)
+ @compileLog("Expected SHA512.update to be a callback but received " ++ @typeName(@TypeOf(SHA512.update)));
+ if (@TypeOf(SHA512.getByteLengthStatic) != StaticGetterType)
+ @compileLog("Expected SHA512.getByteLengthStatic to be a static getter");
+
+ if (@TypeOf(SHA512.hash) != StaticCallbackType)
+ @compileLog("Expected SHA512.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(SHA512.constructor, .{.name = "SHA512Class__construct"});
- @export(SHA512.digest, .{.name = "SHA512Prototype__digest"});
- @export(SHA512.finalize, .{.name = "SHA512Class__finalize"});
- @export(SHA512.getByteLength, .{.name = "SHA512Prototype__getByteLength"});
- @export(SHA512.getByteLengthStatic, .{.name = "SHA512Class__getByteLengthStatic"});
- @export(SHA512.hash, .{.name = "SHA512Class__hash"});
- @export(SHA512.update, .{.name = "SHA512Prototype__update"});
+ @export(SHA512.constructor, .{ .name = "SHA512Class__construct" });
+ @export(SHA512.digest, .{ .name = "SHA512Prototype__digest" });
+ @export(SHA512.finalize, .{ .name = "SHA512Class__finalize" });
+ @export(SHA512.getByteLength, .{ .name = "SHA512Prototype__getByteLength" });
+ @export(SHA512.getByteLengthStatic, .{ .name = "SHA512Class__getByteLengthStatic" });
+ @export(SHA512.hash, .{ .name = "SHA512Class__hash" });
+ @export(SHA512.update, .{ .name = "SHA512Prototype__update" });
}
}
};
pub const JSSHA512_256 = struct {
const SHA512_256 = Classes.SHA512_256;
- const GetterType = fn(*SHA512_256, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*SHA512_256, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*SHA512_256, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*SHA512_256, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*SHA512_256, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*SHA512_256, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*SHA512_256, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*SHA512_256, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*SHA512_256, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*SHA512_256, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -3168,16 +2677,13 @@ pub const JSSHA512_256 = struct {
return SHA512_256__fromJS(value);
}
-
-
-
/// Get the SHA512_256 constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return SHA512_256__getConstructor(globalObject);
}
-
+
/// Create a new instance of SHA512_256
pub fn toJS(this: *SHA512_256, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -3192,14 +2698,14 @@ pub const JSSHA512_256 = struct {
/// Modify the internal ptr to point to a new instance of SHA512_256.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*SHA512_256) bool {
- JSC.markBinding(@src());
- return SHA512_256__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return SHA512_256__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *SHA512_256, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(SHA512_256__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(SHA512_256__dangerouslySetPtr(value, null));
}
extern fn SHA512_256__fromJS(JSC.JSValue) ?*SHA512_256;
@@ -3210,55 +2716,44 @@ pub const JSSHA512_256 = struct {
extern fn SHA512_256__dangerouslySetPtr(JSC.JSValue, ?*SHA512_256) bool;
comptime {
-
- if (@TypeOf(SHA512_256.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA512_256)) {
- @compileLog("SHA512_256.constructor is not a constructor");
+ if (@TypeOf(SHA512_256.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*SHA512_256)) {
+ @compileLog("SHA512_256.constructor is not a constructor");
}
-
- if (@TypeOf(SHA512_256.finalize) != (fn(*SHA512_256) callconv(.C) void)) {
- @compileLog("SHA512_256.finalize is not a finalizer");
+
+ if (@TypeOf(SHA512_256.finalize) != (fn (*SHA512_256) callconv(.C) void)) {
+ @compileLog("SHA512_256.finalize is not a finalizer");
}
-
- if (@TypeOf(SHA512_256.getByteLength) != GetterType)
- @compileLog(
- "Expected SHA512_256.getByteLength to be a getter"
- );
-
- if (@TypeOf(SHA512_256.digest) != CallbackType)
- @compileLog(
- "Expected SHA512_256.digest to be a callback but received " ++ @typeName(@TypeOf(SHA512_256.digest))
- );
- if (@TypeOf(SHA512_256.update) != CallbackType)
- @compileLog(
- "Expected SHA512_256.update to be a callback but received " ++ @typeName(@TypeOf(SHA512_256.update))
- );
- if (@TypeOf(SHA512_256.getByteLengthStatic) != StaticGetterType)
- @compileLog(
- "Expected SHA512_256.getByteLengthStatic to be a static getter"
- );
-
- if (@TypeOf(SHA512_256.hash) != StaticCallbackType)
- @compileLog(
- "Expected SHA512_256.hash to be a static callback"
- );
+
+ if (@TypeOf(SHA512_256.getByteLength) != GetterType)
+ @compileLog("Expected SHA512_256.getByteLength to be a getter");
+
+ if (@TypeOf(SHA512_256.digest) != CallbackType)
+ @compileLog("Expected SHA512_256.digest to be a callback but received " ++ @typeName(@TypeOf(SHA512_256.digest)));
+ if (@TypeOf(SHA512_256.update) != CallbackType)
+ @compileLog("Expected SHA512_256.update to be a callback but received " ++ @typeName(@TypeOf(SHA512_256.update)));
+ if (@TypeOf(SHA512_256.getByteLengthStatic) != StaticGetterType)
+ @compileLog("Expected SHA512_256.getByteLengthStatic to be a static getter");
+
+ if (@TypeOf(SHA512_256.hash) != StaticCallbackType)
+ @compileLog("Expected SHA512_256.hash to be a static callback");
if (!JSC.is_bindgen) {
-@export(SHA512_256.constructor, .{.name = "SHA512_256Class__construct"});
- @export(SHA512_256.digest, .{.name = "SHA512_256Prototype__digest"});
- @export(SHA512_256.finalize, .{.name = "SHA512_256Class__finalize"});
- @export(SHA512_256.getByteLength, .{.name = "SHA512_256Prototype__getByteLength"});
- @export(SHA512_256.getByteLengthStatic, .{.name = "SHA512_256Class__getByteLengthStatic"});
- @export(SHA512_256.hash, .{.name = "SHA512_256Class__hash"});
- @export(SHA512_256.update, .{.name = "SHA512_256Prototype__update"});
+ @export(SHA512_256.constructor, .{ .name = "SHA512_256Class__construct" });
+ @export(SHA512_256.digest, .{ .name = "SHA512_256Prototype__digest" });
+ @export(SHA512_256.finalize, .{ .name = "SHA512_256Class__finalize" });
+ @export(SHA512_256.getByteLength, .{ .name = "SHA512_256Prototype__getByteLength" });
+ @export(SHA512_256.getByteLengthStatic, .{ .name = "SHA512_256Class__getByteLengthStatic" });
+ @export(SHA512_256.hash, .{ .name = "SHA512_256Class__hash" });
+ @export(SHA512_256.update, .{ .name = "SHA512_256Prototype__update" });
}
}
};
pub const JSServerWebSocket = struct {
const ServerWebSocket = Classes.ServerWebSocket;
- const GetterType = fn(*ServerWebSocket, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*ServerWebSocket, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*ServerWebSocket, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*ServerWebSocket, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*ServerWebSocket, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*ServerWebSocket, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*ServerWebSocket, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*ServerWebSocket, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*ServerWebSocket, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -3269,57 +2764,55 @@ pub const JSServerWebSocket = struct {
extern fn ServerWebSocketPrototype__dataSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn ServerWebSocketPrototype__dataGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `ServerWebSocket.data` setter
- /// This value will be visited by the garbage collector.
- pub fn dataSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ServerWebSocketPrototype__dataSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ServerWebSocketPrototype__dataGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ServerWebSocket.data` setter
+ /// This value will be visited by the garbage collector.
+ pub fn dataSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ServerWebSocketPrototype__dataSetCachedValue(thisValue, globalObject, value);
+ }
- /// `ServerWebSocket.data` getter
- /// This value will be visited by the garbage collector.
- pub fn dataGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ServerWebSocketPrototype__dataGetCachedValue(thisValue);
- if (result == .zero)
+ /// `ServerWebSocket.data` getter
+ /// This value will be visited by the garbage collector.
+ pub fn dataGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ServerWebSocketPrototype__dataGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn ServerWebSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn ServerWebSocketPrototype__remoteAddressGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `ServerWebSocket.remoteAddress` setter
- /// This value will be visited by the garbage collector.
- pub fn remoteAddressSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- ServerWebSocketPrototype__remoteAddressSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn ServerWebSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- /// `ServerWebSocket.remoteAddress` getter
- /// This value will be visited by the garbage collector.
- pub fn remoteAddressGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = ServerWebSocketPrototype__remoteAddressGetCachedValue(thisValue);
- if (result == .zero)
+ extern fn ServerWebSocketPrototype__remoteAddressGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `ServerWebSocket.remoteAddress` setter
+ /// This value will be visited by the garbage collector.
+ pub fn remoteAddressSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ ServerWebSocketPrototype__remoteAddressSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `ServerWebSocket.remoteAddress` getter
+ /// This value will be visited by the garbage collector.
+ pub fn remoteAddressGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = ServerWebSocketPrototype__remoteAddressGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the ServerWebSocket constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return ServerWebSocket__getConstructor(globalObject);
}
-
+
/// Create a new instance of ServerWebSocket
pub fn toJS(this: *ServerWebSocket, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -3334,14 +2827,14 @@ extern fn ServerWebSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JS
/// Modify the internal ptr to point to a new instance of ServerWebSocket.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*ServerWebSocket) bool {
- JSC.markBinding(@src());
- return ServerWebSocket__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return ServerWebSocket__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *ServerWebSocket, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(ServerWebSocket__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(ServerWebSocket__dangerouslySetPtr(value, null));
}
extern fn ServerWebSocket__fromJS(JSC.JSValue) ?*ServerWebSocket;
@@ -3352,142 +2845,97 @@ extern fn ServerWebSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JS
extern fn ServerWebSocket__dangerouslySetPtr(JSC.JSValue, ?*ServerWebSocket) bool;
comptime {
-
- if (@TypeOf(ServerWebSocket.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*ServerWebSocket)) {
- @compileLog("ServerWebSocket.constructor is not a constructor");
- }
-
- if (@TypeOf(ServerWebSocket.finalize) != (fn(*ServerWebSocket) callconv(.C) void)) {
- @compileLog("ServerWebSocket.finalize is not a finalizer");
- }
-
- if (@TypeOf(ServerWebSocket.getBinaryType) != GetterType)
- @compileLog(
- "Expected ServerWebSocket.getBinaryType to be a getter"
- );
-
- if (@TypeOf(ServerWebSocket.setBinaryType) != SetterType)
- @compileLog(
- "Expected ServerWebSocket.setBinaryType to be a setter"
- );
- if (@TypeOf(ServerWebSocket.close) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.close to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.close))
- );
- if (@TypeOf(ServerWebSocket.cork) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.cork to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.cork))
- );
- if (@TypeOf(ServerWebSocket.getData) != GetterType)
- @compileLog(
- "Expected ServerWebSocket.getData to be a getter"
- );
-
- if (@TypeOf(ServerWebSocket.setData) != SetterType)
- @compileLog(
- "Expected ServerWebSocket.setData to be a setter"
- );
- if (@TypeOf(ServerWebSocket.getBufferedAmount) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.getBufferedAmount to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.getBufferedAmount))
- );
- if (@TypeOf(ServerWebSocket.isSubscribed) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.isSubscribed to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.isSubscribed))
- );
- if (@TypeOf(ServerWebSocket.publish) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.publish to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.publish))
- );
- if (@TypeOf(ServerWebSocket.publishBinaryWithoutTypeChecks) != fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.JSString, *JSC.JSUint8Array) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected ServerWebSocket.publishBinaryWithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(ServerWebSocket.publishBinary) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.publishBinary to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.publishBinary))
- );
- if (@TypeOf(ServerWebSocket.publishTextWithoutTypeChecks) != fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.JSString, *JSC.JSString) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected ServerWebSocket.publishTextWithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(ServerWebSocket.publishText) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.publishText to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.publishText))
- );
- if (@TypeOf(ServerWebSocket.getReadyState) != GetterType)
- @compileLog(
- "Expected ServerWebSocket.getReadyState to be a getter"
- );
-
- if (@TypeOf(ServerWebSocket.getRemoteAddress) != GetterType)
- @compileLog(
- "Expected ServerWebSocket.getRemoteAddress to be a getter"
- );
-
- if (@TypeOf(ServerWebSocket.send) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.send to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.send))
- );
- if (@TypeOf(ServerWebSocket.sendBinaryWithoutTypeChecks) != fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.JSUint8Array, bool) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected ServerWebSocket.sendBinaryWithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(ServerWebSocket.sendBinary) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.sendBinary to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.sendBinary))
- );
- if (@TypeOf(ServerWebSocket.sendTextWithoutTypeChecks) != fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.JSString, bool) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected ServerWebSocket.sendTextWithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(ServerWebSocket.sendText) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.sendText to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.sendText))
- );
- if (@TypeOf(ServerWebSocket.subscribe) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.subscribe to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.subscribe))
- );
- if (@TypeOf(ServerWebSocket.unsubscribe) != CallbackType)
- @compileLog(
- "Expected ServerWebSocket.unsubscribe to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.unsubscribe))
- );
+ if (@TypeOf(ServerWebSocket.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*ServerWebSocket)) {
+ @compileLog("ServerWebSocket.constructor is not a constructor");
+ }
+
+ if (@TypeOf(ServerWebSocket.finalize) != (fn (*ServerWebSocket) callconv(.C) void)) {
+ @compileLog("ServerWebSocket.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(ServerWebSocket.getBinaryType) != GetterType)
+ @compileLog("Expected ServerWebSocket.getBinaryType to be a getter");
+
+ if (@TypeOf(ServerWebSocket.setBinaryType) != SetterType)
+ @compileLog("Expected ServerWebSocket.setBinaryType to be a setter");
+ if (@TypeOf(ServerWebSocket.close) != CallbackType)
+ @compileLog("Expected ServerWebSocket.close to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.close)));
+ if (@TypeOf(ServerWebSocket.cork) != CallbackType)
+ @compileLog("Expected ServerWebSocket.cork to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.cork)));
+ if (@TypeOf(ServerWebSocket.getData) != GetterType)
+ @compileLog("Expected ServerWebSocket.getData to be a getter");
+
+ if (@TypeOf(ServerWebSocket.setData) != SetterType)
+ @compileLog("Expected ServerWebSocket.setData to be a setter");
+ if (@TypeOf(ServerWebSocket.getBufferedAmount) != CallbackType)
+ @compileLog("Expected ServerWebSocket.getBufferedAmount to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.getBufferedAmount)));
+ if (@TypeOf(ServerWebSocket.isSubscribed) != CallbackType)
+ @compileLog("Expected ServerWebSocket.isSubscribed to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.isSubscribed)));
+ if (@TypeOf(ServerWebSocket.publish) != CallbackType)
+ @compileLog("Expected ServerWebSocket.publish to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.publish)));
+ if (@TypeOf(ServerWebSocket.publishBinaryWithoutTypeChecks) != fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.JSString, *JSC.JSUint8Array) callconv(.C) JSC.JSValue)
+ @compileLog("Expected ServerWebSocket.publishBinaryWithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(ServerWebSocket.publishBinary) != CallbackType)
+ @compileLog("Expected ServerWebSocket.publishBinary to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.publishBinary)));
+ if (@TypeOf(ServerWebSocket.publishTextWithoutTypeChecks) != fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.JSString, *JSC.JSString) callconv(.C) JSC.JSValue)
+ @compileLog("Expected ServerWebSocket.publishTextWithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(ServerWebSocket.publishText) != CallbackType)
+ @compileLog("Expected ServerWebSocket.publishText to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.publishText)));
+ if (@TypeOf(ServerWebSocket.getReadyState) != GetterType)
+ @compileLog("Expected ServerWebSocket.getReadyState to be a getter");
+
+ if (@TypeOf(ServerWebSocket.getRemoteAddress) != GetterType)
+ @compileLog("Expected ServerWebSocket.getRemoteAddress to be a getter");
+
+ if (@TypeOf(ServerWebSocket.send) != CallbackType)
+ @compileLog("Expected ServerWebSocket.send to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.send)));
+ if (@TypeOf(ServerWebSocket.sendBinaryWithoutTypeChecks) != fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.JSUint8Array, bool) callconv(.C) JSC.JSValue)
+ @compileLog("Expected ServerWebSocket.sendBinaryWithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(ServerWebSocket.sendBinary) != CallbackType)
+ @compileLog("Expected ServerWebSocket.sendBinary to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.sendBinary)));
+ if (@TypeOf(ServerWebSocket.sendTextWithoutTypeChecks) != fn (*ServerWebSocket, *JSC.JSGlobalObject, *JSC.JSString, bool) callconv(.C) JSC.JSValue)
+ @compileLog("Expected ServerWebSocket.sendTextWithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(ServerWebSocket.sendText) != CallbackType)
+ @compileLog("Expected ServerWebSocket.sendText to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.sendText)));
+ if (@TypeOf(ServerWebSocket.subscribe) != CallbackType)
+ @compileLog("Expected ServerWebSocket.subscribe to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.subscribe)));
+ if (@TypeOf(ServerWebSocket.unsubscribe) != CallbackType)
+ @compileLog("Expected ServerWebSocket.unsubscribe to be a callback but received " ++ @typeName(@TypeOf(ServerWebSocket.unsubscribe)));
if (!JSC.is_bindgen) {
-@export(ServerWebSocket.close, .{.name = "ServerWebSocketPrototype__close"});
- @export(ServerWebSocket.constructor, .{.name = "ServerWebSocketClass__construct"});
- @export(ServerWebSocket.cork, .{.name = "ServerWebSocketPrototype__cork"});
- @export(ServerWebSocket.finalize, .{.name = "ServerWebSocketClass__finalize"});
- @export(ServerWebSocket.getBinaryType, .{.name = "ServerWebSocketPrototype__getBinaryType"});
- @export(ServerWebSocket.getBufferedAmount, .{.name = "ServerWebSocketPrototype__getBufferedAmount"});
- @export(ServerWebSocket.getData, .{.name = "ServerWebSocketPrototype__getData"});
- @export(ServerWebSocket.getReadyState, .{.name = "ServerWebSocketPrototype__getReadyState"});
- @export(ServerWebSocket.getRemoteAddress, .{.name = "ServerWebSocketPrototype__getRemoteAddress"});
- @export(ServerWebSocket.isSubscribed, .{.name = "ServerWebSocketPrototype__isSubscribed"});
- @export(ServerWebSocket.publish, .{.name = "ServerWebSocketPrototype__publish"});
- @export(ServerWebSocket.publishBinary, .{.name = "ServerWebSocketPrototype__publishBinary"});
- @export(ServerWebSocket.publishBinaryWithoutTypeChecks, .{.name = "ServerWebSocketPrototype__publishBinaryWithoutTypeChecks"});
- @export(ServerWebSocket.publishText, .{.name = "ServerWebSocketPrototype__publishText"});
- @export(ServerWebSocket.publishTextWithoutTypeChecks, .{.name = "ServerWebSocketPrototype__publishTextWithoutTypeChecks"});
- @export(ServerWebSocket.send, .{.name = "ServerWebSocketPrototype__send"});
- @export(ServerWebSocket.sendBinary, .{.name = "ServerWebSocketPrototype__sendBinary"});
- @export(ServerWebSocket.sendBinaryWithoutTypeChecks, .{.name = "ServerWebSocketPrototype__sendBinaryWithoutTypeChecks"});
- @export(ServerWebSocket.sendText, .{.name = "ServerWebSocketPrototype__sendText"});
- @export(ServerWebSocket.sendTextWithoutTypeChecks, .{.name = "ServerWebSocketPrototype__sendTextWithoutTypeChecks"});
- @export(ServerWebSocket.setBinaryType, .{.name = "ServerWebSocketPrototype__setBinaryType"});
- @export(ServerWebSocket.setData, .{.name = "ServerWebSocketPrototype__setData"});
- @export(ServerWebSocket.subscribe, .{.name = "ServerWebSocketPrototype__subscribe"});
- @export(ServerWebSocket.unsubscribe, .{.name = "ServerWebSocketPrototype__unsubscribe"});
+ @export(ServerWebSocket.close, .{ .name = "ServerWebSocketPrototype__close" });
+ @export(ServerWebSocket.constructor, .{ .name = "ServerWebSocketClass__construct" });
+ @export(ServerWebSocket.cork, .{ .name = "ServerWebSocketPrototype__cork" });
+ @export(ServerWebSocket.finalize, .{ .name = "ServerWebSocketClass__finalize" });
+ @export(ServerWebSocket.getBinaryType, .{ .name = "ServerWebSocketPrototype__getBinaryType" });
+ @export(ServerWebSocket.getBufferedAmount, .{ .name = "ServerWebSocketPrototype__getBufferedAmount" });
+ @export(ServerWebSocket.getData, .{ .name = "ServerWebSocketPrototype__getData" });
+ @export(ServerWebSocket.getReadyState, .{ .name = "ServerWebSocketPrototype__getReadyState" });
+ @export(ServerWebSocket.getRemoteAddress, .{ .name = "ServerWebSocketPrototype__getRemoteAddress" });
+ @export(ServerWebSocket.isSubscribed, .{ .name = "ServerWebSocketPrototype__isSubscribed" });
+ @export(ServerWebSocket.publish, .{ .name = "ServerWebSocketPrototype__publish" });
+ @export(ServerWebSocket.publishBinary, .{ .name = "ServerWebSocketPrototype__publishBinary" });
+ @export(ServerWebSocket.publishBinaryWithoutTypeChecks, .{ .name = "ServerWebSocketPrototype__publishBinaryWithoutTypeChecks" });
+ @export(ServerWebSocket.publishText, .{ .name = "ServerWebSocketPrototype__publishText" });
+ @export(ServerWebSocket.publishTextWithoutTypeChecks, .{ .name = "ServerWebSocketPrototype__publishTextWithoutTypeChecks" });
+ @export(ServerWebSocket.send, .{ .name = "ServerWebSocketPrototype__send" });
+ @export(ServerWebSocket.sendBinary, .{ .name = "ServerWebSocketPrototype__sendBinary" });
+ @export(ServerWebSocket.sendBinaryWithoutTypeChecks, .{ .name = "ServerWebSocketPrototype__sendBinaryWithoutTypeChecks" });
+ @export(ServerWebSocket.sendText, .{ .name = "ServerWebSocketPrototype__sendText" });
+ @export(ServerWebSocket.sendTextWithoutTypeChecks, .{ .name = "ServerWebSocketPrototype__sendTextWithoutTypeChecks" });
+ @export(ServerWebSocket.setBinaryType, .{ .name = "ServerWebSocketPrototype__setBinaryType" });
+ @export(ServerWebSocket.setData, .{ .name = "ServerWebSocketPrototype__setData" });
+ @export(ServerWebSocket.subscribe, .{ .name = "ServerWebSocketPrototype__subscribe" });
+ @export(ServerWebSocket.unsubscribe, .{ .name = "ServerWebSocketPrototype__unsubscribe" });
}
}
};
pub const JSStats = struct {
const Stats = Classes.Stats;
- const GetterType = fn(*Stats, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Stats, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Stats, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Stats, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Stats, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Stats, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Stats, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Stats, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Stats, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Stats, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -3498,79 +2946,77 @@ pub const JSStats = struct {
extern fn StatsPrototype__atimeSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn StatsPrototype__atimeGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Stats.atime` setter
- /// This value will be visited by the garbage collector.
- pub fn atimeSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- StatsPrototype__atimeSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn StatsPrototype__atimeGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Stats.atime` setter
+ /// This value will be visited by the garbage collector.
+ pub fn atimeSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ StatsPrototype__atimeSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Stats.atime` getter
- /// This value will be visited by the garbage collector.
- pub fn atimeGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = StatsPrototype__atimeGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Stats.atime` getter
+ /// This value will be visited by the garbage collector.
+ pub fn atimeGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = StatsPrototype__atimeGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn StatsPrototype__ctimeSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn StatsPrototype__ctimeGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Stats.ctime` setter
- /// This value will be visited by the garbage collector.
- pub fn ctimeSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- StatsPrototype__ctimeSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn StatsPrototype__ctimeSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn StatsPrototype__ctimeGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Stats.ctime` setter
+ /// This value will be visited by the garbage collector.
+ pub fn ctimeSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ StatsPrototype__ctimeSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Stats.ctime` getter
- /// This value will be visited by the garbage collector.
- pub fn ctimeGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = StatsPrototype__ctimeGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Stats.ctime` getter
+ /// This value will be visited by the garbage collector.
+ pub fn ctimeGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = StatsPrototype__ctimeGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn StatsPrototype__mtimeSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
+
+ extern fn StatsPrototype__mtimeSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn StatsPrototype__mtimeGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Stats.mtime` setter
- /// This value will be visited by the garbage collector.
- pub fn mtimeSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- StatsPrototype__mtimeSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn StatsPrototype__mtimeGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Stats.mtime` setter
+ /// This value will be visited by the garbage collector.
+ pub fn mtimeSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ StatsPrototype__mtimeSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Stats.mtime` getter
- /// This value will be visited by the garbage collector.
- pub fn mtimeGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = StatsPrototype__mtimeGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Stats.mtime` getter
+ /// This value will be visited by the garbage collector.
+ pub fn mtimeGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = StatsPrototype__mtimeGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the Stats constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return Stats__getConstructor(globalObject);
}
-
+
/// Create a new instance of Stats
pub fn toJS(this: *Stats, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -3585,14 +3031,14 @@ extern fn StatsPrototype__mtimeSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject,
/// Modify the internal ptr to point to a new instance of Stats.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Stats) bool {
- JSC.markBinding(@src());
- return Stats__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Stats__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Stats, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Stats__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Stats__dangerouslySetPtr(value, null));
}
extern fn Stats__fromJS(JSC.JSValue) ?*Stats;
@@ -3603,206 +3049,162 @@ extern fn StatsPrototype__mtimeSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject,
extern fn Stats__dangerouslySetPtr(JSC.JSValue, ?*Stats) bool;
comptime {
-
- if (@TypeOf(Stats.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Stats)) {
- @compileLog("Stats.constructor is not a constructor");
- }
-
- if (@TypeOf(Stats.finalize) != (fn(*Stats) callconv(.C) void)) {
- @compileLog("Stats.finalize is not a finalizer");
- }
-
- if (@TypeOf(Stats.atime) != GetterType)
- @compileLog(
- "Expected Stats.atime to be a getter"
- );
-
- if (@TypeOf(Stats.atimeMs) != GetterType)
- @compileLog(
- "Expected Stats.atimeMs to be a getter"
- );
-
- if (@TypeOf(Stats.birthtime) != GetterType)
- @compileLog(
- "Expected Stats.birthtime to be a getter"
- );
-
- if (@TypeOf(Stats.birthtimeMs) != GetterType)
- @compileLog(
- "Expected Stats.birthtimeMs to be a getter"
- );
-
- if (@TypeOf(Stats.blksize) != GetterType)
- @compileLog(
- "Expected Stats.blksize to be a getter"
- );
-
- if (@TypeOf(Stats.blocks) != GetterType)
- @compileLog(
- "Expected Stats.blocks to be a getter"
- );
-
- if (@TypeOf(Stats.ctime) != GetterType)
- @compileLog(
- "Expected Stats.ctime to be a getter"
- );
-
- if (@TypeOf(Stats.ctimeMs) != GetterType)
- @compileLog(
- "Expected Stats.ctimeMs to be a getter"
- );
-
- if (@TypeOf(Stats.dev) != GetterType)
- @compileLog(
- "Expected Stats.dev to be a getter"
- );
-
- if (@TypeOf(Stats.gid) != GetterType)
- @compileLog(
- "Expected Stats.gid to be a getter"
- );
-
- if (@TypeOf(Stats.ino) != GetterType)
- @compileLog(
- "Expected Stats.ino to be a getter"
- );
-
- if (@TypeOf(Stats.isBlockDevice_WithoutTypeChecks) != fn (*Stats, *JSC.JSGlobalObject, ) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected Stats.isBlockDevice_WithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(Stats.isBlockDevice_) != CallbackType)
- @compileLog(
- "Expected Stats.isBlockDevice_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isBlockDevice_))
- );
- if (@TypeOf(Stats.isCharacterDevice_WithoutTypeChecks) != fn (*Stats, *JSC.JSGlobalObject, ) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected Stats.isCharacterDevice_WithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(Stats.isCharacterDevice_) != CallbackType)
- @compileLog(
- "Expected Stats.isCharacterDevice_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isCharacterDevice_))
- );
- if (@TypeOf(Stats.isDirectory_WithoutTypeChecks) != fn (*Stats, *JSC.JSGlobalObject, ) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected Stats.isDirectory_WithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(Stats.isDirectory_) != CallbackType)
- @compileLog(
- "Expected Stats.isDirectory_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isDirectory_))
- );
- if (@TypeOf(Stats.isFIFO_WithoutTypeChecks) != fn (*Stats, *JSC.JSGlobalObject, ) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected Stats.isFIFO_WithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(Stats.isFIFO_) != CallbackType)
- @compileLog(
- "Expected Stats.isFIFO_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isFIFO_))
- );
- if (@TypeOf(Stats.isFile_WithoutTypeChecks) != fn (*Stats, *JSC.JSGlobalObject, ) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected Stats.isFile_WithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(Stats.isFile_) != CallbackType)
- @compileLog(
- "Expected Stats.isFile_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isFile_))
- );
- if (@TypeOf(Stats.isSocket_WithoutTypeChecks) != fn (*Stats, *JSC.JSGlobalObject, ) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected Stats.isSocket_WithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(Stats.isSocket_) != CallbackType)
- @compileLog(
- "Expected Stats.isSocket_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isSocket_))
- );
- if (@TypeOf(Stats.isSymbolicLink_WithoutTypeChecks) != fn (*Stats, *JSC.JSGlobalObject, ) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected Stats.isSymbolicLink_WithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(Stats.isSymbolicLink_) != CallbackType)
- @compileLog(
- "Expected Stats.isSymbolicLink_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isSymbolicLink_))
- );
- if (@TypeOf(Stats.mode) != GetterType)
- @compileLog(
- "Expected Stats.mode to be a getter"
- );
-
- if (@TypeOf(Stats.mtime) != GetterType)
- @compileLog(
- "Expected Stats.mtime to be a getter"
- );
-
- if (@TypeOf(Stats.mtimeMs) != GetterType)
- @compileLog(
- "Expected Stats.mtimeMs to be a getter"
- );
-
- if (@TypeOf(Stats.nlink) != GetterType)
- @compileLog(
- "Expected Stats.nlink to be a getter"
- );
-
- if (@TypeOf(Stats.rdev) != GetterType)
- @compileLog(
- "Expected Stats.rdev to be a getter"
- );
-
- if (@TypeOf(Stats.size) != GetterType)
- @compileLog(
- "Expected Stats.size to be a getter"
- );
-
- if (@TypeOf(Stats.uid) != GetterType)
- @compileLog(
- "Expected Stats.uid to be a getter"
- );
+ if (@TypeOf(Stats.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Stats)) {
+ @compileLog("Stats.constructor is not a constructor");
+ }
+
+ if (@TypeOf(Stats.finalize) != (fn (*Stats) callconv(.C) void)) {
+ @compileLog("Stats.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(Stats.atime) != GetterType)
+ @compileLog("Expected Stats.atime to be a getter");
+
+ if (@TypeOf(Stats.atimeMs) != GetterType)
+ @compileLog("Expected Stats.atimeMs to be a getter");
+
+ if (@TypeOf(Stats.birthtime) != GetterType)
+ @compileLog("Expected Stats.birthtime to be a getter");
+
+ if (@TypeOf(Stats.birthtimeMs) != GetterType)
+ @compileLog("Expected Stats.birthtimeMs to be a getter");
+
+ if (@TypeOf(Stats.blksize) != GetterType)
+ @compileLog("Expected Stats.blksize to be a getter");
+
+ if (@TypeOf(Stats.blocks) != GetterType)
+ @compileLog("Expected Stats.blocks to be a getter");
+
+ if (@TypeOf(Stats.ctime) != GetterType)
+ @compileLog("Expected Stats.ctime to be a getter");
+
+ if (@TypeOf(Stats.ctimeMs) != GetterType)
+ @compileLog("Expected Stats.ctimeMs to be a getter");
+
+ if (@TypeOf(Stats.dev) != GetterType)
+ @compileLog("Expected Stats.dev to be a getter");
+
+ if (@TypeOf(Stats.gid) != GetterType)
+ @compileLog("Expected Stats.gid to be a getter");
+
+ if (@TypeOf(Stats.ino) != GetterType)
+ @compileLog("Expected Stats.ino to be a getter");
+
+ if (@TypeOf(Stats.isBlockDevice_WithoutTypeChecks) != fn (
+ *Stats,
+ *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Stats.isBlockDevice_WithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Stats.isBlockDevice_) != CallbackType)
+ @compileLog("Expected Stats.isBlockDevice_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isBlockDevice_)));
+ if (@TypeOf(Stats.isCharacterDevice_WithoutTypeChecks) != fn (
+ *Stats,
+ *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Stats.isCharacterDevice_WithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Stats.isCharacterDevice_) != CallbackType)
+ @compileLog("Expected Stats.isCharacterDevice_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isCharacterDevice_)));
+ if (@TypeOf(Stats.isDirectory_WithoutTypeChecks) != fn (
+ *Stats,
+ *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Stats.isDirectory_WithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Stats.isDirectory_) != CallbackType)
+ @compileLog("Expected Stats.isDirectory_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isDirectory_)));
+ if (@TypeOf(Stats.isFIFO_WithoutTypeChecks) != fn (
+ *Stats,
+ *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Stats.isFIFO_WithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Stats.isFIFO_) != CallbackType)
+ @compileLog("Expected Stats.isFIFO_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isFIFO_)));
+ if (@TypeOf(Stats.isFile_WithoutTypeChecks) != fn (
+ *Stats,
+ *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Stats.isFile_WithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Stats.isFile_) != CallbackType)
+ @compileLog("Expected Stats.isFile_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isFile_)));
+ if (@TypeOf(Stats.isSocket_WithoutTypeChecks) != fn (
+ *Stats,
+ *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Stats.isSocket_WithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Stats.isSocket_) != CallbackType)
+ @compileLog("Expected Stats.isSocket_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isSocket_)));
+ if (@TypeOf(Stats.isSymbolicLink_WithoutTypeChecks) != fn (
+ *Stats,
+ *JSC.JSGlobalObject,
+ ) callconv(.C) JSC.JSValue)
+ @compileLog("Expected Stats.isSymbolicLink_WithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(Stats.isSymbolicLink_) != CallbackType)
+ @compileLog("Expected Stats.isSymbolicLink_ to be a callback but received " ++ @typeName(@TypeOf(Stats.isSymbolicLink_)));
+ if (@TypeOf(Stats.mode) != GetterType)
+ @compileLog("Expected Stats.mode to be a getter");
+
+ if (@TypeOf(Stats.mtime) != GetterType)
+ @compileLog("Expected Stats.mtime to be a getter");
+
+ if (@TypeOf(Stats.mtimeMs) != GetterType)
+ @compileLog("Expected Stats.mtimeMs to be a getter");
+
+ if (@TypeOf(Stats.nlink) != GetterType)
+ @compileLog("Expected Stats.nlink to be a getter");
+
+ if (@TypeOf(Stats.rdev) != GetterType)
+ @compileLog("Expected Stats.rdev to be a getter");
+
+ if (@TypeOf(Stats.size) != GetterType)
+ @compileLog("Expected Stats.size to be a getter");
+
+ if (@TypeOf(Stats.uid) != GetterType)
+ @compileLog("Expected Stats.uid to be a getter");
if (!JSC.is_bindgen) {
-@export(Stats.atime, .{.name = "StatsPrototype__atime"});
- @export(Stats.atimeMs, .{.name = "StatsPrototype__atimeMs"});
- @export(Stats.birthtime, .{.name = "StatsPrototype__birthtime"});
- @export(Stats.birthtimeMs, .{.name = "StatsPrototype__birthtimeMs"});
- @export(Stats.blksize, .{.name = "StatsPrototype__blksize"});
- @export(Stats.blocks, .{.name = "StatsPrototype__blocks"});
- @export(Stats.constructor, .{.name = "StatsClass__construct"});
- @export(Stats.ctime, .{.name = "StatsPrototype__ctime"});
- @export(Stats.ctimeMs, .{.name = "StatsPrototype__ctimeMs"});
- @export(Stats.dev, .{.name = "StatsPrototype__dev"});
- @export(Stats.finalize, .{.name = "StatsClass__finalize"});
- @export(Stats.gid, .{.name = "StatsPrototype__gid"});
- @export(Stats.ino, .{.name = "StatsPrototype__ino"});
- @export(Stats.isBlockDevice_, .{.name = "StatsPrototype__isBlockDevice_"});
- @export(Stats.isBlockDevice_WithoutTypeChecks, .{.name = "StatsPrototype__isBlockDevice_WithoutTypeChecks"});
- @export(Stats.isCharacterDevice_, .{.name = "StatsPrototype__isCharacterDevice_"});
- @export(Stats.isCharacterDevice_WithoutTypeChecks, .{.name = "StatsPrototype__isCharacterDevice_WithoutTypeChecks"});
- @export(Stats.isDirectory_, .{.name = "StatsPrototype__isDirectory_"});
- @export(Stats.isDirectory_WithoutTypeChecks, .{.name = "StatsPrototype__isDirectory_WithoutTypeChecks"});
- @export(Stats.isFIFO_, .{.name = "StatsPrototype__isFIFO_"});
- @export(Stats.isFIFO_WithoutTypeChecks, .{.name = "StatsPrototype__isFIFO_WithoutTypeChecks"});
- @export(Stats.isFile_, .{.name = "StatsPrototype__isFile_"});
- @export(Stats.isFile_WithoutTypeChecks, .{.name = "StatsPrototype__isFile_WithoutTypeChecks"});
- @export(Stats.isSocket_, .{.name = "StatsPrototype__isSocket_"});
- @export(Stats.isSocket_WithoutTypeChecks, .{.name = "StatsPrototype__isSocket_WithoutTypeChecks"});
- @export(Stats.isSymbolicLink_, .{.name = "StatsPrototype__isSymbolicLink_"});
- @export(Stats.isSymbolicLink_WithoutTypeChecks, .{.name = "StatsPrototype__isSymbolicLink_WithoutTypeChecks"});
- @export(Stats.mode, .{.name = "StatsPrototype__mode"});
- @export(Stats.mtime, .{.name = "StatsPrototype__mtime"});
- @export(Stats.mtimeMs, .{.name = "StatsPrototype__mtimeMs"});
- @export(Stats.nlink, .{.name = "StatsPrototype__nlink"});
- @export(Stats.rdev, .{.name = "StatsPrototype__rdev"});
- @export(Stats.size, .{.name = "StatsPrototype__size"});
- @export(Stats.uid, .{.name = "StatsPrototype__uid"});
+ @export(Stats.atime, .{ .name = "StatsPrototype__atime" });
+ @export(Stats.atimeMs, .{ .name = "StatsPrototype__atimeMs" });
+ @export(Stats.birthtime, .{ .name = "StatsPrototype__birthtime" });
+ @export(Stats.birthtimeMs, .{ .name = "StatsPrototype__birthtimeMs" });
+ @export(Stats.blksize, .{ .name = "StatsPrototype__blksize" });
+ @export(Stats.blocks, .{ .name = "StatsPrototype__blocks" });
+ @export(Stats.constructor, .{ .name = "StatsClass__construct" });
+ @export(Stats.ctime, .{ .name = "StatsPrototype__ctime" });
+ @export(Stats.ctimeMs, .{ .name = "StatsPrototype__ctimeMs" });
+ @export(Stats.dev, .{ .name = "StatsPrototype__dev" });
+ @export(Stats.finalize, .{ .name = "StatsClass__finalize" });
+ @export(Stats.gid, .{ .name = "StatsPrototype__gid" });
+ @export(Stats.ino, .{ .name = "StatsPrototype__ino" });
+ @export(Stats.isBlockDevice_, .{ .name = "StatsPrototype__isBlockDevice_" });
+ @export(Stats.isBlockDevice_WithoutTypeChecks, .{ .name = "StatsPrototype__isBlockDevice_WithoutTypeChecks" });
+ @export(Stats.isCharacterDevice_, .{ .name = "StatsPrototype__isCharacterDevice_" });
+ @export(Stats.isCharacterDevice_WithoutTypeChecks, .{ .name = "StatsPrototype__isCharacterDevice_WithoutTypeChecks" });
+ @export(Stats.isDirectory_, .{ .name = "StatsPrototype__isDirectory_" });
+ @export(Stats.isDirectory_WithoutTypeChecks, .{ .name = "StatsPrototype__isDirectory_WithoutTypeChecks" });
+ @export(Stats.isFIFO_, .{ .name = "StatsPrototype__isFIFO_" });
+ @export(Stats.isFIFO_WithoutTypeChecks, .{ .name = "StatsPrototype__isFIFO_WithoutTypeChecks" });
+ @export(Stats.isFile_, .{ .name = "StatsPrototype__isFile_" });
+ @export(Stats.isFile_WithoutTypeChecks, .{ .name = "StatsPrototype__isFile_WithoutTypeChecks" });
+ @export(Stats.isSocket_, .{ .name = "StatsPrototype__isSocket_" });
+ @export(Stats.isSocket_WithoutTypeChecks, .{ .name = "StatsPrototype__isSocket_WithoutTypeChecks" });
+ @export(Stats.isSymbolicLink_, .{ .name = "StatsPrototype__isSymbolicLink_" });
+ @export(Stats.isSymbolicLink_WithoutTypeChecks, .{ .name = "StatsPrototype__isSymbolicLink_WithoutTypeChecks" });
+ @export(Stats.mode, .{ .name = "StatsPrototype__mode" });
+ @export(Stats.mtime, .{ .name = "StatsPrototype__mtime" });
+ @export(Stats.mtimeMs, .{ .name = "StatsPrototype__mtimeMs" });
+ @export(Stats.nlink, .{ .name = "StatsPrototype__nlink" });
+ @export(Stats.rdev, .{ .name = "StatsPrototype__rdev" });
+ @export(Stats.size, .{ .name = "StatsPrototype__size" });
+ @export(Stats.uid, .{ .name = "StatsPrototype__uid" });
}
}
};
pub const JSSubprocess = struct {
const Subprocess = Classes.Subprocess;
- const GetterType = fn(*Subprocess, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Subprocess, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Subprocess, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Subprocess, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Subprocess, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Subprocess, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Subprocess, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Subprocess, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Subprocess, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Subprocess, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -3813,72 +3215,70 @@ pub const JSSubprocess = struct {
extern fn SubprocessPrototype__stderrSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn SubprocessPrototype__stderrGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Subprocess.stderr` setter
- /// This value will be visited by the garbage collector.
- pub fn stderrSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- SubprocessPrototype__stderrSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn SubprocessPrototype__stderrGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Subprocess.stderr` setter
+ /// This value will be visited by the garbage collector.
+ pub fn stderrSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ SubprocessPrototype__stderrSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Subprocess.stderr` getter
- /// This value will be visited by the garbage collector.
- pub fn stderrGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = SubprocessPrototype__stderrGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Subprocess.stderr` getter
+ /// This value will be visited by the garbage collector.
+ pub fn stderrGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = SubprocessPrototype__stderrGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn SubprocessPrototype__stdinSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn SubprocessPrototype__stdinGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Subprocess.stdin` setter
- /// This value will be visited by the garbage collector.
- pub fn stdinSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- SubprocessPrototype__stdinSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn SubprocessPrototype__stdinSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn SubprocessPrototype__stdinGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Subprocess.stdin` setter
+ /// This value will be visited by the garbage collector.
+ pub fn stdinSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ SubprocessPrototype__stdinSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Subprocess.stdin` getter
- /// This value will be visited by the garbage collector.
- pub fn stdinGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = SubprocessPrototype__stdinGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Subprocess.stdin` getter
+ /// This value will be visited by the garbage collector.
+ pub fn stdinGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = SubprocessPrototype__stdinGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn SubprocessPrototype__stdoutSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn SubprocessPrototype__stdoutGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `Subprocess.stdout` setter
- /// This value will be visited by the garbage collector.
- pub fn stdoutSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- SubprocessPrototype__stdoutSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn SubprocessPrototype__stdoutSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn SubprocessPrototype__stdoutGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Subprocess.stdout` setter
+ /// This value will be visited by the garbage collector.
+ pub fn stdoutSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ SubprocessPrototype__stdoutSetCachedValue(thisValue, globalObject, value);
+ }
- /// `Subprocess.stdout` getter
- /// This value will be visited by the garbage collector.
- pub fn stdoutGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = SubprocessPrototype__stdoutGetCachedValue(thisValue);
- if (result == .zero)
+ /// `Subprocess.stdout` getter
+ /// This value will be visited by the garbage collector.
+ pub fn stdoutGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = SubprocessPrototype__stdoutGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Create a new instance of Subprocess
pub fn toJS(this: *Subprocess, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -3893,14 +3293,14 @@ extern fn SubprocessPrototype__stdoutSetCachedValue(JSC.JSValue, *JSC.JSGlobalOb
/// Modify the internal ptr to point to a new instance of Subprocess.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Subprocess) bool {
- JSC.markBinding(@src());
- return Subprocess__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Subprocess__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Subprocess, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Subprocess__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Subprocess__dangerouslySetPtr(value, null));
}
extern fn Subprocess__fromJS(JSC.JSValue) ?*Subprocess;
@@ -3911,97 +3311,70 @@ extern fn SubprocessPrototype__stdoutSetCachedValue(JSC.JSValue, *JSC.JSGlobalOb
extern fn Subprocess__dangerouslySetPtr(JSC.JSValue, ?*Subprocess) bool;
comptime {
-
- if (@TypeOf(Subprocess.finalize) != (fn(*Subprocess) callconv(.C) void)) {
- @compileLog("Subprocess.finalize is not a finalizer");
+ if (@TypeOf(Subprocess.finalize) != (fn (*Subprocess) callconv(.C) void)) {
+ @compileLog("Subprocess.finalize is not a finalizer");
}
-
- if (@TypeOf(Subprocess.getExitCode) != GetterType)
- @compileLog(
- "Expected Subprocess.getExitCode to be a getter"
- );
-
- if (@TypeOf(Subprocess.getExited) != GetterType)
- @compileLog(
- "Expected Subprocess.getExited to be a getter"
- );
-
- if (@TypeOf(Subprocess.kill) != CallbackType)
- @compileLog(
- "Expected Subprocess.kill to be a callback but received " ++ @typeName(@TypeOf(Subprocess.kill))
- );
- if (@TypeOf(Subprocess.getKilled) != GetterType)
- @compileLog(
- "Expected Subprocess.getKilled to be a getter"
- );
-
- if (@TypeOf(Subprocess.getPid) != GetterType)
- @compileLog(
- "Expected Subprocess.getPid to be a getter"
- );
-
- if (@TypeOf(Subprocess.getStdout) != GetterType)
- @compileLog(
- "Expected Subprocess.getStdout to be a getter"
- );
-
- if (@TypeOf(Subprocess.doRef) != CallbackType)
- @compileLog(
- "Expected Subprocess.doRef to be a callback but received " ++ @typeName(@TypeOf(Subprocess.doRef))
- );
- if (@TypeOf(Subprocess.getSignalCode) != GetterType)
- @compileLog(
- "Expected Subprocess.getSignalCode to be a getter"
- );
-
- if (@TypeOf(Subprocess.getStderr) != GetterType)
- @compileLog(
- "Expected Subprocess.getStderr to be a getter"
- );
-
- if (@TypeOf(Subprocess.getStdin) != GetterType)
- @compileLog(
- "Expected Subprocess.getStdin to be a getter"
- );
-
- if (@TypeOf(Subprocess.getStdout) != GetterType)
- @compileLog(
- "Expected Subprocess.getStdout to be a getter"
- );
-
- if (@TypeOf(Subprocess.doUnref) != CallbackType)
- @compileLog(
- "Expected Subprocess.doUnref to be a callback but received " ++ @typeName(@TypeOf(Subprocess.doUnref))
- );
- if (@TypeOf(Subprocess.getStdin) != GetterType)
- @compileLog(
- "Expected Subprocess.getStdin to be a getter"
- );
+
+ if (@TypeOf(Subprocess.getExitCode) != GetterType)
+ @compileLog("Expected Subprocess.getExitCode to be a getter");
+
+ if (@TypeOf(Subprocess.getExited) != GetterType)
+ @compileLog("Expected Subprocess.getExited to be a getter");
+
+ if (@TypeOf(Subprocess.kill) != CallbackType)
+ @compileLog("Expected Subprocess.kill to be a callback but received " ++ @typeName(@TypeOf(Subprocess.kill)));
+ if (@TypeOf(Subprocess.getKilled) != GetterType)
+ @compileLog("Expected Subprocess.getKilled to be a getter");
+
+ if (@TypeOf(Subprocess.getPid) != GetterType)
+ @compileLog("Expected Subprocess.getPid to be a getter");
+
+ if (@TypeOf(Subprocess.getStdout) != GetterType)
+ @compileLog("Expected Subprocess.getStdout to be a getter");
+
+ if (@TypeOf(Subprocess.doRef) != CallbackType)
+ @compileLog("Expected Subprocess.doRef to be a callback but received " ++ @typeName(@TypeOf(Subprocess.doRef)));
+ if (@TypeOf(Subprocess.getSignalCode) != GetterType)
+ @compileLog("Expected Subprocess.getSignalCode to be a getter");
+
+ if (@TypeOf(Subprocess.getStderr) != GetterType)
+ @compileLog("Expected Subprocess.getStderr to be a getter");
+
+ if (@TypeOf(Subprocess.getStdin) != GetterType)
+ @compileLog("Expected Subprocess.getStdin to be a getter");
+
+ if (@TypeOf(Subprocess.getStdout) != GetterType)
+ @compileLog("Expected Subprocess.getStdout to be a getter");
+
+ if (@TypeOf(Subprocess.doUnref) != CallbackType)
+ @compileLog("Expected Subprocess.doUnref to be a callback but received " ++ @typeName(@TypeOf(Subprocess.doUnref)));
+ if (@TypeOf(Subprocess.getStdin) != GetterType)
+ @compileLog("Expected Subprocess.getStdin to be a getter");
if (!JSC.is_bindgen) {
-@export(Subprocess.doRef, .{.name = "SubprocessPrototype__doRef"});
- @export(Subprocess.doUnref, .{.name = "SubprocessPrototype__doUnref"});
- @export(Subprocess.finalize, .{.name = "SubprocessClass__finalize"});
- @export(Subprocess.getExitCode, .{.name = "SubprocessPrototype__getExitCode"});
- @export(Subprocess.getExited, .{.name = "SubprocessPrototype__getExited"});
- @export(Subprocess.getKilled, .{.name = "SubprocessPrototype__getKilled"});
- @export(Subprocess.getPid, .{.name = "SubprocessPrototype__getPid"});
- @export(Subprocess.getSignalCode, .{.name = "SubprocessPrototype__getSignalCode"});
- @export(Subprocess.getStderr, .{.name = "SubprocessPrototype__getStderr"});
- @export(Subprocess.getStdin, .{.name = "SubprocessPrototype__getStdin"});
- @export(Subprocess.getStdout, .{.name = "SubprocessPrototype__getStdout"});
- @export(Subprocess.hasPendingActivity, .{.name = "Subprocess__hasPendingActivity"});
- @export(Subprocess.kill, .{.name = "SubprocessPrototype__kill"});
+ @export(Subprocess.doRef, .{ .name = "SubprocessPrototype__doRef" });
+ @export(Subprocess.doUnref, .{ .name = "SubprocessPrototype__doUnref" });
+ @export(Subprocess.finalize, .{ .name = "SubprocessClass__finalize" });
+ @export(Subprocess.getExitCode, .{ .name = "SubprocessPrototype__getExitCode" });
+ @export(Subprocess.getExited, .{ .name = "SubprocessPrototype__getExited" });
+ @export(Subprocess.getKilled, .{ .name = "SubprocessPrototype__getKilled" });
+ @export(Subprocess.getPid, .{ .name = "SubprocessPrototype__getPid" });
+ @export(Subprocess.getSignalCode, .{ .name = "SubprocessPrototype__getSignalCode" });
+ @export(Subprocess.getStderr, .{ .name = "SubprocessPrototype__getStderr" });
+ @export(Subprocess.getStdin, .{ .name = "SubprocessPrototype__getStdin" });
+ @export(Subprocess.getStdout, .{ .name = "SubprocessPrototype__getStdout" });
+ @export(Subprocess.hasPendingActivity, .{ .name = "Subprocess__hasPendingActivity" });
+ @export(Subprocess.kill, .{ .name = "SubprocessPrototype__kill" });
}
}
};
pub const JSTCPSocket = struct {
const TCPSocket = Classes.TCPSocket;
- const GetterType = fn(*TCPSocket, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*TCPSocket, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*TCPSocket, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*TCPSocket, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*TCPSocket, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*TCPSocket, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*TCPSocket, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*TCPSocket, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*TCPSocket, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*TCPSocket, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -4012,50 +3385,48 @@ pub const JSTCPSocket = struct {
extern fn TCPSocketPrototype__dataSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn TCPSocketPrototype__dataGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `TCPSocket.data` setter
- /// This value will be visited by the garbage collector.
- pub fn dataSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- TCPSocketPrototype__dataSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn TCPSocketPrototype__dataGetCachedValue(JSC.JSValue) JSC.JSValue;
- /// `TCPSocket.data` getter
- /// This value will be visited by the garbage collector.
- pub fn dataGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = TCPSocketPrototype__dataGetCachedValue(thisValue);
- if (result == .zero)
+ /// `TCPSocket.data` setter
+ /// This value will be visited by the garbage collector.
+ pub fn dataSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ TCPSocketPrototype__dataSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `TCPSocket.data` getter
+ /// This value will be visited by the garbage collector.
+ pub fn dataGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = TCPSocketPrototype__dataGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn TCPSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn TCPSocketPrototype__remoteAddressGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `TCPSocket.remoteAddress` setter
- /// This value will be visited by the garbage collector.
- pub fn remoteAddressSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- TCPSocketPrototype__remoteAddressSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn TCPSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- /// `TCPSocket.remoteAddress` getter
- /// This value will be visited by the garbage collector.
- pub fn remoteAddressGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = TCPSocketPrototype__remoteAddressGetCachedValue(thisValue);
- if (result == .zero)
+ extern fn TCPSocketPrototype__remoteAddressGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `TCPSocket.remoteAddress` setter
+ /// This value will be visited by the garbage collector.
+ pub fn remoteAddressSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ TCPSocketPrototype__remoteAddressSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `TCPSocket.remoteAddress` getter
+ /// This value will be visited by the garbage collector.
+ pub fn remoteAddressGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = TCPSocketPrototype__remoteAddressGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Create a new instance of TCPSocket
pub fn toJS(this: *TCPSocket, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -4070,14 +3441,14 @@ extern fn TCPSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGl
/// Modify the internal ptr to point to a new instance of TCPSocket.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*TCPSocket) bool {
- JSC.markBinding(@src());
- return TCPSocket__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return TCPSocket__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *TCPSocket, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(TCPSocket__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(TCPSocket__dangerouslySetPtr(value, null));
}
extern fn TCPSocket__fromJS(JSC.JSValue) ?*TCPSocket;
@@ -4088,110 +3459,77 @@ extern fn TCPSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGl
extern fn TCPSocket__dangerouslySetPtr(JSC.JSValue, ?*TCPSocket) bool;
comptime {
-
- if (@TypeOf(TCPSocket.finalize) != (fn(*TCPSocket) callconv(.C) void)) {
- @compileLog("TCPSocket.finalize is not a finalizer");
- }
-
- if (@TypeOf(TCPSocket.getAuthorized) != GetterType)
- @compileLog(
- "Expected TCPSocket.getAuthorized to be a getter"
- );
-
- if (@TypeOf(TCPSocket.getData) != GetterType)
- @compileLog(
- "Expected TCPSocket.getData to be a getter"
- );
-
- if (@TypeOf(TCPSocket.setData) != SetterType)
- @compileLog(
- "Expected TCPSocket.setData to be a setter"
- );
- if (@TypeOf(TCPSocket.end) != CallbackType)
- @compileLog(
- "Expected TCPSocket.end to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.end))
- );
- if (@TypeOf(TCPSocket.flush) != CallbackType)
- @compileLog(
- "Expected TCPSocket.flush to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.flush))
- );
- if (@TypeOf(TCPSocket.getAuthorizationError) != CallbackType)
- @compileLog(
- "Expected TCPSocket.getAuthorizationError to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.getAuthorizationError))
- );
- if (@TypeOf(TCPSocket.getListener) != GetterType)
- @compileLog(
- "Expected TCPSocket.getListener to be a getter"
- );
-
- if (@TypeOf(TCPSocket.getLocalPort) != GetterType)
- @compileLog(
- "Expected TCPSocket.getLocalPort to be a getter"
- );
-
- if (@TypeOf(TCPSocket.getReadyState) != GetterType)
- @compileLog(
- "Expected TCPSocket.getReadyState to be a getter"
- );
-
- if (@TypeOf(TCPSocket.ref) != CallbackType)
- @compileLog(
- "Expected TCPSocket.ref to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.ref))
- );
- if (@TypeOf(TCPSocket.reload) != CallbackType)
- @compileLog(
- "Expected TCPSocket.reload to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.reload))
- );
- if (@TypeOf(TCPSocket.getRemoteAddress) != GetterType)
- @compileLog(
- "Expected TCPSocket.getRemoteAddress to be a getter"
- );
-
- if (@TypeOf(TCPSocket.shutdown) != CallbackType)
- @compileLog(
- "Expected TCPSocket.shutdown to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.shutdown))
- );
- if (@TypeOf(TCPSocket.timeout) != CallbackType)
- @compileLog(
- "Expected TCPSocket.timeout to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.timeout))
- );
- if (@TypeOf(TCPSocket.unref) != CallbackType)
- @compileLog(
- "Expected TCPSocket.unref to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.unref))
- );
- if (@TypeOf(TCPSocket.write) != CallbackType)
- @compileLog(
- "Expected TCPSocket.write to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.write))
- );
+ if (@TypeOf(TCPSocket.finalize) != (fn (*TCPSocket) callconv(.C) void)) {
+ @compileLog("TCPSocket.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(TCPSocket.getAuthorized) != GetterType)
+ @compileLog("Expected TCPSocket.getAuthorized to be a getter");
+
+ if (@TypeOf(TCPSocket.getData) != GetterType)
+ @compileLog("Expected TCPSocket.getData to be a getter");
+
+ if (@TypeOf(TCPSocket.setData) != SetterType)
+ @compileLog("Expected TCPSocket.setData to be a setter");
+ if (@TypeOf(TCPSocket.end) != CallbackType)
+ @compileLog("Expected TCPSocket.end to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.end)));
+ if (@TypeOf(TCPSocket.flush) != CallbackType)
+ @compileLog("Expected TCPSocket.flush to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.flush)));
+ if (@TypeOf(TCPSocket.getAuthorizationError) != CallbackType)
+ @compileLog("Expected TCPSocket.getAuthorizationError to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.getAuthorizationError)));
+ if (@TypeOf(TCPSocket.getListener) != GetterType)
+ @compileLog("Expected TCPSocket.getListener to be a getter");
+
+ if (@TypeOf(TCPSocket.getLocalPort) != GetterType)
+ @compileLog("Expected TCPSocket.getLocalPort to be a getter");
+
+ if (@TypeOf(TCPSocket.getReadyState) != GetterType)
+ @compileLog("Expected TCPSocket.getReadyState to be a getter");
+
+ if (@TypeOf(TCPSocket.ref) != CallbackType)
+ @compileLog("Expected TCPSocket.ref to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.ref)));
+ if (@TypeOf(TCPSocket.reload) != CallbackType)
+ @compileLog("Expected TCPSocket.reload to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.reload)));
+ if (@TypeOf(TCPSocket.getRemoteAddress) != GetterType)
+ @compileLog("Expected TCPSocket.getRemoteAddress to be a getter");
+
+ if (@TypeOf(TCPSocket.shutdown) != CallbackType)
+ @compileLog("Expected TCPSocket.shutdown to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.shutdown)));
+ if (@TypeOf(TCPSocket.timeout) != CallbackType)
+ @compileLog("Expected TCPSocket.timeout to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.timeout)));
+ if (@TypeOf(TCPSocket.unref) != CallbackType)
+ @compileLog("Expected TCPSocket.unref to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.unref)));
+ if (@TypeOf(TCPSocket.write) != CallbackType)
+ @compileLog("Expected TCPSocket.write to be a callback but received " ++ @typeName(@TypeOf(TCPSocket.write)));
if (!JSC.is_bindgen) {
-@export(TCPSocket.end, .{.name = "TCPSocketPrototype__end"});
- @export(TCPSocket.finalize, .{.name = "TCPSocketClass__finalize"});
- @export(TCPSocket.flush, .{.name = "TCPSocketPrototype__flush"});
- @export(TCPSocket.getAuthorizationError, .{.name = "TCPSocketPrototype__getAuthorizationError"});
- @export(TCPSocket.getAuthorized, .{.name = "TCPSocketPrototype__getAuthorized"});
- @export(TCPSocket.getData, .{.name = "TCPSocketPrototype__getData"});
- @export(TCPSocket.getListener, .{.name = "TCPSocketPrototype__getListener"});
- @export(TCPSocket.getLocalPort, .{.name = "TCPSocketPrototype__getLocalPort"});
- @export(TCPSocket.getReadyState, .{.name = "TCPSocketPrototype__getReadyState"});
- @export(TCPSocket.getRemoteAddress, .{.name = "TCPSocketPrototype__getRemoteAddress"});
- @export(TCPSocket.hasPendingActivity, .{.name = "TCPSocket__hasPendingActivity"});
- @export(TCPSocket.ref, .{.name = "TCPSocketPrototype__ref"});
- @export(TCPSocket.reload, .{.name = "TCPSocketPrototype__reload"});
- @export(TCPSocket.setData, .{.name = "TCPSocketPrototype__setData"});
- @export(TCPSocket.shutdown, .{.name = "TCPSocketPrototype__shutdown"});
- @export(TCPSocket.timeout, .{.name = "TCPSocketPrototype__timeout"});
- @export(TCPSocket.unref, .{.name = "TCPSocketPrototype__unref"});
- @export(TCPSocket.write, .{.name = "TCPSocketPrototype__write"});
+ @export(TCPSocket.end, .{ .name = "TCPSocketPrototype__end" });
+ @export(TCPSocket.finalize, .{ .name = "TCPSocketClass__finalize" });
+ @export(TCPSocket.flush, .{ .name = "TCPSocketPrototype__flush" });
+ @export(TCPSocket.getAuthorizationError, .{ .name = "TCPSocketPrototype__getAuthorizationError" });
+ @export(TCPSocket.getAuthorized, .{ .name = "TCPSocketPrototype__getAuthorized" });
+ @export(TCPSocket.getData, .{ .name = "TCPSocketPrototype__getData" });
+ @export(TCPSocket.getListener, .{ .name = "TCPSocketPrototype__getListener" });
+ @export(TCPSocket.getLocalPort, .{ .name = "TCPSocketPrototype__getLocalPort" });
+ @export(TCPSocket.getReadyState, .{ .name = "TCPSocketPrototype__getReadyState" });
+ @export(TCPSocket.getRemoteAddress, .{ .name = "TCPSocketPrototype__getRemoteAddress" });
+ @export(TCPSocket.hasPendingActivity, .{ .name = "TCPSocket__hasPendingActivity" });
+ @export(TCPSocket.ref, .{ .name = "TCPSocketPrototype__ref" });
+ @export(TCPSocket.reload, .{ .name = "TCPSocketPrototype__reload" });
+ @export(TCPSocket.setData, .{ .name = "TCPSocketPrototype__setData" });
+ @export(TCPSocket.shutdown, .{ .name = "TCPSocketPrototype__shutdown" });
+ @export(TCPSocket.timeout, .{ .name = "TCPSocketPrototype__timeout" });
+ @export(TCPSocket.unref, .{ .name = "TCPSocketPrototype__unref" });
+ @export(TCPSocket.write, .{ .name = "TCPSocketPrototype__write" });
}
}
};
pub const JSTLSSocket = struct {
const TLSSocket = Classes.TLSSocket;
- const GetterType = fn(*TLSSocket, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*TLSSocket, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*TLSSocket, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*TLSSocket, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*TLSSocket, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*TLSSocket, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*TLSSocket, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*TLSSocket, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*TLSSocket, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*TLSSocket, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -4202,50 +3540,48 @@ pub const JSTLSSocket = struct {
extern fn TLSSocketPrototype__dataSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn TLSSocketPrototype__dataGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `TLSSocket.data` setter
- /// This value will be visited by the garbage collector.
- pub fn dataSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- TLSSocketPrototype__dataSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn TLSSocketPrototype__dataGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `TLSSocket.data` setter
+ /// This value will be visited by the garbage collector.
+ pub fn dataSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ TLSSocketPrototype__dataSetCachedValue(thisValue, globalObject, value);
+ }
- /// `TLSSocket.data` getter
- /// This value will be visited by the garbage collector.
- pub fn dataGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = TLSSocketPrototype__dataGetCachedValue(thisValue);
- if (result == .zero)
+ /// `TLSSocket.data` getter
+ /// This value will be visited by the garbage collector.
+ pub fn dataGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = TLSSocketPrototype__dataGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
-extern fn TLSSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+ return result;
+ }
- extern fn TLSSocketPrototype__remoteAddressGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `TLSSocket.remoteAddress` setter
- /// This value will be visited by the garbage collector.
- pub fn remoteAddressSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- TLSSocketPrototype__remoteAddressSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn TLSSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- /// `TLSSocket.remoteAddress` getter
- /// This value will be visited by the garbage collector.
- pub fn remoteAddressGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = TLSSocketPrototype__remoteAddressGetCachedValue(thisValue);
- if (result == .zero)
+ extern fn TLSSocketPrototype__remoteAddressGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `TLSSocket.remoteAddress` setter
+ /// This value will be visited by the garbage collector.
+ pub fn remoteAddressSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ TLSSocketPrototype__remoteAddressSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `TLSSocket.remoteAddress` getter
+ /// This value will be visited by the garbage collector.
+ pub fn remoteAddressGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = TLSSocketPrototype__remoteAddressGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Create a new instance of TLSSocket
pub fn toJS(this: *TLSSocket, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -4260,14 +3596,14 @@ extern fn TLSSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGl
/// Modify the internal ptr to point to a new instance of TLSSocket.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*TLSSocket) bool {
- JSC.markBinding(@src());
- return TLSSocket__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return TLSSocket__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *TLSSocket, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(TLSSocket__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(TLSSocket__dangerouslySetPtr(value, null));
}
extern fn TLSSocket__fromJS(JSC.JSValue) ?*TLSSocket;
@@ -4278,110 +3614,77 @@ extern fn TLSSocketPrototype__remoteAddressSetCachedValue(JSC.JSValue, *JSC.JSGl
extern fn TLSSocket__dangerouslySetPtr(JSC.JSValue, ?*TLSSocket) bool;
comptime {
-
- if (@TypeOf(TLSSocket.finalize) != (fn(*TLSSocket) callconv(.C) void)) {
- @compileLog("TLSSocket.finalize is not a finalizer");
- }
-
- if (@TypeOf(TLSSocket.getAuthorized) != GetterType)
- @compileLog(
- "Expected TLSSocket.getAuthorized to be a getter"
- );
-
- if (@TypeOf(TLSSocket.getData) != GetterType)
- @compileLog(
- "Expected TLSSocket.getData to be a getter"
- );
-
- if (@TypeOf(TLSSocket.setData) != SetterType)
- @compileLog(
- "Expected TLSSocket.setData to be a setter"
- );
- if (@TypeOf(TLSSocket.end) != CallbackType)
- @compileLog(
- "Expected TLSSocket.end to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.end))
- );
- if (@TypeOf(TLSSocket.flush) != CallbackType)
- @compileLog(
- "Expected TLSSocket.flush to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.flush))
- );
- if (@TypeOf(TLSSocket.getAuthorizationError) != CallbackType)
- @compileLog(
- "Expected TLSSocket.getAuthorizationError to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.getAuthorizationError))
- );
- if (@TypeOf(TLSSocket.getListener) != GetterType)
- @compileLog(
- "Expected TLSSocket.getListener to be a getter"
- );
-
- if (@TypeOf(TLSSocket.getLocalPort) != GetterType)
- @compileLog(
- "Expected TLSSocket.getLocalPort to be a getter"
- );
-
- if (@TypeOf(TLSSocket.getReadyState) != GetterType)
- @compileLog(
- "Expected TLSSocket.getReadyState to be a getter"
- );
-
- if (@TypeOf(TLSSocket.ref) != CallbackType)
- @compileLog(
- "Expected TLSSocket.ref to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.ref))
- );
- if (@TypeOf(TLSSocket.reload) != CallbackType)
- @compileLog(
- "Expected TLSSocket.reload to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.reload))
- );
- if (@TypeOf(TLSSocket.getRemoteAddress) != GetterType)
- @compileLog(
- "Expected TLSSocket.getRemoteAddress to be a getter"
- );
-
- if (@TypeOf(TLSSocket.shutdown) != CallbackType)
- @compileLog(
- "Expected TLSSocket.shutdown to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.shutdown))
- );
- if (@TypeOf(TLSSocket.timeout) != CallbackType)
- @compileLog(
- "Expected TLSSocket.timeout to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.timeout))
- );
- if (@TypeOf(TLSSocket.unref) != CallbackType)
- @compileLog(
- "Expected TLSSocket.unref to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.unref))
- );
- if (@TypeOf(TLSSocket.write) != CallbackType)
- @compileLog(
- "Expected TLSSocket.write to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.write))
- );
+ if (@TypeOf(TLSSocket.finalize) != (fn (*TLSSocket) callconv(.C) void)) {
+ @compileLog("TLSSocket.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(TLSSocket.getAuthorized) != GetterType)
+ @compileLog("Expected TLSSocket.getAuthorized to be a getter");
+
+ if (@TypeOf(TLSSocket.getData) != GetterType)
+ @compileLog("Expected TLSSocket.getData to be a getter");
+
+ if (@TypeOf(TLSSocket.setData) != SetterType)
+ @compileLog("Expected TLSSocket.setData to be a setter");
+ if (@TypeOf(TLSSocket.end) != CallbackType)
+ @compileLog("Expected TLSSocket.end to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.end)));
+ if (@TypeOf(TLSSocket.flush) != CallbackType)
+ @compileLog("Expected TLSSocket.flush to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.flush)));
+ if (@TypeOf(TLSSocket.getAuthorizationError) != CallbackType)
+ @compileLog("Expected TLSSocket.getAuthorizationError to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.getAuthorizationError)));
+ if (@TypeOf(TLSSocket.getListener) != GetterType)
+ @compileLog("Expected TLSSocket.getListener to be a getter");
+
+ if (@TypeOf(TLSSocket.getLocalPort) != GetterType)
+ @compileLog("Expected TLSSocket.getLocalPort to be a getter");
+
+ if (@TypeOf(TLSSocket.getReadyState) != GetterType)
+ @compileLog("Expected TLSSocket.getReadyState to be a getter");
+
+ if (@TypeOf(TLSSocket.ref) != CallbackType)
+ @compileLog("Expected TLSSocket.ref to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.ref)));
+ if (@TypeOf(TLSSocket.reload) != CallbackType)
+ @compileLog("Expected TLSSocket.reload to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.reload)));
+ if (@TypeOf(TLSSocket.getRemoteAddress) != GetterType)
+ @compileLog("Expected TLSSocket.getRemoteAddress to be a getter");
+
+ if (@TypeOf(TLSSocket.shutdown) != CallbackType)
+ @compileLog("Expected TLSSocket.shutdown to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.shutdown)));
+ if (@TypeOf(TLSSocket.timeout) != CallbackType)
+ @compileLog("Expected TLSSocket.timeout to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.timeout)));
+ if (@TypeOf(TLSSocket.unref) != CallbackType)
+ @compileLog("Expected TLSSocket.unref to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.unref)));
+ if (@TypeOf(TLSSocket.write) != CallbackType)
+ @compileLog("Expected TLSSocket.write to be a callback but received " ++ @typeName(@TypeOf(TLSSocket.write)));
if (!JSC.is_bindgen) {
-@export(TLSSocket.end, .{.name = "TLSSocketPrototype__end"});
- @export(TLSSocket.finalize, .{.name = "TLSSocketClass__finalize"});
- @export(TLSSocket.flush, .{.name = "TLSSocketPrototype__flush"});
- @export(TLSSocket.getAuthorizationError, .{.name = "TLSSocketPrototype__getAuthorizationError"});
- @export(TLSSocket.getAuthorized, .{.name = "TLSSocketPrototype__getAuthorized"});
- @export(TLSSocket.getData, .{.name = "TLSSocketPrototype__getData"});
- @export(TLSSocket.getListener, .{.name = "TLSSocketPrototype__getListener"});
- @export(TLSSocket.getLocalPort, .{.name = "TLSSocketPrototype__getLocalPort"});
- @export(TLSSocket.getReadyState, .{.name = "TLSSocketPrototype__getReadyState"});
- @export(TLSSocket.getRemoteAddress, .{.name = "TLSSocketPrototype__getRemoteAddress"});
- @export(TLSSocket.hasPendingActivity, .{.name = "TLSSocket__hasPendingActivity"});
- @export(TLSSocket.ref, .{.name = "TLSSocketPrototype__ref"});
- @export(TLSSocket.reload, .{.name = "TLSSocketPrototype__reload"});
- @export(TLSSocket.setData, .{.name = "TLSSocketPrototype__setData"});
- @export(TLSSocket.shutdown, .{.name = "TLSSocketPrototype__shutdown"});
- @export(TLSSocket.timeout, .{.name = "TLSSocketPrototype__timeout"});
- @export(TLSSocket.unref, .{.name = "TLSSocketPrototype__unref"});
- @export(TLSSocket.write, .{.name = "TLSSocketPrototype__write"});
+ @export(TLSSocket.end, .{ .name = "TLSSocketPrototype__end" });
+ @export(TLSSocket.finalize, .{ .name = "TLSSocketClass__finalize" });
+ @export(TLSSocket.flush, .{ .name = "TLSSocketPrototype__flush" });
+ @export(TLSSocket.getAuthorizationError, .{ .name = "TLSSocketPrototype__getAuthorizationError" });
+ @export(TLSSocket.getAuthorized, .{ .name = "TLSSocketPrototype__getAuthorized" });
+ @export(TLSSocket.getData, .{ .name = "TLSSocketPrototype__getData" });
+ @export(TLSSocket.getListener, .{ .name = "TLSSocketPrototype__getListener" });
+ @export(TLSSocket.getLocalPort, .{ .name = "TLSSocketPrototype__getLocalPort" });
+ @export(TLSSocket.getReadyState, .{ .name = "TLSSocketPrototype__getReadyState" });
+ @export(TLSSocket.getRemoteAddress, .{ .name = "TLSSocketPrototype__getRemoteAddress" });
+ @export(TLSSocket.hasPendingActivity, .{ .name = "TLSSocket__hasPendingActivity" });
+ @export(TLSSocket.ref, .{ .name = "TLSSocketPrototype__ref" });
+ @export(TLSSocket.reload, .{ .name = "TLSSocketPrototype__reload" });
+ @export(TLSSocket.setData, .{ .name = "TLSSocketPrototype__setData" });
+ @export(TLSSocket.shutdown, .{ .name = "TLSSocketPrototype__shutdown" });
+ @export(TLSSocket.timeout, .{ .name = "TLSSocketPrototype__timeout" });
+ @export(TLSSocket.unref, .{ .name = "TLSSocketPrototype__unref" });
+ @export(TLSSocket.write, .{ .name = "TLSSocketPrototype__write" });
}
}
};
pub const JSTextDecoder = struct {
const TextDecoder = Classes.TextDecoder;
- const GetterType = fn(*TextDecoder, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*TextDecoder, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*TextDecoder, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*TextDecoder, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*TextDecoder, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*TextDecoder, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*TextDecoder, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*TextDecoder, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*TextDecoder, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*TextDecoder, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -4392,35 +3695,33 @@ pub const JSTextDecoder = struct {
extern fn TextDecoderPrototype__encodingSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
- extern fn TextDecoderPrototype__encodingGetCachedValue(JSC.JSValue) JSC.JSValue;
-
- /// `TextDecoder.encoding` setter
- /// This value will be visited by the garbage collector.
- pub fn encodingSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- TextDecoderPrototype__encodingSetCachedValue(thisValue, globalObject, value);
- }
+ extern fn TextDecoderPrototype__encodingGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `TextDecoder.encoding` setter
+ /// This value will be visited by the garbage collector.
+ pub fn encodingSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ TextDecoderPrototype__encodingSetCachedValue(thisValue, globalObject, value);
+ }
- /// `TextDecoder.encoding` getter
- /// This value will be visited by the garbage collector.
- pub fn encodingGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
- JSC.markBinding(@src());
- const result = TextDecoderPrototype__encodingGetCachedValue(thisValue);
- if (result == .zero)
+ /// `TextDecoder.encoding` getter
+ /// This value will be visited by the garbage collector.
+ pub fn encodingGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = TextDecoderPrototype__encodingGetCachedValue(thisValue);
+ if (result == .zero)
return null;
-
- return result;
- }
+ return result;
+ }
-
/// Get the TextDecoder constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return TextDecoder__getConstructor(globalObject);
}
-
+
/// Create a new instance of TextDecoder
pub fn toJS(this: *TextDecoder, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -4435,14 +3736,14 @@ pub const JSTextDecoder = struct {
/// Modify the internal ptr to point to a new instance of TextDecoder.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*TextDecoder) bool {
- JSC.markBinding(@src());
- return TextDecoder__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return TextDecoder__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *TextDecoder, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(TextDecoder__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(TextDecoder__dangerouslySetPtr(value, null));
}
extern fn TextDecoder__fromJS(JSC.JSValue) ?*TextDecoder;
@@ -4453,50 +3754,41 @@ pub const JSTextDecoder = struct {
extern fn TextDecoder__dangerouslySetPtr(JSC.JSValue, ?*TextDecoder) bool;
comptime {
-
- if (@TypeOf(TextDecoder.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*TextDecoder)) {
- @compileLog("TextDecoder.constructor is not a constructor");
+ if (@TypeOf(TextDecoder.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*TextDecoder)) {
+ @compileLog("TextDecoder.constructor is not a constructor");
}
-
- if (@TypeOf(TextDecoder.finalize) != (fn(*TextDecoder) callconv(.C) void)) {
- @compileLog("TextDecoder.finalize is not a finalizer");
+
+ if (@TypeOf(TextDecoder.finalize) != (fn (*TextDecoder) callconv(.C) void)) {
+ @compileLog("TextDecoder.finalize is not a finalizer");
}
-
- if (@TypeOf(TextDecoder.decodeWithoutTypeChecks) != fn (*TextDecoder, *JSC.JSGlobalObject, *JSC.JSUint8Array) callconv(.C) JSC.JSValue)
- @compileLog(
- "Expected TextDecoder.decodeWithoutTypeChecks to be a DOMJIT function"
- );
- if (@TypeOf(TextDecoder.decode) != CallbackType)
- @compileLog(
- "Expected TextDecoder.decode to be a callback but received " ++ @typeName(@TypeOf(TextDecoder.decode))
- );
- if (@TypeOf(TextDecoder.getEncoding) != GetterType)
- @compileLog(
- "Expected TextDecoder.getEncoding to be a getter"
- );
-
- if (@TypeOf(TextDecoder.getFatal) != GetterType)
- @compileLog(
- "Expected TextDecoder.getFatal to be a getter"
- );
+
+ if (@TypeOf(TextDecoder.decodeWithoutTypeChecks) != fn (*TextDecoder, *JSC.JSGlobalObject, *JSC.JSUint8Array) callconv(.C) JSC.JSValue)
+ @compileLog("Expected TextDecoder.decodeWithoutTypeChecks to be a DOMJIT function");
+ if (@TypeOf(TextDecoder.decode) != CallbackType)
+ @compileLog("Expected TextDecoder.decode to be a callback but received " ++ @typeName(@TypeOf(TextDecoder.decode)));
+ if (@TypeOf(TextDecoder.getEncoding) != GetterType)
+ @compileLog("Expected TextDecoder.getEncoding to be a getter");
+
+ if (@TypeOf(TextDecoder.getFatal) != GetterType)
+ @compileLog("Expected TextDecoder.getFatal to be a getter");
if (!JSC.is_bindgen) {
-@export(TextDecoder.constructor, .{.name = "TextDecoderClass__construct"});
- @export(TextDecoder.decode, .{.name = "TextDecoderPrototype__decode"});
- @export(TextDecoder.decodeWithoutTypeChecks, .{.name = "TextDecoderPrototype__decodeWithoutTypeChecks"});
- @export(TextDecoder.finalize, .{.name = "TextDecoderClass__finalize"});
- @export(TextDecoder.getEncoding, .{.name = "TextDecoderPrototype__getEncoding"});
- @export(TextDecoder.getFatal, .{.name = "TextDecoderPrototype__getFatal"});
+ @export(TextDecoder.constructor, .{ .name = "TextDecoderClass__construct" });
+ @export(TextDecoder.decode, .{ .name = "TextDecoderPrototype__decode" });
+ @export(TextDecoder.decodeWithoutTypeChecks, .{ .name = "TextDecoderPrototype__decodeWithoutTypeChecks" });
+ @export(TextDecoder.finalize, .{ .name = "TextDecoderClass__finalize" });
+ @export(TextDecoder.getEncoding, .{ .name = "TextDecoderPrototype__getEncoding" });
+ @export(TextDecoder.getFatal, .{ .name = "TextDecoderPrototype__getFatal" });
}
}
};
pub const JSTimeout = struct {
const Timeout = Classes.Timeout;
- const GetterType = fn(*Timeout, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Timeout, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Timeout, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Timeout, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Timeout, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Timeout, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Timeout, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Timeout, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Timeout, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Timeout, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -4505,9 +3797,6 @@ pub const JSTimeout = struct {
return Timeout__fromJS(value);
}
-
-
-
/// Create a new instance of Timeout
pub fn toJS(this: *Timeout, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -4522,14 +3811,14 @@ pub const JSTimeout = struct {
/// Modify the internal ptr to point to a new instance of Timeout.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Timeout) bool {
- JSC.markBinding(@src());
- return Timeout__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Timeout__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Timeout, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Timeout__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Timeout__dangerouslySetPtr(value, null));
}
extern fn Timeout__fromJS(JSC.JSValue) ?*Timeout;
@@ -4540,43 +3829,34 @@ pub const JSTimeout = struct {
extern fn Timeout__dangerouslySetPtr(JSC.JSValue, ?*Timeout) bool;
comptime {
-
- if (@TypeOf(Timeout.finalize) != (fn(*Timeout) callconv(.C) void)) {
- @compileLog("Timeout.finalize is not a finalizer");
- }
-
- if (@TypeOf(Timeout.toPrimitive) != CallbackType)
- @compileLog(
- "Expected Timeout.toPrimitive to be a callback but received " ++ @typeName(@TypeOf(Timeout.toPrimitive))
- );
- if (@TypeOf(Timeout.hasRef) != CallbackType)
- @compileLog(
- "Expected Timeout.hasRef to be a callback but received " ++ @typeName(@TypeOf(Timeout.hasRef))
- );
- if (@TypeOf(Timeout.doRef) != CallbackType)
- @compileLog(
- "Expected Timeout.doRef to be a callback but received " ++ @typeName(@TypeOf(Timeout.doRef))
- );
- if (@TypeOf(Timeout.doUnref) != CallbackType)
- @compileLog(
- "Expected Timeout.doUnref to be a callback but received " ++ @typeName(@TypeOf(Timeout.doUnref))
- );
+ if (@TypeOf(Timeout.finalize) != (fn (*Timeout) callconv(.C) void)) {
+ @compileLog("Timeout.finalize is not a finalizer");
+ }
+
+ if (@TypeOf(Timeout.toPrimitive) != CallbackType)
+ @compileLog("Expected Timeout.toPrimitive to be a callback but received " ++ @typeName(@TypeOf(Timeout.toPrimitive)));
+ if (@TypeOf(Timeout.hasRef) != CallbackType)
+ @compileLog("Expected Timeout.hasRef to be a callback but received " ++ @typeName(@TypeOf(Timeout.hasRef)));
+ if (@TypeOf(Timeout.doRef) != CallbackType)
+ @compileLog("Expected Timeout.doRef to be a callback but received " ++ @typeName(@TypeOf(Timeout.doRef)));
+ if (@TypeOf(Timeout.doUnref) != CallbackType)
+ @compileLog("Expected Timeout.doUnref to be a callback but received " ++ @typeName(@TypeOf(Timeout.doUnref)));
if (!JSC.is_bindgen) {
-@export(Timeout.doRef, .{.name = "TimeoutPrototype__doRef"});
- @export(Timeout.doUnref, .{.name = "TimeoutPrototype__doUnref"});
- @export(Timeout.finalize, .{.name = "TimeoutClass__finalize"});
- @export(Timeout.hasRef, .{.name = "TimeoutPrototype__hasRef"});
- @export(Timeout.toPrimitive, .{.name = "TimeoutPrototype__toPrimitive"});
+ @export(Timeout.doRef, .{ .name = "TimeoutPrototype__doRef" });
+ @export(Timeout.doUnref, .{ .name = "TimeoutPrototype__doUnref" });
+ @export(Timeout.finalize, .{ .name = "TimeoutClass__finalize" });
+ @export(Timeout.hasRef, .{ .name = "TimeoutPrototype__hasRef" });
+ @export(Timeout.toPrimitive, .{ .name = "TimeoutPrototype__toPrimitive" });
}
}
};
pub const JSTranspiler = struct {
const Transpiler = Classes.Transpiler;
- const GetterType = fn(*Transpiler, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const GetterTypeWithThisValue = fn(*Transpiler, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
- const SetterType = fn(*Transpiler, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const SetterTypeWithThisValue = fn(*Transpiler, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
- const CallbackType = fn(*Transpiler, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
+ const GetterType = fn (*Transpiler, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const GetterTypeWithThisValue = fn (*Transpiler, JSC.JSValue, *JSC.JSGlobalObject) callconv(.C) JSC.JSValue;
+ const SetterType = fn (*Transpiler, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const SetterTypeWithThisValue = fn (*Transpiler, JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) callconv(.C) bool;
+ const CallbackType = fn (*Transpiler, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) JSC.JSValue;
/// Return the pointer to the wrapped object.
/// If the object does not match the type, return null.
@@ -4585,16 +3865,13 @@ pub const JSTranspiler = struct {
return Transpiler__fromJS(value);
}
-
-
-
/// Get the Transpiler constructor value.
/// This loads lazily from the global object.
pub fn getConstructor(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
return Transpiler__getConstructor(globalObject);
}
-
+
/// Create a new instance of Transpiler
pub fn toJS(this: *Transpiler, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -4609,14 +3886,14 @@ pub const JSTranspiler = struct {
/// Modify the internal ptr to point to a new instance of Transpiler.
pub fn dangerouslySetPtr(value: JSC.JSValue, ptr: ?*Transpiler) bool {
- JSC.markBinding(@src());
- return Transpiler__dangerouslySetPtr(value, ptr);
+ JSC.markBinding(@src());
+ return Transpiler__dangerouslySetPtr(value, ptr);
}
/// Detach the ptr from the thisValue
pub fn detachPtr(_: *Transpiler, value: JSC.JSValue) void {
- JSC.markBinding(@src());
- std.debug.assert(Transpiler__dangerouslySetPtr(value, null));
+ JSC.markBinding(@src());
+ std.debug.assert(Transpiler__dangerouslySetPtr(value, null));
}
extern fn Transpiler__fromJS(JSC.JSValue) ?*Transpiler;
@@ -4627,70 +3904,60 @@ pub const JSTranspiler = struct {
extern fn Transpiler__dangerouslySetPtr(JSC.JSValue, ?*Transpiler) bool;
comptime {
-
- if (@TypeOf(Transpiler.constructor) != (fn(*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Transpiler)) {
- @compileLog("Transpiler.constructor is not a constructor");
+ if (@TypeOf(Transpiler.constructor) != (fn (*JSC.JSGlobalObject, *JSC.CallFrame) callconv(.C) ?*Transpiler)) {
+ @compileLog("Transpiler.constructor is not a constructor");
}
-
- if (@TypeOf(Transpiler.finalize) != (fn(*Transpiler) callconv(.C) void)) {
- @compileLog("Transpiler.finalize is not a finalizer");
+
+ if (@TypeOf(Transpiler.finalize) != (fn (*Transpiler) callconv(.C) void)) {
+ @compileLog("Transpiler.finalize is not a finalizer");
}
-
- if (@TypeOf(Transpiler.scan) != CallbackType)
- @compileLog(
- "Expected Transpiler.scan to be a callback but received " ++ @typeName(@TypeOf(Transpiler.scan))
- );
- if (@TypeOf(Transpiler.scanImports) != CallbackType)
- @compileLog(
- "Expected Transpiler.scanImports to be a callback but received " ++ @typeName(@TypeOf(Transpiler.scanImports))
- );
- if (@TypeOf(Transpiler.transform) != CallbackType)
- @compileLog(
- "Expected Transpiler.transform to be a callback but received " ++ @typeName(@TypeOf(Transpiler.transform))
- );
- if (@TypeOf(Transpiler.transformSync) != CallbackType)
- @compileLog(
- "Expected Transpiler.transformSync to be a callback but received " ++ @typeName(@TypeOf(Transpiler.transformSync))
- );
+
+ if (@TypeOf(Transpiler.scan) != CallbackType)
+ @compileLog("Expected Transpiler.scan to be a callback but received " ++ @typeName(@TypeOf(Transpiler.scan)));
+ if (@TypeOf(Transpiler.scanImports) != CallbackType)
+ @compileLog("Expected Transpiler.scanImports to be a callback but received " ++ @typeName(@TypeOf(Transpiler.scanImports)));
+ if (@TypeOf(Transpiler.transform) != CallbackType)
+ @compileLog("Expected Transpiler.transform to be a callback but received " ++ @typeName(@TypeOf(Transpiler.transform)));
+ if (@TypeOf(Transpiler.transformSync) != CallbackType)
+ @compileLog("Expected Transpiler.transformSync to be a callback but received " ++ @typeName(@TypeOf(Transpiler.transformSync)));
if (!JSC.is_bindgen) {
-@export(Transpiler.constructor, .{.name = "TranspilerClass__construct"});
- @export(Transpiler.finalize, .{.name = "TranspilerClass__finalize"});
- @export(Transpiler.scan, .{.name = "TranspilerPrototype__scan"});
- @export(Transpiler.scanImports, .{.name = "TranspilerPrototype__scanImports"});
- @export(Transpiler.transform, .{.name = "TranspilerPrototype__transform"});
- @export(Transpiler.transformSync, .{.name = "TranspilerPrototype__transformSync"});
+ @export(Transpiler.constructor, .{ .name = "TranspilerClass__construct" });
+ @export(Transpiler.finalize, .{ .name = "TranspilerClass__finalize" });
+ @export(Transpiler.scan, .{ .name = "TranspilerPrototype__scan" });
+ @export(Transpiler.scanImports, .{ .name = "TranspilerPrototype__scanImports" });
+ @export(Transpiler.transform, .{ .name = "TranspilerPrototype__transform" });
+ @export(Transpiler.transformSync, .{ .name = "TranspilerPrototype__transformSync" });
}
}
};
comptime {
- _ = JSBlob;
- _ = JSCryptoHasher;
- _ = JSDirent;
- _ = JSExpect;
- _ = JSExpectAny;
- _ = JSFileSystemRouter;
- _ = JSListener;
- _ = JSMD4;
- _ = JSMD5;
- _ = JSMatchedRoute;
- _ = JSNodeJSFS;
- _ = JSRequest;
- _ = JSResponse;
- _ = JSSHA1;
- _ = JSSHA224;
- _ = JSSHA256;
- _ = JSSHA384;
- _ = JSSHA512;
- _ = JSSHA512_256;
- _ = JSServerWebSocket;
- _ = JSStats;
- _ = JSSubprocess;
- _ = JSTCPSocket;
- _ = JSTLSSocket;
- _ = JSTextDecoder;
- _ = JSTimeout;
- _ = JSTranspiler;
+ _ = JSBlob;
+ _ = JSBundler;
+ _ = JSCryptoHasher;
+ _ = JSDirent;
+ _ = JSExpect;
+ _ = JSExpectAny;
+ _ = JSFileSystemRouter;
+ _ = JSListener;
+ _ = JSMD4;
+ _ = JSMD5;
+ _ = JSMatchedRoute;
+ _ = JSNodeJSFS;
+ _ = JSRequest;
+ _ = JSResponse;
+ _ = JSSHA1;
+ _ = JSSHA224;
+ _ = JSSHA256;
+ _ = JSSHA384;
+ _ = JSSHA512;
+ _ = JSSHA512_256;
+ _ = JSServerWebSocket;
+ _ = JSStats;
+ _ = JSSubprocess;
+ _ = JSTCPSocket;
+ _ = JSTLSSocket;
+ _ = JSTextDecoder;
+ _ = JSTimeout;
+ _ = JSTranspiler;
}
-
- \ No newline at end of file
diff --git a/src/bun.js/bindings/generated_classes_list.zig b/src/bun.js/bindings/generated_classes_list.zig
index 3c895e219..267905086 100644
--- a/src/bun.js/bindings/generated_classes_list.zig
+++ b/src/bun.js/bindings/generated_classes_list.zig
@@ -1,31 +1,34 @@
const JSC = @import("bun").JSC;
pub const Classes = struct {
+ pub const Blob = JSC.WebCore.Blob;
+ pub const CryptoHasher = JSC.API.Bun.Crypto.CryptoHasher;
+ pub const Dirent = JSC.Node.Dirent;
+ pub const Expect = JSC.Jest.Expect;
+ pub const ExpectAny = JSC.Jest.ExpectAny;
+ pub const FileSystemRouter = JSC.API.FileSystemRouter;
+ pub const Bundler = JSC.API.JSBundler;
+ pub const JSBundler = Bundler;
+ pub const Transpiler = JSC.API.JSTranspiler;
+ pub const JSTranspiler = Transpiler;
+ pub const Listener = JSC.API.Listener;
+ pub const MD4 = JSC.API.Bun.Crypto.MD4;
+ pub const MD5 = JSC.API.Bun.Crypto.MD5;
+ pub const MatchedRoute = JSC.API.MatchedRoute;
+ pub const NodeJSFS = JSC.Node.NodeJSFS;
pub const Request = JSC.WebCore.Request;
pub const Response = JSC.WebCore.Response;
pub const SHA1 = JSC.API.Bun.Crypto.SHA1;
- pub const MD5 = JSC.API.Bun.Crypto.MD5;
- pub const MD4 = JSC.API.Bun.Crypto.MD4;
pub const SHA224 = JSC.API.Bun.Crypto.SHA224;
- pub const SHA512 = JSC.API.Bun.Crypto.SHA512;
- pub const SHA384 = JSC.API.Bun.Crypto.SHA384;
pub const SHA256 = JSC.API.Bun.Crypto.SHA256;
+ pub const SHA384 = JSC.API.Bun.Crypto.SHA384;
+ pub const SHA512 = JSC.API.Bun.Crypto.SHA512;
pub const SHA512_256 = JSC.API.Bun.Crypto.SHA512_256;
- pub const CryptoHasher = JSC.API.Bun.Crypto.CryptoHasher;
- pub const TextDecoder = JSC.WebCore.TextDecoder;
- pub const Blob = JSC.WebCore.Blob;
- pub const Subprocess = JSC.Subprocess;
pub const ServerWebSocket = JSC.API.ServerWebSocket;
+ pub const Stats = JSC.Node.Stats;
+ pub const Subprocess = JSC.Subprocess;
pub const TCPSocket = JSC.API.TCPSocket;
pub const TLSSocket = JSC.API.TLSSocket;
- pub const Listener = JSC.API.Listener;
- pub const Expect = JSC.Jest.Expect;
- pub const ExpectAny = JSC.Jest.ExpectAny;
- pub const FileSystemRouter = JSC.API.FileSystemRouter;
- pub const MatchedRoute = JSC.API.MatchedRoute;
- pub const Dirent = JSC.Node.Dirent;
- pub const NodeJSFS = JSC.Node.NodeJSFS;
- pub const Transpiler = JSC.API.Transpiler;
- pub const Stats = JSC.Node.Stats;
+ pub const TextDecoder = JSC.WebCore.TextDecoder;
pub const Timeout = JSC.API.Bun.Timer.TimerObject;
};
diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig
index 6928cd2b8..35ba93eaa 100644
--- a/src/bun.js/event_loop.zig
+++ b/src/bun.js/event_loop.zig
@@ -12,7 +12,7 @@ const Bun = JSC.API.Bun;
const TaggedPointerUnion = @import("../tagged_pointer.zig").TaggedPointerUnion;
const typeBaseName = @import("../meta.zig").typeBaseName;
const CopyFilePromiseTask = WebCore.Blob.Store.CopyFile.CopyFilePromiseTask;
-const AsyncTransformTask = @import("./api/transpiler.zig").TransformTask.AsyncTransformTask;
+const AsyncTransformTask = JSC.API.JSTranspiler.TransformTask.AsyncTransformTask;
const ReadFileTask = WebCore.Blob.Store.ReadFile.ReadFileTask;
const WriteFileTask = WebCore.Blob.Store.WriteFile.WriteFileTask;
const napi_async_work = JSC.napi.napi_async_work;
@@ -154,7 +154,9 @@ pub const AnyTask = struct {
pub fn run(this: *AnyTask) void {
@setRuntimeSafety(false);
- this.callback(this.ctx.?);
+ var callback = this.callback;
+ var ctx = this.ctx;
+ callback(ctx.?);
}
pub fn New(comptime Type: type, comptime Callback: anytype) type {
@@ -167,7 +169,42 @@ pub const AnyTask = struct {
}
pub fn wrap(this: ?*anyopaque) void {
- Callback(@ptrCast(*Type, @alignCast(@alignOf(Type), this.?)));
+ @call(.always_inline, Callback, .{@ptrCast(*Type, @alignCast(@alignOf(Type), this.?))});
+ }
+ };
+ }
+};
+
+pub const AnyTaskWithExtraContext = struct {
+ ctx: ?*anyopaque,
+ callback: *const (fn (*anyopaque, *anyopaque) void),
+ next: ?*AnyTaskWithExtraContext = null,
+
+ pub fn run(this: *AnyTaskWithExtraContext, extra: *anyopaque) void {
+ @setRuntimeSafety(false);
+ var callback = this.callback;
+ var ctx = this.ctx;
+ callback(ctx.?, extra);
+ }
+
+ pub fn New(comptime Type: type, comptime ContextType: type, comptime Callback: anytype) type {
+ return struct {
+ pub fn init(ctx: *Type) AnyTaskWithExtraContext {
+ return AnyTaskWithExtraContext{
+ .callback = wrap,
+ .ctx = ctx,
+ };
+ }
+
+ pub fn wrap(this: ?*anyopaque, extra: ?*anyopaque) void {
+ @call(
+ .always_inline,
+ Callback,
+ .{
+ @ptrCast(*Type, @alignCast(@alignOf(Type), this.?)),
+ @ptrCast(*ContextType, @alignCast(@alignOf(ContextType), extra.?)),
+ },
+ );
}
};
}
@@ -411,7 +448,7 @@ pub const EventLoop = struct {
transform_task.*.runFromJS();
transform_task.deinit();
},
- .HotReloadTask => {
+ @field(Task.Tag, @typeName(HotReloadTask)) => {
var transform_task: *HotReloadTask = task.get(HotReloadTask).?;
transform_task.*.run();
transform_task.deinit();
@@ -673,3 +710,174 @@ pub const EventLoop = struct {
}
}
};
+
+pub const MiniEventLoop = struct {
+ tasks: Queue,
+ concurrent_tasks: UnboundedQueue(AnyTaskWithExtraContext, .next) = .{},
+ loop: *uws.Loop,
+ allocator: std.mem.Allocator,
+
+ const Queue = std.fifo.LinearFifo(*AnyTaskWithExtraContext, .Dynamic);
+
+ pub const Task = AnyTaskWithExtraContext;
+
+ pub fn init(
+ allocator: std.mem.Allocator,
+ ) MiniEventLoop {
+ return .{
+ .tasks = Queue.init(allocator),
+ .allocator = allocator,
+ .loop = uws.Loop.get().?,
+ };
+ }
+
+ pub fn deinit(this: *MiniEventLoop) void {
+ this.tasks.deinit();
+ std.debug.assert(this.concurrent_tasks.isEmpty());
+ }
+
+ pub fn tickConcurrentWithCount(this: *MiniEventLoop) usize {
+ var concurrent = this.concurrent_tasks.popBatch();
+ const count = concurrent.count;
+ if (count == 0)
+ return 0;
+
+ var iter = concurrent.iterator();
+ const start_count = this.tasks.count;
+ if (start_count == 0) {
+ this.tasks.head = 0;
+ }
+
+ this.tasks.ensureUnusedCapacity(count) catch unreachable;
+ var writable = this.tasks.writableSlice(0);
+ while (iter.next()) |task| {
+ writable[0] = task;
+ writable = writable[1..];
+ this.tasks.count += 1;
+ if (writable.len == 0) break;
+ }
+
+ return this.tasks.count - start_count;
+ }
+
+ pub fn tick(
+ this: *MiniEventLoop,
+ context: *anyopaque,
+ ) void {
+ while (true) {
+ _ = this.tickConcurrentWithCount();
+ while (this.tasks.readItem()) |task| {
+ task.run(context);
+ }
+
+ if (this.tickConcurrentWithCount() == 0) {
+ if (this.loop.active > 0 or this.loop.num_polls > 0) {
+ this.loop.run();
+ continue;
+ }
+
+ break;
+ }
+ }
+ }
+
+ pub fn enqueueTask(
+ this: *MiniEventLoop,
+ comptime Context: type,
+ ctx: *Context,
+ comptime Callback: fn (*Context) void,
+ comptime field: std.meta.FieldEnum(Context),
+ ) void {
+ const TaskType = MiniEventLoop.Task.New(Context, Callback);
+ @field(ctx, @tagName(field)) = TaskType.init(ctx);
+ this.enqueueJSCTask(&@field(ctx, @tagName(field)));
+ }
+
+ pub fn enqueueTaskConcurrent(
+ this: *MiniEventLoop,
+ comptime Context: type,
+ comptime ParentContext: type,
+ ctx: *Context,
+ comptime Callback: fn (*Context, *ParentContext) void,
+ comptime field: std.meta.FieldEnum(Context),
+ ) void {
+ JSC.markBinding(@src());
+ const TaskType = MiniEventLoop.Task.New(Context, ParentContext, Callback);
+ @field(ctx, @tagName(field)) = TaskType.init(ctx);
+
+ this.concurrent_tasks.push(&@field(ctx, @tagName(field)));
+
+ this.loop.wakeup();
+ }
+};
+
+pub const AnyEventLoop = union(enum) {
+ jsc: *EventLoop,
+ mini: MiniEventLoop,
+
+ pub const Task = AnyTaskWithExtraContext;
+
+ pub fn fromJSC(
+ this: *AnyEventLoop,
+ jsc: *EventLoop,
+ ) void {
+ this.* = .{ .jsc = jsc };
+ }
+
+ pub fn init(
+ allocator: std.mem.Allocator,
+ ) AnyEventLoop {
+ return .{ .mini = MiniEventLoop.init(allocator) };
+ }
+
+ // pub fn enqueueTask(
+ // this: *AnyEventLoop,
+ // comptime Context: type,
+ // ctx: *Context,
+ // comptime Callback: fn (*Context) void,
+ // comptime field: std.meta.FieldEnum(Context),
+ // ) void {
+ // const TaskType = MiniEventLoop.Task.New(Context, Callback);
+ // @field(ctx, field) = TaskType.init(ctx);
+ // this.enqueueTaskConcurrent(&@field(ctx, field));
+ // }
+
+ pub fn tick(
+ this: *AnyEventLoop,
+ context: *anyopaque,
+ ) void {
+ switch (this.*) {
+ .jsc => {
+ this.jsc.tick();
+ this.jsc.autoTick();
+ },
+ .mini => {
+ this.mini.tick(context);
+ },
+ }
+ }
+
+ pub fn enqueueTaskConcurrent(
+ this: *AnyEventLoop,
+ comptime Context: type,
+ comptime ParentContext: type,
+ ctx: *Context,
+ comptime Callback: fn (*Context, *ParentContext) void,
+ comptime field: std.meta.FieldEnum(Context),
+ ) void {
+ switch (this.*) {
+ .jsc => {
+ unreachable; // TODO:
+ // const TaskType = AnyTask.New(Context, Callback);
+ // @field(ctx, field) = TaskType.init(ctx);
+ // var concurrent = bun.default_allocator.create(ConcurrentTask) catch unreachable;
+ // _ = concurrent.from(JSC.Task.init(&@field(ctx, field)));
+ // concurrent.auto_delete = true;
+ // this.jsc.enqueueTaskConcurrent(concurrent);
+ },
+ .mini => {
+ this.mini.enqueueTaskConcurrent(Context, ParentContext, ctx, Callback, field);
+ },
+ }
+ }
+};
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index 39cead99f..f57f53fd6 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -79,7 +79,6 @@ const VM = @import("bun").JSC.VM;
const JSFunction = @import("bun").JSC.JSFunction;
const Config = @import("./config.zig");
const URL = @import("../url.zig").URL;
-const Transpiler = @import("./api/transpiler.zig");
const Bun = JSC.API.Bun;
const EventLoop = JSC.EventLoop;
const PendingResolution = @import("../resolver/resolver.zig").PendingResolution;
@@ -2730,290 +2729,315 @@ pub const BuildError = struct {
};
pub const JSPrivateDataTag = JSPrivateDataPtr.Tag;
+pub const HotReloader = NewHotReloader(VirtualMachine, JSC.EventLoop, false);
+pub const Watcher = HotReloader.Watcher;
-pub const Watcher = @import("../watcher.zig").NewWatcher(*HotReloader);
+pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime reload_immediately: bool) type {
+ return struct {
+ const watcher = @import("../watcher.zig");
+ pub const Watcher = watcher.NewWatcher(*@This());
+ const Reloader = @This();
-pub const HotReloader = struct {
- const watcher = @import("../watcher.zig");
+ onAccept: std.ArrayHashMapUnmanaged(@This().Watcher.HashType, bun.BabyList(OnAcceptCallback), bun.ArrayIdentityContext, false) = .{},
+ ctx: *Ctx,
+ verbose: bool = false,
- onAccept: std.ArrayHashMapUnmanaged(Watcher.HashType, bun.BabyList(OnAcceptCallback), bun.ArrayIdentityContext, false) = .{},
- vm: *JSC.VirtualMachine,
- verbose: bool = false,
+ tombstones: std.StringHashMapUnmanaged(*bun.fs.FileSystem.RealFS.EntriesOption) = .{},
- tombstones: std.StringHashMapUnmanaged(*bun.fs.FileSystem.RealFS.EntriesOption) = .{},
+ pub fn eventLoop(this: @This()) *EventLoopType {
+ return this.ctx.eventLoop();
+ }
- pub const HotReloadTask = struct {
- reloader: *HotReloader,
- count: u8 = 0,
- hashes: [8]u32 = [_]u32{0} ** 8,
- concurrent_task: JSC.ConcurrentTask = undefined,
+ pub fn enqueueTaskConcurrent(this: @This(), task: *JSC.ConcurrentTask) void {
+ if (comptime reload_immediately)
+ unreachable;
- pub fn append(this: *HotReloadTask, id: u32) void {
- if (this.count == 8) {
- this.enqueue();
- var reloader = this.reloader;
- this.* = .{
- .reloader = reloader,
- .count = 0,
- };
+ this.eventLoop().enqueueTaskConcurrent(task);
+ }
+
+ pub const HotReloadTask = struct {
+ reloader: *Reloader,
+ count: u8 = 0,
+ hashes: [8]u32 = [_]u32{0} ** 8,
+ concurrent_task: JSC.ConcurrentTask = undefined,
+
+ pub fn append(this: *HotReloadTask, id: u32) void {
+ if (this.count == 8) {
+ this.enqueue();
+ var reloader = this.reloader;
+ this.* = .{
+ .reloader = reloader,
+ .count = 0,
+ };
+ }
+
+ this.hashes[this.count] = id;
+ this.count += 1;
}
- this.hashes[this.count] = id;
- this.count += 1;
- }
+ pub fn run(this: *HotReloadTask) void {
+ this.reloader.ctx.reload();
+ }
- pub fn run(this: *HotReloadTask) void {
- this.reloader.vm.reload();
+ pub fn enqueue(this: *HotReloadTask) void {
+ if (this.count == 0)
+ return;
+
+ if (comptime reload_immediately) {
+ bun.reloadProcess(bun.default_allocator, Output.enable_ansi_colors);
+ unreachable;
+ }
+
+ var that = bun.default_allocator.create(HotReloadTask) catch unreachable;
+
+ that.* = this.*;
+ this.count = 0;
+ that.concurrent_task.task = Task.init(that);
+ this.reloader.enqueueTaskConcurrent(&that.concurrent_task);
+ }
+
+ pub fn deinit(this: *HotReloadTask) void {
+ bun.default_allocator.destroy(this);
+ }
+ };
+
+ fn NewCallback(comptime FunctionSignature: type) type {
+ return union(enum) {
+ javascript_callback: JSC.Strong,
+ zig_callback: struct {
+ ptr: *anyopaque,
+ function: *const FunctionSignature,
+ },
+ };
}
- pub fn enqueue(this: *HotReloadTask) void {
- if (this.count == 0)
+ pub const OnAcceptCallback = NewCallback(fn (
+ vm: *JSC.VirtualMachine,
+ specifier: []const u8,
+ ) void);
+
+ pub fn enableHotModuleReloading(this: *Ctx) void {
+ if (this.bun_watcher != null)
return;
- var that = bun.default_allocator.create(HotReloadTask) catch unreachable;
- that.* = this.*;
- this.count = 0;
- that.concurrent_task.task = Task.init(that);
- that.reloader.vm.eventLoop().enqueueTaskConcurrent(&that.concurrent_task);
- }
+ var reloader = bun.default_allocator.create(Reloader) catch @panic("OOM");
+ reloader.* = .{
+ .ctx = this,
+ .verbose = if (@hasField(Ctx, "log")) this.log.level.atLeast(.info) else false,
+ };
+ this.bun_watcher = @This().Watcher.init(
+ reloader,
+ this.bundler.fs,
+ bun.default_allocator,
+ ) catch @panic("Failed to enable File Watcher");
+
+ this.bundler.resolver.watcher = Resolver.ResolveWatcher(*@This().Watcher, onMaybeWatchDirectory).init(this.bun_watcher.?);
- pub fn deinit(this: *HotReloadTask) void {
- bun.default_allocator.destroy(this);
+ this.bun_watcher.?.start() catch @panic("Failed to start File Watcher");
}
- };
- fn NewCallback(comptime FunctionSignature: type) type {
- return union(enum) {
- javascript_callback: JSC.Strong,
- zig_callback: struct {
- ptr: *anyopaque,
- function: *const FunctionSignature,
- },
- };
- }
+ pub fn onMaybeWatchDirectory(watch: *@This().Watcher, file_path: string, dir_fd: StoredFileDescriptorType) void {
+ // We don't want to watch:
+ // - Directories outside the root directory
+ // - Directories inside node_modules
+ if (std.mem.indexOf(u8, file_path, "node_modules") == null and std.mem.indexOf(u8, file_path, watch.fs.top_level_dir) != null) {
+ watch.addDirectory(dir_fd, file_path, @This().Watcher.getHash(file_path), false) catch {};
+ }
+ }
- pub const OnAcceptCallback = NewCallback(fn (
- vm: *JSC.VirtualMachine,
- specifier: []const u8,
- ) void);
+ fn putTombstone(this: *@This(), key: []const u8, value: *bun.fs.FileSystem.RealFS.EntriesOption) void {
+ this.tombstones.put(bun.default_allocator, key, value) catch unreachable;
+ }
- pub fn enableHotModuleReloading(this: *VirtualMachine) void {
- if (this.bun_watcher != null)
- return;
+ fn getTombstone(this: *@This(), key: []const u8) ?*bun.fs.FileSystem.RealFS.EntriesOption {
+ return this.tombstones.get(key);
+ }
- var reloader = bun.default_allocator.create(HotReloader) catch @panic("OOM");
- reloader.* = .{
- .vm = this,
- .verbose = this.log.level.atLeast(.info),
- };
- this.bun_watcher = JSC.Watcher.init(
- reloader,
- this.bundler.fs,
- bun.default_allocator,
- ) catch @panic("Failed to enable File Watcher");
+ pub fn onFileUpdate(
+ this: *@This(),
+ events: []watcher.WatchEvent,
+ changed_files: []?[:0]u8,
+ watchlist: watcher.Watchlist,
+ ) void {
+ var slice = watchlist.slice();
+ const file_paths = slice.items(.file_path);
+ var counts = slice.items(.count);
+ const kinds = slice.items(.kind);
+ const hashes = slice.items(.hash);
+ const parents = slice.items(.parent_hash);
+ var file_descriptors = slice.items(.fd);
+ var ctx = this.ctx.bun_watcher.?;
+ defer ctx.flushEvictions();
+ defer Output.flush();
- this.bundler.resolver.watcher = Resolver.ResolveWatcher(*Watcher, onMaybeWatchDirectory).init(this.bun_watcher.?);
+ var bundler = if (@TypeOf(this.ctx.bundler) == *bun.Bundler)
+ this.ctx.bundler
+ else
+ &this.ctx.bundler;
- this.bun_watcher.?.start() catch @panic("Failed to start File Watcher");
- }
+ var fs: *Fs.FileSystem = bundler.fs;
+ var rfs: *Fs.FileSystem.RealFS = &fs.fs;
+ var resolver = &bundler.resolver;
+ var _on_file_update_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
- pub fn onMaybeWatchDirectory(watch: *Watcher, file_path: string, dir_fd: StoredFileDescriptorType) void {
- // We don't want to watch:
- // - Directories outside the root directory
- // - Directories inside node_modules
- if (std.mem.indexOf(u8, file_path, "node_modules") == null and std.mem.indexOf(u8, file_path, watch.fs.top_level_dir) != null) {
- watch.addDirectory(dir_fd, file_path, Watcher.getHash(file_path), false) catch {};
- }
- }
+ var current_task: HotReloadTask = .{
+ .reloader = this,
+ };
+ defer current_task.enqueue();
- fn putTombstone(this: *HotReloader, key: []const u8, value: *bun.fs.FileSystem.RealFS.EntriesOption) void {
- this.tombstones.put(bun.default_allocator, key, value) catch unreachable;
- }
+ for (events) |event| {
+ const file_path = file_paths[event.index];
+ const update_count = counts[event.index] + 1;
+ counts[event.index] = update_count;
+ const kind = kinds[event.index];
- fn getTombstone(this: *HotReloader, key: []const u8) ?*bun.fs.FileSystem.RealFS.EntriesOption {
- return this.tombstones.get(key);
- }
+ // so it's consistent with the rest
+ // if we use .extname we might run into an issue with whether or not the "." is included.
+ // const path = Fs.PathName.init(file_path);
+ const id = hashes[event.index];
- pub fn onFileUpdate(
- this: *HotReloader,
- events: []watcher.WatchEvent,
- changed_files: []?[:0]u8,
- watchlist: watcher.Watchlist,
- ) void {
- var slice = watchlist.slice();
- const file_paths = slice.items(.file_path);
- var counts = slice.items(.count);
- const kinds = slice.items(.kind);
- const hashes = slice.items(.hash);
- const parents = slice.items(.parent_hash);
- var file_descriptors = slice.items(.fd);
- var ctx = this.vm.bun_watcher.?;
- defer ctx.flushEvictions();
- defer Output.flush();
-
- var bundler = &this.vm.bundler;
- var fs: *Fs.FileSystem = bundler.fs;
- var rfs: *Fs.FileSystem.RealFS = &fs.fs;
- var resolver = &bundler.resolver;
- var _on_file_update_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
-
- var current_task: HotReloadTask = .{
- .reloader = this,
- };
- defer current_task.enqueue();
+ if (comptime Environment.isDebug) {
+ Output.prettyErrorln("[watch] {s} ({s}, {})", .{ file_path, @tagName(kind), event.op });
+ }
- for (events) |event| {
- const file_path = file_paths[event.index];
- const update_count = counts[event.index] + 1;
- counts[event.index] = update_count;
- const kind = kinds[event.index];
+ switch (kind) {
+ .file => {
+ if (event.op.delete or event.op.rename) {
+ ctx.removeAtIndex(
+ event.index,
+ 0,
+ &.{},
+ .file,
+ );
+ }
- // so it's consistent with the rest
- // if we use .extname we might run into an issue with whether or not the "." is included.
- // const path = Fs.PathName.init(file_path);
- const id = hashes[event.index];
+ if (this.verbose)
+ Output.prettyErrorln("<r><d>File changed: {s}<r>", .{fs.relativeTo(file_path)});
- if (comptime Environment.isDebug) {
- Output.prettyErrorln("[watch] {s} ({s}, {})", .{ file_path, @tagName(kind), event.op });
- }
+ if (event.op.write or event.op.delete or event.op.rename) {
+ current_task.append(id);
+ }
+ },
+ .directory => {
+ var affected_buf: [128][]const u8 = undefined;
+ var entries_option: ?*Fs.FileSystem.RealFS.EntriesOption = null;
+
+ const affected = brk: {
+ if (comptime Environment.isMac) {
+ if (rfs.entries.get(file_path)) |existing| {
+ this.putTombstone(file_path, existing);
+ entries_option = existing;
+ } else if (this.getTombstone(file_path)) |existing| {
+ entries_option = existing;
+ }
- switch (kind) {
- .file => {
- if (event.op.delete or event.op.rename) {
- ctx.removeAtIndex(
- event.index,
- 0,
- &.{},
- .file,
- );
- }
+ var affected_i: usize = 0;
+
+ // if a file descriptor is stale, we need to close it
+ if (event.op.delete and entries_option != null) {
+ for (parents, 0..) |parent_hash, entry_id| {
+ if (parent_hash == id) {
+ const affected_path = file_paths[entry_id];
+ const was_deleted = check: {
+ std.os.access(affected_path, std.os.F_OK) catch break :check true;
+ break :check false;
+ };
+ if (!was_deleted) continue;
+
+ affected_buf[affected_i] = affected_path[file_path.len..];
+ affected_i += 1;
+ if (affected_i >= affected_buf.len) break;
+ }
+ }
+ }
- if (this.verbose)
- Output.prettyErrorln("<r><d>File changed: {s}<r>", .{fs.relativeTo(file_path)});
+ break :brk affected_buf[0..affected_i];
+ }
- if (event.op.write or event.op.delete or event.op.rename) {
- current_task.append(id);
- }
- },
- .directory => {
- var affected_buf: [128][]const u8 = undefined;
- var entries_option: ?*Fs.FileSystem.RealFS.EntriesOption = null;
+ break :brk event.names(changed_files);
+ };
- const affected = brk: {
- if (comptime Environment.isMac) {
+ if (affected.len > 0 and !Environment.isMac) {
if (rfs.entries.get(file_path)) |existing| {
this.putTombstone(file_path, existing);
entries_option = existing;
} else if (this.getTombstone(file_path)) |existing| {
entries_option = existing;
}
-
- var affected_i: usize = 0;
-
- // if a file descriptor is stale, we need to close it
- if (event.op.delete and entries_option != null) {
- for (parents, 0..) |parent_hash, entry_id| {
- if (parent_hash == id) {
- const affected_path = file_paths[entry_id];
- const was_deleted = check: {
- std.os.access(affected_path, std.os.F_OK) catch break :check true;
- break :check false;
- };
- if (!was_deleted) continue;
-
- affected_buf[affected_i] = affected_path[file_path.len..];
- affected_i += 1;
- if (affected_i >= affected_buf.len) break;
- }
- }
- }
-
- break :brk affected_buf[0..affected_i];
- }
-
- break :brk event.names(changed_files);
- };
-
- if (affected.len > 0 and !Environment.isMac) {
- if (rfs.entries.get(file_path)) |existing| {
- this.putTombstone(file_path, existing);
- entries_option = existing;
- } else if (this.getTombstone(file_path)) |existing| {
- entries_option = existing;
}
- }
- resolver.bustDirCache(file_path);
-
- if (entries_option) |dir_ent| {
- var last_file_hash: Watcher.HashType = std.math.maxInt(Watcher.HashType);
-
- for (affected) |changed_name_| {
- const changed_name: []const u8 = if (comptime Environment.isMac)
- changed_name_
- else
- bun.asByteSlice(changed_name_.?);
- if (changed_name.len == 0 or changed_name[0] == '~' or changed_name[0] == '.') continue;
-
- const loader = (bundler.options.loaders.get(Fs.PathName.init(changed_name).ext) orelse .file);
- var prev_entry_id: usize = std.math.maxInt(usize);
- if (loader.isJavaScriptLikeOrJSON() or loader == .css) {
- var path_string: bun.PathString = undefined;
- var file_hash: Watcher.HashType = last_file_hash;
- const abs_path: string = brk: {
- if (dir_ent.entries.get(@ptrCast([]const u8, changed_name))) |file_ent| {
- // reset the file descriptor
- file_ent.entry.cache.fd = 0;
- file_ent.entry.need_stat = true;
- path_string = file_ent.entry.abs_path;
- file_hash = Watcher.getHash(path_string.slice());
- for (hashes, 0..) |hash, entry_id| {
- if (hash == file_hash) {
- if (file_descriptors[entry_id] != 0) {
- if (prev_entry_id != entry_id) {
- current_task.append(@truncate(u32, entry_id));
- ctx.removeAtIndex(
- @truncate(u16, entry_id),
- 0,
- &.{},
- .file,
- );
+ resolver.bustDirCache(file_path);
+
+ if (entries_option) |dir_ent| {
+ var last_file_hash: @This().Watcher.HashType = std.math.maxInt(@This().Watcher.HashType);
+
+ for (affected) |changed_name_| {
+ const changed_name: []const u8 = if (comptime Environment.isMac)
+ changed_name_
+ else
+ bun.asByteSlice(changed_name_.?);
+ if (changed_name.len == 0 or changed_name[0] == '~' or changed_name[0] == '.') continue;
+
+ const loader = (bundler.options.loaders.get(Fs.PathName.init(changed_name).ext) orelse .file);
+ var prev_entry_id: usize = std.math.maxInt(usize);
+ if (loader.isJavaScriptLikeOrJSON() or loader == .css) {
+ var path_string: bun.PathString = undefined;
+ var file_hash: @This().Watcher.HashType = last_file_hash;
+ const abs_path: string = brk: {
+ if (dir_ent.entries.get(@ptrCast([]const u8, changed_name))) |file_ent| {
+ // reset the file descriptor
+ file_ent.entry.cache.fd = 0;
+ file_ent.entry.need_stat = true;
+ path_string = file_ent.entry.abs_path;
+ file_hash = @This().Watcher.getHash(path_string.slice());
+ for (hashes, 0..) |hash, entry_id| {
+ if (hash == file_hash) {
+ if (file_descriptors[entry_id] != 0) {
+ if (prev_entry_id != entry_id) {
+ current_task.append(@truncate(u32, entry_id));
+ ctx.removeAtIndex(
+ @truncate(u16, entry_id),
+ 0,
+ &.{},
+ .file,
+ );
+ }
}
- }
- prev_entry_id = entry_id;
- break;
+ prev_entry_id = entry_id;
+ break;
+ }
}
- }
- break :brk path_string.slice();
- } else {
- var file_path_without_trailing_slash = std.mem.trimRight(u8, file_path, std.fs.path.sep_str);
- @memcpy(&_on_file_update_path_buf, file_path_without_trailing_slash.ptr, file_path_without_trailing_slash.len);
- _on_file_update_path_buf[file_path_without_trailing_slash.len] = std.fs.path.sep;
+ break :brk path_string.slice();
+ } else {
+ var file_path_without_trailing_slash = std.mem.trimRight(u8, file_path, std.fs.path.sep_str);
+ @memcpy(&_on_file_update_path_buf, file_path_without_trailing_slash.ptr, file_path_without_trailing_slash.len);
+ _on_file_update_path_buf[file_path_without_trailing_slash.len] = std.fs.path.sep;
- @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len + 1 ..].ptr, changed_name.ptr, changed_name.len);
- const path_slice = _on_file_update_path_buf[0 .. file_path_without_trailing_slash.len + changed_name.len + 1];
- file_hash = Watcher.getHash(path_slice);
- break :brk path_slice;
- }
- };
+ @memcpy(_on_file_update_path_buf[file_path_without_trailing_slash.len + 1 ..].ptr, changed_name.ptr, changed_name.len);
+ const path_slice = _on_file_update_path_buf[0 .. file_path_without_trailing_slash.len + changed_name.len + 1];
+ file_hash = @This().Watcher.getHash(path_slice);
+ break :brk path_slice;
+ }
+ };
- // skip consecutive duplicates
- if (last_file_hash == file_hash) continue;
- last_file_hash = file_hash;
+ // skip consecutive duplicates
+ if (last_file_hash == file_hash) continue;
+ last_file_hash = file_hash;
- if (this.verbose)
- Output.prettyErrorln("<r> <d>File change: {s}<r>", .{fs.relativeTo(abs_path)});
+ if (this.verbose)
+ Output.prettyErrorln("<r> <d>File change: {s}<r>", .{fs.relativeTo(abs_path)});
+ }
}
}
- }
- if (this.verbose) {
- Output.prettyErrorln("<r> <d>Dir change: {s}<r>", .{fs.relativeTo(file_path)});
- }
- },
+ if (this.verbose) {
+ Output.prettyErrorln("<r> <d>Dir change: {s}<r>", .{fs.relativeTo(file_path)});
+ }
+ },
+ }
}
}
- }
-};
+ };
+}
diff --git a/src/bun.js/javascript_core_c_api.zig b/src/bun.js/javascript_core_c_api.zig
index 32414829b..f2b6d19a4 100644
--- a/src/bun.js/javascript_core_c_api.zig
+++ b/src/bun.js/javascript_core_c_api.zig
@@ -493,6 +493,8 @@ pub const CellType = enum(u8) {
}
};
pub const ExternalStringFinalizer = *const fn (finalize_ptr: ?*anyopaque, ref: JSStringRef, buffer: *anyopaque, byteLength: usize) callconv(.C) void;
+
+/// **DEPRECATED**: USE from JSValue instead! This whole file should be used sparingly.
pub extern fn JSStringCreate(string: UTF8Ptr, length: usize) JSStringRef;
pub extern fn JSStringCreateStatic(string: UTF8Ptr, length: usize) JSStringRef;
pub extern fn JSStringCreateExternal(string: UTF8Ptr, length: usize, finalize_ptr: ?*anyopaque, finalizer: ExternalStringFinalizer) JSStringRef;
diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig
index 4f57d8c67..8a46b063a 100644
--- a/src/bun.js/module_loader.zig
+++ b/src/bun.js/module_loader.zig
@@ -79,7 +79,6 @@ const VM = @import("bun").JSC.VM;
const JSFunction = @import("bun").JSC.JSFunction;
const Config = @import("./config.zig");
const URL = @import("../url.zig").URL;
-const Transpiler = @import("./api/transpiler.zig");
const Bun = JSC.API.Bun;
const EventLoop = JSC.EventLoop;
const PendingResolution = @import("../resolver/resolver.zig").PendingResolution;
@@ -172,8 +171,8 @@ pub const ModuleLoader = struct {
// This is all the state used by the printer to print the module
parse_result: ParseResult,
- stmt_blocks: []*js_ast.Stmt.Data.Store.All.Block = &[_]*js_ast.Stmt.Data.Store.All.Block{},
- expr_blocks: []*js_ast.Expr.Data.Store.All.Block = &[_]*js_ast.Expr.Data.Store.All.Block{},
+ // stmt_blocks: []*js_ast.Stmt.Data.Store.All.Block = &[_]*js_ast.Stmt.Data.Store.All.Block{},
+ // expr_blocks: []*js_ast.Expr.Data.Store.All.Block = &[_]*js_ast.Expr.Data.Store.All.Block{},
promise: JSC.Strong = .{},
path: Fs.Path,
specifier: string = "",
@@ -485,8 +484,8 @@ pub const ModuleLoader = struct {
pub fn init(opts: anytype, globalObject: *JSC.JSGlobalObject) !AsyncModule {
var promise = JSC.Strong{};
- var stmt_blocks = js_ast.Stmt.Data.Store.toOwnedSlice();
- var expr_blocks = js_ast.Expr.Data.Store.toOwnedSlice();
+ // var stmt_blocks = js_ast.Stmt.Data.toOwnedSlice();
+ // var expr_blocks = js_ast.Expr.Data.toOwnedSlice();
const this_promise = JSValue.createInternalPromise(globalObject);
promise.set(globalObject, this_promise);
@@ -511,9 +510,9 @@ pub const ModuleLoader = struct {
.package_json = opts.package_json,
.loader = opts.loader.toAPI(),
.string_buf = buf.allocatedSlice(),
- .stmt_blocks = stmt_blocks,
+ // .stmt_blocks = stmt_blocks,
+ // .expr_blocks = expr_blocks,
.globalThis = globalObject,
- .expr_blocks = expr_blocks,
};
}
@@ -636,7 +635,7 @@ pub const ModuleLoader = struct {
error_instance.put(globalThis, ZigString.static("name"), ZigString.init(name).withEncoding().toValueGC(globalThis));
error_instance.put(globalThis, ZigString.static("pkg"), ZigString.init(result.name).withEncoding().toValueGC(globalThis));
error_instance.put(globalThis, ZigString.static("specifier"), ZigString.init(this.specifier).withEncoding().toValueGC(globalThis));
- const location = logger.rangeData(&this.parse_result.source, this.parse_result.ast.import_records[import_record_id].range, "").location.?;
+ const location = logger.rangeData(&this.parse_result.source, this.parse_result.ast.import_records.at(import_record_id).range, "").location.?;
error_instance.put(globalThis, ZigString.static("sourceURL"), ZigString.init(this.parse_result.source.path.text).withEncoding().toValueGC(globalThis));
error_instance.put(globalThis, ZigString.static("line"), JSValue.jsNumber(location.line));
if (location.line_text) |line_text| {
@@ -730,9 +729,9 @@ pub const ModuleLoader = struct {
error_instance.put(globalThis, ZigString.static("referrer"), ZigString.init(this.specifier).withEncoding().toValueGC(globalThis));
}
- const location = logger.rangeData(&this.parse_result.source, this.parse_result.ast.import_records[import_record_id].range, "").location.?;
+ const location = logger.rangeData(&this.parse_result.source, this.parse_result.ast.import_records.at(import_record_id).range, "").location.?;
error_instance.put(globalThis, ZigString.static("specifier"), ZigString.init(
- this.parse_result.ast.import_records[import_record_id].path.text,
+ this.parse_result.ast.import_records.at(import_record_id).path.text,
).withEncoding().toValueGC(globalThis));
error_instance.put(globalThis, ZigString.static("sourceURL"), ZigString.init(this.parse_result.source.path.text).withEncoding().toValueGC(globalThis));
error_instance.put(globalThis, ZigString.static("line"), JSValue.jsNumber(location.line));
@@ -837,8 +836,8 @@ pub const ModuleLoader = struct {
pub fn deinit(this: *AsyncModule) void {
this.parse_result.deinit();
- bun.default_allocator.free(this.stmt_blocks);
- bun.default_allocator.free(this.expr_blocks);
+ // bun.default_allocator.free(this.stmt_blocks);
+ // bun.default_allocator.free(this.expr_blocks);
this.promise.deinit();
bun.default_allocator.free(this.string_buf);
}
@@ -1301,10 +1300,10 @@ pub const ModuleLoader = struct {
if (!was_printing_plugin) jsc_vm.bundler.resolver.caches.fs.use_alternate_source_cache = !prev;
// this is a bad idea, but it should work for now.
- const original_name = parse_result.ast.symbols[parse_result.ast.bun_plugin.ref.innerIndex()].original_name;
- parse_result.ast.symbols[parse_result.ast.bun_plugin.ref.innerIndex()].original_name = "globalThis.Bun.plugin";
+ const original_name = parse_result.ast.symbols.mut(parse_result.ast.bun_plugin.ref.innerIndex()).original_name;
+ parse_result.ast.symbols.mut(parse_result.ast.bun_plugin.ref.innerIndex()).original_name = "globalThis.Bun.plugin";
defer {
- parse_result.ast.symbols[parse_result.ast.bun_plugin.ref.innerIndex()].original_name = original_name;
+ parse_result.ast.symbols.mut(parse_result.ast.bun_plugin.ref.innerIndex()).original_name = original_name;
}
const hoisted_stmts = parse_result.ast.bun_plugin.hoisted_stmts.items;
@@ -1314,9 +1313,9 @@ pub const ModuleLoader = struct {
},
};
var ast_copy = parse_result.ast;
- ast_copy.import_records = try jsc_vm.allocator.dupe(ImportRecord, ast_copy.import_records);
- defer jsc_vm.allocator.free(ast_copy.import_records);
- ast_copy.parts = &parts;
+ ast_copy.import_records.set(try jsc_vm.allocator.dupe(ImportRecord, ast_copy.import_records.slice()));
+ defer ast_copy.import_records.deinitWithAllocator(jsc_vm.allocator);
+ ast_copy.parts.set(&parts);
ast_copy.prepend_part = null;
var temporary_source = parse_result.source;
var source_name = try std.fmt.allocPrint(jsc_vm.allocator, "{s}.plugin.{s}", .{ temporary_source.path.text, temporary_source.path.name.ext[1..] });
@@ -1587,7 +1586,7 @@ pub const ModuleLoader = struct {
var jsx = bundler.options.jsx;
jsx.parse = false;
var opts = js_parser.Parser.Options.init(jsx, .js);
- opts.enable_bundling = false;
+ opts.enable_legacy_bundling = false;
opts.transform_require_to_import = false;
opts.features.dynamic_require = true;
opts.can_import_from_bundle = bundler.options.node_modules_bundle != null;
diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig
index 963a13967..197bba03f 100644
--- a/src/bun.js/test/jest.zig
+++ b/src/bun.js/test/jest.zig
@@ -613,13 +613,13 @@ pub const Snapshots = struct {
var ast = if (parse_result.ok) parse_result.ast else return error.ParseError;
defer ast.deinit();
- if (ast.exports_ref == null) return;
- const exports_ref = ast.exports_ref.?;
+ if (ast.exports_ref.isNull()) return;
+ const exports_ref = ast.exports_ref;
// TODO: when common js transform changes, keep this updated or add flag to support this version
const export_default = brk: {
- for (ast.parts) |part| {
+ for (ast.parts.slice()) |part| {
for (part.stmts) |stmt| {
if (stmt.data == .s_export_default and stmt.data.s_export_default.value == .expr) {
break :brk stmt.data.s_export_default.value.expr;
diff --git a/src/bun.zig b/src/bun.zig
index ae987d4ec..f5231b72e 100644
--- a/src/bun.zig
+++ b/src/bun.zig
@@ -370,6 +370,29 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {
pub const IdentityContext = @import("./identity_context.zig").IdentityContext;
pub const ArrayIdentityContext = @import("./identity_context.zig").ArrayIdentityContext;
+pub const StringHashMapUnowned = struct {
+ pub const Key = struct {
+ hash: u64,
+ len: usize,
+
+ pub fn init(str: []const u8) Key {
+ return Key{
+ .hash = hash(str),
+ .len = str.len,
+ };
+ }
+ };
+
+ pub const Adapter = struct {
+ pub fn eql(_: @This(), a: Key, b: Key) bool {
+ return a.hash == b.hash and a.len == b.len;
+ }
+
+ pub fn hash(_: @This(), key: Key) u64 {
+ return key.hash;
+ }
+ };
+};
pub const BabyList = @import("./baby_list.zig").BabyList;
pub const ByteList = BabyList(u8);
@@ -498,6 +521,11 @@ pub fn hash(content: []const u8) u64 {
return std.hash.Wyhash.hash(0, content);
}
+pub fn hash32(content: []const u8) u32 {
+ const res = hash(content);
+ return @truncate(u32, res);
+}
+
pub const HiveArray = @import("./hive_array.zig").HiveArray;
pub fn rand(bytes: []u8) void {
@@ -660,6 +688,27 @@ pub const StringArrayHashMapContext = struct {
pub fn eql(_: @This(), a: []const u8, b: []const u8, _: usize) bool {
return strings.eqlLong(a, b, true);
}
+
+ pub fn pre(input: []const u8) Prehashed {
+ return Prehashed{
+ .value = @This().hash(.{}, input),
+ .input = input,
+ };
+ }
+
+ pub const Prehashed = struct {
+ value: u32,
+ input: []const u8,
+ pub fn hash(this: @This(), s: []const u8) u32 {
+ if (s.ptr == this.input.ptr and s.len == this.input.len)
+ return this.value;
+ return @truncate(u32, std.hash.Wyhash.hash(0, s));
+ }
+
+ pub fn eql(_: @This(), a: []const u8, b: []const u8) bool {
+ return strings.eqlLong(a, b, true);
+ }
+ };
};
pub const StringHashMapContext = struct {
@@ -670,13 +719,20 @@ pub const StringHashMapContext = struct {
return strings.eqlLong(a, b, true);
}
+ pub fn pre(input: []const u8) Prehashed {
+ return Prehashed{
+ .value = @This().hash(.{}, input),
+ .input = input,
+ };
+ }
+
pub const Prehashed = struct {
value: u64,
input: []const u8,
pub fn hash(this: @This(), s: []const u8) u64 {
if (s.ptr == this.input.ptr and s.len == this.input.len)
return this.value;
- return std.hash.Wyhash.hash(0, s);
+ return StringHashMapContext.hash(.{}, s);
}
pub fn eql(_: @This(), a: []const u8, b: []const u8) bool {
@@ -797,7 +853,7 @@ pub const js_printer = @import("./js_printer.zig");
pub const js_lexer = @import("./js_lexer.zig");
pub const JSON = @import("./json_parser.zig");
pub const JSAst = @import("./js_ast.zig");
-pub const bit_set = @import("./install/bit_set.zig");
+pub const bit_set = @import("./bit_set.zig");
pub fn enumMap(comptime T: type, comptime args: anytype) (fn (T) []const u8) {
const Map = struct {
@@ -1001,6 +1057,19 @@ pub fn cstring(input: []const u8) [:0]const u8 {
}
pub const Semver = @import("./install/semver.zig");
+pub const ImportRecord = @import("./import_record.zig").ImportRecord;
+pub const ImportKind = @import("./import_record.zig").ImportKind;
+
+pub usingnamespace @import("./util.zig");
+pub const fast_debug_build_cmd = .None;
+pub const fast_debug_build_mode = fast_debug_build_cmd != .None and
+ Environment.isDebug;
+
+pub const MultiArrayList = @import("./multi_array_list.zig").MultiArrayList;
+
+pub const Joiner = @import("./string_joiner.zig");
+pub const renamer = @import("./renamer.zig");
+pub const sourcemap = @import("./sourcemap/sourcemap.zig");
pub fn asByteSlice(buffer: anytype) []const u8 {
return switch (@TypeOf(buffer)) {
@@ -1017,6 +1086,68 @@ pub fn asByteSlice(buffer: anytype) []const u8 {
};
}
+comptime {
+ if (fast_debug_build_cmd != .RunCommand and fast_debug_build_mode) {
+ _ = @import("./bun.js/node/buffer.zig").BufferVectorized.fill;
+ _ = @import("./cli/upgrade_command.zig").Version;
+ }
+}
+
+pub fn DebugOnlyDisabler(comptime Type: type) type {
+ return struct {
+ const T = Type;
+ threadlocal var disable_create_in_debug: if (Environment.allow_assert) usize else u0 = 0;
+ pub inline fn disable() void {
+ if (comptime !Environment.allow_assert) return;
+ disable_create_in_debug += 1;
+ }
+
+ pub inline fn enable() void {
+ if (comptime !Environment.allow_assert) return;
+ disable_create_in_debug -= 1;
+ }
+
+ pub inline fn assert() void {
+ if (comptime !Environment.allow_assert) return;
+ if (disable_create_in_debug > 0) {
+ Output.panic(comptime "[" ++ @typeName(T) ++ "] called while disabled (did you forget to call enable?)", .{});
+ }
+ }
+ };
+}
+
+const FailingAllocator = struct {
+ fn alloc(_: *anyopaque, _: usize, _: u8, _: usize) ?[*]u8 {
+ if (comptime Environment.allow_assert) {
+ unreachablePanic("FailingAllocator should never be reached. This means some memory was not defined", .{});
+ }
+ return null;
+ }
+
+ fn resize(_: *anyopaque, _: []u8, _: u8, _: usize, _: usize) bool {
+ if (comptime Environment.allow_assert) {
+ unreachablePanic("FailingAllocator should never be reached. This means some memory was not defined", .{});
+ }
+ return false;
+ }
+
+ fn free(
+ _: *anyopaque,
+ _: []u8,
+ _: u8,
+ _: usize,
+ ) void {
+ unreachable;
+ }
+};
+
+/// When we want to avoid initializing a value as undefined, we can use this allocator
+pub const failing_allocator = std.mem.Allocator{ .ptr = undefined, .vtable = &.{
+ .alloc = FailingAllocator.alloc,
+ .resize = FailingAllocator.resize,
+ .free = FailingAllocator.free,
+} };
+
/// Reload Bun's process
///
/// This clones envp, argv, and gets the current executable path
@@ -1094,3 +1225,5 @@ pub fn reloadProcess(
}
}
pub var auto_reload_on_crash = false;
+
+pub const options = @import("./options.zig");
diff --git a/src/bundler.zig b/src/bundler.zig
index e1701ecd7..45cda93ff 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -381,6 +381,7 @@ pub const Bundler = struct {
to.log.* = logger.Log.init(allocator);
to.setLog(to.log);
to.macro_context = null;
+ to.linker.resolver = &to.resolver;
}
pub inline fn getPackageManager(this: *Bundler) *PackageManager {
@@ -1145,7 +1146,7 @@ pub const Bundler = struct {
comptime enable_source_map: bool,
source_map_context: ?js_printer.SourceMapHandler,
) !usize {
- var symbols: [][]js_ast.Symbol = &([_][]js_ast.Symbol{ast.symbols});
+ var symbols = js_ast.Symbol.NestedList.init(&[_]js_ast.Symbol.List{ast.symbols});
return switch (format) {
.cjs => try js_printer.printCommonJS(
@@ -1156,7 +1157,6 @@ pub const Bundler = struct {
source,
false,
js_printer.Options{
- .to_module_ref = Ref.RuntimeRef,
.externals = ast.externals,
.runtime_imports = ast.runtime_imports,
.require_ref = ast.require_ref,
@@ -1165,8 +1165,6 @@ pub const Bundler = struct {
.rewrite_require_resolve = bundler.options.platform != .node,
.minify_whitespace = bundler.options.minify_whitespace,
},
- Linker,
- &bundler.linker,
enable_source_map,
),
@@ -1178,7 +1176,6 @@ pub const Bundler = struct {
source,
false,
js_printer.Options{
- .to_module_ref = Ref.RuntimeRef,
.externals = ast.externals,
.runtime_imports = ast.runtime_imports,
.require_ref = ast.require_ref,
@@ -1187,98 +1184,40 @@ pub const Bundler = struct {
.rewrite_require_resolve = bundler.options.platform != .node,
.minify_whitespace = bundler.options.minify_whitespace,
},
- Linker,
- &bundler.linker,
enable_source_map,
),
- .esm_ascii => if (bundler.options.platform.isBun())
- try js_printer.printAst(
- Writer,
- writer,
- ast,
- js_ast.Symbol.Map.initList(symbols),
- source,
- true,
- js_printer.Options{
- .to_module_ref = Ref.RuntimeRef,
- .externals = ast.externals,
- .runtime_imports = ast.runtime_imports,
- .require_ref = ast.require_ref,
- .css_import_behavior = bundler.options.cssImportBehavior(),
- .source_map_handler = source_map_context,
- .rewrite_require_resolve = bundler.options.platform != .node,
- .minify_whitespace = bundler.options.minify_whitespace,
- },
- Linker,
- &bundler.linker,
- enable_source_map,
- )
- else
- try js_printer.printAst(
- Writer,
- writer,
- ast,
- js_ast.Symbol.Map.initList(symbols),
- source,
- false,
- js_printer.Options{
- .to_module_ref = Ref.RuntimeRef,
- .externals = ast.externals,
- .runtime_imports = ast.runtime_imports,
- .require_ref = ast.require_ref,
- .css_import_behavior = bundler.options.cssImportBehavior(),
- .source_map_handler = source_map_context,
- .rewrite_require_resolve = bundler.options.platform != .node,
- .minify_whitespace = bundler.options.minify_whitespace,
- },
- Linker,
- &bundler.linker,
- enable_source_map,
- ),
- .cjs_ascii => if (bundler.options.platform.isBun())
- try js_printer.printCommonJS(
- Writer,
- writer,
- ast,
- js_ast.Symbol.Map.initList(symbols),
- source,
- true,
- js_printer.Options{
- .to_module_ref = Ref.RuntimeRef,
- .externals = ast.externals,
- .runtime_imports = ast.runtime_imports,
- .require_ref = ast.require_ref,
- .css_import_behavior = bundler.options.cssImportBehavior(),
- .source_map_handler = source_map_context,
- .rewrite_require_resolve = bundler.options.platform != .node,
- .minify_whitespace = bundler.options.minify_whitespace,
- },
- Linker,
- &bundler.linker,
- enable_source_map,
- )
- else
- try js_printer.printCommonJS(
- Writer,
- writer,
- ast,
- js_ast.Symbol.Map.initList(symbols),
- source,
- false,
- js_printer.Options{
- .to_module_ref = Ref.RuntimeRef,
- .externals = ast.externals,
- .runtime_imports = ast.runtime_imports,
- .require_ref = ast.require_ref,
- .css_import_behavior = bundler.options.cssImportBehavior(),
- .source_map_handler = source_map_context,
- .rewrite_require_resolve = bundler.options.platform != .node,
- .minify_whitespace = bundler.options.minify_whitespace,
- },
- Linker,
- &bundler.linker,
- enable_source_map,
- ),
+ .esm_ascii => try js_printer.printAst(
+ Writer,
+ writer,
+ ast,
+ js_ast.Symbol.Map.initList(symbols),
+ source,
+ true,
+ js_printer.Options{
+ .externals = ast.externals,
+ .runtime_imports = ast.runtime_imports,
+ .require_ref = ast.require_ref,
+ .css_import_behavior = bundler.options.cssImportBehavior(),
+ .source_map_handler = source_map_context,
+ },
+ enable_source_map,
+ ),
+ .cjs_ascii => try js_printer.printCommonJS(
+ Writer,
+ writer,
+ ast,
+ js_ast.Symbol.Map.initList(symbols),
+ source,
+ true,
+ js_printer.Options{
+ .externals = ast.externals,
+ .runtime_imports = ast.runtime_imports,
+ .require_ref = ast.require_ref,
+ .css_import_behavior = bundler.options.cssImportBehavior(),
+ .source_map_handler = source_map_context,
+ },
+ enable_source_map,
+ ),
};
}
@@ -1437,7 +1376,7 @@ pub const Bundler = struct {
jsx.parse = loader.isJSX();
var opts = js_parser.Parser.Options.init(jsx, loader);
- opts.enable_bundling = false;
+ opts.enable_legacy_bundling = false;
opts.transform_require_to_import = bundler.options.allow_runtime and !bundler.options.platform.isBun();
opts.features.allow_runtime = bundler.options.allow_runtime;
opts.features.trim_unused_imports = bundler.options.trim_unused_imports orelse loader.isTypeScript();
diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig
new file mode 100644
index 000000000..77904edd7
--- /dev/null
+++ b/src/bundler/bundle_v2.zig
@@ -0,0 +1,7773 @@
+const Bundler = bun.Bundler;
+const GenerateNodeModulesBundle = @This();
+const bun = @import("bun");
+const from = bun.from;
+const string = bun.string;
+const Output = bun.Output;
+const Global = bun.Global;
+const Environment = bun.Environment;
+const strings = bun.strings;
+const MutableString = bun.MutableString;
+const stringZ = bun.stringZ;
+const default_allocator = bun.default_allocator;
+const StoredFileDescriptorType = bun.StoredFileDescriptorType;
+const FeatureFlags = bun.FeatureFlags;
+const C = bun.C;
+const std = @import("std");
+const lex = @import("../js_lexer.zig");
+const Logger = @import("../logger.zig");
+const options = @import("../options.zig");
+const js_parser = bun.js_parser;
+const json_parser = @import("../json_parser.zig");
+const js_printer = @import("../js_printer.zig");
+const js_ast = @import("../js_ast.zig");
+const linker = @import("../linker.zig");
+const Ref = @import("../ast/base.zig").Ref;
+const Define = @import("../defines.zig").Define;
+const DebugOptions = @import("../cli.zig").Command.DebugOptions;
+const ThreadPoolLib = @import("../thread_pool.zig");
+const ThreadlocalArena = @import("../mimalloc_arena.zig").Arena;
+const BabyList = @import("../baby_list.zig").BabyList;
+const panicky = @import("../panic_handler.zig");
+const Fs = @import("../fs.zig");
+const schema = @import("../api/schema.zig");
+const Api = schema.Api;
+const _resolver = @import("../resolver/resolver.zig");
+const sync = bun.ThreadPool;
+const ImportRecord = bun.ImportRecord;
+const ImportKind = bun.ImportKind;
+const allocators = @import("../allocators.zig");
+const MimeType = @import("../http/mime_type.zig");
+const resolve_path = @import("../resolver/resolve_path.zig");
+const runtime = @import("../runtime.zig");
+const Timer = @import("../system_timer.zig");
+const PackageJSON = @import("../resolver/package_json.zig").PackageJSON;
+const MacroRemap = @import("../resolver/package_json.zig").MacroMap;
+const DebugLogs = _resolver.DebugLogs;
+const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
+const Router = @import("../router.zig");
+const isPackagePath = _resolver.isPackagePath;
+const Lock = @import("../lock.zig").Lock;
+const NodeFallbackModules = @import("../node_fallbacks.zig");
+const CacheEntry = @import("../cache.zig").FsCacheEntry;
+const Analytics = @import("../analytics/analytics_thread.zig");
+const URL = @import("../url.zig").URL;
+const Report = @import("../report.zig");
+const Linker = linker.Linker;
+const Resolver = _resolver.Resolver;
+const TOML = @import("../toml/toml_parser.zig").TOML;
+const EntryPoints = @import("./entry_points.zig");
+const ThisBundler = @import("../bundler.zig").Bundler;
+const wyhash = std.hash.Wyhash.hash;
+const Dependency = js_ast.Dependency;
+const JSAst = js_ast.Ast;
+const Loader = options.Loader;
+const Index = @import("../ast/base.zig").Index;
+const Batcher = bun.Batcher;
+const Symbol = js_ast.Symbol;
+const EventLoop = bun.JSC.AnyEventLoop;
+const MultiArrayList = bun.MultiArrayList;
+const Stmt = js_ast.Stmt;
+const Expr = js_ast.Expr;
+const E = js_ast.E;
+const S = js_ast.S;
+const G = js_ast.G;
+const B = js_ast.B;
+const Binding = js_ast.Binding;
+const AutoBitSet = bun.bit_set.AutoBitSet;
+const renamer = bun.renamer;
+const Scope = js_ast.Scope;
+const JSC = bun.JSC;
+const debugTreeShake = Output.scoped(.TreeShake, true);
+const BitSet = bun.bit_set.DynamicBitSetUnmanaged;
+
+pub const ThreadPool = struct {
+ pool: ThreadPoolLib = undefined,
+ // Hardcode 512 as max number of threads for now.
+ workers: [512]Worker = undefined,
+ workers_used: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ cpu_count: u32 = 0,
+ started_workers: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ stopped_workers: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ completed_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ pending_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+
+ v2: *BundleV2 = undefined,
+
+ const debug = Output.scoped(.ThreadPool, false);
+
+ pub fn go(this: *ThreadPool, allocator: std.mem.Allocator, comptime Function: anytype) !ThreadPoolLib.ConcurrentFunction(Function) {
+ return this.pool.go(allocator, Function);
+ }
+
+ pub fn start(this: *ThreadPool, v2: *BundleV2) !void {
+ v2.bundler.env.loadProcess();
+ this.v2 = v2;
+
+ this.cpu_count = @truncate(u32, @max(std.Thread.getCpuCount() catch 2, 2));
+
+ if (v2.bundler.env.map.get("GOMAXPROCS")) |max_procs| {
+ if (std.fmt.parseInt(u32, max_procs, 10)) |cpu_count| {
+ this.cpu_count = @max(cpu_count, 2);
+ } else |_| {}
+ }
+
+ this.cpu_count = @min(this.cpu_count, @truncate(u32, this.workers.len - 1));
+
+ this.pool = ThreadPoolLib.init(.{
+ .max_threads = this.cpu_count,
+ });
+ this.pool.on_thread_spawn = Worker.onSpawn;
+ this.pool.threadpool_context = this;
+ var workers_used: u32 = 0;
+ while (workers_used < this.cpu_count) : (workers_used += 1) {
+ try this.workers[workers_used].init(v2);
+ }
+
+ if (workers_used > 0)
+ this.pool.forceSpawn();
+ debug("allocated {d} workers", .{this.cpu_count});
+ }
+
+ pub const Worker = struct {
+ thread_id: std.Thread.Id,
+ thread: std.Thread,
+ heap: ThreadlocalArena = ThreadlocalArena{},
+ allocator: std.mem.Allocator,
+ ctx: *BundleV2,
+
+ data: *WorkerData = undefined,
+ quit: bool = false,
+
+ ast_memory_allocator: js_ast.ASTMemoryAllocator = undefined,
+
+ has_notify_started: bool = false,
+ has_created: bool = false,
+ pub fn get() *Worker {
+ var worker = @ptrCast(
+ *ThreadPool.Worker,
+ @alignCast(
+ @alignOf(*ThreadPool.Worker),
+ ThreadPoolLib.Thread.current.?.ctx.?,
+ ),
+ );
+ if (!worker.has_created) {
+ worker.create();
+ }
+
+ return worker;
+ }
+
+ pub const WorkerData = struct {
+ log: *Logger.Log,
+ estimated_input_lines_of_code: usize = 0,
+ macro_context: js_ast.Macro.MacroContext,
+ bundler: Bundler = undefined,
+
+ pub fn deinit(this: *WorkerData, allocator: std.mem.Allocator) void {
+ allocator.destroy(this);
+ }
+ };
+
+ pub fn init(worker: *Worker, v2: *BundleV2) !void {
+ worker.ctx = v2;
+ }
+
+ pub fn onSpawn(ctx: ?*anyopaque) ?*anyopaque {
+ var pool = @ptrCast(*ThreadPool, @alignCast(@alignOf(*ThreadPool), ctx.?));
+
+ const id = pool.workers_used.fetchAdd(1, .Monotonic);
+ pool.workers[id].run();
+ return &pool.workers[id];
+ }
+
+ pub fn notifyStarted(this: *Worker) void {
+ if (!this.has_notify_started) {
+ this.has_notify_started = true;
+ _ = this.v2.pool.started_workers.fetchAdd(1, .Release);
+ std.Thread.Futex.wake(&this.v2.pool.started_workers, std.math.maxInt(u32));
+ }
+ }
+
+ fn create(this: *Worker) void {
+ this.has_created = true;
+ Output.Source.configureThread();
+ this.thread_id = std.Thread.getCurrentId();
+ this.heap = ThreadlocalArena.init() catch unreachable;
+ this.allocator = this.heap.allocator();
+ var allocator = this.allocator;
+
+ this.ast_memory_allocator = .{ .allocator = this.allocator };
+ this.ast_memory_allocator.push();
+
+ this.data = allocator.create(WorkerData) catch unreachable;
+ this.data.* = WorkerData{
+ .log = allocator.create(Logger.Log) catch unreachable,
+ .estimated_input_lines_of_code = 0,
+ .macro_context = undefined,
+ };
+ this.data.log.* = Logger.Log.init(allocator);
+ this.data.bundler = this.ctx.bundler.*;
+ this.data.bundler.setLog(this.data.log);
+ this.data.bundler.setAllocator(allocator);
+ this.data.bundler.linker.resolver = &this.data.bundler.resolver;
+ this.data.bundler.macro_context = js_ast.Macro.MacroContext.init(&this.data.bundler);
+ this.data.macro_context = this.data.bundler.macro_context.?;
+
+ const CacheSet = @import("../cache.zig");
+
+ this.data.bundler.resolver.caches = CacheSet.Set.init(this.allocator);
+ }
+
+ pub fn run(this: *Worker) void {
+ if (!this.has_created) {
+ this.create();
+ }
+
+ // no funny business mr. cache
+
+ }
+ };
+};
+
+const Watcher = bun.JSC.NewHotReloader(BundleV2, EventLoop, true);
+
+pub const BundleV2 = struct {
+ bundler: *Bundler,
+ client_bundler: *Bundler,
+ server_bundler: *Bundler,
+ graph: Graph = Graph{},
+ linker: LinkerContext = LinkerContext{ .loop = undefined },
+ bun_watcher: ?*Watcher.Watcher = null,
+
+ const debug = Output.scoped(.Bundle, false);
+
+ pub inline fn loop(this: *BundleV2) *EventLoop {
+ return &this.linker.loop;
+ }
+
+ pub fn findReachableFiles(this: *BundleV2) ![]Index {
+ const Visitor = struct {
+ reachable: std.ArrayList(Index),
+ visited: bun.bit_set.DynamicBitSet = undefined,
+ all_import_records: []ImportRecord.List,
+ redirects: []?u32,
+ redirect_map: PathToSourceIndexMap,
+
+ // Find all files reachable from all entry points. This order should be
+ // deterministic given that the entry point order is deterministic, since the
+ // returned order is the postorder of the graph traversal and import record
+ // order within a given file is deterministic.
+ pub fn visit(v: *@This(), source_index: Index) void {
+ if (source_index.isInvalid()) return;
+ if (v.visited.isSet(source_index.get())) {
+ return;
+ }
+ v.visited.set(source_index.get());
+
+ const import_record_list_id = source_index;
+ // when there are no import records, v index will be invalid
+ if (import_record_list_id.get() < v.all_import_records.len) {
+ var import_records = v.all_import_records[import_record_list_id.get()].slice();
+ for (import_records) |*import_record| {
+ const other_source = import_record.source_index;
+ if (other_source.isValid()) {
+ if (v.redirects[other_source.get()]) |redirect_id| {
+ var other_import_records = v.all_import_records[other_source.get()].slice();
+ const other_import_record = &other_import_records[redirect_id];
+ import_record.source_index = other_import_record.source_index;
+ import_record.path = other_import_record.path;
+ }
+
+ v.visit(import_record.source_index);
+ }
+ }
+
+ // Redirects replace the source file with another file
+ if (v.redirects[source_index.get()]) |redirect_id| {
+ const redirect_source_index = v.all_import_records[source_index.get()].slice()[redirect_id].source_index.get();
+ v.visit(Index.source(redirect_source_index));
+ return;
+ }
+ }
+
+ // Each file must come after its dependencies
+ v.reachable.append(source_index) catch unreachable;
+ }
+ };
+
+ var visitor = Visitor{
+ .reachable = try std.ArrayList(Index).initCapacity(this.graph.allocator, this.graph.entry_points.items.len + 1),
+ .visited = try bun.bit_set.DynamicBitSet.initEmpty(this.graph.allocator, this.graph.input_files.len),
+ .redirects = this.graph.ast.items(.redirect_import_record_index),
+ .all_import_records = this.graph.ast.items(.import_records),
+ .redirect_map = this.graph.path_to_source_index_map,
+ };
+ defer visitor.visited.deinit();
+
+ for (this.graph.entry_points.items) |entry_point| {
+ visitor.visit(entry_point);
+ }
+
+ // if (comptime Environment.allow_assert) {
+ // Output.prettyln("Reachable count: {d} / {d}", .{ visitor.reachable.items.len, this.graph.input_files.len });
+ // }
+
+ return visitor.reachable.toOwnedSlice();
+ }
+
+ pub fn waitForParse(this: *BundleV2) void {
+ while (this.graph.parse_pending > 0) {
+ this.loop().tick(this);
+ }
+
+ debug("Parsed {d} files, producing {d} ASTs", .{ this.graph.input_files.len, this.graph.ast.len });
+ }
+
+ pub fn enqueueItem(
+ this: *BundleV2,
+ hash: ?u64,
+ batch: *ThreadPoolLib.Batch,
+ resolve: _resolver.Result,
+ ) !?Index.Int {
+ var result = resolve;
+ var path = result.path() orelse return null;
+
+ const loader = this.bundler.options.loaders.get(path.name.ext) orelse .file;
+ if (!loader.isJavaScriptLikeOrJSON()) return null;
+
+ var entry = try this.graph.path_to_source_index_map.getOrPut(this.graph.allocator, hash orelse wyhash(0, path.text));
+ if (entry.found_existing) {
+ return null;
+ }
+ this.graph.parse_pending += 1;
+ const source_index = Index.source(this.graph.input_files.len);
+ if (path.pretty.ptr == path.text.ptr) {
+ // TODO: outbase
+ const rel = bun.path.relative(this.bundler.fs.top_level_dir, path.text);
+ if (rel.len > 0 and rel[0] != '.') {
+ path.pretty = rel;
+ }
+ }
+ path.* = try path.dupeAlloc(this.graph.allocator);
+ entry.value_ptr.* = source_index.get();
+ this.graph.ast.append(this.graph.allocator, js_ast.Ast.empty) catch unreachable;
+
+ try this.graph.input_files.append(this.graph.allocator, .{
+ .source = .{
+ .path = path.*,
+ .key_path = path.*,
+ .contents = "",
+ .index = source_index,
+ },
+ .loader = loader,
+ .side_effects = resolve.primary_side_effects_data,
+ });
+ var task = try this.graph.allocator.create(ParseTask);
+ task.* = ParseTask.init(&result, source_index);
+ task.loader = loader;
+ task.jsx = this.bundler.options.jsx;
+ task.task.node.next = null;
+ task.tree_shaking = this.linker.options.tree_shaking;
+ batch.push(ThreadPoolLib.Batch.from(&task.task));
+ return source_index.get();
+ }
+
+ pub fn generate(
+ bundler: *ThisBundler,
+ allocator: std.mem.Allocator,
+ estimated_input_lines_of_code: *usize,
+ package_bundle_map: options.BundlePackage.Map,
+ event_loop: EventLoop,
+ unique_key: u64,
+ enable_reloading: bool,
+ ) !std.ArrayList(options.OutputFile) {
+ _ = try bundler.fs.fs.openTmpDir();
+ bundler.resetStore();
+ try bundler.configureDefines();
+ _ = estimated_input_lines_of_code;
+ _ = package_bundle_map;
+
+ var generator = try allocator.create(BundleV2);
+ bundler.options.mark_bun_builtins_as_external = bundler.options.platform.isBun();
+ bundler.resolver.opts.mark_bun_builtins_as_external = bundler.options.platform.isBun();
+
+ defer allocator.destroy(generator);
+ generator.* = BundleV2{
+ .bundler = bundler,
+ .client_bundler = bundler,
+ .server_bundler = bundler,
+ .graph = .{
+ .pool = undefined,
+ .heap = try ThreadlocalArena.init(),
+ .allocator = undefined,
+ },
+ .linker = .{
+ .loop = event_loop,
+ .graph = .{
+ .allocator = undefined,
+ },
+ },
+ };
+ generator.linker.graph.allocator = generator.graph.heap.allocator();
+ generator.graph.allocator = generator.linker.graph.allocator;
+ generator.bundler.allocator = generator.graph.allocator;
+ generator.bundler.resolver.allocator = generator.graph.allocator;
+ generator.bundler.linker.allocator = generator.graph.allocator;
+ generator.bundler.log.msgs.allocator = generator.graph.allocator;
+ generator.linker.resolver = &generator.bundler.resolver;
+ generator.linker.graph.code_splitting = bundler.options.code_splitting;
+ generator.graph.code_splitting = bundler.options.code_splitting;
+ var pool = try generator.graph.allocator.create(ThreadPool);
+ if (enable_reloading) {
+ Watcher.enableHotModuleReloading(generator);
+ }
+ // errdefer pool.destroy();
+ errdefer generator.graph.heap.deinit();
+
+ pool.* = ThreadPool{};
+ generator.graph.pool = pool;
+
+ var batch = ThreadPoolLib.Batch{};
+
+ var this = generator;
+
+ if (this.bundler.env.isProduction()) {
+ this.bundler.options.jsx.development = false;
+ }
+
+ if (!this.bundler.options.jsx.development) {
+ this.bundler.options.jsx.import_source = std.fmt.allocPrint(allocator, "{s}/jsx-runtime", .{generator.bundler.options.jsx.classic_import_source}) catch unreachable;
+ }
+
+ this.bundler.resolver.opts.jsx = this.bundler.options.jsx;
+
+ try pool.start(this);
+
+ {
+ // Add the runtime
+ try this.graph.input_files.append(allocator, Graph.InputFile{
+ .source = ParseTask.runtime_source,
+ .loader = .js,
+ .side_effects = _resolver.SideEffects.no_side_effects__pure_data,
+ });
+
+ // try this.graph.entry_points.append(allocator, Index.runtime);
+ this.graph.ast.append(this.graph.allocator, js_ast.Ast.empty) catch unreachable;
+ this.graph.path_to_source_index_map.put(this.graph.allocator, bun.hash("bun:wrap"), Index.runtime.get()) catch unreachable;
+ var runtime_parse_task = try this.graph.allocator.create(ParseTask);
+ runtime_parse_task.* = ParseTask.runtime;
+ runtime_parse_task.task.node.next = null;
+ runtime_parse_task.tree_shaking = true;
+ runtime_parse_task.loader = .js;
+ this.graph.parse_pending += 1;
+ batch.push(ThreadPoolLib.Batch.from(&runtime_parse_task.task));
+ }
+
+ if (bundler.router) |router| {
+ defer this.bundler.resetStore();
+ Analytics.Features.filesystem_router = true;
+
+ const entry_points = try router.getEntryPoints();
+ try this.graph.entry_points.ensureUnusedCapacity(this.graph.allocator, entry_points.len);
+ try this.graph.input_files.ensureUnusedCapacity(this.graph.allocator, entry_points.len);
+ try this.graph.path_to_source_index_map.ensureUnusedCapacity(this.graph.allocator, @truncate(u32, entry_points.len));
+
+ for (entry_points) |entry_point| {
+ const resolved = bundler.resolveEntryPoint(entry_point) catch continue;
+ if (try this.enqueueItem(null, &batch, resolved)) |source_index| {
+ this.graph.entry_points.append(this.graph.allocator, Index.source(source_index)) catch unreachable;
+ } else {}
+ }
+ } else {}
+
+ {
+ // Setup entry points
+ try this.graph.entry_points.ensureUnusedCapacity(this.graph.allocator, bundler.options.entry_points.len);
+ try this.graph.input_files.ensureUnusedCapacity(this.graph.allocator, bundler.options.entry_points.len);
+ try this.graph.path_to_source_index_map.ensureUnusedCapacity(this.graph.allocator, @truncate(u32, bundler.options.entry_points.len));
+
+ defer this.bundler.resetStore();
+ for (bundler.options.entry_points) |entry_point| {
+ const resolved = bundler.resolveEntryPoint(entry_point) catch continue;
+ if (try this.enqueueItem(null, &batch, resolved)) |source_index| {
+ this.graph.entry_points.append(this.graph.allocator, Index.source(source_index)) catch unreachable;
+ } else {}
+ }
+ }
+
+ this.graph.pool.pool.schedule(batch);
+ this.waitForParse();
+
+ if (this.bundler.log.msgs.items.len > 0) {
+ return error.BuildFailed;
+ }
+
+ this.linker.allocator = this.bundler.allocator;
+ this.linker.graph.allocator = this.bundler.allocator;
+ this.linker.graph.ast = try this.graph.ast.clone(this.linker.allocator);
+ var ast = this.linker.graph.ast.slice();
+ for (ast.items(.module_scope)) |*new_module_scope| {
+ for (new_module_scope.children.slice()) |new_child| {
+ new_child.parent = new_module_scope;
+ }
+ }
+
+ var chunks = try this.linker.link(
+ this,
+ this.graph.entry_points.items,
+ this.graph.use_directive_entry_points,
+ try this.findReachableFiles(),
+ unique_key,
+ );
+
+ const output_files = try this.linker.generateChunksInParallel(chunks);
+
+ return output_files;
+ }
+
+ pub fn onParseTaskComplete(parse_result: *ParseTask.Result, this: *BundleV2) void {
+ var graph = &this.graph;
+ var batch = ThreadPoolLib.Batch{};
+ var diff: isize = -1;
+
+ defer graph.parse_pending = if (diff > 0)
+ graph.parse_pending + @intCast(usize, diff)
+ else
+ graph.parse_pending - @intCast(usize, -diff);
+ switch (parse_result.value) {
+ .empty => |empty_result| {
+ var input_files = graph.input_files.slice();
+ var side_effects = input_files.items(.side_effects);
+ side_effects[empty_result.source_index.get()] = .no_side_effects__empty_ast;
+ if (comptime Environment.allow_assert) {
+ debug("onParse({d}, {s}) = empty", .{
+ empty_result.source_index.get(),
+ input_files.items(.source)[empty_result.source_index.get()].path.text,
+ });
+ }
+
+ if (this.bun_watcher != null) {
+ if (empty_result.watcher_data.fd > 0) {
+ this.bun_watcher.?.addFile(
+ empty_result.watcher_data.fd,
+ input_files.items(.source)[empty_result.source_index.get()].path.text,
+ bun.hash32(input_files.items(.source)[empty_result.source_index.get()].path.text),
+ graph.input_files.items(.loader)[empty_result.source_index.get()],
+ empty_result.watcher_data.dir_fd,
+ null,
+ false,
+ ) catch {};
+ }
+ }
+ },
+ .success => |*result| {
+ result.log.appendTo(this.bundler.log) catch unreachable;
+
+ {
+ // to minimize contention, we add watcher here
+ if (this.bun_watcher != null) {
+ if (result.watcher_data.fd > 0) {
+ this.bun_watcher.?.addFile(
+ result.watcher_data.fd,
+ result.source.path.text,
+ bun.hash32(result.source.path.text),
+ this.bundler.options.loader(result.source.path.name.ext),
+ result.watcher_data.dir_fd,
+ result.watcher_data.package_json,
+ false,
+ ) catch {};
+ }
+ }
+
+ var input_files = graph.input_files.slice();
+ input_files.items(.source)[result.source.index.get()] = result.source;
+ debug("onParse({d}, {s}) = {d} imports, {d} exports", .{
+ result.source.index.get(),
+ result.source.path.text,
+ result.ast.import_records.len,
+ result.ast.named_exports.count(),
+ });
+ }
+
+ var iter = result.resolve_queue.iterator();
+
+ while (iter.next()) |entry| {
+ const hash = entry.key_ptr.*;
+ const value = entry.value_ptr.*;
+ const loader = value.loader orelse options.Loader.file;
+ if (!loader.isJavaScriptLikeOrJSON()) {
+ // TODO:
+ continue;
+ }
+ var existing = graph.path_to_source_index_map.getOrPut(graph.allocator, hash) catch unreachable;
+
+ // If the same file is imported and required, and those point to different files
+ // Automatically rewrite it to the secondary one
+ if (value.secondary_path_for_commonjs_interop) |secondary_path| {
+ const secondary_hash = bun.hash(secondary_path.text);
+ if (graph.path_to_source_index_map.get(secondary_hash)) |secondary| {
+ existing.found_existing = true;
+ existing.value_ptr.* = secondary;
+ }
+ }
+
+ if (!existing.found_existing) {
+ var new_input_file = Graph.InputFile{
+ .source = Logger.Source.initEmptyFile(entry.value_ptr.path.text),
+ .side_effects = value.side_effects,
+ };
+ new_input_file.source.index = Index.source(graph.input_files.len);
+ new_input_file.source.path = entry.value_ptr.path;
+ new_input_file.source.key_path = new_input_file.source.path;
+ // graph.source_index_map.put(graph.allocator, new_input_file.source.index.get, new_input_file.source) catch unreachable;
+ existing.value_ptr.* = new_input_file.source.index.get();
+ entry.value_ptr.source_index = new_input_file.source.index;
+ graph.input_files.append(graph.allocator, new_input_file) catch unreachable;
+ graph.ast.append(graph.allocator, js_ast.Ast.empty) catch unreachable;
+ batch.push(ThreadPoolLib.Batch.from(&entry.value_ptr.task));
+
+ diff += 1;
+ }
+ }
+
+ var import_records = result.ast.import_records.clone(this.graph.allocator) catch unreachable;
+ for (import_records.slice(), 0..) |*record, i| {
+ if (graph.path_to_source_index_map.get(wyhash(0, record.path.text))) |source_index| {
+ record.source_index.value = source_index;
+
+ if (result.ast.redirect_import_record_index) |compare| {
+ if (compare == @truncate(u32, i)) {
+ graph.path_to_source_index_map.put(
+ graph.allocator,
+ bun.hash(result.source.path.text),
+ source_index,
+ ) catch unreachable;
+ }
+ }
+ }
+ }
+ result.ast.import_records = import_records;
+
+ graph.ast.set(result.source.index.get(), result.ast);
+ if (result.use_directive != .none) {
+ graph.use_directive_entry_points.append(
+ graph.allocator,
+ .{
+ .source_index = result.source.index.get(),
+ .use_directive = result.use_directive,
+ },
+ ) catch unreachable;
+ }
+ // schedule as early as possible
+ graph.pool.pool.schedule(batch);
+ },
+ .err => |*err| {
+ if (comptime Environment.allow_assert) {
+ debug("onParse() = err", .{});
+ }
+
+ if (err.log.msgs.items.len > 0) {
+ err.log.appendTo(this.bundler.log) catch unreachable;
+ } else {
+ this.bundler.log.addErrorFmt(
+ null,
+ Logger.Loc.Empty,
+ this.bundler.allocator,
+ "{s} while {s}",
+ .{ @errorName(err.err), @tagName(err.step) },
+ ) catch unreachable;
+ }
+ },
+ }
+ }
+};
+
+const UseDirective = js_ast.UseDirective;
+
+const ParseTask = struct {
+ path: Fs.Path,
+ secondary_path_for_commonjs_interop: ?Fs.Path = null,
+ contents_or_fd: union(enum) {
+ fd: struct {
+ dir: StoredFileDescriptorType,
+ file: StoredFileDescriptorType,
+ },
+ contents: string,
+ },
+ side_effects: _resolver.SideEffects,
+ loader: ?Loader = null,
+ jsx: options.JSX.Pragma,
+ source_index: Index = Index.invalid,
+ task: ThreadPoolLib.Task = .{ .callback = &callback },
+ tree_shaking: bool = false,
+ known_platform: ?options.Platform = null,
+ module_type: options.ModuleType = .unknown,
+
+ const debug = Output.scoped(.ParseTask, false);
+
+ pub const ResolveQueue = std.AutoArrayHashMap(u64, ParseTask);
+
+ pub fn init(resolve_result: *const _resolver.Result, source_index: ?Index) ParseTask {
+ return .{
+ .path = resolve_result.path_pair.primary,
+ .contents_or_fd = .{
+ .fd = .{
+ .dir = resolve_result.dirname_fd,
+ .file = resolve_result.file_fd,
+ },
+ },
+ .side_effects = resolve_result.primary_side_effects_data,
+ .jsx = resolve_result.jsx,
+ .source_index = source_index orelse Index.invalid,
+ .module_type = resolve_result.module_type,
+ };
+ }
+
+ pub const runtime = ParseTask{
+ .path = Fs.Path.initWithNamespace("runtime", "bun:runtime"),
+ .side_effects = _resolver.SideEffects.no_side_effects__pure_data,
+ .jsx = options.JSX.Pragma{
+ .parse = false,
+ // .supports_react_refresh = false,
+ },
+ .contents_or_fd = .{
+ .contents = @as(string, @embedFile("../runtime.js")),
+ },
+ .source_index = Index.runtime,
+ .loader = Loader.js,
+ };
+ pub const runtime_source = Logger.Source{
+ .path = ParseTask.runtime.path,
+ .key_path = ParseTask.runtime.path,
+ .contents = ParseTask.runtime.contents_or_fd.contents,
+ .index = Index.runtime,
+ };
+
+ pub const Result = struct {
+ task: EventLoop.Task = undefined,
+
+ value: union(Tag) {
+ err: Error,
+ success: Success,
+ empty: struct {
+ source_index: Index,
+
+ watcher_data: WatcherData = .{},
+ },
+ },
+
+ const WatcherData = struct {
+ fd: bun.StoredFileDescriptorType = 0,
+ dir_fd: bun.StoredFileDescriptorType = 0,
+ package_json: ?*PackageJSON = null,
+ };
+
+ pub const Success = struct {
+ ast: js_ast.Ast,
+ resolve_queue: ResolveQueue,
+ source: Logger.Source,
+ log: Logger.Log,
+
+ use_directive: UseDirective = .none,
+ watcher_data: WatcherData = .{},
+ };
+
+ pub const Error = struct {
+ err: anyerror,
+ step: Step,
+ log: Logger.Log,
+
+ pub const Step = enum {
+ pending,
+ read_file,
+ parse,
+ resolve,
+ };
+ };
+
+ pub const Tag = enum {
+ success,
+ err,
+ empty,
+ };
+ };
+
+ threadlocal var override_file_path_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+
+ fn run_(
+ task: *ParseTask,
+ this: *ThreadPool.Worker,
+ step: *ParseTask.Result.Error.Step,
+ log: *Logger.Log,
+ ) anyerror!?Result.Success {
+ var allocator = this.allocator;
+
+ var data = this.data;
+ var bundler = &data.bundler;
+ errdefer bundler.resetStore();
+ var resolver: *Resolver = &bundler.resolver;
+ var file_path = task.path;
+ step.* = .read_file;
+
+ var entry: CacheEntry = switch (task.contents_or_fd) {
+ .fd => brk: {
+ if (bundler.options.framework) |framework| {
+ if (framework.override_modules_hashes.len > 0) {
+ const package_relative_path_hash = wyhash(0, file_path.pretty);
+ if (std.mem.indexOfScalar(
+ u64,
+ framework.override_modules_hashes,
+ package_relative_path_hash,
+ )) |index| {
+ const relative_path = [_]string{
+ framework.resolved_dir,
+ framework.override_modules.values[index],
+ };
+ var override_path = bundler.fs.absBuf(
+ &relative_path,
+ &override_file_path_buf,
+ );
+ override_file_path_buf[override_path.len] = 0;
+ var override_pathZ = override_file_path_buf[0..override_path.len :0];
+ debug("{s} -> {s}", .{ file_path.text, override_path });
+ break :brk try resolver.caches.fs.readFile(
+ bundler.fs,
+ override_pathZ,
+ 0,
+ false,
+ null,
+ );
+ }
+ }
+ }
+
+ if (strings.eqlComptime(file_path.namespace, "node"))
+ break :brk CacheEntry{
+ .contents = NodeFallbackModules.contentsFromPath(file_path.text) orelse "",
+ };
+
+ break :brk try resolver.caches.fs.readFile(
+ bundler.fs,
+ file_path.text,
+ task.contents_or_fd.fd.dir,
+ false,
+ if (task.contents_or_fd.fd.file > 0)
+ task.contents_or_fd.fd.file
+ else
+ null,
+ );
+ },
+ .contents => |contents| CacheEntry{
+ .contents = contents,
+ .fd = 0,
+ },
+ };
+
+ errdefer if (task.contents_or_fd == .fd) entry.deinit(allocator);
+
+ if (entry.fd > 2) task.contents_or_fd = .{
+ .fd = .{
+ .file = entry.fd,
+ .dir = bun.invalid_fd,
+ },
+ };
+ step.* = .parse;
+
+ if (entry.contents.len == 0 or (entry.contents.len < 33 and strings.trim(entry.contents, " \n\r").len == 0)) {
+ debug("skipping empty file: {s}", .{file_path.text});
+ return null;
+ }
+
+ const use_directive = if (this.ctx.bundler.options.react_server_components)
+ UseDirective.parse(entry.contents)
+ else
+ .none;
+
+ var source = Logger.Source{
+ .path = file_path,
+ .key_path = file_path,
+ .index = task.source_index,
+ .contents = entry.contents,
+ .contents_is_recycled = false,
+ };
+
+ const source_dir = file_path.sourceDir();
+ const loader = task.loader orelse bundler.options.loader(file_path.name.ext);
+ const platform = use_directive.platform(task.known_platform orelse bundler.options.platform);
+
+ var resolve_queue = ResolveQueue.init(bun.default_allocator);
+ // TODO: server ESM condition
+
+ errdefer resolve_queue.clearAndFree();
+
+ switch (loader) {
+ .jsx, .tsx, .js, .ts => {
+ task.jsx.parse = loader.isJSX();
+
+ var opts = js_parser.Parser.Options.init(task.jsx, loader);
+ opts.transform_require_to_import = false;
+ opts.can_import_from_bundle = false;
+ opts.features.allow_runtime = !source.index.isRuntime();
+ opts.features.dynamic_require = platform.isBun();
+ opts.warn_about_unbundled_modules = false;
+ opts.macro_context = &this.data.macro_context;
+ opts.bundle = true;
+ opts.features.top_level_await = true;
+ opts.features.jsx_optimization_inline = platform.isBun() and (bundler.options.jsx_optimization_inline orelse !task.jsx.development);
+ opts.features.auto_import_jsx = !opts.features.jsx_optimization_inline and task.jsx.parse and bundler.options.auto_import_jsx;
+ opts.features.trim_unused_imports = bundler.options.trim_unused_imports orelse loader.isTypeScript();
+ opts.tree_shaking = task.tree_shaking;
+ opts.module_type = task.module_type;
+
+ var ast = (try resolver.caches.js.parse(
+ bundler.allocator,
+ opts,
+ bundler.options.define,
+ log,
+ &source,
+ )) orelse return error.EmptyAST;
+
+ step.* = .resolve;
+ ast.platform = platform;
+ var estimated_resolve_queue_count: usize = 0;
+ for (ast.import_records.slice()) |*import_record| {
+ if (import_record.is_internal) {
+ import_record.tag = .runtime;
+ import_record.source_index = Index.runtime;
+ }
+
+ if (import_record.is_unused) {
+ import_record.source_index = Index.invalid;
+ }
+
+ // Don't resolve the runtime
+ if (import_record.is_internal or import_record.is_unused) {
+ continue;
+ }
+ estimated_resolve_queue_count += 1;
+ }
+
+ try resolve_queue.ensureUnusedCapacity(estimated_resolve_queue_count);
+ var last_error: ?anyerror = null;
+ for (ast.import_records.slice()) |*import_record| {
+ // Don't resolve the runtime
+ if (import_record.is_unused or import_record.is_internal) {
+ continue;
+ }
+
+ if (platform.isBun()) {
+ if (JSC.HardcodedModule.Aliases.get(import_record.path.text)) |replacement| {
+ import_record.path.text = replacement.path;
+ import_record.tag = replacement.tag;
+ import_record.source_index = Index.invalid;
+ continue;
+ }
+
+ if (JSC.DisabledModule.has(import_record.path.text)) {
+ import_record.path.is_disabled = true;
+ import_record.do_commonjs_transform_in_printer = true;
+ import_record.source_index = Index.invalid;
+ continue;
+ }
+
+ if (bundler.options.rewrite_jest_for_tests) {
+ if (strings.eqlComptime(
+ import_record.path.text,
+ "@jest/globals",
+ ) or strings.eqlComptime(
+ import_record.path.text,
+ "vitest",
+ )) {
+ import_record.path.namespace = "bun";
+ import_record.tag = .bun_test;
+ import_record.path.text = "test";
+ continue;
+ }
+ }
+
+ if (strings.hasPrefixComptime(import_record.path.text, "bun:")) {
+ import_record.path = Fs.Path.init(import_record.path.text["bun:".len..]);
+ import_record.path.namespace = "bun";
+ import_record.source_index = Index.invalid;
+
+ if (strings.eqlComptime(import_record.path.text, "test")) {
+ import_record.tag = .bun_test;
+ }
+
+ // don't link bun
+ continue;
+ }
+ }
+
+ if (resolver.resolve(source_dir, import_record.path.text, import_record.kind)) |_resolved_import| {
+ var resolve_result = _resolved_import;
+ // if there were errors, lets go ahead and collect them all
+ if (last_error != null) continue;
+
+ var path: *Fs.Path = resolve_result.path() orelse {
+ import_record.path.is_disabled = true;
+ import_record.source_index = Index.invalid;
+
+ continue;
+ };
+
+ if (resolve_result.is_external) {
+ continue;
+ }
+
+ var resolve_entry = try resolve_queue.getOrPut(wyhash(0, path.text));
+ if (resolve_entry.found_existing) {
+ import_record.path = resolve_entry.value_ptr.path;
+
+ continue;
+ }
+
+ if (path.pretty.ptr == path.text.ptr) {
+ // TODO: outbase
+ const rel = bun.path.relative(bundler.fs.top_level_dir, path.text);
+ if (rel.len > 0 and rel[0] != '.') {
+ path.pretty = rel;
+ }
+ }
+
+ var secondary_path_to_copy: ?Fs.Path = null;
+ if (resolve_result.path_pair.secondary) |*secondary| {
+ if (!secondary.is_disabled and
+ secondary != path and
+ !strings.eqlLong(secondary.text, path.text, true))
+ {
+ secondary_path_to_copy = try secondary.dupeAlloc(allocator);
+ }
+ }
+
+ path.* = try path.dupeAlloc(allocator);
+ import_record.path = path.*;
+ debug("created ParseTask: {s}", .{path.text});
+
+ resolve_entry.value_ptr.* = ParseTask.init(&resolve_result, null);
+ resolve_entry.value_ptr.secondary_path_for_commonjs_interop = secondary_path_to_copy;
+ if (use_directive != .none) {
+ resolve_entry.value_ptr.known_platform = platform;
+ } else if (task.known_platform) |known_platform| {
+ resolve_entry.value_ptr.known_platform = known_platform;
+ }
+
+ resolve_entry.value_ptr.jsx.development = task.jsx.development;
+
+ if (resolve_entry.value_ptr.loader == null) {
+ resolve_entry.value_ptr.loader = bundler.options.loader(path.name.ext);
+ resolve_entry.value_ptr.tree_shaking = task.tree_shaking;
+ }
+ } else |err| {
+ // Disable failing packages from being printed.
+ // This may cause broken code to write.
+ // However, doing this means we tell them all the resolve errors
+ // Rather than just the first one.
+ import_record.path.is_disabled = true;
+
+ switch (err) {
+ error.ModuleNotFound => {
+ const addError = Logger.Log.addResolveErrorWithTextDupe;
+
+ if (!import_record.handles_import_errors) {
+ last_error = err;
+ if (isPackagePath(import_record.path.text)) {
+ if (platform.isWebLike() and options.ExternalModules.isNodeBuiltin(import_record.path.text)) {
+ try addError(
+ log,
+ &source,
+ import_record.range,
+ this.allocator,
+ "Could not resolve Node.js builtin: \"{s}\".",
+ .{import_record.path.text},
+ import_record.kind,
+ );
+ } else {
+ try addError(
+ log,
+ &source,
+ import_record.range,
+ this.allocator,
+ "Could not resolve: \"{s}\". Maybe you need to \"bun install\"?",
+ .{import_record.path.text},
+ import_record.kind,
+ );
+ }
+ } else {
+ try addError(
+ log,
+ &source,
+ import_record.range,
+ this.allocator,
+ "Could not resolve: \"{s}\"",
+ .{
+ import_record.path.text,
+ },
+ import_record.kind,
+ );
+ }
+ }
+ },
+ // assume other errors are already in the log
+ else => {
+ last_error = err;
+ },
+ }
+ }
+ }
+
+ if (last_error) |err| {
+ debug("failed with error: {s}", .{@errorName(err)});
+ return err;
+ }
+
+ // Allow the AST to outlive this call
+ _ = js_ast.Expr.Data.Store.toOwnedSlice();
+ _ = js_ast.Stmt.Data.Store.toOwnedSlice();
+
+ // never a react client component if RSC is not enabled.
+ std.debug.assert(use_directive == .none or bundler.options.react_server_components);
+
+ return Result.Success{
+ .ast = ast,
+ .source = source,
+ .resolve_queue = resolve_queue,
+ .log = log.*,
+ .use_directive = use_directive,
+ .watcher_data = .{
+ .fd = if (task.contents_or_fd == .fd) task.contents_or_fd.fd.file else 0,
+ .dir_fd = if (task.contents_or_fd == .fd) task.contents_or_fd.fd.dir else 0,
+ },
+ };
+ },
+ else => return null,
+ }
+ }
+
+ pub fn callback(this: *ThreadPoolLib.Task) void {
+ run(@fieldParentPtr(ParseTask, "task", this));
+ }
+
+ fn run(this: *ParseTask) void {
+ var worker = @ptrCast(
+ *ThreadPool.Worker,
+ @alignCast(
+ @alignOf(*ThreadPool.Worker),
+ ThreadPoolLib.Thread.current.?.ctx.?,
+ ),
+ );
+ var step: ParseTask.Result.Error.Step = .pending;
+ var log = Logger.Log.init(worker.allocator);
+ std.debug.assert(this.source_index.isValid()); // forgot to set source_index
+ defer {
+ if (comptime FeatureFlags.help_catch_memory_issues) {
+ worker.heap.gc(false);
+ }
+ }
+ var result = bun.default_allocator.create(Result) catch unreachable;
+ result.* = .{
+ .value = brk: {
+ if (run_(
+ this,
+ worker,
+ &step,
+ &log,
+ )) |ast_or_null| {
+ if (ast_or_null) |ast| {
+ break :brk .{ .success = ast };
+ } else {
+ log.deinit();
+ break :brk .{
+ .empty = .{
+ .source_index = this.source_index,
+ .watcher_data = .{
+ .fd = if (this.contents_or_fd == .fd) this.contents_or_fd.fd.file else 0,
+ .dir_fd = if (this.contents_or_fd == .fd) this.contents_or_fd.fd.dir else 0,
+ },
+ },
+ };
+ }
+ } else |err| {
+ if (err == error.EmptyAST) {
+ log.deinit();
+ break :brk .{
+ .empty = .{
+ .source_index = this.source_index,
+ .watcher_data = .{
+ .fd = if (this.contents_or_fd == .fd) this.contents_or_fd.fd.file else 0,
+ .dir_fd = if (this.contents_or_fd == .fd) this.contents_or_fd.fd.dir else 0,
+ },
+ },
+ };
+ }
+ break :brk .{
+ .err = .{
+ .err = err,
+ .step = step,
+ .log = log,
+ },
+ };
+ }
+ },
+ };
+
+ worker.ctx.loop().enqueueTaskConcurrent(
+ Result,
+ BundleV2,
+ result,
+ BundleV2.onParseTaskComplete,
+ .task,
+ );
+ }
+};
+
+const IdentityContext = @import("../identity_context.zig").IdentityContext;
+
+const RefVoidMap = std.ArrayHashMapUnmanaged(Ref, void, Ref.ArrayHashCtx, false);
+const RefVoidMapManaged = std.ArrayHashMap(Ref, void, Ref.ArrayHashCtx, false);
+const RefImportData = std.ArrayHashMapUnmanaged(Ref, ImportData, Ref.ArrayHashCtx, false);
+const ResolvedExports = bun.StringArrayHashMapUnmanaged(ExportData);
+const TopLevelSymbolToParts = js_ast.Ast.TopLevelSymbolToParts;
+
+pub const WrapKind = enum(u2) {
+ none = 0,
+ cjs = 1,
+ esm = 2,
+};
+
+pub const ImportData = struct {
+ // This is an array of intermediate statements that re-exported this symbol
+ // in a chain before getting to the final symbol. This can be done either with
+ // "export * from" or "export {} from". If this is done with "export * from"
+ // then this may not be the result of a single chain but may instead form
+ // a diamond shape if this same symbol was re-exported multiple times from
+ // different files.
+ re_exports: Dependency.List = Dependency.List{},
+
+ data: ImportTracker = .{},
+};
+
+pub const ExportData = struct {
+ // Export star resolution happens first before import resolution. That means
+ // it cannot yet determine if duplicate names from export star resolution are
+ // ambiguous (point to different symbols) or not (point to the same symbol).
+ // This issue can happen in the following scenario:
+ //
+ // // entry.js
+ // export * from './a'
+ // export * from './b'
+ //
+ // // a.js
+ // export * from './c'
+ //
+ // // b.js
+ // export {x} from './c'
+ //
+ // // c.js
+ // export let x = 1, y = 2
+ //
+ // In this case "entry.js" should have two exports "x" and "y", neither of
+ // which are ambiguous. To handle this case, ambiguity resolution must be
+ // deferred until import resolution time. That is done using this array.
+ potentially_ambiguous_export_star_refs: BabyList(ImportData) = .{},
+
+ // This is the file that the named export above came from. This will be
+ // different from the file that contains this object if this is a re-export.
+ data: ImportTracker = .{},
+};
+
+pub const JSMeta = struct {
+ /// This is only for TypeScript files. If an import symbol is in this map, it
+ /// means the import couldn't be found and doesn't actually exist. This is not
+ /// an error in TypeScript because the import is probably just a type.
+ ///
+ /// Normally we remove all unused imports for TypeScript files during parsing,
+ /// which automatically removes type-only imports. But there are certain re-
+ /// export situations where it's impossible to tell if an import is a type or
+ /// not:
+ ///
+ /// import {typeOrNotTypeWhoKnows} from 'path';
+ /// export {typeOrNotTypeWhoKnows};
+ ///
+ /// Really people should be using the TypeScript "isolatedModules" flag with
+ /// bundlers like this one that compile TypeScript files independently without
+ /// type checking. That causes the TypeScript type checker to emit the error
+ /// "Re-exporting a type when the '--isolatedModules' flag is provided requires
+ /// using 'export type'." But we try to be robust to such code anyway.
+ probably_typescript_type: RefVoidMap = .{},
+
+ /// Imports are matched with exports in a separate pass from when the matched
+ /// exports are actually bound to the imports. Here "binding" means adding non-
+ /// local dependencies on the parts in the exporting file that declare the
+ /// exported symbol to all parts in the importing file that use the imported
+ /// symbol.
+ ///
+ /// This must be a separate pass because of the "probably TypeScript type"
+ /// check above. We can't generate the part for the export namespace until
+ /// we've matched imports with exports because the generated code must omit
+ /// type-only imports in the export namespace code. And we can't bind exports
+ /// to imports until the part for the export namespace is generated since that
+ /// part needs to participate in the binding.
+ ///
+ /// This array holds the deferred imports to bind so the pass can be split
+ /// into two separate passes.
+ imports_to_bind: RefImportData = .{},
+
+ /// This includes both named exports and re-exports.
+ ///
+ /// Named exports come from explicit export statements in the original file,
+ /// and are copied from the "NamedExports" field in the AST.
+ ///
+ /// Re-exports come from other files and are the result of resolving export
+ /// star statements (i.e. "export * from 'foo'").
+ resolved_exports: ResolvedExports = .{},
+ resolved_export_star: ExportData = ExportData{},
+
+ /// Never iterate over "resolvedExports" directly. Instead, iterate over this
+ /// array. Some exports in that map aren't meant to end up in generated code.
+ /// This array excludes these exports and is also sorted, which avoids non-
+ /// determinism due to random map iteration order.
+ sorted_and_filtered_export_aliases: []const string = &[_]string{},
+
+ /// This is merged on top of the corresponding map from the parser in the AST.
+ /// You should call "TopLevelSymbolToParts" to access this instead of accessing
+ /// it directly.
+ top_level_symbol_to_parts_overlay: TopLevelSymbolToParts = .{},
+
+ /// If this is an entry point, this array holds a reference to one free
+ /// temporary symbol for each entry in "sortedAndFilteredExportAliases".
+ /// These may be needed to store copies of CommonJS re-exports in ESM.
+ cjs_export_copies: []const Ref = &[_]Ref{},
+
+ /// The index of the automatically-generated part used to represent the
+ /// CommonJS or ESM wrapper. This part is empty and is only useful for tree
+ /// shaking and code splitting. The wrapper can't be inserted into the part
+ /// because the wrapper contains other parts, which can't be represented by
+ /// the current part system. Only wrapped files have one of these.
+ wrapper_part_index: Index = Index.invalid,
+
+ /// The index of the automatically-generated part used to handle entry point
+ /// specific stuff. If a certain part is needed by the entry point, it's added
+ /// as a dependency of this part. This is important for parts that are marked
+ /// as removable when unused and that are not used by anything else. Only
+ /// entry point files have one of these.
+ entry_point_part_index: Index = Index.invalid,
+
+ flags: Flags = .{},
+
+ pub const Flags = packed struct {
+ /// This is true if this file is affected by top-level await, either by having
+ /// a top-level await inside this file or by having an import/export statement
+ /// that transitively imports such a file. It is forbidden to call "require()"
+ /// on these files since they are evaluated asynchronously.
+ is_async_or_has_async_dependency: bool = false,
+
+ /// If true, we need to insert "var exports = {};". This is the case for ESM
+ /// files when the import namespace is captured via "import * as" and also
+ /// when they are the target of a "require()" call.
+ needs_exports_variable: bool = false,
+
+ /// If true, the "__export(exports, { ... })" call will be force-included even
+ /// if there are no parts that reference "exports". Otherwise this call will
+ /// be removed due to the tree shaking pass. This is used when for entry point
+ /// files when code related to the current output format needs to reference
+ /// the "exports" variable.
+ force_include_exports_for_entry_point: bool = false,
+
+ /// This is set when we need to pull in the "__export" symbol in to the part
+ /// at "nsExportPartIndex". This can't be done in "createExportsForFile"
+ /// because of concurrent map hazards. Instead, it must be done later.
+ needs_export_symbol_from_runtime: bool = false,
+
+ /// Wrapped files must also ensure that their dependencies are wrapped. This
+ /// flag is used during the traversal that enforces this invariant, and is used
+ /// to detect when the fixed point has been reached.
+ did_wrap_dependencies: bool = false,
+
+ wrap: WrapKind = WrapKind.none,
+ };
+};
+
+pub const Graph = struct {
+ entry_points: std.ArrayListUnmanaged(Index) = .{},
+ ast: MultiArrayList(JSAst) = .{},
+
+ input_files: InputFile.List = .{},
+
+ code_splitting: bool = false,
+
+ pool: *ThreadPool = undefined,
+
+ heap: ThreadlocalArena = ThreadlocalArena{},
+ /// Main thread only!!
+ allocator: std.mem.Allocator = undefined,
+
+ parse_pending: usize = 0,
+
+ /// Stable source index mapping
+ source_index_map: std.AutoArrayHashMapUnmanaged(Index.Int, Ref.Int) = .{},
+
+ /// Stable source index mapping
+ path_to_source_index_map: PathToSourceIndexMap = .{},
+
+ use_directive_entry_points: UseDirective.List = .{},
+
+ pub const InputFile = struct {
+ source: Logger.Source,
+ loader: options.Loader = options.Loader.file,
+ side_effects: _resolver.SideEffects = _resolver.SideEffects.has_side_effects,
+
+ pub const List = MultiArrayList(InputFile);
+ };
+};
+
+const PathToSourceIndexMap = std.HashMapUnmanaged(u64, Index.Int, IdentityContext(u64), 80);
+
+const EntryPoint = struct {
+ // This may be an absolute path or a relative path. If absolute, it will
+ // eventually be turned into a relative path by computing the path relative
+ // to the "outbase" directory. Then this relative path will be joined onto
+ // the "outdir" directory to form the final output path for this entry point.
+ output_path: bun.PathString = bun.PathString.empty,
+
+ // This is the source index of the entry point. This file must have a valid
+ // entry point kind (i.e. not "none").
+ source_index: Index.Int = 0,
+
+ // Manually specified output paths are ignored when computing the default
+ // "outbase" directory, which is computed as the lowest common ancestor of
+ // all automatically generated output paths.
+ output_path_was_auto_generated: bool = false,
+
+ pub const List = MultiArrayList(EntryPoint);
+
+ pub const Kind = enum {
+ none,
+ user_specified,
+ dynamic_import,
+
+ /// Created via an import of a "use client" file
+ react_client_component,
+
+ /// Created via an import of a "use server" file
+ react_server_component,
+
+ pub inline fn isEntryPoint(this: Kind) bool {
+ return this != .none;
+ }
+
+ pub inline fn isUserSpecifiedEntryPoint(this: Kind) bool {
+ return this == .user_specified;
+ }
+
+ pub inline fn isServerEntryPoint(this: Kind) bool {
+ return this == .user_specified or this == .react_server_component;
+ }
+
+ pub fn isReactReference(this: Kind) bool {
+ return this == .react_client_component or this == .react_server_component;
+ }
+
+ pub fn useDirective(this: Kind) UseDirective {
+ return switch (this) {
+ .react_client_component => .@"use client",
+ .react_server_component => .@"use server",
+ else => .none,
+ };
+ }
+ };
+};
+
+const AstSourceIDMapping = struct {
+ id: Index.Int,
+ source_index: Index.Int,
+};
+
+const LinkerGraph = struct {
+ const debug = Output.scoped(.LinkerGraph, false);
+
+ files: File.List = .{},
+ files_live: BitSet = undefined,
+ entry_points: EntryPoint.List = .{},
+ symbols: js_ast.Symbol.Map = .{},
+
+ allocator: std.mem.Allocator,
+
+ code_splitting: bool = false,
+
+ // This is an alias from Graph
+ // it is not a clone!
+ ast: MultiArrayList(js_ast.Ast) = .{},
+ meta: MultiArrayList(JSMeta) = .{},
+
+ reachable_files: []Index = &[_]Index{},
+
+ stable_source_indices: []const u32 = &[_]u32{},
+
+ react_client_component_boundary: BitSet = .{},
+ react_server_component_boundary: BitSet = .{},
+ has_client_components: bool = false,
+ has_server_components: bool = false,
+
+ pub fn init(allocator: std.mem.Allocator, file_count: usize) !LinkerGraph {
+ return LinkerGraph{
+ .allocator = allocator,
+ .files_live = try BitSet.initEmpty(allocator, file_count),
+ };
+ }
+
+ pub fn useDirectiveBoundary(this: *const LinkerGraph, source_index: Index.Int) UseDirective {
+ if (this.react_client_component_boundary.bit_length > 0) {
+ if (this.react_client_component_boundary.isSet(source_index)) {
+ return .@"use client";
+ }
+ }
+
+ if (this.react_server_component_boundary.bit_length > 0) {
+ if (this.react_server_component_boundary.isSet(source_index)) {
+ return .@"use server";
+ }
+ }
+
+ return .none;
+ }
+
+ pub fn runtimeFunction(this: *const LinkerGraph, name: string) Ref {
+ return this.ast.items(.named_exports)[Index.runtime.value].get(name).?.ref;
+ }
+
+ pub fn generateNewSymbol(this: *LinkerGraph, source_index: u32, kind: Symbol.Kind, original_name: string) Ref {
+ var source_symbols = &this.symbols.symbols_for_source.slice()[source_index];
+
+ var ref = Ref.init(
+ @truncate(Ref.Int, source_symbols.len),
+ @truncate(Ref.Int, source_index),
+ false,
+ );
+ ref.tag = .symbol;
+
+ // TODO: will this crash on resize due to using threadlocal mimalloc heap?
+ source_symbols.push(
+ this.allocator,
+ .{
+ .kind = kind,
+ .original_name = original_name,
+ },
+ ) catch unreachable;
+
+ this.ast.items(.module_scope)[source_index].generated.push(this.allocator, ref) catch unreachable;
+ return ref;
+ }
+
+ pub fn generateRuntimeSymbolImportAndUse(
+ graph: *LinkerGraph,
+ source_index: Index.Int,
+ entry_point_part_index: Index,
+ name: []const u8,
+ count: u32,
+ ) !void {
+ if (count > 0) debug("generateRuntimeSymbolImportAndUse({s}) for {d}", .{ name, source_index });
+
+ const ref = graph.runtimeFunction(name);
+ try graph.generateSymbolImportAndUse(
+ source_index,
+ entry_point_part_index.get(),
+ ref,
+ count,
+ Index.runtime,
+ );
+ }
+
+ pub fn addPartToFile(
+ graph: *LinkerGraph,
+ id: u32,
+ part: js_ast.Part,
+ ) !u32 {
+ var parts: *js_ast.Part.List = &graph.ast.items(.parts)[id];
+ const part_id = @truncate(u32, parts.len);
+ try parts.push(graph.allocator, part);
+ var top_level_symbol_to_parts_overlay: ?*TopLevelSymbolToParts = null;
+
+ const Iterator = struct {
+ graph: *LinkerGraph,
+ id: u32,
+ top_level_symbol_to_parts_overlay: *?*TopLevelSymbolToParts,
+ part_id: u32,
+
+ pub fn next(self: *@This(), ref: Ref) void {
+ var overlay = brk: {
+ if (self.top_level_symbol_to_parts_overlay.*) |out| {
+ break :brk out;
+ }
+
+ var out = &self.graph.meta.items(.top_level_symbol_to_parts_overlay)[self.id];
+
+ self.top_level_symbol_to_parts_overlay.* = out;
+ break :brk out;
+ };
+
+ var entry = overlay.getOrPut(self.graph.allocator, ref) catch unreachable;
+ if (!entry.found_existing) {
+ if (self.graph.ast.items(.top_level_symbols_to_parts)[self.id].get(ref)) |original_parts| {
+ var list = std.ArrayList(u32).init(self.graph.allocator);
+ list.ensureTotalCapacityPrecise(original_parts.len + 1) catch unreachable;
+ list.appendSliceAssumeCapacity(original_parts.slice());
+ list.appendAssumeCapacity(self.part_id);
+
+ entry.value_ptr.* = BabyList(u32).init(list.items);
+ } else {
+ entry.value_ptr.* = bun.from(
+ BabyList(u32),
+ self.graph.allocator,
+ &[_]u32{
+ self.part_id,
+ },
+ ) catch unreachable;
+ }
+ } else {
+ entry.value_ptr.push(self.graph.allocator, self.part_id) catch unreachable;
+ }
+ }
+ };
+
+ var ctx = Iterator{
+ .graph = graph,
+ .id = id,
+ .part_id = part_id,
+ .top_level_symbol_to_parts_overlay = &top_level_symbol_to_parts_overlay,
+ };
+
+ js_ast.DeclaredSymbol.forEachTopLevelSymbol(&parts.ptr[part_id].declared_symbols, &ctx, Iterator.next);
+
+ return part_id;
+ }
+ pub fn generateSymbolImportAndUse(
+ g: *LinkerGraph,
+ source_index: u32,
+ part_index: u32,
+ ref: Ref,
+ use_count: u32,
+ source_index_to_import_from: Index,
+ ) !void {
+ if (use_count == 0) return;
+
+ // Mark this symbol as used by this part
+ var parts_list = g.ast.items(.parts)[source_index].slice();
+ var part: *js_ast.Part = &parts_list[part_index];
+ var uses = part.symbol_uses;
+ var entry = uses.getOrPut(g.allocator, ref) catch unreachable;
+ if (entry.found_existing) {
+ entry.value_ptr.count_estimate += use_count;
+ } else {
+ entry.value_ptr.* = .{ .count_estimate = use_count };
+ }
+ part.symbol_uses = uses;
+
+ const exports_ref = g.ast.items(.exports_ref)[source_index];
+ const module_ref = g.ast.items(.module_ref)[source_index].?;
+ if (ref.eql(exports_ref)) {
+ g.ast.items(.uses_exports_ref)[source_index] = true;
+ }
+
+ if (ref.eql(module_ref)) {
+ g.ast.items(.uses_module_ref)[source_index] = true;
+ }
+
+ // null ref shouldn't be there.
+ std.debug.assert(!ref.isEmpty());
+
+ // Track that this specific symbol was imported
+ if (source_index_to_import_from.get() != source_index) {
+ var to_bind = &g.meta.items(.imports_to_bind)[source_index];
+ try to_bind.put(g.allocator, ref, .{
+ .data = .{
+ .source_index = source_index_to_import_from,
+ .import_ref = ref,
+ },
+ });
+ }
+
+ // Pull in all parts that declare this symbol
+ var dependencies = &part.dependencies;
+ const part_ids = g.topLevelSymbolToParts(source_index_to_import_from.get(), ref);
+ try dependencies.ensureUnusedCapacity(g.allocator, part_ids.len);
+ const old_len = dependencies.len;
+ dependencies.len += @truncate(u32, part_ids.len);
+ var new_dependencies = dependencies.slice()[old_len..];
+ for (part_ids, new_dependencies) |part_id, *dependency| {
+ dependency.* = .{
+ .source_index = source_index_to_import_from,
+ .part_index = @truncate(u32, part_id),
+ };
+ }
+ }
+
+ pub fn topLevelSymbolToParts(g: *LinkerGraph, id: u32, ref: Ref) []u32 {
+ if (g.meta.items(.top_level_symbol_to_parts_overlay)[id].get(ref)) |overlay| {
+ return overlay.slice();
+ }
+
+ if (g.ast.items(.top_level_symbols_to_parts)[id].get(ref)) |list| {
+ return list.slice();
+ }
+
+ return &.{};
+ }
+
+ pub fn load(
+ this: *LinkerGraph,
+ entry_points: []const Index,
+ sources: []const Logger.Source,
+ use_directive_entry_points: UseDirective.List,
+ ) !void {
+ try this.files.ensureTotalCapacity(this.allocator, sources.len);
+ this.files.zero();
+ this.files_live = try BitSet.initEmpty(
+ this.allocator,
+ sources.len,
+ );
+ this.files.len = sources.len;
+ var files = this.files.slice();
+
+ var entry_point_kinds = files.items(.entry_point_kind);
+ {
+ var kinds = std.mem.sliceAsBytes(entry_point_kinds);
+ @memset(kinds.ptr, 0, kinds.len);
+ }
+
+ // Setup entry points
+ {
+ try this.entry_points.ensureTotalCapacity(this.allocator, entry_points.len + use_directive_entry_points.len);
+ this.entry_points.len = entry_points.len;
+ var source_indices = this.entry_points.items(.source_index);
+
+ var path_strings: []bun.PathString = this.entry_points.items(.output_path);
+ {
+ var output_was_auto_generated = std.mem.sliceAsBytes(this.entry_points.items(.output_path_was_auto_generated));
+ @memset(output_was_auto_generated.ptr, 0, output_was_auto_generated.len);
+ }
+
+ for (entry_points, path_strings, source_indices) |i, *path_string, *source_index| {
+ const source = sources[i.get()];
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(source.index.get() == i.get());
+ }
+ entry_point_kinds[source.index.get()] = EntryPoint.Kind.user_specified;
+ path_string.* = bun.PathString.init(source.path.text);
+ source_index.* = source.index.get();
+ }
+
+ var import_records_list: []ImportRecord.List = this.ast.items(.import_records);
+ try this.meta.ensureTotalCapacity(this.allocator, import_records_list.len);
+ this.meta.len = this.ast.len;
+ this.meta.zero();
+
+ if (use_directive_entry_points.len > 0) {
+ this.react_client_component_boundary = BitSet.initEmpty(this.allocator, this.files.len) catch unreachable;
+ this.react_server_component_boundary = BitSet.initEmpty(this.allocator, this.files.len) catch unreachable;
+ var any_server = false;
+ var any_client = false;
+
+ // Loop #1: populate the list of files that are react client components
+ for (use_directive_entry_points.items(.use_directive), use_directive_entry_points.items(.source_index)) |use, source_id| {
+ if (use == .@"use client") {
+ any_client = true;
+ this.react_client_component_boundary.set(source_id);
+ } else if (use == .@"use server") {
+ any_server = true;
+ this.react_server_component_boundary.set(source_id);
+ }
+ }
+
+ if (any_client or any_server) {
+
+ // Loop #2: For each import in the entire module graph
+ for (this.reachable_files) |source_id| {
+ const use_directive = this.useDirectiveBoundary(source_id.get());
+ // If the reachable file has a "use client"; at the top
+ for (import_records_list[source_id.get()].slice()) |*import_record| {
+ const source_index_ = import_record.source_index;
+ if (source_index_.isValid()) {
+ const source_index = import_record.source_index.get();
+
+ // and the import path refers to a server entry point
+ if (import_record.tag == .none) {
+ const other = this.useDirectiveBoundary(source_index);
+ import_record.module_id = bun.hash32(sources[source_index].path.pretty);
+
+ if (use_directive.boundering(other)) |boundary| {
+ // That import is a React Server Component reference.
+ switch (boundary) {
+ .@"use client" => {
+ import_record.tag = .react_client_component;
+ import_record.path.namespace = "client";
+ import_record.print_namespace_in_path = true;
+
+ if (entry_point_kinds[source_index] == .none) {
+ if (comptime Environment.allow_assert)
+ debug("Adding client component entry point for {s}", .{sources[source_index].path.text});
+
+ try this.entry_points.append(this.allocator, .{
+ .source_index = source_index,
+ .output_path = bun.PathString.init(sources[source_index].path.text),
+ .output_path_was_auto_generated = true,
+ });
+ entry_point_kinds[source_index] = .react_client_component;
+ }
+ },
+ .@"use server" => {
+ import_record.tag = .react_server_component;
+ import_record.path.namespace = "server";
+ import_record.print_namespace_in_path = true;
+
+ if (entry_point_kinds[source_index] == .none) {
+ if (comptime Environment.allow_assert)
+ debug("Adding server component entry point for {s}", .{sources[source_index].path.text});
+
+ try this.entry_points.append(this.allocator, .{
+ .source_index = source_index,
+ .output_path = bun.PathString.init(sources[source_index].path.text),
+ .output_path_was_auto_generated = true,
+ });
+ entry_point_kinds[source_index] = .react_server_component;
+ }
+ },
+ else => unreachable,
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ this.react_client_component_boundary = .{};
+ this.react_server_component_boundary = .{};
+ }
+ }
+ }
+
+ // Setup files
+ {
+ var stable_source_indices = try this.allocator.alloc(Index, sources.len + 1);
+
+ // set it to max value so that if we access an invalid one, it crashes
+ @memset(std.mem.sliceAsBytes(stable_source_indices).ptr, 255, std.mem.sliceAsBytes(stable_source_indices).len);
+
+ for (this.reachable_files, 0..) |source_index, i| {
+ stable_source_indices[source_index.get()] = Index.source(i);
+ }
+
+ const file = comptime LinkerGraph.File{};
+ // TODO: verify this outputs efficient code
+ std.mem.set(
+ @TypeOf(file.distance_from_entry_point),
+ files.items(.distance_from_entry_point),
+ comptime file.distance_from_entry_point,
+ );
+ this.stable_source_indices = @ptrCast([]const u32, stable_source_indices);
+ }
+
+ {
+ var input_symbols = js_ast.Symbol.Map.initList(js_ast.Symbol.NestedList.init(this.ast.items(.symbols)));
+ var symbols = input_symbols.symbols_for_source.clone(this.allocator) catch @panic("Out of memory");
+ for (symbols.slice(), input_symbols.symbols_for_source.slice()) |*dest, src| {
+ dest.* = src.clone(this.allocator) catch @panic("Out of memory");
+ }
+ this.symbols = js_ast.Symbol.Map.initList(symbols);
+ }
+
+ var in_resolved_exports: []ResolvedExports = this.meta.items(.resolved_exports);
+ var src_resolved_exports: []js_ast.Ast.NamedExports = this.ast.items(.named_exports);
+ for (src_resolved_exports, in_resolved_exports, 0..) |src, *dest, source_index| {
+ var resolved = ResolvedExports{};
+ resolved.ensureTotalCapacity(this.allocator, src.count()) catch unreachable;
+ for (src.keys(), src.values()) |key, value| {
+ resolved.putAssumeCapacityNoClobber(
+ key,
+ .{
+ .data = .{
+ .import_ref = value.ref,
+ .name_loc = value.alias_loc,
+ .source_index = Index.source(source_index),
+ },
+ },
+ );
+ }
+ dest.* = resolved;
+ }
+ }
+
+ pub const File = struct {
+ entry_bits: AutoBitSet = undefined,
+
+ input_file: Index = Index.source(0),
+
+ /// The minimum number of links in the module graph to get from an entry point
+ /// to this file
+ distance_from_entry_point: u32 = std.math.maxInt(u32),
+
+ /// If "entryPointKind" is not "entryPointNone", this is the index of the
+ /// corresponding entry point chunk.
+ entry_point_chunk_index: u32 = 0,
+
+ /// This file is an entry point if and only if this is not "entryPointNone".
+ /// Note that dynamically-imported files are allowed to also be specified by
+ /// the user as top-level entry points, so some dynamically-imported files
+ /// may be "entryPointUserSpecified" instead of "entryPointDynamicImport".
+ entry_point_kind: EntryPoint.Kind = .none,
+
+ pub fn isEntryPoint(this: *const File) bool {
+ return this.entry_point_kind.isEntryPoint();
+ }
+
+ pub fn isUserSpecifiedEntryPoint(this: *const File) bool {
+ return this.entry_point_kind.isUserSpecifiedEntryPoint();
+ }
+
+ pub const List = MultiArrayList(File);
+ };
+};
+
+const LinkerContext = struct {
+ const debug = Output.scoped(.LinkerCtx, false);
+
+ parse_graph: *Graph = undefined,
+ graph: LinkerGraph = undefined,
+ allocator: std.mem.Allocator = undefined,
+ log: *Logger.Log = undefined,
+
+ resolver: *Resolver = undefined,
+ cycle_detector: std.ArrayList(ImportTracker) = undefined,
+ swap_cycle_detector: std.ArrayList(ImportTracker) = undefined,
+
+ /// We may need to refer to the "__esm" and/or "__commonJS" runtime symbols
+ cjs_runtime_ref: Ref = Ref.None,
+ esm_runtime_ref: Ref = Ref.None,
+
+ /// We may need to refer to the CommonJS "module" symbol for exports
+ unbound_module_ref: Ref = Ref.None,
+
+ options: LinkerOptions = LinkerOptions{},
+
+ wait_group: ThreadPoolLib.WaitGroup = undefined,
+
+ ambiguous_result_pool: std.ArrayList(MatchImport) = undefined,
+
+ loop: EventLoop,
+
+ /// string buffer containing pre-formatted unique keys
+ unique_key_buf: []u8 = "",
+
+ /// string buffer containing prefix for each unique keys
+ unique_key_prefix: string = "",
+
+ pub const LinkerOptions = struct {
+ output_format: options.OutputFormat = .esm,
+ ignore_dce_annotations: bool = false,
+ tree_shaking: bool = true,
+ minify_whitespace: bool = false,
+ minify_syntax: bool = false,
+
+ mode: Mode = Mode.bundle,
+
+ public_path: []const u8 = "",
+
+ pub const Mode = enum {
+ passthrough,
+ bundle,
+ };
+ };
+
+ fn isExternalDynamicImport(this: *LinkerContext, record: *const ImportRecord, source_index: u32) bool {
+ return this.graph.code_splitting and
+ record.kind == .dynamic and
+ this.graph.files.items(.entry_point_kind)[record.source_index.get()].isEntryPoint() and
+ record.source_index.get() != source_index;
+ }
+
+ inline fn shouldCallRuntimeRequire(format: options.OutputFormat) bool {
+ return format != .cjs;
+ }
+
+ pub fn shouldIncludePart(c: *LinkerContext, source_index: Index.Int, part: js_ast.Part) bool {
+ // As an optimization, ignore parts containing a single import statement to
+ // an internal non-wrapped file. These will be ignored anyway and it's a
+ // performance hit to spin up a goroutine only to discover this later.
+ if (part.stmts.len == 1) {
+ if (part.stmts[0].data == .s_import) {
+ const record = c.graph.ast.items(.import_records)[source_index].at(part.stmts[0].data.s_import.import_record_index);
+ if (record.tag.isReactReference())
+ return true;
+
+ if (record.source_index.isValid() and c.graph.meta.items(.flags)[record.source_index.get()].wrap == .none) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ fn load(
+ this: *LinkerContext,
+ bundle: *BundleV2,
+ entry_points: []Index,
+ use_directive_entry_points: UseDirective.List,
+ reachable: []Index,
+ ) !void {
+ this.parse_graph = &bundle.graph;
+
+ this.graph.code_splitting = bundle.bundler.options.code_splitting;
+ this.log = bundle.bundler.log;
+
+ this.resolver = &bundle.bundler.resolver;
+ this.cycle_detector = std.ArrayList(ImportTracker).init(this.allocator);
+ this.swap_cycle_detector = std.ArrayList(ImportTracker).init(this.allocator);
+
+ this.graph.reachable_files = reachable;
+
+ const sources: []const Logger.Source = this.parse_graph.input_files.items(.source);
+
+ try this.graph.load(entry_points, sources, use_directive_entry_points);
+ this.wait_group.init();
+ this.ambiguous_result_pool = std.ArrayList(MatchImport).init(this.allocator);
+
+ var runtime_named_exports = &this.graph.ast.items(.named_exports)[Index.runtime.get()];
+
+ this.esm_runtime_ref = runtime_named_exports.get("__esm").?.ref;
+ this.cjs_runtime_ref = runtime_named_exports.get("__commonJS").?.ref;
+ }
+
+ pub noinline fn link(
+ this: *LinkerContext,
+ bundle: *BundleV2,
+ entry_points: []Index,
+ use_directive_entry_points: UseDirective.List,
+ reachable: []Index,
+ unique_key: u64,
+ ) ![]Chunk {
+ try this.load(
+ bundle,
+ entry_points,
+ use_directive_entry_points,
+ reachable,
+ );
+
+ try this.scanImportsAndExports();
+
+ // Stop now if there were errors
+ if (this.log.hasErrors()) {
+ return &[_]Chunk{};
+ }
+
+ try this.treeShakingAndCodeSplitting();
+
+ const chunks = try this.computeChunks(unique_key);
+
+ try this.computeCrossChunkDependencies(chunks);
+
+ this.graph.symbols.followAll();
+
+ return chunks;
+ }
+
+ pub noinline fn computeChunks(
+ this: *LinkerContext,
+ unique_key: u64,
+ ) ![]Chunk {
+ var stack_fallback = std.heap.stackFallback(4096, this.allocator);
+ var stack_all = stack_fallback.get();
+ var arena = std.heap.ArenaAllocator.init(stack_all);
+ defer arena.deinit();
+
+ var temp_allocator = arena.allocator();
+ var js_chunks = bun.StringArrayHashMap(Chunk).init(this.allocator);
+ try js_chunks.ensureUnusedCapacity(this.graph.entry_points.len);
+
+ const entry_source_indices = this.graph.entry_points.items(.source_index);
+
+ // Create chunks for entry points
+ for (entry_source_indices, 0..) |source_index, entry_id_| {
+ const entry_bit = @truncate(Chunk.EntryPoint.ID, entry_id_);
+
+ var entry_bits = &this.graph.files.items(.entry_bits)[source_index];
+ entry_bits.set(entry_bit);
+
+ // Create a chunk for the entry point here to ensure that the chunk is
+ // always generated even if the resulting file is empty
+ var js_chunk_entry = try js_chunks.getOrPut(try temp_allocator.dupe(u8, entry_bits.bytes(this.graph.entry_points.len)));
+
+ js_chunk_entry.value_ptr.* = .{
+ .entry_point = .{
+ .entry_point_id = entry_bit,
+ .source_index = source_index,
+ .is_entry_point = true,
+ },
+ .entry_bits = entry_bits.*,
+ .content = .{
+ .javascript = .{},
+ },
+ };
+ }
+ var file_entry_bits: []AutoBitSet = this.graph.files.items(.entry_bits);
+
+ const Handler = struct {
+ chunks: []Chunk,
+ allocator: std.mem.Allocator,
+ source_id: u32,
+ pub fn next(c: *@This(), chunk_id: usize) void {
+ _ = c.chunks[chunk_id].files_with_parts_in_chunk.getOrPut(c.allocator, @truncate(u32, c.source_id)) catch unreachable;
+ }
+ };
+
+ // Figure out which JS files are in which chunk
+ for (this.graph.reachable_files) |source_index| {
+ if (this.graph.files_live.isSet(source_index.get())) {
+ const entry_bits: *const AutoBitSet = &file_entry_bits[source_index.get()];
+
+ if (this.graph.code_splitting) {
+ var js_chunk_entry = try js_chunks.getOrPut(
+ try temp_allocator.dupe(u8, entry_bits.bytes(this.graph.entry_points.len)),
+ );
+
+ if (!js_chunk_entry.found_existing) {
+ js_chunk_entry.value_ptr.* = .{
+ .entry_bits = entry_bits.*,
+ .entry_point = .{
+ .source_index = source_index.get(),
+ },
+ .content = .{
+ .javascript = .{},
+ },
+ };
+ }
+
+ _ = js_chunk_entry.value_ptr.files_with_parts_in_chunk.getOrPut(this.allocator, @truncate(u32, source_index.get())) catch unreachable;
+ } else {
+ var handler = Handler{
+ .chunks = js_chunks.values(),
+ .allocator = this.allocator,
+ .source_id = source_index.get(),
+ };
+ entry_bits.forEach(Handler, &handler, Handler.next);
+ }
+ }
+ }
+
+ js_chunks.sort(strings.StringArrayByIndexSorter.init(try temp_allocator.dupe(string, js_chunks.keys())));
+
+ var chunks: []Chunk = js_chunks.values();
+
+ var entry_point_chunk_indices: []u32 = this.graph.files.items(.entry_point_chunk_index);
+ // Map from the entry point file to this chunk. We will need this later if
+ // a file contains a dynamic import to this entry point, since we'll need
+ // to look up the path for this chunk to use with the import.
+ for (chunks, 0..) |*chunk, chunk_id| {
+ if (chunk.entry_point.is_entry_point) {
+ entry_point_chunk_indices[chunk.entry_point.source_index] = @truncate(u32, chunk_id);
+ }
+ }
+
+ // Determine the order of JS files (and parts) within the chunk ahead of time
+ try this.findAllImportedPartsInJSOrder(temp_allocator, chunks);
+
+ const unique_key_item_len = std.fmt.count("{any}C{d:0>8}", .{ bun.fmt.hexIntLower(unique_key), chunks.len });
+ var unique_key_builder = try bun.StringBuilder.initCapacity(this.allocator, unique_key_item_len * chunks.len);
+ this.unique_key_buf = unique_key_builder.allocatedSlice();
+
+ errdefer {
+ unique_key_builder.deinit(this.allocator);
+ this.unique_key_buf = "";
+ }
+
+ for (chunks, 0..) |*chunk, chunk_id| {
+
+ // Assign a unique key to each chunk. This key encodes the index directly so
+ // we can easily recover it later without needing to look it up in a map. The
+ // last 8 numbers of the key are the chunk index.
+ chunk.unique_key = unique_key_builder.fmt("{any}C{d:0>8}", .{ bun.fmt.hexIntLower(unique_key), chunk_id });
+ if (this.unique_key_prefix.len == 0)
+ this.unique_key_prefix = chunk.unique_key[0..std.fmt.count("{any}", .{bun.fmt.hexIntLower(unique_key)})];
+
+ if (chunk.entry_point.is_entry_point) {
+ chunk.template = PathTemplate.file;
+ if (this.resolver.opts.entry_names.len > 0)
+ chunk.template.data = this.resolver.opts.entry_names;
+ const pathname = Fs.PathName.init(this.graph.entry_points.items(.output_path)[chunk.entry_point.entry_point_id].slice());
+ chunk.template.placeholder.name = pathname.base;
+ chunk.template.placeholder.ext = "js";
+ chunk.template.placeholder.dir = pathname.dir;
+ } else {
+ chunk.template = PathTemplate.chunk;
+ }
+ }
+
+ return chunks;
+ }
+
+ pub fn findAllImportedPartsInJSOrder(this: *LinkerContext, temp_allocator: std.mem.Allocator, chunks: []Chunk) !void {
+ var part_ranges_shared = std.ArrayList(PartRange).init(temp_allocator);
+ var parts_prefix_shared = std.ArrayList(PartRange).init(temp_allocator);
+ defer part_ranges_shared.deinit();
+ defer parts_prefix_shared.deinit();
+ for (chunks) |*chunk| {
+ try this.findImportedPartsInJSOrder(
+ chunk,
+ &part_ranges_shared,
+ &parts_prefix_shared,
+ );
+ }
+ }
+
+ pub fn findImportedPartsInJSOrder(
+ this: *LinkerContext,
+ chunk: *Chunk,
+ part_ranges_shared: *std.ArrayList(PartRange),
+ parts_prefix_shared: *std.ArrayList(PartRange),
+ ) !void {
+ var chunk_order_array = try std.ArrayList(Chunk.Order).initCapacity(this.allocator, chunk.files_with_parts_in_chunk.count());
+ defer chunk_order_array.deinit();
+ var distances = this.graph.files.items(.distance_from_entry_point);
+ for (chunk.files_with_parts_in_chunk.keys()) |source_index| {
+ chunk_order_array.appendAssumeCapacity(
+ .{
+ .source_index = source_index,
+ .distance = distances[source_index],
+
+ .tie_breaker = this.graph.stable_source_indices[source_index],
+ },
+ );
+ }
+
+ Chunk.Order.sort(chunk_order_array.items);
+
+ const Visitor = struct {
+ entry_bits: *const AutoBitSet,
+ flags: []const JSMeta.Flags,
+ parts: []BabyList(js_ast.Part),
+ import_records: []BabyList(ImportRecord),
+ files: std.ArrayList(Index.Int) = undefined,
+ part_ranges: std.ArrayList(PartRange) = undefined,
+ visited: std.AutoHashMap(Index.Int, void) = undefined,
+ parts_prefix: std.ArrayList(PartRange) = undefined,
+ c: *LinkerContext,
+ entry_point: Chunk.EntryPoint,
+
+ fn appendOrExtendRange(
+ ranges: *std.ArrayList(PartRange),
+ source_index: Index.Int,
+ part_index: Index.Int,
+ ) void {
+ if (ranges.items.len > 0) {
+ var last_range = &ranges.items[ranges.items.len - 1];
+ if (last_range.source_index.get() == source_index and last_range.part_index_end == part_index) {
+ last_range.part_index_end += 1;
+ return;
+ }
+ }
+
+ ranges.append(.{
+ .source_index = Index.init(source_index),
+ .part_index_begin = part_index,
+ .part_index_end = part_index + 1,
+ }) catch unreachable;
+ }
+
+ // Traverse the graph using this stable order and linearize the files with
+ // dependencies before dependents
+ pub fn visit(
+ v: *@This(),
+ source_index: Index.Int,
+ comptime with_react_server_components: UseDirective.Flags,
+ comptime with_code_splitting: bool,
+ ) void {
+ if (source_index == Index.invalid.value) return;
+ const visited_entry = v.visited.getOrPut(source_index) catch unreachable;
+ if (visited_entry.found_existing) return;
+
+ var is_file_in_chunk = if (comptime with_code_splitting)
+ // when code splitting, include the file in the chunk if ALL of the entry points overlap
+ v.entry_bits.eql(&v.c.graph.files.items(.entry_bits)[source_index])
+ else
+ // when NOT code splitting, include the file in the chunk if ANY of the entry points overlap
+ v.entry_bits.hasIntersection(&v.c.graph.files.items(.entry_bits)[source_index]);
+
+ if (comptime with_react_server_components.is_client or with_react_server_components.is_server) {
+ if (is_file_in_chunk and
+ v.entry_point.is_entry_point and
+ v.entry_point.source_index != source_index)
+ {
+ if (comptime with_react_server_components.is_client) {
+ if (v.c.graph.react_client_component_boundary.isSet(source_index)) {
+ if (!v.c.graph.react_client_component_boundary.isSet(v.entry_point.source_index)) {
+ return;
+ }
+ }
+ }
+
+ if (comptime with_react_server_components.is_server) {
+ if (v.c.graph.react_server_component_boundary.isSet(source_index)) {
+ if (!v.c.graph.react_server_component_boundary.isSet(v.entry_point.source_index)) {
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ // Wrapped files can't be split because they are all inside the wrapper
+ const can_be_split = v.flags[source_index].wrap == .none;
+
+ const parts = v.parts[source_index].slice();
+ if (can_be_split and is_file_in_chunk and parts[js_ast.namespace_export_part_index].is_live) {
+ appendOrExtendRange(&v.part_ranges, source_index, js_ast.namespace_export_part_index);
+ }
+
+ const records = v.import_records[source_index].slice();
+
+ for (parts, 0..) |part, part_index_| {
+ const part_index = @truncate(u32, part_index_);
+ const is_part_in_this_chunk = is_file_in_chunk and part.is_live;
+ for (part.import_record_indices.slice()) |record_id| {
+ const record = &records[record_id];
+ if (record.source_index.isValid() and (record.kind == .stmt or is_part_in_this_chunk)) {
+ if (v.c.isExternalDynamicImport(record, source_index)) {
+ // Don't follow import() dependencies
+ continue;
+ }
+
+ v.visit(record.source_index.get(), with_react_server_components, with_code_splitting);
+ }
+ }
+
+ // Then include this part after the files it imports
+ if (is_part_in_this_chunk) {
+ is_file_in_chunk = true;
+
+ if (can_be_split and
+ part_index != js_ast.namespace_export_part_index and
+ v.c.shouldIncludePart(source_index, part))
+ {
+ var js_parts = if (source_index == Index.runtime.value)
+ &v.parts_prefix
+ else
+ &v.part_ranges;
+
+ appendOrExtendRange(js_parts, source_index, part_index);
+ }
+ }
+ }
+
+ if (is_file_in_chunk) {
+ v.files.append(source_index) catch unreachable;
+
+ // CommonJS files are all-or-nothing so all parts must be contiguous
+ if (!can_be_split) {
+ v.parts_prefix.append(
+ .{
+ .source_index = Index.init(source_index),
+ .part_index_begin = 0,
+ .part_index_end = @truncate(u32, parts.len),
+ },
+ ) catch unreachable;
+ }
+ }
+ }
+ };
+
+ part_ranges_shared.clearRetainingCapacity();
+ parts_prefix_shared.clearRetainingCapacity();
+
+ var visitor = Visitor{
+ .files = std.ArrayList(Index.Int).init(this.allocator),
+ .part_ranges = part_ranges_shared.*,
+ .parts_prefix = parts_prefix_shared.*,
+ .visited = std.AutoHashMap(Index.Int, void).init(this.allocator),
+ .flags = this.graph.meta.items(.flags),
+ .parts = this.graph.ast.items(.parts),
+ .import_records = this.graph.ast.items(.import_records),
+ .entry_bits = chunk.entryBits(),
+ .c = this,
+ .entry_point = chunk.entry_point,
+ };
+ defer {
+ part_ranges_shared.* = visitor.part_ranges;
+ parts_prefix_shared.* = visitor.parts_prefix;
+ visitor.visited.deinit();
+ }
+
+ switch (this.graph.code_splitting) {
+ inline else => |with_code_splitting| switch (this.graph.react_client_component_boundary.bit_length > 0) {
+ inline else => |with_client| switch (this.graph.react_server_component_boundary.bit_length > 0) {
+ inline else => |with_server| {
+ visitor.visit(
+ Index.runtime.value,
+ .{
+ .is_server = with_server,
+ .is_client = with_client,
+ },
+ with_code_splitting,
+ );
+ for (chunk_order_array.items) |order| {
+ visitor.visit(
+ order.source_index,
+ .{
+ .is_server = with_server,
+ .is_client = with_client,
+ },
+ with_code_splitting,
+ );
+ }
+ },
+ },
+ },
+ }
+
+ var parts_in_chunk_order = try this.allocator.alloc(PartRange, visitor.part_ranges.items.len + visitor.parts_prefix.items.len);
+ bun.concat(
+ PartRange,
+ parts_in_chunk_order,
+ &.{ visitor.parts_prefix.items, visitor.part_ranges.items },
+ );
+ chunk.content.javascript.files_in_chunk_order = visitor.files.items;
+
+ chunk.content.javascript.parts_in_chunk_in_order = parts_in_chunk_order;
+ }
+
+ pub fn scanImportsAndExports(this: *LinkerContext) !void {
+ const reachable = this.graph.reachable_files;
+ const output_format = this.options.output_format;
+ {
+ var import_records_list: []ImportRecord.List = this.graph.ast.items(.import_records);
+
+ // var parts_list: [][]js_ast.Part = this.graph.ast.items(.parts);
+ var exports_kind: []js_ast.ExportsKind = this.graph.ast.items(.exports_kind);
+ var entry_point_kinds: []EntryPoint.Kind = this.graph.files.items(.entry_point_kind);
+ var named_imports: []js_ast.Ast.NamedImports = this.graph.ast.items(.named_imports);
+ var flags: []JSMeta.Flags = this.graph.meta.items(.flags);
+
+ var export_star_import_records: [][]u32 = this.graph.ast.items(.export_star_import_records);
+ var exports_refs: []Ref = this.graph.ast.items(.exports_ref);
+ var module_refs: []?Ref = this.graph.ast.items(.module_ref);
+ var symbols = &this.graph.symbols;
+ defer this.graph.symbols = symbols.*;
+
+ // Step 1: Figure out what modules must be CommonJS
+ for (reachable) |source_index_| {
+ const id = source_index_.get();
+
+ // does it have a JS AST?
+ if (!(id < import_records_list.len)) continue;
+
+ var import_records: []ImportRecord = import_records_list[id].slice();
+ for (import_records) |record| {
+ if (!record.source_index.isValid()) {
+ continue;
+ }
+
+ const other_file = record.source_index.get();
+ // other file is empty
+ if (other_file >= exports_kind.len) continue;
+ const other_kind = exports_kind[other_file];
+
+ switch (record.kind) {
+ ImportKind.stmt => {
+ // Importing using ES6 syntax from a file without any ES6 syntax
+ // causes that module to be considered CommonJS-style, even if it
+ // doesn't have any CommonJS exports.
+ //
+ // That means the ES6 imports will become undefined instead of
+ // causing errors. This is for compatibility with older CommonJS-
+ // style bundlers.
+ //
+ // We emit a warning in this case but try to avoid turning the module
+ // into a CommonJS module if possible. This is possible with named
+ // imports (the module stays an ECMAScript module but the imports are
+ // rewritten with undefined) but is not possible with star or default
+ // imports:
+ //
+ // import * as ns from './empty-file'
+ // import defVal from './empty-file'
+ // console.log(ns, defVal)
+ //
+ // In that case the module *is* considered a CommonJS module because
+ // the namespace object must be created.
+ if ((record.contains_import_star or record.contains_default_alias) and
+ // TODO: hasLazyExport
+ exports_kind[other_file] == .none)
+ {
+ exports_kind[other_file] = .cjs;
+ flags[other_file].wrap = .cjs;
+ }
+ },
+ ImportKind.require =>
+ // Files that are imported with require() must be CommonJS modules
+ {
+ if (other_kind == .esm) {
+ flags[other_file].wrap = .esm;
+ } else {
+ flags[other_file].wrap = .cjs;
+ exports_kind[other_file] = .cjs;
+ }
+ },
+ ImportKind.dynamic => {
+ if (!this.graph.code_splitting) {
+ // If we're not splitting, then import() is just a require() that
+ // returns a promise, so the imported file must be a CommonJS module
+ if (exports_kind[other_file] == .esm) {
+ flags[other_file].wrap = .esm;
+ } else {
+ flags[other_file].wrap = .cjs;
+ exports_kind[other_file] = .cjs;
+ }
+ }
+ },
+ else => {},
+ }
+ }
+
+ const kind = exports_kind[id];
+
+ // If the output format doesn't have an implicit CommonJS wrapper, any file
+ // that uses CommonJS features will need to be wrapped, even though the
+ // resulting wrapper won't be invoked by other files. An exception is made
+ // for entry point files in CommonJS format (or when in pass-through mode).
+ if (kind == .cjs and (!entry_point_kinds[id].isEntryPoint() or output_format == .iife or output_format == .esm)) {
+ flags[id].wrap = .cjs;
+ std.debug.assert(kind == .cjs);
+ }
+ }
+
+ if (comptime Environment.allow_assert) {
+ var cjs_count: usize = 0;
+ var esm_count: usize = 0;
+ var wrap_cjs_count: usize = 0;
+ var wrap_esm_count: usize = 0;
+ for (exports_kind) |kind| {
+ cjs_count += @boolToInt(kind == .cjs);
+ esm_count += @boolToInt(kind == .esm);
+ }
+
+ for (flags) |flag| {
+ wrap_cjs_count += @boolToInt(flag.wrap == .cjs);
+ wrap_esm_count += @boolToInt(flag.wrap == .esm);
+ }
+
+ debug("Step 1: {d} CommonJS modules (+ {d} wrapped), {d} ES modules (+ {d} wrapped)", .{
+ cjs_count,
+ wrap_cjs_count,
+ esm_count,
+ wrap_esm_count,
+ });
+ }
+
+ // Step 2: Propagate dynamic export status for export star statements that
+ // are re-exports from a module whose exports are not statically analyzable.
+ // In this case the export star must be evaluated at run time instead of at
+ // bundle time.
+
+ {
+ var dependency_wrapper = DependencyWrapper{
+ .linker = this,
+ .flags = flags,
+ .import_records = import_records_list,
+ .exports_kind = exports_kind,
+ .entry_point_kinds = entry_point_kinds,
+ .export_star_map = std.AutoHashMap(u32, void).init(this.allocator),
+ .export_star_records = export_star_import_records,
+ .output_format = output_format,
+ };
+ defer dependency_wrapper.export_star_map.deinit();
+
+ for (reachable) |source_index_| {
+ const source_index = source_index_.get();
+ const id = source_index;
+
+ // does it have a JS AST?
+ if (!(id < import_records_list.len)) continue;
+
+ if (flags[id].wrap != .none) {
+ dependency_wrapper.wrap(id);
+ }
+
+ if (export_star_import_records[id].len > 0) {
+ dependency_wrapper.export_star_map.clearRetainingCapacity();
+ _ = dependency_wrapper.hasDynamicExportsDueToExportStar(id);
+ }
+
+ // Even if the output file is CommonJS-like, we may still need to wrap
+ // CommonJS-style files. Any file that imports a CommonJS-style file will
+ // cause that file to need to be wrapped. This is because the import
+ // method, whatever it is, will need to invoke the wrapper. Note that
+ // this can include entry points (e.g. an entry point that imports a file
+ // that imports that entry point).
+ for (import_records_list[id].slice()) |record| {
+ if (record.source_index.isValid()) {
+ if (exports_kind[record.source_index.get()] == .cjs) {
+ dependency_wrapper.wrap(record.source_index.get());
+ }
+ }
+ }
+ }
+ }
+
+ // Step 3: Resolve "export * from" statements. This must be done after we
+ // discover all modules that can have dynamic exports because export stars
+ // are ignored for those modules.
+ {
+ var export_star_ctx: ?ExportStarContext = null;
+ var resolved_exports: []ResolvedExports = this.graph.meta.items(.resolved_exports);
+ var resolved_export_stars: []ExportData = this.graph.meta.items(.resolved_export_star);
+
+ for (reachable) |source_index_| {
+ const source_index = source_index_.get();
+ const id = source_index;
+
+ // --
+ // TODO: generateCodeForLazyExport here!
+ // --
+
+ // Propagate exports for export star statements
+ var export_star_ids = export_star_import_records[id];
+ if (export_star_ids.len > 0) {
+ if (export_star_ctx == null) {
+ export_star_ctx = ExportStarContext{
+ .allocator = this.allocator,
+ .resolved_exports = resolved_exports,
+ .import_records_list = import_records_list,
+ .export_star_records = export_star_import_records,
+
+ .imports_to_bind = this.graph.meta.items(.imports_to_bind),
+
+ .source_index_stack = std.ArrayList(u32).initCapacity(this.allocator, 32) catch unreachable,
+ .exports_kind = exports_kind,
+ .named_exports = this.graph.ast.items(.named_exports),
+ };
+ } else {
+ export_star_ctx.?.source_index_stack.clearRetainingCapacity();
+ }
+ export_star_ctx.?.addExports(&resolved_exports[id], source_index);
+ }
+
+ // Also add a special export so import stars can bind to it. This must be
+ // done in this step because it must come after CommonJS module discovery
+ // but before matching imports with exports.
+ resolved_export_stars[id] = ExportData{
+ .data = .{
+ .source_index = Index.source(source_index),
+ .import_ref = exports_refs[id],
+ },
+ };
+ }
+ }
+
+ // Step 4: Match imports with exports. This must be done after we process all
+ // export stars because imports can bind to export star re-exports.
+ {
+ this.cycle_detector.clearRetainingCapacity();
+ var wrapper_part_indices = this.graph.meta.items(.wrapper_part_index);
+ var imports_to_bind = this.graph.meta.items(.imports_to_bind);
+
+ for (reachable) |source_index_| {
+ const source_index = source_index_.get();
+ const id = source_index;
+
+ // not a JS ast or empty
+ if (id >= named_imports.len) {
+ continue;
+ }
+
+ var named_imports_ = &named_imports[id];
+ if (named_imports_.count() > 0) {
+ this.matchImportsWithExportsForFile(
+ named_imports_,
+ &imports_to_bind[id],
+ source_index,
+ );
+ }
+ const export_kind = exports_kind[id];
+ var flag = flags[id];
+ // If we're exporting as CommonJS and this file was originally CommonJS,
+ // then we'll be using the actual CommonJS "exports" and/or "module"
+ // symbols. In that case make sure to mark them as such so they don't
+ // get minified.
+ if ((output_format == .cjs or output_format == .preserve) and
+ entry_point_kinds[source_index].isEntryPoint() and
+ export_kind == .cjs and flag.wrap == .none)
+ {
+ const exports_ref = symbols.follow(exports_refs[id]);
+ const module_ref = symbols.follow(module_refs[id].?);
+ symbols.get(exports_ref).?.kind = .unbound;
+ symbols.get(module_ref).?.kind = .unbound;
+ } else if (flag.force_include_exports_for_entry_point or export_kind != .cjs) {
+ flag.needs_exports_variable = true;
+ flags[id] = flag;
+ }
+
+ const wrapped_ref = this.graph.ast.items(.wrapper_ref)[id] orelse continue;
+ if (wrapped_ref.isNull()) continue;
+
+ // Create the wrapper part for wrapped files. This is needed by a later step.
+ this.createWrapperForFile(
+ flag.wrap,
+ // if this one is null, the AST does not need to be wrapped.
+ wrapped_ref,
+ &wrapper_part_indices[id],
+ source_index,
+ );
+ }
+ }
+
+ // Step 5: Create namespace exports for every file. This is always necessary
+ // for CommonJS files, and is also necessary for other files if they are
+ // imported using an import star statement.
+ // Note: `do` will wait for all to finish before moving forward
+ try this.parse_graph.pool.pool.do(this.allocator, &this.wait_group, this, doStep5, this.graph.reachable_files);
+ }
+ // Step 6: Bind imports to exports. This adds non-local dependencies on the
+ // parts that declare the export to all parts that use the import. Also
+ // generate wrapper parts for wrapped files.
+ {
+ const bufPrint = std.fmt.bufPrint;
+ var parts_list: []js_ast.Part.List = this.graph.ast.items(.parts);
+ var wrapper_refs = this.graph.ast.items(.wrapper_ref);
+ // const needs_export_symbol_from_runtime: []const bool = this.graph.meta.items(.needs_export_symbol_from_runtime);
+ var imports_to_bind_list: []RefImportData = this.graph.meta.items(.imports_to_bind);
+ var runtime_export_symbol_ref: Ref = Ref.None;
+ var entry_point_kinds: []EntryPoint.Kind = this.graph.files.items(.entry_point_kind);
+ const flags: []const JSMeta.Flags = this.graph.meta.items(.flags);
+ const exports_kind = this.graph.ast.items(.exports_kind);
+ const exports_refs = this.graph.ast.items(.exports_ref);
+ const module_refs = this.graph.ast.items(.module_ref);
+ const named_imports = this.graph.ast.items(.named_imports);
+ const import_records_list = this.graph.ast.items(.import_records);
+ const export_star_import_records = this.graph.ast.items(.export_star_import_records);
+ for (reachable) |source_index_| {
+ const source_index = source_index_.get();
+ const id = source_index;
+
+ const is_entry_point = entry_point_kinds[source_index].isEntryPoint();
+ const aliases = this.graph.meta.items(.sorted_and_filtered_export_aliases)[id];
+ const flag = flags[id];
+ const wrap = flag.wrap;
+ const export_kind = exports_kind[id];
+ const source: *const Logger.Source = &this.parse_graph.input_files.items(.source)[source_index];
+
+ const exports_ref = exports_refs[id];
+ var exports_symbol: ?*js_ast.Symbol = if (exports_ref.isValid())
+ this.graph.symbols.get(exports_ref)
+ else
+ null;
+ const module_ref = module_refs[id] orelse Ref.None;
+ var module_symbol: ?*js_ast.Symbol = if (module_ref.isValid())
+ this.graph.symbols.get(module_ref)
+ else
+ null;
+
+ // TODO: see if counting and batching into a single large allocation instead of per-file improves perf
+ const string_buffer_len: usize = brk: {
+ var count: usize = 0;
+ if (is_entry_point and this.options.output_format == .esm) {
+ for (aliases) |alias| {
+ count += std.fmt.count("export_{}", .{strings.fmtIdentifier(alias)});
+ }
+ }
+
+ const ident_fmt_len: usize = if (source.identifier_name.len > 0)
+ source.identifier_name.len
+ else
+ std.fmt.count("{}", .{source.fmtIdentifier()});
+
+ if (wrap == .esm) {
+ count += "init_".len + ident_fmt_len;
+ }
+
+ if (wrap != .cjs and export_kind != .cjs) {
+ count += "exports_".len + ident_fmt_len;
+ count += "module_".len + ident_fmt_len;
+ }
+
+ break :brk count;
+ };
+
+ var string_buffer = this.allocator.alloc(u8, string_buffer_len) catch unreachable;
+ var buf = string_buffer;
+
+ defer std.debug.assert(buf.len == 0); // ensure we used all of it
+
+ // Pre-generate symbols for re-exports CommonJS symbols in case they
+ // are necessary later. This is done now because the symbols map cannot be
+ // mutated later due to parallelism.
+ if (is_entry_point and this.options.output_format == .esm) {
+ var copies = this.allocator.alloc(Ref, aliases.len) catch unreachable;
+
+ for (aliases, copies) |alias, *copy| {
+ const original_name = bufPrint(buf, "export_{}", .{strings.fmtIdentifier(alias)}) catch unreachable;
+ buf = buf[original_name.len..];
+ copy.* = this.graph.generateNewSymbol(source_index, .other, original_name);
+ }
+ this.graph.meta.items(.cjs_export_copies)[id] = copies;
+ }
+
+ // Use "init_*" for ESM wrappers instead of "require_*"
+ if (wrap == .esm) {
+ const original_name = bufPrint(
+ buf,
+ "init_{}",
+ .{
+ source.fmtIdentifier(),
+ },
+ ) catch unreachable;
+
+ buf = buf[original_name.len..];
+ this.graph.symbols.get(wrapper_refs[id].?).?.original_name = original_name;
+ }
+
+ // If this isn't CommonJS, then rename the unused "exports" and "module"
+ // variables to avoid them causing the identically-named variables in
+ // actual CommonJS files from being renamed. This is purely about
+ // aesthetics and is not about correctness. This is done here because by
+ // this point, we know the CommonJS status will not change further.
+ if (wrap != .cjs and export_kind != .cjs) {
+ const exports_name = bufPrint(buf, "exports_{any}", .{source.fmtIdentifier()}) catch unreachable;
+ buf = buf[exports_name.len..];
+ const module_name = bufPrint(buf, "module_{any}", .{source.fmtIdentifier()}) catch unreachable;
+ buf = buf[module_name.len..];
+ if (exports_symbol != null)
+ exports_symbol.?.original_name = exports_name;
+ if (module_symbol != null)
+ module_symbol.?.original_name = module_name;
+ }
+
+ // Include the "__export" symbol from the runtime if it was used in the
+ // previous step. The previous step can't do this because it's running in
+ // parallel and can't safely mutate the "importsToBind" map of another file.
+ if (flag.needs_export_symbol_from_runtime) {
+ if (!runtime_export_symbol_ref.isValid()) {
+ runtime_export_symbol_ref = this.runtimeFunction("__export");
+ }
+
+ std.debug.assert(runtime_export_symbol_ref.isValid());
+
+ this.graph.generateSymbolImportAndUse(
+ id,
+ js_ast.namespace_export_part_index,
+ runtime_export_symbol_ref,
+ 1,
+ Index.runtime,
+ ) catch unreachable;
+ }
+
+ var imports_to_bind = &imports_to_bind_list[id];
+
+ var parts: []js_ast.Part = parts_list[id].slice();
+ var needs_reindex = false;
+ for (imports_to_bind.keys(), imports_to_bind.values()) |*import_ref, import| {
+ const import_source_index = import.data.source_index.get();
+ const import_id = import_source_index;
+ const ref = import_ref.*;
+
+ if (named_imports[id].get(ref)) |named_import| {
+ for (named_import.local_parts_with_uses.slice()) |part_index| {
+ var part: *js_ast.Part = &parts[part_index];
+ const parts_declaring_symbol: []u32 =
+ this.graph.ast.items(.top_level_symbols_to_parts)[import_id].get(import.data.import_ref).?.slice();
+
+ part.dependencies.ensureUnusedCapacity(
+ this.allocator,
+ parts_declaring_symbol.len + @as(usize, import.re_exports.len),
+ ) catch unreachable;
+
+ // Depend on the file containing the imported symbol
+ for (parts_declaring_symbol) |resolved_part_index| {
+ part.dependencies.appendAssumeCapacity(
+ .{
+ .source_index = Index.source(import_source_index),
+ .part_index = resolved_part_index,
+ },
+ );
+ }
+
+ // Also depend on any files that re-exported this symbol in between the
+ // file containing the import and the file containing the imported symbol
+ part.dependencies.appendSliceAssumeCapacity(import.re_exports.slice());
+ }
+
+ // Merge these symbols so they will share the same name
+ const merged = this.graph.symbols.merge(ref, import.data.import_ref);
+ import_ref.* = merged;
+ needs_reindex = needs_reindex or !merged.eql(ref);
+ }
+ }
+
+ if (needs_reindex)
+ imports_to_bind.reIndex(this.allocator) catch unreachable;
+
+ // If this is an entry point, depend on all exports so they are included
+ if (is_entry_point) {
+ const force_include_exports = flag.force_include_exports_for_entry_point;
+ const add_wrapper = wrap != .none;
+ var dependencies = std.ArrayList(js_ast.Dependency).initCapacity(
+ this.allocator,
+ @as(usize, @boolToInt(force_include_exports)) + @as(usize, @boolToInt(add_wrapper)),
+ ) catch unreachable;
+ var resolved_exports_list: *ResolvedExports = &this.graph.meta.items(.resolved_exports)[id];
+ for (aliases) |alias| {
+ var export_ = resolved_exports_list.get(alias).?;
+ var target_source_index = export_.data.source_index.get();
+ var target_id = target_source_index;
+ var target_ref = export_.data.import_ref;
+
+ // If this is an import, then target what the import points to
+
+ if (imports_to_bind.get(target_ref)) |import_data| {
+ target_source_index = import_data.data.source_index.get();
+ target_id = target_source_index;
+ target_ref = import_data.data.import_ref;
+ dependencies.appendSlice(import_data.re_exports.slice()) catch unreachable;
+ }
+
+ const top_to_parts = this.topLevelSymbolsToParts(target_id, target_ref);
+ dependencies.ensureUnusedCapacity(top_to_parts.len) catch unreachable;
+ // Pull in all declarations of this symbol
+ for (top_to_parts) |part_index| {
+ dependencies.appendAssumeCapacity(
+ .{
+ .source_index = Index.source(target_source_index),
+ .part_index = part_index,
+ },
+ );
+ }
+ }
+
+ dependencies.ensureUnusedCapacity(@as(usize, @boolToInt(force_include_exports)) + @as(usize, @boolToInt(add_wrapper))) catch unreachable;
+
+ // Ensure "exports" is included if the current output format needs it
+ if (force_include_exports) {
+ dependencies.appendAssumeCapacity(
+ .{ .source_index = Index.source(source_index), .part_index = js_ast.namespace_export_part_index },
+ );
+ }
+
+ if (add_wrapper) {
+ dependencies.appendAssumeCapacity(
+ .{
+ .source_index = Index.source(source_index),
+ .part_index = this.graph.meta.items(.wrapper_part_index)[id].get(),
+ },
+ );
+ }
+
+ // Represent these constraints with a dummy part
+ const entry_point_part_index = this.graph.addPartToFile(
+ id,
+ .{
+ .dependencies = js_ast.Dependency.List.fromList(dependencies),
+ .can_be_removed_if_unused = false,
+ },
+ ) catch unreachable;
+ parts = parts_list[id].slice();
+ this.graph.meta.items(.entry_point_part_index)[id] = Index.part(entry_point_part_index);
+
+ // Pull in the "__toCommonJS" symbol if we need it due to being an entry point
+ if (force_include_exports) {
+ this.graph.generateRuntimeSymbolImportAndUse(
+ source_index,
+ Index.part(entry_point_part_index),
+ "__toCommonJS",
+ 1,
+ ) catch unreachable;
+ }
+ }
+
+ // Encode import-specific constraints in the dependency graph
+ var import_records: []ImportRecord = import_records_list[id].slice();
+ debug("Binding {d} imports for file {s} (#{d})", .{ import_records.len, source.path.text, id });
+
+ for (parts, 0..) |*part, part_index| {
+ var to_esm_uses: u32 = 0;
+ var to_common_js_uses: u32 = 0;
+ var runtime_require_uses: u32 = 0;
+
+ for (part.import_record_indices.slice()) |import_record_index| {
+ var record = &import_records[import_record_index];
+ const kind = record.kind;
+
+ // Don't follow external imports (this includes import() expressions)
+ if (!record.source_index.isValid() or this.isExternalDynamicImport(record, source_index)) {
+ // This is an external import. Check if it will be a "require()" call.
+ if (kind == .require or !output_format.keepES6ImportExportSyntax() or
+ (kind == .dynamic))
+ {
+ // We should use "__require" instead of "require" if we're not
+ // generating a CommonJS output file, since it won't exist otherwise
+ if (shouldCallRuntimeRequire(output_format)) {
+ record.calls_runtime_require = true;
+ runtime_require_uses += 1;
+ }
+
+ // If this wasn't originally a "require()" call, then we may need
+ // to wrap this in a call to the "__toESM" wrapper to convert from
+ // CommonJS semantics to ESM semantics.
+ //
+ // Unfortunately this adds some additional code since the conversion
+ // is somewhat complex. As an optimization, we can avoid this if the
+ // following things are true:
+ //
+ // - The import is an ES module statement (e.g. not an "import()" expression)
+ // - The ES module namespace object must not be captured
+ // - The "default" and "__esModule" exports must not be accessed
+ //
+ if (kind != .require and
+ (kind != .stmt or
+ record.contains_import_star or
+ record.contains_default_alias or
+ record.contains_es_module_alias))
+ {
+ record.wrap_with_to_esm = true;
+ to_esm_uses += 1;
+ }
+ }
+ continue;
+ }
+
+ const other_source_index = record.source_index.get();
+ const other_id = other_source_index;
+ std.debug.assert(@intCast(usize, other_id) < this.graph.meta.len);
+ const other_flags = flags[other_id];
+ const other_export_kind = exports_kind[other_id];
+
+ if (other_flags.wrap != .none) {
+ // Depend on the automatically-generated require wrapper symbol
+ const wrapper_ref = wrapper_refs[other_id].?;
+ this.graph.generateSymbolImportAndUse(
+ source_index,
+ @intCast(u32, part_index),
+ wrapper_ref,
+ 1,
+ Index.source(other_source_index),
+ ) catch unreachable;
+
+ // This is an ES6 import of a CommonJS module, so it needs the
+ // "__toESM" wrapper as long as it's not a bare "require()"
+ if (kind != .require and other_export_kind == .cjs) {
+ record.wrap_with_to_esm = true;
+ to_esm_uses += 1;
+ }
+
+ // If this is an ESM wrapper, also depend on the exports object
+ // since the final code will contain an inline reference to it.
+ // This must be done for "require()" and "import()" expressions
+ // but does not need to be done for "import" statements since
+ // those just cause us to reference the exports directly.
+ if (other_flags.wrap == .esm and record.kind != .stmt) {
+ this.graph.generateSymbolImportAndUse(
+ source_index,
+ @intCast(u32, part_index),
+ this.graph.ast.items(.exports_ref)[other_id],
+ 1,
+ Index.source(other_source_index),
+ ) catch unreachable;
+
+ // If this is a "require()" call, then we should add the
+ // "__esModule" marker to behave as if the module was converted
+ // from ESM to CommonJS. This is done via a wrapper instead of
+ // by modifying the exports object itself because the same ES
+ // module may be simultaneously imported and required, and the
+ // importing code should not see "__esModule" while the requiring
+ // code should see "__esModule". This is an extremely complex
+ // and subtle set of bundler interop issues. See for example
+ // https://github.com/evanw/esbuild/issues/1591.
+ if (record.kind == .require) {
+ record.wrap_with_to_commonjs = true;
+ to_common_js_uses += 1;
+ }
+ }
+ } else if (kind == .stmt and other_export_kind == .esm_with_dynamic_fallback) {
+ // This is an import of a module that has a dynamic export fallback
+ // object. In that case we need to depend on that object in case
+ // something ends up needing to use it later. This could potentially
+ // be omitted in some cases with more advanced analysis if this
+ // dynamic export fallback object doesn't end up being needed.
+ this.graph.generateSymbolImportAndUse(
+ source_index,
+ @intCast(u32, part_index),
+ this.graph.ast.items(.exports_ref)[other_id],
+ 1,
+ Index.source(other_source_index),
+ ) catch unreachable;
+ }
+ }
+
+ // If there's an ES6 import of a non-ES6 module, then we're going to need the
+ // "__toESM" symbol from the runtime to wrap the result of "require()"
+ this.graph.generateRuntimeSymbolImportAndUse(
+ source_index,
+ Index.part(part_index),
+
+ "__toESM",
+ to_esm_uses,
+ ) catch unreachable;
+
+ // If there's a CommonJS require of an ES6 module, then we're going to need the
+ // "__toCommonJS" symbol from the runtime to wrap the exports object
+ this.graph.generateRuntimeSymbolImportAndUse(
+ source_index,
+ Index.part(part_index),
+ "__toCommonJS",
+ to_common_js_uses,
+ ) catch unreachable;
+
+ // If there are unbundled calls to "require()" and we're not generating
+ // code for node, then substitute a "__require" wrapper for "require".
+ this.graph.generateRuntimeSymbolImportAndUse(
+ source_index,
+ Index.part(part_index),
+
+ // TODO: refactor this runtime symbol
+ "__require",
+ runtime_require_uses,
+ ) catch unreachable;
+
+ // If there's an ES6 export star statement of a non-ES6 module, then we're
+ // going to need the "__reExport" symbol from the runtime
+ var re_export_uses: u32 = 0;
+
+ for (export_star_import_records[id]) |import_record_index| {
+ var record = &import_records[import_record_index];
+
+ var happens_at_runtime = record.source_index.isInvalid() and (!is_entry_point or !output_format.keepES6ImportExportSyntax());
+ if (record.source_index.isValid()) {
+ var other_source_index = record.source_index.get();
+ const other_id = other_source_index;
+ std.debug.assert(@intCast(usize, other_id) < this.graph.meta.len);
+ const other_export_kind = exports_kind[other_id];
+ if (other_source_index != source_index and other_export_kind.isDynamic()) {
+ happens_at_runtime = true;
+ }
+
+ if (other_export_kind == .esm_with_dynamic_fallback) {
+ // This looks like "__reExport(exports_a, exports_b)". Make sure to
+ // pull in the "exports_b" symbol into this export star. This matters
+ // in code splitting situations where the "export_b" symbol might live
+ // in a different chunk than this export star.
+ this.graph.generateSymbolImportAndUse(
+ source_index,
+ @intCast(u32, part_index),
+ this.graph.ast.items(.exports_ref)[other_id],
+ 1,
+ Index.source(other_source_index),
+ ) catch unreachable;
+ }
+ }
+
+ if (happens_at_runtime) {
+ // Depend on this file's "exports" object for the first argument to "__reExport"
+ this.graph.generateSymbolImportAndUse(
+ source_index,
+ @intCast(u32, part_index),
+ this.graph.ast.items(.exports_ref)[id],
+ 1,
+ Index.source(source_index),
+ ) catch unreachable;
+ this.graph.ast.items(.uses_exports_ref)[id] = true;
+ record.calls_runtime_re_export_fn = true;
+ re_export_uses += 1;
+ }
+ }
+
+ this.graph.generateRuntimeSymbolImportAndUse(
+ source_index,
+ Index.part(part_index),
+
+ "__reExport",
+ re_export_uses,
+ ) catch unreachable;
+ }
+ }
+ }
+ }
+
+ pub fn createExportsForFile(
+ c: *LinkerContext,
+ allocator_: std.mem.Allocator,
+ id: u32,
+ resolved_exports: *ResolvedExports,
+ imports_to_bind: []RefImportData,
+ export_aliases: []const string,
+ re_exports_count: usize,
+ ) void {
+ ////////////////////////////////////////////////////////////////////////////////
+ // WARNING: This method is run in parallel over all files. Do not mutate data
+ // for other files within this method or you will create a data race.
+ ////////////////////////////////////////////////////////////////////////////////
+
+ Stmt.Disabler.disable();
+ defer Stmt.Disabler.enable();
+ Expr.Disabler.disable();
+ defer Expr.Disabler.enable();
+
+ // 1 property per export
+ var properties = std.ArrayList(js_ast.G.Property)
+ .initCapacity(allocator_, export_aliases.len) catch unreachable;
+
+ var ns_export_symbol_uses = js_ast.Part.SymbolUseMap{};
+ ns_export_symbol_uses.ensureTotalCapacity(allocator_, export_aliases.len) catch unreachable;
+
+ const needs_exports_variable = c.graph.meta.items(.flags)[id].needs_exports_variable;
+
+ const stmts_count =
+ // 2 statements for every export
+ export_aliases.len * 2 +
+ // + 1 if there are non-zero exports
+ @as(usize, @boolToInt(export_aliases.len > 0)) +
+ // + 1 if we need to inject the exports variable
+ @as(usize, @boolToInt(needs_exports_variable));
+
+ var stmts = js_ast.Stmt.Batcher.init(allocator_, stmts_count) catch unreachable;
+ defer stmts.done();
+ const loc = Logger.Loc.Empty;
+ // todo: investigate if preallocating this array is faster
+ var ns_export_dependencies = std.ArrayList(js_ast.Dependency).initCapacity(allocator_, re_exports_count) catch unreachable;
+
+ for (export_aliases) |alias| {
+ var export_ = resolved_exports.getPtr(alias).?;
+
+ const other_id = export_.data.source_index.get();
+
+ // If this is an export of an import, reference the symbol that the import
+ // was eventually resolved to. We need to do this because imports have
+ // already been resolved by this point, so we can't generate a new import
+ // and have that be resolved later.
+ if (imports_to_bind[other_id].get(export_.data.import_ref)) |import_data| {
+ export_.data = import_data.data;
+ ns_export_dependencies.appendSlice(import_data.re_exports.slice()) catch unreachable;
+ }
+
+ // Exports of imports need EImportIdentifier in case they need to be re-
+ // written to a property access later on
+ // note: this is stack allocated
+ const value: js_ast.Expr = brk: {
+ if (c.graph.symbols.getConst(export_.data.import_ref)) |symbol| {
+ if (symbol.namespace_alias != null) {
+ break :brk js_ast.Expr.init(
+ js_ast.E.ImportIdentifier,
+ js_ast.E.ImportIdentifier{
+ .ref = export_.data.import_ref,
+ },
+ loc,
+ );
+ }
+ }
+
+ break :brk js_ast.Expr.init(
+ js_ast.E.Identifier,
+ js_ast.E.Identifier{
+ .ref = export_.data.import_ref,
+ },
+ loc,
+ );
+ };
+
+ const block = stmts.eat1(
+ js_ast.Stmt.allocate(allocator_, js_ast.S.Block, .{
+ .stmts = stmts.eat1(
+ js_ast.Stmt.allocate(
+ allocator_,
+ js_ast.S.Return,
+ .{ .value = value },
+ loc,
+ ),
+ ),
+ }, loc),
+ );
+ const fn_body = js_ast.G.FnBody{
+ .stmts = block,
+ .loc = loc,
+ };
+ properties.appendAssumeCapacity(
+ .{
+ .key = js_ast.Expr.allocate(
+ allocator_,
+ js_ast.E.String,
+ .{
+ // TODO: test emoji work as expected
+ // relevant for WASM exports
+ .data = alias,
+ },
+ loc,
+ ),
+ .value = js_ast.Expr.allocate(
+ allocator_,
+ js_ast.E.Arrow,
+ .{ .prefer_expr = true, .body = fn_body },
+ loc,
+ ),
+ },
+ );
+ ns_export_symbol_uses.putAssumeCapacity(export_.data.import_ref, .{ .count_estimate = 1 });
+
+ // Make sure the part that declares the export is included
+ const parts = c.topLevelSymbolsToParts(other_id, export_.data.import_ref);
+ ns_export_dependencies.ensureUnusedCapacity(parts.len) catch unreachable;
+ var ptr = ns_export_dependencies.items.ptr + ns_export_dependencies.items.len;
+ ns_export_dependencies.items.len += parts.len;
+
+ for (parts, ptr[0..parts.len]) |part_id, *dependency| {
+ // Use a non-local dependency since this is likely from a different
+ // file if it came in through an export star
+ dependency.* = .{
+ .source_index = export_.data.source_index,
+ .part_index = part_id,
+ };
+ }
+ }
+
+ var declared_symbols = js_ast.DeclaredSymbol.List{};
+ var exports_ref = c.graph.ast.items(.exports_ref)[id];
+ var all_export_stmts: []js_ast.Stmt = stmts.head[0 .. @as(usize, @boolToInt(needs_exports_variable)) + @as(usize, @boolToInt(properties.items.len > 0))];
+ stmts.head = stmts.head[all_export_stmts.len..];
+ var remaining_stmts = all_export_stmts;
+ defer std.debug.assert(remaining_stmts.len == 0); // all must be used
+
+ // Prefix this part with "var exports = {}" if this isn't a CommonJS entry point
+ if (needs_exports_variable) {
+ var decls = allocator_.alloc(js_ast.G.Decl, 1) catch unreachable;
+ decls[0] = .{
+ .binding = js_ast.Binding.alloc(
+ allocator_,
+ js_ast.B.Identifier{
+ .ref = exports_ref,
+ },
+ loc,
+ ),
+ .value = js_ast.Expr.allocate(allocator_, js_ast.E.Object, .{}, loc),
+ };
+ remaining_stmts[0] = js_ast.Stmt.allocate(
+ allocator_,
+ js_ast.S.Local,
+ .{
+ .decls = decls,
+ },
+ loc,
+ );
+ remaining_stmts = remaining_stmts[1..];
+ declared_symbols.append(allocator_, .{ .ref = exports_ref, .is_top_level = true }) catch unreachable;
+ }
+
+ // "__export(exports, { foo: () => foo })"
+ var export_ref = Ref.None;
+ if (properties.items.len > 0) {
+ export_ref = c.graph.ast.items(.module_scope)[Index.runtime.get()].members.get("__export").?.ref;
+ var args = allocator_.alloc(js_ast.Expr, 2) catch unreachable;
+ args[0..2].* = [_]js_ast.Expr{
+ js_ast.Expr.initIdentifier(exports_ref, loc),
+ js_ast.Expr.allocate(allocator_, js_ast.E.Object, .{ .properties = js_ast.G.Property.List.fromList(properties) }, loc),
+ };
+ remaining_stmts[0] = js_ast.Stmt.allocate(
+ allocator_,
+ js_ast.S.SExpr,
+ .{
+ .value = js_ast.Expr.allocate(
+ allocator_,
+ js_ast.E.Call,
+ .{
+ .target = js_ast.Expr.initIdentifier(export_ref, loc),
+ .args = js_ast.ExprNodeList.init(args),
+ },
+ loc,
+ ),
+ },
+ loc,
+ );
+ remaining_stmts = remaining_stmts[1..];
+ // Make sure this file depends on the "__export" symbol
+ const parts = c.topLevelSymbolsToPartsForRuntime(export_ref);
+ ns_export_dependencies.ensureUnusedCapacity(parts.len) catch unreachable;
+ for (parts) |part_index| {
+ ns_export_dependencies.appendAssumeCapacity(
+ .{ .source_index = Index.runtime, .part_index = part_index },
+ );
+ }
+
+ // Make sure the CommonJS closure, if there is one, includes "exports"
+ c.graph.ast.items(.uses_exports_ref)[id] = true;
+ }
+
+ // No need to generate a part if it'll be empty
+ if (all_export_stmts.len > 0) {
+ // - we must already have preallocated the parts array
+ // - if the parts list is completely empty, we shouldn't have gotten here in the first place
+
+ // Initialize the part that was allocated for us earlier. The information
+ // here will be used after this during tree shaking.
+ c.graph.ast.items(.parts)[id].slice()[js_ast.namespace_export_part_index] = .{
+ .stmts = all_export_stmts,
+ .symbol_uses = ns_export_symbol_uses,
+ .dependencies = js_ast.Dependency.List.fromList(ns_export_dependencies),
+ .declared_symbols = declared_symbols,
+
+ // This can be removed if nothing uses it
+ .can_be_removed_if_unused = true,
+
+ // Make sure this is trimmed if unused even if tree shaking is disabled
+ .force_tree_shaking = true,
+ };
+
+ // Pull in the "__export" symbol if it was used
+ if (export_ref.isValid()) {
+ c.graph.meta.items(.flags)[id].needs_export_symbol_from_runtime = true;
+ }
+ }
+ }
+
+ /// Step 5: Create namespace exports for every file. This is always necessary
+ /// for CommonJS files, and is also necessary for other files if they are
+ /// imported using an import star statement.
+ pub fn doStep5(c: *LinkerContext, source_index_: Index, _: usize) void {
+ const source_index = source_index_.get();
+
+ const id = source_index;
+ if (id > c.graph.meta.len) return;
+
+ var worker: *ThreadPool.Worker = @ptrCast(
+ *ThreadPool.Worker,
+ @alignCast(
+ @alignOf(*ThreadPool.Worker),
+ ThreadPoolLib.Thread.current.?.ctx.?,
+ ),
+ );
+ // we must use this allocator here
+ const allocator_ = worker.allocator;
+ if (comptime FeatureFlags.help_catch_memory_issues) {
+ worker.heap.gc(false);
+ }
+ defer {
+ if (comptime FeatureFlags.help_catch_memory_issues) {
+ worker.heap.gc(false);
+ }
+ }
+
+ var resolved_exports: *ResolvedExports = &c.graph.meta.items(.resolved_exports)[id];
+
+ // Now that all exports have been resolved, sort and filter them to create
+ // something we can iterate over later.
+ var aliases = std.ArrayList(string).initCapacity(allocator_, resolved_exports.count()) catch unreachable;
+ var alias_iter = resolved_exports.iterator();
+ var imports_to_bind = c.graph.meta.items(.imports_to_bind);
+ var probably_typescript_type = c.graph.meta.items(.probably_typescript_type);
+
+ // counting in here saves us an extra pass through the array
+ var re_exports_count: usize = 0;
+
+ next_alias: while (alias_iter.next()) |entry| {
+ var export_ = entry.value_ptr.*;
+ var alias = entry.key_ptr.*;
+ const this_id = export_.data.source_index.get();
+ var inner_count: usize = 0;
+ // Re-exporting multiple symbols with the same name causes an ambiguous
+ // export. These names cannot be used and should not end up in generated code.
+ if (export_.potentially_ambiguous_export_star_refs.len > 0) {
+ const main = imports_to_bind[this_id].get(export_.data.import_ref) orelse ImportData{ .data = export_.data };
+ for (export_.potentially_ambiguous_export_star_refs.slice()) |ambig| {
+ const _id = ambig.data.source_index.get();
+ const ambig_ref = if (imports_to_bind[_id].get(ambig.data.import_ref)) |bound|
+ bound.data.import_ref
+ else
+ ambig.data.import_ref;
+ if (!main.data.import_ref.eql(ambig_ref)) {
+ continue :next_alias;
+ }
+ inner_count += @as(usize, ambig.re_exports.len);
+ }
+ }
+
+ // Ignore re-exported imports in TypeScript files that failed to be
+ // resolved. These are probably just type-only imports so the best thing to
+ // do is to silently omit them from the export list.
+ if (probably_typescript_type[this_id].contains(export_.data.import_ref)) {
+ continue;
+ }
+ re_exports_count += inner_count;
+
+ aliases.appendAssumeCapacity(alias);
+ }
+ // TODO: can this be u32 instead of a string?
+ // if yes, we could just move all the hidden exports to the end of the array
+ // and only store a count instead of an array
+ strings.sortDesc(aliases.items);
+ const export_aliases = aliases.toOwnedSlice() catch unreachable;
+ c.graph.meta.items(.sorted_and_filtered_export_aliases)[id] = export_aliases;
+
+ // Export creation uses "sortedAndFilteredExportAliases" so this must
+ // come second after we fill in that array
+ c.createExportsForFile(
+ allocator_,
+ id,
+ resolved_exports,
+ imports_to_bind,
+ export_aliases,
+ re_exports_count,
+ );
+
+ // Each part tracks the other parts it depends on within this file
+ var local_dependencies = std.AutoHashMap(u32, u32).init(allocator_);
+ defer local_dependencies.deinit();
+ var parts = &c.graph.ast.items(.parts)[id];
+ var parts_slice: []js_ast.Part = parts.slice();
+ var named_imports: js_ast.Ast.NamedImports = c.graph.ast.items(.named_imports)[id];
+ defer c.graph.ast.items(.named_imports)[id] = named_imports;
+ for (parts_slice, 0..) |*part, part_index| {
+
+ // TODO: inline const TypeScript enum here
+
+ // TODO: inline function calls here
+
+ // note: if we crash on append, it is due to threadlocal heaps in mimalloc
+ const symbol_uses = part.symbol_uses.keys();
+
+ // Now that we know this, we can determine cross-part dependencies
+ for (symbol_uses, 0..) |ref, j| {
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(part.symbol_uses.values()[j].count_estimate > 0);
+ }
+
+ // TODO: inline const values from an import
+
+ const other_parts = c.topLevelSymbolsToParts(id, ref);
+
+ for (other_parts) |other_part_index| {
+ var local = local_dependencies.getOrPut(@intCast(u32, other_part_index)) catch unreachable;
+ if (!local.found_existing or local.value_ptr.* != part_index) {
+ local.value_ptr.* = @intCast(u32, part_index);
+ // note: if we crash on append, it is due to threadlocal heaps in mimalloc
+ part.dependencies.push(
+ allocator_,
+ .{
+ .source_index = Index.source(source_index),
+ .part_index = other_part_index,
+ },
+ ) catch unreachable;
+ }
+ }
+
+ // Also map from imports to parts that use them
+ if (named_imports.getPtr(ref)) |existing| {
+ existing.local_parts_with_uses.push(allocator_, @intCast(u32, part_index)) catch unreachable;
+ }
+ }
+ }
+ }
+
+ const MatchImport = struct {
+ alias: string = "",
+ kind: MatchImport.Kind = MatchImport.Kind.ignore,
+ namespace_ref: Ref = Ref.None,
+ source_index: u32 = 0,
+ name_loc: Logger.Loc = Logger.Loc.Empty, // Optional, goes with sourceIndex, ignore if zero,
+ other_source_index: u32 = 0,
+ other_name_loc: Logger.Loc = Logger.Loc.Empty, // Optional, goes with otherSourceIndex, ignore if zero,
+ ref: Ref = Ref.None,
+
+ pub const Kind = enum {
+ /// The import is either external or undefined
+ ignore,
+
+ /// "sourceIndex" and "ref" are in use
+ normal,
+
+ /// "namespaceRef" and "alias" are in use
+ namespace,
+
+ /// Both "normal" and "namespace"
+ normal_and_namespace,
+
+ /// The import could not be evaluated due to a cycle
+ cycle,
+
+ /// The import is missing but came from a TypeScript file
+ probably_typescript_type,
+
+ /// The import resolved to multiple symbols via "export * from"
+ ambiguous,
+ };
+ };
+ pub fn source_(c: *LinkerContext, index: anytype) *const Logger.Source {
+ return &c.parse_graph.input_files.items(.source)[index];
+ }
+
+ pub fn treeShakingAndCodeSplitting(c: *LinkerContext) !void {
+ var parts = c.graph.ast.items(.parts);
+ var import_records = c.graph.ast.items(.import_records);
+ var side_effects = c.parse_graph.input_files.items(.side_effects);
+ var entry_point_kinds = c.graph.files.items(.entry_point_kind);
+ const entry_points = c.graph.entry_points.items(.source_index);
+ var distances = c.graph.files.items(.distance_from_entry_point);
+
+ // Tree shaking: Each entry point marks all files reachable from itself
+ for (entry_points) |entry_point| {
+ c.markFileLiveForTreeShaking(
+ entry_point,
+ side_effects,
+ parts,
+ import_records,
+ entry_point_kinds,
+ );
+ }
+
+ var file_entry_bits: []AutoBitSet = c.graph.files.items(.entry_bits);
+ // AutoBitSet needs to be initialized if it is dynamic
+ if (AutoBitSet.needsDynamic(entry_points.len)) {
+ for (file_entry_bits) |*bits| {
+ bits.* = try AutoBitSet.initEmpty(c.allocator, entry_points.len);
+ }
+ } else if (file_entry_bits.len > 0) {
+ // assert that the tag is correct
+ std.debug.assert(file_entry_bits[0] == .static);
+ }
+
+ // Code splitting: Determine which entry points can reach which files. This
+ // has to happen after tree shaking because there is an implicit dependency
+ // between live parts within the same file. All liveness has to be computed
+ // first before determining which entry points can reach which files.
+ for (entry_points, 0..) |entry_point, i| {
+ c.markFileReachableForCodeSplitting(
+ entry_point,
+ i,
+ distances,
+ 0,
+ parts,
+ import_records,
+ file_entry_bits,
+ );
+ }
+ }
+
+ const ChunkMeta = struct {
+ imports: Map,
+ exports: Map,
+ dynamic_imports: std.AutoArrayHashMap(Index.Int, void),
+
+ pub const Map = std.AutoArrayHashMap(Ref, void);
+ };
+
+ const CrossChunkDependencies = struct {
+ chunk_meta: []ChunkMeta,
+ chunks: []Chunk,
+ parts: []BabyList(js_ast.Part),
+ import_records: []BabyList(bun.ImportRecord),
+ flags: []const JSMeta.Flags,
+ entry_point_chunk_indices: []Index.Int,
+ imports_to_bind: []RefImportData,
+ wrapper_refs: []const ?Ref,
+ sorted_and_filtered_export_aliases: []const []const string,
+ resolved_exports: []const ResolvedExports,
+ ctx: *LinkerContext,
+ symbols: *Symbol.Map,
+
+ pub fn walk(deps: *@This(), chunk: *Chunk, chunk_index: usize) void {
+ var chunk_meta = &deps.chunk_meta[chunk_index];
+ var imports = &deps.chunk_meta[chunk_index].imports;
+
+ const entry_point_chunk_indices = deps.entry_point_chunk_indices;
+
+ // Go over each file in this chunk
+ for (chunk.files_with_parts_in_chunk.keys()) |source_index| {
+ if (chunk.content != .javascript) continue;
+
+ // Go over each part in this file that's marked for inclusion in this chunk
+ const parts = deps.parts[source_index].slice();
+ var import_records = deps.import_records[source_index].slice();
+ const imports_to_bind = deps.imports_to_bind[source_index];
+ const wrap = deps.flags[source_index].wrap;
+ const wrapper_ref = deps.wrapper_refs[source_index].?;
+ const _chunks = deps.chunks;
+
+ for (parts) |part| {
+ if (!part.is_live)
+ continue;
+
+ // Rewrite external dynamic imports to point to the chunk for that entry point
+ for (part.import_record_indices.slice()) |import_record_id| {
+ var import_record = &import_records[import_record_id];
+ if (import_record.source_index.isValid() and deps.ctx.isExternalDynamicImport(import_record, source_index)) {
+ const other_chunk_index = entry_point_chunk_indices[import_record.source_index.get()];
+ import_record.path.text = _chunks[other_chunk_index].unique_key;
+ import_record.source_index = Index.invalid;
+
+ // Track this cross-chunk dynamic import so we make sure to
+ // include its hash when we're calculating the hashes of all
+ // dependencies of this chunk.
+ if (other_chunk_index != chunk_index)
+ chunk_meta.dynamic_imports.put(other_chunk_index, void{}) catch unreachable;
+ }
+ }
+
+ // Remember what chunk each top-level symbol is declared in. Symbols
+ // with multiple declarations such as repeated "var" statements with
+ // the same name should already be marked as all being in a single
+ // chunk. In that case this will overwrite the same value below which
+ // is fine.
+ deps.symbols.assignChunkIndex(part.declared_symbols, @truncate(u32, chunk_index));
+
+ const used_refs = part.symbol_uses.keys();
+
+ for (used_refs) |ref_| {
+ const ref_to_use = brk: {
+ var ref = ref_;
+ var symbol = deps.symbols.getConst(ref).?;
+
+ // Ignore unbound symbols
+ if (symbol.kind == .unbound)
+ continue;
+
+ // Ignore symbols that are going to be replaced by undefined
+ if (symbol.import_item_status == .missing) {
+ continue;
+ }
+
+ // If this is imported from another file, follow the import
+ // reference and reference the symbol in that file instead
+ if (imports_to_bind.get(ref)) |import_data| {
+ ref = import_data.data.import_ref;
+ symbol = deps.symbols.getConst(ref).?;
+ } else if (wrap == .cjs and ref.eql(wrapper_ref)) {
+ // The only internal symbol that wrapped CommonJS files export
+ // is the wrapper itself.
+ continue;
+ } else if (symbol.kind == .other) {
+ // TODO: figure out why we need to do this
+ // Without this, we are unable to map the import to runtime symbols across chunks
+ // which means we miss any runtime-imported symbol
+ if (imports_to_bind.get(deps.symbols.follow(ref))) |import_data| {
+ ref = import_data.data.import_ref;
+ symbol = deps.symbols.getConst(ref).?;
+ }
+ }
+
+ // If this is an ES6 import from a CommonJS file, it will become a
+ // property access off the namespace symbol instead of a bare
+ // identifier. In that case we want to pull in the namespace symbol
+ // instead. The namespace symbol stores the result of "require()".
+ if (symbol.namespace_alias) |*namespace_alias| {
+ ref = namespace_alias.namespace_ref;
+ }
+ break :brk ref;
+ };
+
+ if (comptime Environment.allow_assert)
+ debug("Cross-chunk import: {s} {}", .{ deps.symbols.get(ref_to_use).?.original_name, ref_to_use });
+
+ // We must record this relationship even for symbols that are not
+ // imports. Due to code splitting, the definition of a symbol may
+ // be moved to a separate chunk than the use of a symbol even if
+ // the definition and use of that symbol are originally from the
+ // same source file.
+ imports.put(ref_to_use, void{}) catch unreachable;
+ }
+ }
+ }
+
+ // Include the exports if this is an entry point chunk
+ if (chunk.content == .javascript) {
+ if (chunk.entry_point.is_entry_point) {
+ const flags = deps.flags[chunk.entry_point.source_index];
+ if (flags.wrap != .cjs) {
+ const resolved_exports = deps.resolved_exports[chunk.entry_point.source_index];
+ const sorted_and_filtered_export_aliases = deps.sorted_and_filtered_export_aliases[chunk.entry_point.source_index];
+ for (sorted_and_filtered_export_aliases) |alias| {
+ const export_ = resolved_exports.get(alias).?;
+ var target_ref = export_.data.import_ref;
+
+ // If this is an import, then target what the import points to
+ if (deps.imports_to_bind[export_.data.source_index.get()].get(target_ref)) |import_data| {
+ target_ref = import_data.data.import_ref;
+ }
+
+ // If this is an ES6 import from a CommonJS file, it will become a
+ // property access off the namespace symbol instead of a bare
+ // identifier. In that case we want to pull in the namespace symbol
+ // instead. The namespace symbol stores the result of "require()".
+ if (deps.symbols.getConst(target_ref).?.namespace_alias) |namespace_alias| {
+ target_ref = namespace_alias.namespace_ref;
+ }
+ if (comptime Environment.allow_assert)
+ debug("Cross-chunk export: {s}", .{deps.symbols.get(target_ref).?.original_name});
+
+ imports.put(target_ref, void{}) catch unreachable;
+ }
+ }
+
+ // Ensure "exports" is included if the current output format needs it
+ if (flags.force_include_exports_for_entry_point) {
+ imports.put(deps.wrapper_refs[chunk.entry_point.source_index].?, void{}) catch unreachable;
+ }
+
+ // Include the wrapper if present
+ if (flags.wrap != .none) {
+ imports.put(deps.wrapper_refs[chunk.entry_point.source_index].?, void{}) catch unreachable;
+ }
+ }
+ }
+ }
+ };
+
+ pub fn computeCrossChunkDependencies(c: *LinkerContext, chunks: []Chunk) !void {
+ if (!c.graph.code_splitting) {
+ // No need to compute cross-chunk dependencies if there can't be any
+ return;
+ }
+
+ var chunk_metas = try c.allocator.alloc(ChunkMeta, chunks.len);
+ for (chunk_metas) |*meta| {
+ // these must be global allocator
+ meta.* = .{
+ .imports = ChunkMeta.Map.init(bun.default_allocator),
+ .exports = ChunkMeta.Map.init(bun.default_allocator),
+ .dynamic_imports = std.AutoArrayHashMap(Index.Int, void).init(bun.default_allocator),
+ };
+ }
+ defer {
+ for (chunk_metas) |*meta| {
+ meta.imports.deinit();
+ meta.exports.deinit();
+ meta.dynamic_imports.deinit();
+ }
+ c.allocator.free(chunk_metas);
+ }
+
+ {
+ var cross_chunk_dependencies = c.allocator.create(CrossChunkDependencies) catch unreachable;
+ defer c.allocator.destroy(cross_chunk_dependencies);
+
+ cross_chunk_dependencies.* = .{
+ .chunks = chunks,
+ .chunk_meta = chunk_metas,
+ .parts = c.graph.ast.items(.parts),
+ .import_records = c.graph.ast.items(.import_records),
+ .flags = c.graph.meta.items(.flags),
+ .entry_point_chunk_indices = c.graph.files.items(.entry_point_chunk_index),
+ .imports_to_bind = c.graph.meta.items(.imports_to_bind),
+ .wrapper_refs = c.graph.ast.items(.wrapper_ref),
+ .sorted_and_filtered_export_aliases = c.graph.meta.items(.sorted_and_filtered_export_aliases),
+ .resolved_exports = c.graph.meta.items(.resolved_exports),
+ .ctx = c,
+ .symbols = &c.graph.symbols,
+ };
+
+ c.parse_graph.pool.pool.doPtr(
+ c.allocator,
+ &c.wait_group,
+ cross_chunk_dependencies,
+ CrossChunkDependencies.walk,
+ chunks,
+ ) catch unreachable;
+ }
+
+ // Mark imported symbols as exported in the chunk from which they are declared
+ for (chunks, chunk_metas, 0..) |*chunk, *chunk_meta, chunk_index| {
+ if (chunk.content != .javascript) {
+ continue;
+ }
+ var js = &chunk.content.javascript;
+
+ // Find all uses in this chunk of symbols from other chunks
+ for (chunk_meta.imports.keys()) |import_ref| {
+ const symbol = c.graph.symbols.getConst(import_ref).?;
+
+ // Ignore uses that aren't top-level symbols
+ if (symbol.chunkIndex()) |other_chunk_index| {
+ if (@as(usize, other_chunk_index) != chunk_index) {
+ if (comptime Environment.allow_assert)
+ debug("Import name: {s} (in {s})", .{
+ symbol.original_name,
+ c.parse_graph.input_files.get(import_ref.sourceIndex()).source.path.text,
+ });
+
+ {
+ var entry = try js
+ .imports_from_other_chunks
+ .getOrPutValue(c.allocator, other_chunk_index, .{});
+ try entry.value_ptr.push(c.allocator, .{
+ .ref = import_ref,
+ });
+ }
+ _ = chunk_metas[other_chunk_index].exports.getOrPut(import_ref) catch unreachable;
+ }
+ }
+ }
+
+ // If this is an entry point, make sure we import all chunks belonging to
+ // this entry point, even if there are no imports. We need to make sure
+ // these chunks are evaluated for their side effects too.
+ if (chunk.entry_point.is_entry_point) {
+ for (chunks, 0..) |*other_chunk, other_chunk_index| {
+ if (other_chunk_index == chunk_index or other_chunk.content != .javascript) continue;
+
+ if (other_chunk.entry_bits.isSet(chunk.entry_point.entry_point_id)) {
+ if (other_chunk.entry_point.is_entry_point) {
+ if (c.graph.react_client_component_boundary.bit_length > 0 or c.graph.react_server_component_boundary.bit_length > 0) {
+ const other_kind = c.graph.files.items(.entry_point_kind)[other_chunk.entry_point.source_index];
+ const this_kind = c.graph.files.items(.entry_point_kind)[chunk.entry_point.source_index];
+
+ if (this_kind != .react_client_component and
+ other_kind.isReactReference())
+ {
+ continue;
+ }
+ }
+ }
+ _ = js.imports_from_other_chunks.getOrPutValue(
+ c.allocator,
+ @truncate(u32, other_chunk_index),
+ CrossChunkImport.Item.List{},
+ ) catch unreachable;
+ }
+ }
+ }
+
+ // Make sure we also track dynamic cross-chunk imports. These need to be
+ // tracked so we count them as dependencies of this chunk for the purpose
+ // of hash calculation.
+ if (chunk_meta.dynamic_imports.count() > 0) {
+ var dynamic_chunk_indices = chunk_meta.dynamic_imports.keys();
+ std.sort.sort(Index.Int, dynamic_chunk_indices, void{}, std.sort.asc(Index.Int));
+
+ var imports = chunk.cross_chunk_imports.listManaged(c.allocator);
+ defer chunk.cross_chunk_imports.update(imports);
+ imports.ensureUnusedCapacity(dynamic_chunk_indices.len) catch unreachable;
+ const prev_len = imports.items.len;
+ imports.items.len += dynamic_chunk_indices.len;
+ for (dynamic_chunk_indices, imports.items[prev_len..]) |dynamic_chunk_index, *item| {
+ item.* = .{
+ .import_kind = .dynamic,
+ .chunk_index = dynamic_chunk_index,
+ };
+ }
+ }
+ }
+
+ // Generate cross-chunk exports. These must be computed before cross-chunk
+ // imports because of export alias renaming, which must consider all export
+ // aliases simultaneously to avoid collisions.
+ {
+ std.debug.assert(chunk_metas.len == chunks.len);
+ var r = renamer.ExportRenamer.init(c.allocator);
+ defer r.deinit();
+ debug("Generating cross-chunk exports", .{});
+
+ var stable_ref_list = std.ArrayList(StableRef).init(c.allocator);
+ defer stable_ref_list.deinit();
+
+ for (chunks, chunk_metas) |*chunk, *chunk_meta| {
+ if (chunk.content != .javascript) continue;
+
+ var repr = &chunk.content.javascript;
+
+ switch (c.options.output_format) {
+ .esm => {
+ c.sortedCrossChunkExportItems(
+ chunk_meta.exports,
+ &stable_ref_list,
+ );
+ var clause_items = BabyList(js_ast.ClauseItem).initCapacity(c.allocator, stable_ref_list.items.len) catch unreachable;
+ clause_items.len = @truncate(u32, stable_ref_list.items.len);
+ repr.exports_to_other_chunks.ensureUnusedCapacity(c.allocator, stable_ref_list.items.len) catch unreachable;
+ r.clearRetainingCapacity();
+
+ for (stable_ref_list.items, clause_items.slice()) |stable_ref, *clause_item| {
+ const ref = stable_ref.ref;
+ const alias = r.nextRenamedName(c.graph.symbols.get(ref).?.original_name);
+
+ clause_item.* = .{
+ .name = .{
+ .ref = ref,
+ .loc = Logger.Loc.Empty,
+ },
+ .alias = alias,
+ .alias_loc = Logger.Loc.Empty,
+ .original_name = "",
+ };
+
+ repr.exports_to_other_chunks.putAssumeCapacity(
+ ref,
+ alias,
+ );
+ }
+
+ if (clause_items.len > 0) {
+ var stmts = BabyList(js_ast.Stmt).initCapacity(c.allocator, 1) catch unreachable;
+ var export_clause = c.allocator.create(js_ast.S.ExportClause) catch unreachable;
+ export_clause.* = .{
+ .items = clause_items.slice(),
+ .is_single_line = true,
+ };
+ stmts.appendAssumeCapacity(.{
+ .data = .{
+ .s_export_clause = export_clause,
+ },
+ .loc = Logger.Loc.Empty,
+ });
+ repr.cross_chunk_suffix_stmts = stmts;
+ }
+ },
+ else => {},
+ // else => bun.unreachablePanic("Unexpected output format", .{}),
+ }
+ }
+ }
+
+ // Generate cross-chunk imports. These must be computed after cross-chunk
+ // exports because the export aliases must already be finalized so they can
+ // be embedded in the generated import statements.
+ {
+ debug("Generating cross-chunk imports", .{});
+ var list = CrossChunkImport.List.init(c.allocator);
+ defer list.deinit();
+
+ for (chunks) |*chunk| {
+ if (chunk.content != .javascript) continue;
+ var repr = &chunk.content.javascript;
+ var cross_chunk_prefix_stmts = BabyList(js_ast.Stmt){};
+
+ list.clearRetainingCapacity();
+ CrossChunkImport.sortedCrossChunkImports(&list, chunks, &repr.imports_from_other_chunks) catch unreachable;
+ var cross_chunk_imports_input: []CrossChunkImport = list.items;
+ var cross_chunk_imports = chunk.cross_chunk_imports;
+ for (cross_chunk_imports_input) |cross_chunk_import| {
+ switch (c.options.output_format) {
+ .esm => {
+ const import_record_index = @intCast(u32, cross_chunk_imports.len);
+
+ var clauses = std.ArrayList(js_ast.ClauseItem).initCapacity(c.allocator, cross_chunk_import.sorted_import_items.len) catch unreachable;
+ for (cross_chunk_import.sorted_import_items.slice()) |item| {
+ clauses.appendAssumeCapacity(.{
+ .name = .{
+ .ref = item.ref,
+ .loc = Logger.Loc.Empty,
+ },
+ .alias = item.export_alias,
+ .alias_loc = Logger.Loc.Empty,
+ });
+ }
+
+ cross_chunk_imports.push(c.allocator, .{
+ .import_kind = .stmt,
+ .chunk_index = cross_chunk_import.chunk_index,
+ }) catch unreachable;
+ var import = c.allocator.create(js_ast.S.Import) catch unreachable;
+ import.* = .{
+ .items = clauses.items,
+ .import_record_index = import_record_index,
+ .namespace_ref = Ref.None,
+ };
+ cross_chunk_prefix_stmts.push(
+ c.allocator,
+ .{
+ .data = .{
+ .s_import = import,
+ },
+ .loc = Logger.Loc.Empty,
+ },
+ ) catch unreachable;
+ },
+ else => {},
+ }
+ }
+
+ repr.cross_chunk_prefix_stmts = cross_chunk_prefix_stmts;
+ chunk.cross_chunk_imports = cross_chunk_imports;
+ }
+ }
+ }
+
+ const GenerateChunkCtx = struct {
+ wg: *sync.WaitGroup,
+ c: *LinkerContext,
+ chunks: []Chunk,
+ };
+ fn generateChunkJS(ctx: GenerateChunkCtx, chunk: *Chunk, chunk_index: usize) void {
+ generateChunkJS_(ctx, chunk, chunk_index) catch |err| Output.panic("TODO: handle error: {s}", .{@errorName(err)});
+ }
+
+ // TODO: investigate if we need to parallelize this function
+ // esbuild does parallelize it.
+ fn renameSymbolsInChunk(
+ c: *LinkerContext,
+ allocator: std.mem.Allocator,
+ chunk: *Chunk,
+ files_in_order: []const u32,
+ ) !renamer.Renamer {
+
+ // TODO: minify identifiers
+ const all_module_scopes = c.graph.ast.items(.module_scope);
+ const all_flags: []const JSMeta.Flags = c.graph.meta.items(.flags);
+ const all_parts: []const js_ast.Part.List = c.graph.ast.items(.parts);
+ const all_wrapper_refs: []const ?Ref = c.graph.ast.items(.wrapper_ref);
+ const all_import_records: []const ImportRecord.List = c.graph.ast.items(.import_records);
+
+ var r = try renamer.NumberRenamer.init(
+ allocator,
+ allocator,
+ c.graph.symbols,
+ brk: {
+ var reserved_names = try renamer.computeInitialReservedNames(allocator);
+
+ for (files_in_order) |source_index| {
+ renamer.computeReservedNamesForScope(&all_module_scopes[source_index], &c.graph.symbols, &reserved_names, allocator);
+ }
+
+ break :brk reserved_names;
+ },
+ );
+ {
+ var sorted_imports_from_other_chunks: std.ArrayList(StableRef) = brk: {
+ var list = std.ArrayList(StableRef).init(allocator);
+ var count: u32 = 0;
+ var imports_from_other_chunks = chunk.content.javascript.imports_from_other_chunks.values();
+ for (imports_from_other_chunks) |item| {
+ count += item.len;
+ }
+
+ list.ensureTotalCapacityPrecise(count) catch unreachable;
+ list.items.len = count;
+ var remain = list.items;
+ const stable_source_indices = c.graph.stable_source_indices;
+ for (imports_from_other_chunks) |item| {
+ for (item.slice()) |ref| {
+ remain[0] = StableRef{
+ .stable_source_index = stable_source_indices[ref.ref.sourceIndex()],
+ .ref = ref.ref,
+ };
+ remain = remain[1..];
+ }
+ }
+
+ std.sort.sort(StableRef, list.items, void{}, StableRef.isLessThan);
+ break :brk list;
+ };
+ defer sorted_imports_from_other_chunks.deinit();
+
+ for (sorted_imports_from_other_chunks.items) |stable_ref| {
+ r.addTopLevelSymbol(stable_ref.ref);
+ }
+ }
+
+ var sorted_ = std.ArrayList(u32).init(r.temp_allocator);
+ var sorted = &sorted_;
+ defer sorted.deinit();
+
+ for (files_in_order) |source_index| {
+ const wrap = all_flags[source_index].wrap;
+ const parts: []const js_ast.Part = all_parts[source_index].slice();
+
+ switch (wrap) {
+ // Modules wrapped in a CommonJS closure look like this:
+ //
+ // // foo.js
+ // var require_foo = __commonJS((exports, module) => {
+ // exports.foo = 123;
+ // });
+ //
+ // The symbol "require_foo" is stored in "file.ast.WrapperRef". We want
+ // to be able to minify everything inside the closure without worrying
+ // about collisions with other CommonJS modules. Set up the scopes such
+ // that it appears as if the file was structured this way all along. It's
+ // not completely accurate (e.g. we don't set the parent of the module
+ // scope to this new top-level scope) but it's good enough for the
+ // renaming code.
+ .cjs => {
+ r.addTopLevelSymbol(all_wrapper_refs[source_index].?);
+
+ // External import statements will be hoisted outside of the CommonJS
+ // wrapper if the output format supports import statements. We need to
+ // add those symbols to the top-level scope to avoid causing name
+ // collisions. This code special-cases only those symbols.
+ if (c.options.output_format.keepES6ImportExportSyntax()) {
+ const import_records = all_import_records[source_index].slice();
+ for (parts) |*part| {
+ for (part.stmts) |stmt| {
+ switch (stmt.data) {
+ .s_import => |import| {
+ if (!import_records[import.import_record_index].source_index.isValid()) {
+ r.addTopLevelSymbol(import.namespace_ref);
+ if (import.default_name) |default_name| {
+ if (default_name.ref) |ref| {
+ r.addTopLevelSymbol(ref);
+ }
+ }
+
+ for (import.items) |*item| {
+ if (item.name.ref) |ref| {
+ r.addTopLevelSymbol(ref);
+ }
+ }
+ }
+ },
+ .s_export_star => |export_| {
+ if (!import_records[export_.import_record_index].source_index.isValid()) {
+ r.addTopLevelSymbol(export_.namespace_ref);
+ }
+ },
+ .s_export_from => |export_| {
+ if (!import_records[export_.import_record_index].source_index.isValid()) {
+ r.addTopLevelSymbol(export_.namespace_ref);
+
+ for (export_.items) |*item| {
+ if (item.name.ref) |ref| {
+ r.addTopLevelSymbol(ref);
+ }
+ }
+ }
+ },
+ else => {},
+ }
+ }
+ }
+ }
+ r.assignNamesRecursiveWithNumberScope(&r.root, &all_module_scopes[source_index], source_index, sorted);
+ continue;
+ },
+
+ // Modules wrapped in an ESM closure look like this:
+ //
+ // // foo.js
+ // var foo, foo_exports = {};
+ // __export(foo_exports, {
+ // foo: () => foo
+ // });
+ // let init_foo = __esm(() => {
+ // foo = 123;
+ // });
+ //
+ // The symbol "init_foo" is stored in "file.ast.WrapperRef". We need to
+ // minify everything inside the closure without introducing a new scope
+ // since all top-level variables will be hoisted outside of the closure.
+ .esm => {
+ r.addTopLevelSymbol(all_wrapper_refs[source_index].?);
+ },
+
+ else => {},
+ }
+
+ for (parts) |*part| {
+ if (!part.is_live) continue;
+
+ r.addTopLevelDeclaredSymbols(part.declared_symbols);
+ for (part.scopes) |scope| {
+ r.assignNamesRecursiveWithNumberScope(&r.root, scope, source_index, sorted);
+ }
+ r.number_scope_pool.hive.available = @TypeOf(r.number_scope_pool.hive.available).initFull();
+ }
+ }
+
+ return r.toRenamer();
+ }
+
+ fn generateChunkJS_(ctx: GenerateChunkCtx, chunk: *Chunk, chunk_index: usize) !void {
+ _ = chunk_index;
+ defer ctx.wg.finish();
+ var worker = ThreadPool.Worker.get();
+
+ if (comptime FeatureFlags.help_catch_memory_issues) {
+ worker.heap.gc(false);
+ }
+
+ const allocator = worker.allocator;
+ const c = ctx.c;
+ std.debug.assert(chunk.content == .javascript);
+
+ var repr = &chunk.content.javascript;
+
+ var runtime_scope: *Scope = &c.graph.ast.items(.module_scope)[c.graph.files.items(.input_file)[Index.runtime.value].get()];
+ var runtime_members = &runtime_scope.members;
+ const toCommonJSRef = c.graph.symbols.follow(runtime_members.get("__toCommonJS").?.ref);
+ const toESMRef = c.graph.symbols.follow(runtime_members.get("__toESM").?.ref);
+ const runtimeRequireRef = c.graph.symbols.follow(runtime_members.get("__require").?.ref);
+
+ js_ast.Expr.Data.Store.create(bun.default_allocator);
+ js_ast.Stmt.Data.Store.create(bun.default_allocator);
+
+ var r = try c.renameSymbolsInChunk(allocator, chunk, repr.files_in_chunk_order);
+ defer r.deinit();
+ const part_ranges = repr.parts_in_chunk_in_order;
+ var stmts = StmtList.init(allocator);
+ defer stmts.deinit();
+
+ var arena = std.heap.ArenaAllocator.init(allocator);
+ defer arena.deinit();
+ var compile_results = std.ArrayList(CompileResult).initCapacity(allocator, part_ranges.len) catch unreachable;
+ {
+ defer _ = arena.reset(.retain_capacity);
+
+ var buffer_writer = js_printer.BufferWriter.init(allocator) catch unreachable;
+
+ for (part_ranges, 0..) |part_range, i| {
+ if (i > 0) _ = arena.reset(.retain_capacity);
+ const result = c.generateCodeForFileInChunkJS(
+ &buffer_writer,
+ r,
+ chunk,
+ part_range,
+ toCommonJSRef,
+ toESMRef,
+ runtimeRequireRef,
+ &stmts,
+ allocator,
+ arena.allocator(),
+ );
+
+ if (i < part_ranges.len - 1) {
+ compile_results.appendAssumeCapacity(
+ // we reuse the memory buffer up until the final chunk to minimize reallocations
+ .{
+ .javascript = .{
+ .result = result.clone(allocator) catch unreachable,
+ .source_index = part_range.source_index.get(),
+ },
+ },
+ );
+ } else {
+ if (comptime Environment.allow_assert) {
+ if (result == .result) {
+ if (buffer_writer.buffer.list.capacity > result.result.code.len) {
+ // add a 0 to make it easier to view the code in a debugger
+ // but only if room
+ buffer_writer.buffer.list.items.ptr[result.result.code.len] = 0;
+ }
+ }
+ }
+
+ // the final chunk owns the memory buffer
+ compile_results.appendAssumeCapacity(.{
+ .javascript = .{
+ .result = result,
+ .source_index = part_range.source_index.get(),
+ },
+ });
+ }
+ }
+ }
+
+ // Also generate the cross-chunk binding code
+ var cross_chunk_prefix: []u8 = &.{};
+ var cross_chunk_suffix: []u8 = &.{};
+
+ {
+ const indent: usize = 0;
+ // TODO: IIFE indent
+
+ const print_options = js_printer.Options{
+ // TODO: IIFE
+ .indent = indent,
+
+ .allocator = allocator,
+ .require_ref = runtimeRequireRef,
+ .minify_whitespace = c.options.minify_whitespace,
+ };
+
+ var cross_chunk_import_records = ImportRecord.List.initCapacity(allocator, chunk.cross_chunk_imports.len) catch unreachable;
+ defer cross_chunk_import_records.deinitWithAllocator(allocator);
+ for (chunk.cross_chunk_imports.slice()) |import_record| {
+ cross_chunk_import_records.appendAssumeCapacity(
+ .{
+ .kind = import_record.import_kind,
+ .path = Fs.Path.init(ctx.chunks[import_record.chunk_index].unique_key),
+ .range = Logger.Range.None,
+ },
+ );
+ }
+
+ cross_chunk_prefix = js_printer.print(
+ allocator,
+ c.resolver.opts.platform,
+ print_options,
+ cross_chunk_import_records.slice(),
+ &[_]js_ast.Part{
+ .{ .stmts = chunk.content.javascript.cross_chunk_prefix_stmts.slice() },
+ },
+ r,
+ ).result.code;
+ cross_chunk_suffix = js_printer.print(
+ allocator,
+ c.resolver.opts.platform,
+ print_options,
+ &.{},
+ &[_]js_ast.Part{
+ .{ .stmts = chunk.content.javascript.cross_chunk_suffix_stmts.slice() },
+ },
+ r,
+ ).result.code;
+ }
+
+ // Generate the exports for the entry point, if there are any
+ const entry_point_tail = brk: {
+ if (chunk.isEntryPoint()) {
+ break :brk c.generateEntryPointTailJS(
+ toCommonJSRef,
+ toESMRef,
+ chunk.entry_point.source_index,
+ allocator,
+ arena.allocator(),
+ r,
+ );
+ }
+
+ break :brk CompileResult.empty;
+ };
+
+ var j = bun.Joiner{
+ .use_pool = false,
+ .node_allocator = allocator,
+ .watcher = .{
+ .input = chunk.unique_key,
+ },
+ };
+ var line_offset: bun.sourcemap.LineColumnOffset.Optional = .{ .null = {} };
+
+ // Concatenate the generated JavaScript chunks together
+
+ var newline_before_comment = false;
+ var is_executable = false;
+
+ // Start with the hashbang if there is one. This must be done before the
+ // banner because it only works if it's literally the first character.
+ if (chunk.isEntryPoint()) {
+ if (c.graph.ast.items(.hashbang)[chunk.entry_point.source_index]) |hashbang| {
+ std.debug.assert(hashbang.len > 0);
+ j.push(hashbang);
+ j.push("\n");
+ line_offset.advance(hashbang);
+ newline_before_comment = true;
+ is_executable = true;
+ }
+ }
+
+ // TODO: banner
+
+ // TODO: directive
+
+ // TODO: IIFE wrap
+
+ if (cross_chunk_prefix.len > 0) {
+ newline_before_comment = true;
+ line_offset.advance(cross_chunk_prefix);
+ j.push(cross_chunk_prefix);
+ }
+
+ // Concatenate the generated JavaScript chunks together
+
+ var prev_filename_comment: Index.Int = 0;
+
+ const sources: []const Logger.Source = c.parse_graph.input_files.items(.source);
+ for (@as([]CompileResult, compile_results.items)) |compile_result| {
+ const source_index = compile_result.sourceIndex();
+ const is_runtime = source_index == Index.runtime.value;
+
+ // TODO: extracated legal comments
+
+ // Add a comment with the file path before the file contents
+ if (c.options.mode == .bundle and !c.options.minify_whitespace and source_index != prev_filename_comment and compile_result.code().len > 0) {
+ prev_filename_comment = source_index;
+ if (newline_before_comment) {
+ j.push("\n");
+ line_offset.advance("\n");
+ }
+
+ // Make sure newlines in the path can't cause a syntax error. This does
+ // not minimize allocations because it's expected that this case never
+ // comes up in practice.
+ const CommentType = enum {
+ multiline,
+ single,
+ };
+
+ const pretty = sources[source_index].path.pretty;
+
+ // TODO: quote this. This is really janky.
+ const comment_type = if (strings.indexOfNewlineOrNonASCII(pretty, 0) != null)
+ CommentType.multiline
+ else
+ CommentType.single;
+
+ switch (comment_type) {
+ .multiline => {
+ j.push("/* ");
+ line_offset.advance("/* ");
+ },
+ .single => {
+ j.push("// ");
+ line_offset.advance("// ");
+ },
+ }
+
+ j.push(pretty);
+ line_offset.advance(pretty);
+
+ switch (comment_type) {
+ .multiline => {
+ j.push(" */\n");
+ line_offset.advance(" */\n");
+ },
+ .single => {
+ j.push("\n");
+ line_offset.advance("\n");
+ },
+ }
+ prev_filename_comment = source_index;
+ }
+
+ if (is_runtime) {
+ line_offset.advance(compile_result.code());
+ j.append(compile_result.code(), 0, allocator);
+ } else {
+ line_offset.advance(compile_result.code());
+ j.append(compile_result.code(), 0, allocator);
+
+ // TODO: sourcemap
+ }
+
+ // TODO: metafile
+ newline_before_comment = compile_result.code().len > 0;
+ }
+
+ const tail_code = entry_point_tail.code();
+ if (tail_code.len > 0) {
+ // Stick the entry point tail at the end of the file. Deliberately don't
+ // include any source mapping information for this because it's automatically
+ // generated and doesn't correspond to a location in the input file.
+ j.push(tail_code);
+ }
+
+ // Put the cross-chunk suffix inside the IIFE
+ if (cross_chunk_suffix.len > 0) {
+ if (newline_before_comment) {
+ j.push("\n");
+ line_offset.advance("\n");
+ }
+
+ j.push(cross_chunk_suffix);
+ }
+
+ if (c.options.output_format == .iife) {
+ const without_newline = "})();";
+
+ const with_newline = if (newline_before_comment)
+ without_newline ++ "\n"
+ else
+ without_newline;
+
+ j.push(with_newline);
+ }
+
+ j.ensureNewlineAtEnd();
+ // TODO: maybeAppendLegalComments
+
+ // TODO: footer
+
+ chunk.intermediate_output = c.breakOutputIntoPieces(
+ allocator,
+ &j,
+ cross_chunk_prefix.len > 0 or
+ cross_chunk_suffix.len > 0,
+ @truncate(u32, ctx.chunks.len),
+ ) catch @panic("Unhandled out of memory error in breakOutputIntoPieces()");
+
+ // TODO: meta contents
+
+ chunk.isolated_hash = c.generateIsolatedHash(chunk);
+ chunk.is_executable = is_executable;
+ }
+
+ pub fn generateIsolatedHash(c: *LinkerContext, chunk: *const Chunk) u64 {
+ var hasher = ContentHasher{};
+
+ // Mix the file names and part ranges of all of the files in this chunk into
+ // the hash. Objects that appear identical but that live in separate files or
+ // that live in separate parts in the same file must not be merged. This only
+ // needs to be done for JavaScript files, not CSS files.
+ if (chunk.content == .javascript) {
+ const sources = c.parse_graph.input_files.items(.source);
+ for (chunk.content.javascript.parts_in_chunk_in_order) |part_range| {
+ const source: Logger.Source = sources[part_range.source_index.get()];
+
+ const file_path = brk: {
+ if (strings.eqlComptime(source.path.namespace, "file")) {
+ // Use the pretty path as the file name since it should be platform-
+ // independent (relative paths and the "/" path separator)
+ break :brk source.path.pretty;
+ } else {
+ // If this isn't in the "file" namespace, just use the full path text
+ // verbatim. This could be a source of cross-platform differences if
+ // plugins are storing platform-specific information in here, but then
+ // that problem isn't caused by esbuild itself.
+ break :brk source.path.text;
+ }
+ };
+
+ // Include the path namespace in the hash so that files with the same
+ hasher.write(source.key_path.namespace);
+
+ // Then include the file path
+ hasher.write(file_path);
+
+ // Then include the part range
+ hasher.writeInts(&[_]u32{
+ part_range.part_index_begin,
+ part_range.part_index_end,
+ });
+ }
+ }
+
+ // Hash the output path template as part of the content hash because we want
+ // any import to be considered different if the import's output path has changed.
+ hasher.write(chunk.template.data);
+
+ // Also hash the public path. If provided, this is used whenever files
+ // reference each other such as cross-chunk imports, asset file references,
+ // and source map comments. We always include the hash in all chunks instead
+ // of trying to figure out which chunks will include the public path for
+ // simplicity and for robustness to code changes in the future.
+ if (c.options.public_path.len > 0) {
+ hasher.write(c.options.public_path);
+ }
+
+ // Include the generated output content in the hash. This excludes the
+ // randomly-generated import paths (the unique keys) and only includes the
+ // data in the spans between them.
+ if (chunk.intermediate_output == .pieces) {
+ for (chunk.intermediate_output.pieces.slice()) |piece| {
+ hasher.write(piece.data());
+ }
+ } else {
+ var el = chunk.intermediate_output.joiner.head;
+ while (el) |e| : (el = e.next) {
+ hasher.write(e.data.slice);
+ }
+ }
+
+ return hasher.digest();
+ }
+
+ pub fn generateEntryPointTailJS(
+ c: *LinkerContext,
+ toCommonJSRef: Ref,
+ toESMRef: Ref,
+ source_index: Index.Int,
+ allocator: std.mem.Allocator,
+ temp_allocator: std.mem.Allocator,
+ r: renamer.Renamer,
+ ) CompileResult {
+ const flags: JSMeta.Flags = c.graph.meta.items(.flags)[source_index];
+ var stmts = std.ArrayList(Stmt).init(temp_allocator);
+ defer stmts.deinit();
+ const ast: js_ast.Ast = c.graph.ast.get(source_index);
+
+ switch (c.options.output_format) {
+ // TODO:
+ .preserve => {},
+
+ .esm => {
+ switch (flags.wrap) {
+ .cjs => {
+ stmts.append(
+ Stmt.alloc(
+ // "export default require_foo();"
+ S.ExportDefault,
+ .{
+ .default_name = .{
+ .loc = Logger.Loc.Empty,
+ .ref = ast.wrapper_ref.?,
+ },
+ .value = .{
+ .expr = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.initIdentifier(
+ ast.wrapper_ref.?,
+ Logger.Loc.Empty,
+ ),
+ },
+ Logger.Loc.Empty,
+ ),
+ },
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+ },
+ else => {
+ if (flags.wrap == .esm) {
+ if (flags.is_async_or_has_async_dependency) {
+ // "await init_foo();"
+ stmts.append(
+ Stmt.alloc(
+ S.SExpr,
+ .{
+ .value = Expr.init(
+ E.Await,
+ E.Await{
+ .value = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.initIdentifier(
+ ast.wrapper_ref.?,
+ Logger.Loc.Empty,
+ ),
+ },
+ Logger.Loc.Empty,
+ ),
+ },
+ Logger.Loc.Empty,
+ ),
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+ } else {
+ // "init_foo();"
+ stmts.append(
+ Stmt.alloc(
+ S.SExpr,
+ .{
+ .value = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.initIdentifier(
+ ast.wrapper_ref.?,
+ Logger.Loc.Empty,
+ ),
+ },
+ Logger.Loc.Empty,
+ ),
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+ }
+ }
+
+ const sorted_and_filtered_export_aliases = c.graph.meta.items(.sorted_and_filtered_export_aliases)[source_index];
+
+ if (sorted_and_filtered_export_aliases.len > 0) {
+ const resolved_exports: ResolvedExports = c.graph.meta.items(.resolved_exports)[source_index];
+ const imports_to_bind: RefImportData = c.graph.meta.items(.imports_to_bind)[source_index];
+
+ // If the output format is ES6 modules and we're an entry point, generate an
+ // ES6 export statement containing all exports. Except don't do that if this
+ // entry point is a CommonJS-style module, since that would generate an ES6
+ // export statement that's not top-level. Instead, we will export the CommonJS
+ // exports as a default export later on.
+ var items = std.ArrayList(js_ast.ClauseItem).init(temp_allocator);
+ const cjs_export_copies = c.graph.meta.items(.cjs_export_copies)[source_index];
+
+ for (sorted_and_filtered_export_aliases, 0..) |alias, i| {
+ var resolved_export = resolved_exports.get(alias).?;
+
+ // If this is an export of an import, reference the symbol that the import
+ // was eventually resolved to. We need to do this because imports have
+ // already been resolved by this point, so we can't generate a new import
+ // and have that be resolved later.
+ if (imports_to_bind.get(resolved_export.data.import_ref)) |import_data| {
+ resolved_export.data.import_ref = import_data.data.import_ref;
+ resolved_export.data.source_index = import_data.data.source_index;
+ }
+
+ // Exports of imports need EImportIdentifier in case they need to be re-
+ // written to a property access later on
+ if (c.graph.symbols.get(resolved_export.data.import_ref).?.namespace_alias != null) {
+ const temp_ref = cjs_export_copies[i];
+
+ // Create both a local variable and an export clause for that variable.
+ // The local variable is initialized with the initial value of the
+ // export. This isn't fully correct because it's a "dead" binding and
+ // doesn't update with the "live" value as it changes. But ES6 modules
+ // don't have any syntax for bare named getter functions so this is the
+ // best we can do.
+ //
+ // These input files:
+ //
+ // // entry_point.js
+ // export {foo} from './cjs-format.js'
+ //
+ // // cjs-format.js
+ // Object.defineProperty(exports, 'foo', {
+ // enumerable: true,
+ // get: () => Math.random(),
+ // })
+ //
+ // Become this output file:
+ //
+ // // cjs-format.js
+ // var require_cjs_format = __commonJS((exports) => {
+ // Object.defineProperty(exports, "foo", {
+ // enumerable: true,
+ // get: () => Math.random()
+ // });
+ // });
+ //
+ // // entry_point.js
+ // var cjs_format = __toESM(require_cjs_format());
+ // var export_foo = cjs_format.foo;
+ // export {
+ // export_foo as foo
+ // };
+ //
+ stmts.append(
+ Stmt.alloc(
+ S.Local,
+ .{
+ .decls = bun.fromSlice(
+ []js_ast.G.Decl,
+ temp_allocator,
+ []const js_ast.G.Decl,
+ &.{
+ .{
+ .binding = Binding.alloc(
+ temp_allocator,
+ B.Identifier{
+ .ref = temp_ref,
+ },
+ Logger.Loc.Empty,
+ ),
+ },
+ },
+ ) catch unreachable,
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+
+ items.append(
+ .{
+ .name = js_ast.LocRef{
+ .ref = temp_ref,
+ .loc = Logger.Loc.Empty,
+ },
+ .alias = alias,
+ .alias_loc = Logger.Loc.Empty,
+ },
+ ) catch unreachable;
+ } else {
+ // Local identifiers can be exported using an export clause. This is done
+ // this way instead of leaving the "export" keyword on the local declaration
+ // itself both because it lets the local identifier be minified and because
+ // it works transparently for re-exports across files.
+ //
+ // These input files:
+ //
+ // // entry_point.js
+ // export * from './esm-format.js'
+ //
+ // // esm-format.js
+ // export let foo = 123
+ //
+ // Become this output file:
+ //
+ // // esm-format.js
+ // let foo = 123;
+ //
+ // // entry_point.js
+ // export {
+ // foo
+ // };
+ //
+ items.append(.{
+ .name = js_ast.LocRef{
+ .ref = resolved_export.data.import_ref,
+ .loc = resolved_export.data.name_loc,
+ },
+ .alias = alias,
+ .alias_loc = resolved_export.data.name_loc,
+ }) catch unreachable;
+ }
+ }
+
+ stmts.append(
+ Stmt.alloc(
+ S.ExportClause,
+ .{
+ .items = items.items,
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+ }
+ },
+ }
+ },
+
+ // TODO: iife
+ .iife => {},
+
+ .cjs => {
+ switch (flags.wrap) {
+ .cjs => {
+ // "module.exports = require_foo();"
+ stmts.append(
+ Stmt.assign(
+ Expr.init(
+ E.Dot,
+ .{
+ .target = Expr.initIdentifier(c.unbound_module_ref, Logger.Loc.Empty),
+ .name = "exports",
+ .name_loc = Logger.Loc.Empty,
+ },
+ Logger.Loc.Empty,
+ ),
+ Expr.init(
+ E.Call,
+ .{
+ .target = Expr.initIdentifier(ast.wrapper_ref.?, Logger.Loc.Empty),
+ },
+ Logger.Loc.Empty,
+ ),
+ temp_allocator,
+ ),
+ ) catch unreachable;
+ },
+ .esm => {
+ // "init_foo();"
+ stmts.append(
+ Stmt.alloc(
+ S.SExpr,
+ .{
+ .value = Expr.init(
+ E.Call,
+ .{
+ .target = Expr.initIdentifier(ast.wrapper_ref.?, Logger.Loc.Empty),
+ },
+ Logger.Loc.Empty,
+ ),
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+ },
+ else => {},
+ }
+
+ // TODO:
+ // If we are generating CommonJS for node, encode the known export names in
+ // a form that node can understand them. This relies on the specific behavior
+ // of this parser, which the node project uses to detect named exports in
+ // CommonJS files: https://github.com/guybedford/cjs-module-lexer. Think of
+ // this code as an annotation for that parser.
+ },
+ }
+
+ if (stmts.items.len == 0) {
+ return .{
+ .javascript = .{
+ .source_index = source_index,
+ .result = .{ .result = .{
+ .code = "",
+ } },
+ },
+ };
+ }
+
+ const print_options = js_printer.Options{
+ // TODO: IIFE
+ .indent = 0,
+
+ .allocator = allocator,
+ .to_esm_ref = toESMRef,
+ .to_commonjs_ref = toCommonJSRef,
+ .require_or_import_meta_for_source_callback = js_printer.RequireOrImportMeta.Callback.init(LinkerContext, requireOrImportMetaForSource, c),
+
+ .minify_whitespace = c.options.minify_whitespace,
+ };
+
+ return .{
+ .javascript = .{
+ .result = js_printer.print(
+ allocator,
+ c.resolver.opts.platform,
+ print_options,
+ ast.import_records.slice(),
+ &[_]js_ast.Part{
+ .{
+ .stmts = stmts.items,
+ },
+ },
+ r,
+ ),
+ .source_index = source_index,
+ },
+ };
+ }
+
+ const StmtList = struct {
+ inside_wrapper_prefix: std.ArrayList(Stmt),
+ outside_wrapper_prefix: std.ArrayList(Stmt),
+ inside_wrapper_suffix: std.ArrayList(Stmt),
+
+ all_stmts: std.ArrayList(Stmt),
+
+ pub fn reset(this: *StmtList) void {
+ this.inside_wrapper_prefix.clearRetainingCapacity();
+ this.outside_wrapper_prefix.clearRetainingCapacity();
+ this.inside_wrapper_suffix.clearRetainingCapacity();
+ this.all_stmts.clearRetainingCapacity();
+ }
+
+ pub fn deinit(this: *StmtList) void {
+ this.inside_wrapper_prefix.deinit();
+ this.outside_wrapper_prefix.deinit();
+ this.inside_wrapper_suffix.deinit();
+ this.all_stmts.deinit();
+ }
+
+ pub fn init(allocator: std.mem.Allocator) StmtList {
+ return .{
+ .inside_wrapper_prefix = std.ArrayList(Stmt).init(allocator),
+ .outside_wrapper_prefix = std.ArrayList(Stmt).init(allocator),
+ .inside_wrapper_suffix = std.ArrayList(Stmt).init(allocator),
+ .all_stmts = std.ArrayList(Stmt).init(allocator),
+ };
+ }
+ };
+
+ fn shouldRemoveImportExportStmt(
+ c: *LinkerContext,
+ stmts: *StmtList,
+ loc: Logger.Loc,
+ namespace_ref: Ref,
+ import_record_index: u32,
+ allocator: std.mem.Allocator,
+ ast: *const js_ast.Ast,
+ ) !bool {
+ const record = ast.import_records.at(import_record_index);
+ if (record.tag.isReactReference())
+ return false;
+
+ // Is this an external import?
+ if (!record.source_index.isValid()) {
+ // Keep the "import" statement if import statements are supported
+ if (c.options.output_format.keepES6ImportExportSyntax()) {
+ return false;
+ }
+
+ // Otherwise, replace this statement with a call to "require()"
+ stmts.inside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.Local,
+ S.Local{
+ .decls = try bun.fromSlice(
+ []G.Decl,
+ allocator,
+ []const G.Decl,
+ &.{
+ .{
+ .binding = Binding.alloc(
+ allocator,
+ B.Identifier{
+ .ref = namespace_ref,
+ },
+ loc,
+ ),
+ .value = Expr.init(
+ E.Require,
+ E.Require{
+ .import_record_index = import_record_index,
+ },
+ loc,
+ ),
+ },
+ },
+ ),
+ },
+ record.range.loc,
+ ),
+ ) catch unreachable;
+ return true;
+ }
+
+ // We don't need a call to "require()" if this is a self-import inside a
+ // CommonJS-style module, since we can just reference the exports directly.
+ if (ast.exports_kind == .cjs and c.graph.symbols.follow(namespace_ref).eql(ast.exports_ref)) {
+ return true;
+ }
+
+ const other_flags = c.graph.meta.items(.flags)[record.source_index.get()];
+ switch (other_flags.wrap) {
+ .none => {},
+ .cjs => {
+ // Replace the statement with a call to "require()" if this module is not wrapped
+ try stmts.inside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.Local,
+ S.Local{
+ .decls = try bun.fromSlice(
+ []G.Decl,
+ allocator,
+ []const G.Decl,
+ &.{
+ .{
+ .binding = Binding.alloc(
+ allocator,
+ B.Identifier{
+ .ref = namespace_ref,
+ },
+ loc,
+ ),
+ .value = Expr.init(
+ E.Require,
+ E.Require{
+ .import_record_index = import_record_index,
+ },
+ loc,
+ ),
+ },
+ },
+ ),
+ },
+ loc,
+ ),
+ );
+ },
+ .esm => {
+ // Ignore this file if it's not included in the bundle. This can happen for
+ // wrapped ESM files but not for wrapped CommonJS files because we allow
+ // tree shaking inside wrapped ESM files.
+ if (!c.graph.files_live.isSet(record.source_index.get())) {
+ return true;
+ }
+
+ // Replace the statement with a call to "init()"
+ const value: Expr = brk: {
+ const default = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.initIdentifier(
+ c.graph.ast.items(.wrapper_ref)[record.source_index.get()].?,
+ loc,
+ ),
+ },
+ loc,
+ );
+
+ if (other_flags.is_async_or_has_async_dependency) {
+ // This currently evaluates sibling dependencies in serial instead of in
+ // parallel, which is incorrect. This should be changed to store a promise
+ // and await all stored promises after all imports but before any code.
+ break :brk Expr.init(
+ E.Await,
+ E.Await{
+ .value = default,
+ },
+ loc,
+ );
+ }
+
+ break :brk default;
+ };
+
+ try stmts.inside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.SExpr,
+ S.SExpr{
+ .value = value,
+ },
+ loc,
+ ),
+ );
+ },
+ }
+
+ return true;
+ }
+
+ fn convertStmtsForChunk(
+ c: *LinkerContext,
+ source_index: u32,
+ stmts: *StmtList,
+ part_stmts: []const js_ast.Stmt,
+ chunk: *Chunk,
+ allocator: std.mem.Allocator,
+ wrap: WrapKind,
+ ast: *const js_ast.Ast,
+ ) !void {
+ const shouldExtractESMStmtsForWrap = wrap != .none;
+ const shouldStripExports = c.options.mode != .passthrough or !chunk.isEntryPoint();
+
+ const flags = c.graph.meta.items(.flags);
+
+ // If this file is a CommonJS entry point, double-write re-exports to the
+ // external CommonJS "module.exports" object in addition to our internal ESM
+ // export namespace object. The difference between these two objects is that
+ // our internal one must not have the "__esModule" marker while the external
+ // one must have the "__esModule" marker. This is done because an ES module
+ // importing itself should not see the "__esModule" marker but a CommonJS module
+ // importing us should see the "__esModule" marker.
+ var module_exports_for_export: ?Expr = null;
+ if (c.options.output_format == .cjs and chunk.isEntryPoint()) {
+ module_exports_for_export = Expr.init(
+ E.Dot,
+ E.Dot{
+ .target = Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = c.unbound_module_ref,
+ },
+ Logger.Loc.Empty,
+ ),
+ .name = "exports",
+ .name_loc = Logger.Loc.Empty,
+ },
+ Logger.Loc.Empty,
+ );
+ }
+
+ for (part_stmts) |_stmt| {
+ var stmt = _stmt;
+ switch (stmt.data) {
+ .s_import => |s| {
+ // "import * as ns from 'path'"
+ // "import {foo} from 'path'"
+ if (try c.shouldRemoveImportExportStmt(
+ stmts,
+ stmt.loc,
+ s.namespace_ref,
+ s.import_record_index,
+ allocator,
+ ast,
+ )) {
+ continue;
+ }
+
+ // Make sure these don't end up in the wrapper closure
+ if (shouldExtractESMStmtsForWrap) {
+ try stmts.outside_wrapper_prefix.append(stmt);
+ continue;
+ }
+ },
+ .s_export_star => |s| {
+ // "export * as ns from 'path'"
+ if (s.alias) |alias| {
+ if (try c.shouldRemoveImportExportStmt(
+ stmts,
+ stmt.loc,
+ s.namespace_ref,
+ s.import_record_index,
+ allocator,
+ ast,
+ )) {
+ continue;
+ }
+
+ if (shouldStripExports) {
+ // Turn this statement into "import * as ns from 'path'"
+ stmt = Stmt.alloc(
+ S.Import,
+ S.Import{
+ .namespace_ref = s.namespace_ref,
+ .import_record_index = s.import_record_index,
+ .star_name_loc = alias.loc,
+ },
+ stmt.loc,
+ );
+ }
+
+ // Make sure these don't end up in the wrapper closure
+ if (shouldExtractESMStmtsForWrap) {
+ try stmts.outside_wrapper_prefix.append(stmt);
+ continue;
+ }
+
+ break;
+ }
+
+ // "export * from 'path'"
+ if (!shouldStripExports) {
+ break;
+ }
+
+ const record = ast.import_records.at(s.import_record_index);
+
+ // Is this export star evaluated at run time?
+ if (!record.source_index.isValid() and c.options.output_format.keepES6ImportExportSyntax()) {
+ if (record.calls_runtime_re_export_fn) {
+ // Turn this statement into "import * as ns from 'path'"
+ stmt = Stmt.alloc(
+ S.Import,
+ S.Import{
+ .namespace_ref = s.namespace_ref,
+ .import_record_index = s.import_record_index,
+ .star_name_loc = stmt.loc,
+ },
+ stmt.loc,
+ );
+
+ // Prefix this module with "__reExport(exports, ns, module.exports)"
+ const export_star_ref = c.runtimeFunction("__reExport");
+ var args = try allocator.alloc(Expr, 2 + @as(usize, @boolToInt(module_exports_for_export != null)));
+ args[0..2].* = .{
+ Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = ast.exports_ref,
+ },
+ stmt.loc,
+ ),
+ Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = s.namespace_ref,
+ },
+ stmt.loc,
+ ),
+ };
+
+ if (module_exports_for_export) |mod| {
+ args[3] = mod;
+ }
+
+ try stmts.inside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.SExpr,
+ S.SExpr{
+ .value = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = export_star_ref,
+ },
+ stmt.loc,
+ ),
+ .args = bun.BabyList(Expr).init(args),
+ },
+ stmt.loc,
+ ),
+ },
+ stmt.loc,
+ ),
+ );
+
+ // Make sure these don't end up in the wrapper closure
+ if (shouldExtractESMStmtsForWrap) {
+ try stmts.outside_wrapper_prefix.append(stmt);
+ continue;
+ }
+ }
+ } else {
+ if (record.source_index.isValid()) {
+ const flag = flags[record.source_index.get()];
+ if (flag.wrap == .esm) {
+ try stmts.inside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.SExpr,
+ .{
+ .value = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = c.graph.ast.items(.wrapper_ref)[record.source_index.get()].?,
+ },
+ stmt.loc,
+ ),
+ },
+ stmt.loc,
+ ),
+ },
+ stmt.loc,
+ ),
+ );
+ }
+ }
+
+ if (record.calls_runtime_re_export_fn) {
+ const target: Expr = brk: {
+ if (c.graph.ast.items(.exports_kind)[source_index] == .esm_with_dynamic_fallback) {
+ // Prefix this module with "__reExport(exports, otherExports, module.exports)"
+ break :brk Expr.initIdentifier(c.graph.ast.items(.exports_ref)[source_index], stmt.loc);
+ }
+
+ break :brk Expr.init(
+ E.Require,
+ E.Require{
+ .import_record_index = s.import_record_index,
+ },
+ stmt.loc,
+ );
+ };
+
+ // Prefix this module with "__reExport(exports, require(path), module.exports)"
+ const export_star_ref = c.runtimeFunction("__reExport");
+ var args = try allocator.alloc(Expr, 2 + @as(usize, @boolToInt(module_exports_for_export != null)));
+ args[0..2].* = .{
+ Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = ast.exports_ref,
+ },
+ stmt.loc,
+ ),
+ target,
+ };
+
+ if (module_exports_for_export) |mod| {
+ args[3] = mod;
+ }
+
+ try stmts.inside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.SExpr,
+ S.SExpr{
+ .value = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = export_star_ref,
+ },
+ stmt.loc,
+ ),
+ .args = js_ast.ExprNodeList.init(args),
+ },
+ stmt.loc,
+ ),
+ },
+ stmt.loc,
+ ),
+ );
+ }
+
+ // Remove the export star statement
+ continue;
+ }
+ },
+
+ .s_export_from => |s| {
+ // "export {foo} from 'path'"
+
+ if (try c.shouldRemoveImportExportStmt(
+ stmts,
+ stmt.loc,
+ s.namespace_ref,
+ s.import_record_index,
+ allocator,
+ ast,
+ )) {
+ continue;
+ }
+
+ if (shouldStripExports) {
+ // Turn this statement into "import {foo} from 'path'"
+
+ for (s.items) |*item| {
+ item.alias = item.original_name;
+ }
+
+ stmt = Stmt.alloc(
+ S.Import,
+ S.Import{
+ .items = s.items,
+ .import_record_index = s.import_record_index,
+ .star_name_loc = stmt.loc,
+ .namespace_ref = s.namespace_ref,
+ .is_single_line = s.is_single_line,
+ },
+ stmt.loc,
+ );
+ }
+
+ // Make sure these don't end up in the wrapper closure
+ if (shouldExtractESMStmtsForWrap) {
+ try stmts.outside_wrapper_prefix.append(stmt);
+ continue;
+ }
+ },
+
+ .s_export_clause => {
+ // "export {foo}"
+
+ if (shouldStripExports) {
+ // Remove export statements entirely
+
+ continue;
+ }
+
+ // Make sure these don't end up in the wrapper closure
+ if (shouldExtractESMStmtsForWrap) {
+ try stmts.outside_wrapper_prefix.append(stmt);
+ continue;
+ }
+ },
+
+ .s_function => |s| {
+
+ // Strip the "export" keyword while bundling
+ if (shouldStripExports and s.func.flags.contains(.is_export)) {
+ // Be c areful to not modify the original statement
+ stmt = Stmt.alloc(
+ S.Function,
+ S.Function{
+ .func = s.func,
+ },
+ stmt.loc,
+ );
+ stmt.data.s_function.func.flags.remove(.is_export);
+ }
+ },
+
+ .s_class => |s| {
+
+ // Strip the "export" keyword while bundling
+ if (shouldStripExports and s.is_export) {
+ // Be c areful to not modify the original statement
+ stmt = Stmt.alloc(
+ S.Class,
+ S.Class{
+ .class = s.class,
+ .is_export = false,
+ },
+ stmt.loc,
+ );
+ }
+ },
+
+ .s_local => |s| {
+ // Strip the "export" keyword while bundling
+ if (shouldStripExports and s.is_export) {
+ // Be c areful to not modify the original statement
+ stmt = Stmt.alloc(
+ S.Local,
+ s.*,
+ stmt.loc,
+ );
+ stmt.data.s_local.is_export = false;
+ }
+ },
+
+ .s_export_default => |s| {
+ // "export default foo"
+
+ if (shouldStripExports) {
+ switch (s.value) {
+ .stmt => |stmt2| {
+ switch (stmt2.data) {
+ .s_expr => |s2| {
+ // "export default foo;" => "var default = foo;"
+ stmt = Stmt.alloc(
+ S.Local,
+ S.Local{
+ .decls = try bun.fromSlice(
+ []js_ast.G.Decl,
+ allocator,
+ []const js_ast.G.Decl,
+ &.{
+ .{
+ .binding = Binding.alloc(
+ allocator,
+ B.Identifier{
+ .ref = s.default_name.ref.?,
+ },
+ s2.value.loc,
+ ),
+ .value = s2.value,
+ },
+ },
+ ),
+ },
+ stmt.loc,
+ );
+ },
+ .s_function => |s2| {
+ // "export default function() {}" => "function default() {}"
+ // "export default function foo() {}" => "function foo() {}"
+
+ // Be careful to not modify the original statement
+ stmt = Stmt.alloc(
+ S.Function,
+ S.Function{
+ .func = s2.func,
+ },
+ stmt.loc,
+ );
+ stmt.data.s_function.func.name = s.default_name;
+ },
+
+ .s_class => |s2| {
+ // "export default class {}" => "class default {}"
+ // "export default class foo {}" => "class foo {}"
+
+ // Be careful to not modify the original statement
+ stmt = Stmt.alloc(
+ S.Class,
+ S.Class{
+ .class = s2.class,
+ .is_export = false,
+ },
+ stmt.loc,
+ );
+ stmt.data.s_class.class.class_name = s.default_name;
+ },
+
+ else => bun.unreachablePanic(
+ "Unexpected type {any} in source file {s}",
+ .{
+ stmt2.data,
+ c.parse_graph.input_files.get(c.graph.files.get(source_index).input_file.get()).source.path.text,
+ },
+ ),
+ }
+ },
+ .expr => |e| {
+ stmt = Stmt.alloc(
+ S.Local,
+ S.Local{
+ .decls = try bun.fromSlice(
+ []js_ast.G.Decl,
+ allocator,
+ []const js_ast.G.Decl,
+ &.{
+ .{
+ .binding = Binding.alloc(
+ allocator,
+ B.Identifier{
+ .ref = s.default_name.ref.?,
+ },
+ e.loc,
+ ),
+ .value = e,
+ },
+ },
+ ),
+ },
+ stmt.loc,
+ );
+ },
+ }
+ }
+ },
+
+ else => {},
+ }
+
+ try stmts.inside_wrapper_suffix.append(stmt);
+ }
+ }
+
+ fn runtimeFunction(c: *LinkerContext, name: []const u8) Ref {
+ return c.graph.runtimeFunction(name);
+ }
+
+ fn generateCodeForFileInChunkJS(
+ c: *LinkerContext,
+ writer: *js_printer.BufferWriter,
+ r: renamer.Renamer,
+ chunk: *Chunk,
+ part_range: PartRange,
+ toCommonJSRef: Ref,
+ toESMRef: Ref,
+ runtimeRequireRef: Ref,
+ stmts: *StmtList,
+ allocator: std.mem.Allocator,
+ temp_allocator: std.mem.Allocator,
+ ) js_printer.PrintResult {
+ // var file = &c.graph.files.items(.input_file)[part.source_index.get()];
+ var parts: []js_ast.Part = c.graph.ast.items(.parts)[part_range.source_index.get()].slice()[part_range.part_index_begin..part_range.part_index_end];
+ // const resolved_exports: []ResolvedExports = c.graph.meta.items(.resolved_exports);
+ const all_flags: []const JSMeta.Flags = c.graph.meta.items(.flags);
+ const flags = all_flags[part_range.source_index.get()];
+ const wrapper_part_index = c.graph.meta.items(.wrapper_part_index)[part_range.source_index.get()];
+
+ // referencing everything by array makes the code a lot more annoying :(
+ const ast: js_ast.Ast = c.graph.ast.get(part_range.source_index.get());
+
+ js_ast.Expr.Data.Store.reset();
+ js_ast.Stmt.Data.Store.reset();
+
+ var needs_wrapper = false;
+
+ const namespace_export_part_index = js_ast.namespace_export_part_index;
+
+ stmts.reset();
+
+ // TODO: handle directive
+ if (namespace_export_part_index >= part_range.part_index_begin and
+ namespace_export_part_index < part_range.part_index_end and
+ parts[namespace_export_part_index].is_live)
+ {
+ c.convertStmtsForChunk(
+ part_range.source_index.get(),
+ stmts,
+ parts[namespace_export_part_index].stmts,
+ chunk,
+ temp_allocator,
+ flags.wrap,
+ &ast,
+ ) catch |err| return .{
+ .err = err,
+ };
+
+ switch (flags.wrap) {
+ .esm => {
+ stmts.outside_wrapper_prefix.appendSlice(stmts.inside_wrapper_suffix.items) catch unreachable;
+ },
+ else => {
+ stmts.inside_wrapper_prefix.appendSlice(stmts.inside_wrapper_suffix.items) catch unreachable;
+ },
+ }
+ stmts.inside_wrapper_suffix.clearRetainingCapacity();
+ }
+
+ // TODO: defaultLazyExport
+
+ // Add all other parts in this chunk
+ for (parts, 0..) |part, index_| {
+ const index = part_range.part_index_begin + @truncate(u32, index_);
+ if (!part.is_live) {
+ // Skip the part if it's not in this chunk
+
+ continue;
+ }
+
+ if (index == namespace_export_part_index) {
+ // Skip the namespace export part because we already handled it above
+ continue;
+ }
+
+ if (index == wrapper_part_index.get()) {
+ // Skip the wrapper part because we already handled it above
+ needs_wrapper = true;
+ continue;
+ }
+
+ // TODO: lazy default export
+
+ // convert
+ c.convertStmtsForChunk(
+ part_range.source_index.get(),
+ stmts,
+ part.stmts,
+ chunk,
+ temp_allocator,
+ flags.wrap,
+ &ast,
+ ) catch |err| return .{
+ .err = err,
+ };
+ }
+
+ // Hoist all import statements before any normal statements. ES6 imports
+ // are different than CommonJS imports. All modules imported via ES6 import
+ // statements are evaluated before the module doing the importing is
+ // evaluated (well, except for cyclic import scenarios). We need to preserve
+ // these semantics even when modules imported via ES6 import statements end
+ // up being CommonJS modules.
+ stmts.all_stmts.ensureUnusedCapacity(stmts.inside_wrapper_prefix.items.len + stmts.inside_wrapper_suffix.items.len) catch unreachable;
+ stmts.all_stmts.appendSliceAssumeCapacity(stmts.inside_wrapper_prefix.items);
+ stmts.all_stmts.appendSliceAssumeCapacity(stmts.inside_wrapper_suffix.items);
+ stmts.inside_wrapper_prefix.items.len = 0;
+ stmts.inside_wrapper_suffix.items.len = 0;
+
+ // TODO: mergeAdjacentLocalStmts
+
+ var out_stmts: []js_ast.Stmt = stmts.all_stmts.items;
+ // Optionally wrap all statements in a closure
+ if (needs_wrapper) {
+ switch (flags.wrap) {
+ .cjs => {
+ // Only include the arguments that are actually used
+ var args = std.ArrayList(js_ast.G.Arg).initCapacity(
+ temp_allocator,
+ if (ast.uses_module_ref or ast.uses_exports_ref) 2 else 0,
+ ) catch unreachable;
+
+ if (ast.uses_module_ref or ast.uses_exports_ref) {
+ args.appendAssumeCapacity(
+ js_ast.G.Arg{
+ .binding = js_ast.Binding.alloc(
+ temp_allocator,
+ js_ast.B.Identifier{
+ .ref = ast.exports_ref,
+ },
+ Logger.Loc.Empty,
+ ),
+ },
+ );
+
+ if (ast.uses_module_ref) {
+ args.appendAssumeCapacity(
+ js_ast.G.Arg{
+ .binding = js_ast.Binding.alloc(
+ temp_allocator,
+ js_ast.B.Identifier{
+ .ref = ast.module_ref.?,
+ },
+ Logger.Loc.Empty,
+ ),
+ },
+ );
+ }
+ }
+
+ // TODO: variants of the runtime functions
+ var cjs_args = temp_allocator.alloc(Expr, 1) catch unreachable;
+ cjs_args[0] = Expr.init(
+ E.Arrow,
+ E.Arrow{
+ .args = args.items,
+ .body = .{
+ .stmts = stmts.all_stmts.items,
+ .loc = Logger.Loc.Empty,
+ },
+ },
+ Logger.Loc.Empty,
+ );
+
+ const commonjs_wrapper_definition = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = c.cjs_runtime_ref,
+ },
+ Logger.Loc.Empty,
+ ),
+ .args = bun.BabyList(Expr).init(cjs_args),
+ },
+ Logger.Loc.Empty,
+ );
+
+ // "var require_foo = __commonJS(...);"
+ {
+ var decls = temp_allocator.alloc(G.Decl, 1) catch unreachable;
+ decls[0] = G.Decl{
+ .binding = Binding.alloc(
+ temp_allocator,
+ B.Identifier{
+ .ref = ast.wrapper_ref.?,
+ },
+ Logger.Loc.Empty,
+ ),
+ .value = commonjs_wrapper_definition,
+ };
+
+ stmts.outside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.Local,
+ S.Local{
+ .decls = decls,
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+ }
+ },
+ .esm => {
+ // The wrapper only needs to be "async" if there is a transitive async
+ // dependency. For correctness, we must not use "async" if the module
+ // isn't async because then calling "require()" on that module would
+ // swallow any exceptions thrown during module initialization.
+ const is_async = flags.is_async_or_has_async_dependency;
+ const Hoisty = struct {
+ decls: std.ArrayList(G.Decl),
+ allocator: std.mem.Allocator,
+
+ pub fn wrapIdentifier(w: *@This(), loc: Logger.Loc, ref: Ref) Expr {
+ w.decls.append(
+ G.Decl{
+ .binding = Binding.alloc(
+ w.allocator,
+ B.Identifier{
+ .ref = ref,
+ },
+ loc,
+ ),
+ },
+ ) catch unreachable;
+ return Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = ref,
+ },
+ loc,
+ );
+ }
+ };
+ var hoisty = Hoisty{
+ .decls = std.ArrayList(G.Decl).init(temp_allocator),
+ .allocator = temp_allocator,
+ };
+ var inner_stmts = stmts.all_stmts.items;
+ // Hoist all top-level "var" and "function" declarations out of the closure
+ {
+ var end: usize = 0;
+ for (stmts.all_stmts.items) |stmt_| {
+ var stmt: Stmt = stmt_;
+ switch (stmt.data) {
+ .s_local => |local| {
+ var value: Expr = Expr.init(E.Missing, E.Missing{}, Logger.Loc.Empty);
+ for (local.decls) |*decl| {
+ const binding = decl.binding.toExpr(&hoisty);
+ if (decl.value) |other| {
+ value = value.joinWithComma(
+ binding.assign(
+ other,
+ temp_allocator,
+ ),
+ temp_allocator,
+ );
+ }
+ }
+
+ if (value.isEmpty()) {
+ continue;
+ }
+ stmt = Stmt.alloc(
+ S.SExpr,
+ S.SExpr{
+ .value = value,
+ },
+ stmt.loc,
+ );
+ },
+ .s_class, .s_function => {
+ stmts.outside_wrapper_prefix.append(stmt) catch unreachable;
+ continue;
+ },
+ else => {},
+ }
+ inner_stmts[end] = stmt;
+ end += 1;
+ }
+ inner_stmts.len = end;
+ }
+
+ if (!c.options.minify_syntax and hoisty.decls.items.len > 0) {
+ stmts.outside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.Local,
+ S.Local{
+ .decls = hoisty.decls.items,
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+ hoisty.decls.items.len = 0;
+ }
+
+ // "__esm(() => { ... })"
+ var esm_args = temp_allocator.alloc(Expr, 1) catch unreachable;
+ esm_args[0] = Expr.init(
+ E.Arrow,
+ E.Arrow{
+ .args = &.{},
+ .is_async = is_async,
+ .body = .{
+ .stmts = inner_stmts,
+ .loc = Logger.Loc.Empty,
+ },
+ },
+ Logger.Loc.Empty,
+ );
+
+ // "var init_foo = __esm(...);"
+ {
+ const value = Expr.init(
+ E.Call,
+ E.Call{
+ .target = Expr.init(
+ E.Identifier,
+ E.Identifier{
+ .ref = c.esm_runtime_ref,
+ },
+ Logger.Loc.Empty,
+ ),
+ .args = bun.BabyList(Expr).init(esm_args),
+ },
+ Logger.Loc.Empty,
+ );
+
+ var decls = temp_allocator.alloc(G.Decl, 1) catch unreachable;
+ decls[0] = G.Decl{
+ .binding = Binding.alloc(
+ temp_allocator,
+ B.Identifier{
+ .ref = ast.wrapper_ref.?,
+ },
+ Logger.Loc.Empty,
+ ),
+ .value = value,
+ };
+
+ stmts.outside_wrapper_prefix.append(
+ Stmt.alloc(
+ S.Local,
+ S.Local{
+ .decls = decls,
+ },
+ Logger.Loc.Empty,
+ ),
+ ) catch unreachable;
+ }
+ },
+ else => {},
+ }
+
+ out_stmts = stmts.outside_wrapper_prefix.items;
+ }
+
+ if (out_stmts.len == 0) {
+ return .{
+ .result = .{
+ .code = &[_]u8{},
+ .source_map = null,
+ },
+ };
+ }
+
+ const parts_to_print = &[_]js_ast.Part{
+ js_ast.Part{
+ // .tag = .stmts,
+ .stmts = out_stmts,
+ },
+ };
+
+ const print_options = js_printer.Options{
+ // TODO: IIFE
+ .indent = 0,
+
+ .commonjs_named_exports = ast.commonjs_named_exports,
+ .commonjs_named_exports_ref = ast.exports_ref,
+
+ .allocator = allocator,
+ .to_esm_ref = toESMRef,
+ .to_commonjs_ref = toCommonJSRef,
+ .require_ref = runtimeRequireRef,
+ .require_or_import_meta_for_source_callback = js_printer.RequireOrImportMeta.Callback.init(
+ LinkerContext,
+ requireOrImportMetaForSource,
+ c,
+ ),
+ };
+
+ writer.buffer.reset();
+ var printer = js_printer.BufferPrinter.init(
+ writer.*,
+ );
+ defer writer.* = printer.ctx;
+
+ return js_printer.printWithWriter(
+ *js_printer.BufferPrinter,
+ &printer,
+ ast.platform,
+ print_options,
+ ast.import_records.slice(),
+ parts_to_print,
+ r,
+ );
+ }
+
+ fn requireOrImportMetaForSource(
+ c: *LinkerContext,
+ source_index: Index.Int,
+ ) js_printer.RequireOrImportMeta {
+ const flags = c.graph.meta.items(.flags)[source_index];
+ return .{
+ .exports_ref = if (flags.wrap == .esm)
+ c.graph.ast.items(.exports_ref)[source_index]
+ else
+ Ref.None,
+ .is_wrapper_async = flags.is_async_or_has_async_dependency,
+ .wrapper_ref = c.graph.ast.items(.wrapper_ref)[source_index] orelse Ref.None,
+ };
+ }
+
+ pub fn generateChunksInParallel(c: *LinkerContext, chunks: []Chunk) !std.ArrayList(options.OutputFile) {
+ {
+ debug("START Generating {d} chunks in parallel", .{chunks.len});
+ defer debug(" DONE Generating {d} chunks in parallel", .{chunks.len});
+ var wait_group = try c.allocator.create(sync.WaitGroup);
+ wait_group.init();
+ defer {
+ wait_group.deinit();
+ c.allocator.destroy(wait_group);
+ }
+ wait_group.counter = @truncate(u32, chunks.len);
+ var ctx = GenerateChunkCtx{ .wg = wait_group, .c = c, .chunks = chunks };
+ try c.parse_graph.pool.pool.doPtr(c.allocator, wait_group, ctx, generateChunkJS, chunks);
+ }
+
+ // TODO: enforceNoCyclicChunkImports()
+ {
+
+ // Compute the final hashes of each chunk. This can technically be done in
+ // parallel but it probably doesn't matter so much because we're not hashing
+ // that much data.
+ for (chunks) |*chunk| {
+ // TODO: non-isolated-hash
+ chunk.template.placeholder.hash = chunk.isolated_hash;
+
+ chunk.final_rel_path = std.fmt.allocPrint(c.allocator, "{any}", .{chunk.template}) catch unreachable;
+ }
+ }
+
+ var react_client_components_manifest: []u8 = if (c.resolver.opts.react_server_components) brk: {
+ var bytes = std.ArrayList(u8).init(c.allocator);
+ defer bytes.deinit();
+ var all_sources = c.parse_graph.input_files.items(.source);
+ var all_named_exports = c.graph.ast.items(.named_exports);
+ var export_names = std.ArrayList(Api.StringPointer).init(c.allocator);
+ defer export_names.deinit();
+
+ var client_modules = std.ArrayList(Api.ClientServerModule).initCapacity(c.allocator, c.graph.react_client_component_boundary.count()) catch unreachable;
+ defer client_modules.deinit();
+ var server_modules = std.ArrayList(Api.ClientServerModule).initCapacity(c.allocator, c.graph.react_server_component_boundary.count()) catch unreachable;
+ defer server_modules.deinit();
+
+ var react_client_components_iterator = c.graph.react_client_component_boundary.iterator(.{});
+ var react_server_components_iterator = c.graph.react_server_component_boundary.iterator(.{});
+
+ var sorted_client_component_ids = std.ArrayList(u32).initCapacity(c.allocator, client_modules.capacity) catch unreachable;
+ defer sorted_client_component_ids.deinit();
+ while (react_client_components_iterator.next()) |source_index| {
+ if (!c.graph.files_live.isSet(source_index)) continue;
+ sorted_client_component_ids.appendAssumeCapacity(@intCast(u32, source_index));
+ }
+
+ var sorted_server_component_ids = std.ArrayList(u32).initCapacity(c.allocator, server_modules.capacity) catch unreachable;
+ defer sorted_server_component_ids.deinit();
+ while (react_server_components_iterator.next()) |source_index| {
+ if (!c.graph.files_live.isSet(source_index)) continue;
+ sorted_server_component_ids.appendAssumeCapacity(@intCast(u32, source_index));
+ }
+
+ const Sorter = struct {
+ sources: []const Logger.Source,
+ pub fn isLessThan(ctx: @This(), a_index: u32, b_index: u32) bool {
+ const a = ctx.sources[a_index].path.text;
+ const b = ctx.sources[b_index].path.text;
+ return strings.order(a, b) == .lt;
+ }
+ };
+ std.sort.sort(u32, sorted_client_component_ids.items, Sorter{ .sources = all_sources }, Sorter.isLessThan);
+ std.sort.sort(u32, sorted_server_component_ids.items, Sorter{ .sources = all_sources }, Sorter.isLessThan);
+
+ inline for (.{
+ sorted_client_component_ids.items,
+ sorted_server_component_ids.items,
+ }, .{
+ &client_modules,
+ &server_modules,
+ }) |sorted_component_ids, modules| {
+ for (sorted_component_ids) |source_index| {
+ const named_exports = all_named_exports[source_index].keys();
+ const exports_len = @intCast(u32, named_exports.len);
+ const exports_start = @intCast(u32, export_names.items.len);
+
+ var grow_length: usize = 0;
+ try export_names.ensureUnusedCapacity(named_exports.len);
+
+ var chunk: *Chunk = brk2: {
+ for (chunks) |*chunk_| {
+ if (chunk_.entry_point.source_index == @intCast(u32, source_index)) {
+ break :brk2 chunk_;
+ }
+ }
+
+ @panic("Assertion failure: missing chunk for react client component");
+ };
+
+ grow_length += chunk.final_rel_path.len;
+
+ grow_length += all_sources[source_index].path.pretty.len;
+
+ for (named_exports) |export_name| {
+ try export_names.append(Api.StringPointer{
+ .offset = @intCast(u32, bytes.items.len + grow_length),
+ .length = @intCast(u32, export_name.len),
+ });
+ grow_length += export_name.len;
+ }
+
+ try bytes.ensureUnusedCapacity(grow_length);
+
+ const input_name = Api.StringPointer{
+ .offset = @intCast(u32, bytes.items.len),
+ .length = @intCast(u32, all_sources[source_index].path.pretty.len),
+ };
+
+ bytes.appendSliceAssumeCapacity(all_sources[source_index].path.pretty);
+
+ const asset_name = Api.StringPointer{
+ .offset = @intCast(u32, bytes.items.len),
+ .length = @intCast(u32, chunk.final_rel_path.len),
+ };
+
+ bytes.appendSliceAssumeCapacity(chunk.final_rel_path);
+
+ for (named_exports) |export_name| {
+ bytes.appendSliceAssumeCapacity(export_name);
+ }
+
+ modules.appendAssumeCapacity(.{
+ .module_id = bun.hash32(all_sources[source_index].path.pretty),
+ .asset_name = asset_name,
+ .input_name = input_name,
+ .export_names = .{
+ .length = exports_len,
+ .offset = exports_start,
+ },
+ });
+ }
+ }
+
+ if (client_modules.items.len == 0 and server_modules.items.len == 0) break :brk &.{};
+
+ var manifest = Api.ClientServerModuleManifest{
+ .version = 2,
+ .client_modules = client_modules.items,
+
+ // TODO:
+ .ssr_modules = client_modules.items,
+
+ .server_modules = server_modules.items,
+ .export_names = export_names.items,
+ .contents = bytes.items,
+ };
+ var byte_buffer = std.ArrayList(u8).initCapacity(c.allocator, bytes.items.len) catch unreachable;
+ var byte_buffer_writer = byte_buffer.writer();
+ const SchemaWriter = schema.Writer(@TypeOf(&byte_buffer_writer));
+ var writer = SchemaWriter.init(&byte_buffer_writer);
+ manifest.encode(&writer) catch unreachable;
+ break :brk byte_buffer.items;
+ } else &.{};
+
+ // Generate the final output files by joining file pieces together
+ var output_files = std.ArrayList(options.OutputFile).initCapacity(c.allocator, chunks.len + @as(
+ usize,
+ @boolToInt(react_client_components_manifest.len > 0),
+ )) catch unreachable;
+ output_files.items.len = chunks.len;
+ for (chunks, output_files.items) |*chunk, *output_file| {
+ output_file.* = options.OutputFile.initBuf(
+ chunk.intermediate_output.code(c.allocator, chunk, chunks) catch @panic("Failed to allocate memory for output file"),
+ chunk.final_rel_path,
+ // TODO: remove this field
+ .js,
+ );
+ }
+
+ if (react_client_components_manifest.len > 0) {
+ output_files.appendAssumeCapacity(options.OutputFile.initBuf(
+ react_client_components_manifest,
+ "./components-manifest.blob",
+ .file,
+ ));
+ }
+
+ return output_files;
+ }
+
+ // Sort cross-chunk exports by chunk name for determinism
+ fn sortedCrossChunkExportItems(
+ c: *LinkerContext,
+ export_refs: ChunkMeta.Map,
+ list: *std.ArrayList(StableRef),
+ ) void {
+ var result = list.*;
+ defer list.* = result;
+ result.clearRetainingCapacity();
+ result.ensureTotalCapacity(export_refs.count()) catch unreachable;
+ result.items.len = export_refs.count();
+ for (export_refs.keys(), result.items) |export_ref, *item| {
+ if (comptime Environment.allow_assert)
+ debugTreeShake("Export name: {s} (in {s})", .{
+ c.graph.symbols.get(export_ref).?.original_name,
+ c.parse_graph.input_files.get(export_ref.sourceIndex()).source.path.text,
+ });
+ item.* = .{
+ .stable_source_index = c.graph.stable_source_indices[export_ref.sourceIndex()],
+ .ref = export_ref,
+ };
+ }
+ std.sort.sort(StableRef, result.items, void{}, StableRef.isLessThan);
+ }
+
+ pub fn markFileReachableForCodeSplitting(
+ c: *LinkerContext,
+ source_index: Index.Int,
+ entry_points_count: usize,
+ distances: []u32,
+ distance: u32,
+ parts: []bun.BabyList(js_ast.Part),
+ import_records: []bun.BabyList(bun.ImportRecord),
+ file_entry_bits: []AutoBitSet,
+ ) void {
+ if (!c.graph.files_live.isSet(source_index))
+ return;
+
+ const cur_dist = distances[source_index];
+ const traverse_again = distance < cur_dist;
+ if (traverse_again) {
+ distances[source_index] = distance;
+ }
+ const out_dist = distance + 1;
+
+ var bits = &file_entry_bits[source_index];
+
+ // Don't mark this file more than once
+ if (bits.isSet(entry_points_count) and !traverse_again)
+ return;
+
+ bits.set(entry_points_count);
+
+ if (comptime bun.Environment.allow_assert)
+ debugTreeShake(
+ "markFileReachableForCodeSplitting(entry: {d}): {s} ({d})",
+ .{
+ entry_points_count,
+ c.parse_graph.input_files.get(source_index).source.path.text,
+ out_dist,
+ },
+ );
+
+ // TODO: CSS AST
+ var imports_a_boundary = false;
+ const use_directive = c.graph.useDirectiveBoundary(source_index);
+
+ for (import_records[source_index].slice()) |*record| {
+ const is_boundary = use_directive.isBoundary(record.tag.useDirective());
+ imports_a_boundary = use_directive != .none and (imports_a_boundary or is_boundary);
+ if (record.source_index.isValid() and !is_boundary and !c.isExternalDynamicImport(record, source_index)) {
+ c.markFileReachableForCodeSplitting(
+ record.source_index.get(),
+ entry_points_count,
+ distances,
+ out_dist,
+ parts,
+ import_records,
+ file_entry_bits,
+ );
+ }
+ }
+
+ for (parts[source_index].slice()) |part| {
+ for (part.dependencies.slice()) |dependency| {
+ if (dependency.source_index.get() != source_index) {
+ if (imports_a_boundary and
+ // "use client" -> "use server" imports don't
+ use_directive.isBoundary(c.graph.files.items(.entry_point_kind)[dependency.source_index.get()]
+ .useDirective()))
+ continue;
+
+ c.markFileReachableForCodeSplitting(
+ dependency.source_index.get(),
+ entry_points_count,
+ distances,
+ out_dist,
+ parts,
+ import_records,
+ file_entry_bits,
+ );
+ }
+ }
+ }
+ }
+
+ pub fn markFileLiveForTreeShaking(
+ c: *LinkerContext,
+ source_index: Index.Int,
+ side_effects: []_resolver.SideEffects,
+ parts: []bun.BabyList(js_ast.Part),
+ import_records: []bun.BabyList(bun.ImportRecord),
+ entry_point_kinds: []EntryPoint.Kind,
+ ) void {
+ if (comptime bun.Environment.allow_assert)
+ debugTreeShake(
+ "markFileLiveForTreeShaking({d}, {s}) = {s}",
+ .{
+ source_index,
+ c.parse_graph.input_files.get(source_index).source.path.text,
+ if (c.graph.files_live.isSet(source_index)) "seen" else "not seen",
+ },
+ );
+
+ if (c.graph.files_live.isSet(source_index))
+ return;
+
+ c.graph.files_live.set(source_index);
+
+ // TODO: CSS source index
+
+ const id = source_index;
+ if (@as(usize, id) >= c.graph.ast.len)
+ return;
+ var _parts = parts[id].slice();
+ for (_parts, 0..) |part, part_index| {
+ var can_be_removed_if_unused = part.can_be_removed_if_unused;
+
+ // Also include any statement-level imports
+ for (part.import_record_indices.slice()) |import_record_Index| {
+ var record: *ImportRecord = &import_records[source_index].slice()[import_record_Index];
+
+ if (record.kind != .stmt)
+ continue;
+
+ if (record.source_index.isValid()) {
+ const other_source_index = record.source_index.get();
+
+ // Don't include this module for its side effects if it can be
+ // considered to have no side effects
+ if (side_effects[other_source_index] != .has_side_effects and !c.options.ignore_dce_annotations) {
+ continue;
+ }
+
+ // Otherwise, include this module for its side effects
+ c.markFileLiveForTreeShaking(
+ other_source_index,
+ side_effects,
+ parts,
+ import_records,
+ entry_point_kinds,
+ );
+ } else if (record.is_external_without_side_effects) {
+ // This can be removed if it's unused
+ continue;
+ }
+
+ // If we get here then the import was included for its side effects, so
+ // we must also keep this part
+ can_be_removed_if_unused = false;
+ }
+
+ // Include all parts in this file with side effects, or just include
+ // everything if tree-shaking is disabled. Note that we still want to
+ // perform tree-shaking on the runtime even if tree-shaking is disabled.
+ if (!can_be_removed_if_unused or
+ (!part.force_tree_shaking and
+ !c.options.tree_shaking and
+ entry_point_kinds[id].isEntryPoint()))
+ {
+ _ = c.markPartLiveForTreeShaking(
+ @intCast(u32, part_index),
+ id,
+ side_effects,
+ parts,
+ import_records,
+ entry_point_kinds,
+ );
+ }
+ }
+ }
+
+ pub fn markPartLiveForTreeShaking(
+ c: *LinkerContext,
+ part_index: Index.Int,
+ id: Index.Int,
+ side_effects: []_resolver.SideEffects,
+ parts: []bun.BabyList(js_ast.Part),
+ import_records: []bun.BabyList(bun.ImportRecord),
+ entry_point_kinds: []EntryPoint.Kind,
+ ) bool {
+ var part: *js_ast.Part = &parts[id].slice()[part_index];
+ // only once
+ if (part.is_live) {
+ return false;
+ }
+
+ part.is_live = true;
+ if (comptime bun.Environment.allow_assert)
+ debugTreeShake("markPartLiveForTreeShaking({d}): {s}:{d} = {d}, {s}", .{
+ id,
+ c.parse_graph.input_files.get(id).source.path.text,
+ part_index,
+ if (part.stmts.len > 0) part.stmts[0].loc.start else Logger.Loc.Empty.start,
+ if (part.stmts.len > 0) @tagName(part.stmts[0].data) else @tagName(Stmt.empty().data),
+ });
+
+ // Include the file containing this part
+ c.markFileLiveForTreeShaking(
+ id,
+ side_effects,
+ parts,
+ import_records,
+ entry_point_kinds,
+ );
+
+ for (part.dependencies.slice()) |dependency| {
+ _ = c.markPartLiveForTreeShaking(
+ dependency.part_index,
+ dependency.source_index.get(),
+ side_effects,
+ parts,
+ import_records,
+ entry_point_kinds,
+ );
+ }
+
+ return true;
+ }
+
+ pub fn matchImportWithExport(
+ c: *LinkerContext,
+ init_tracker: *ImportTracker,
+ re_exports: *std.ArrayList(js_ast.Dependency),
+ ) MatchImport {
+ var tracker = init_tracker;
+ var ambiguous_results = std.ArrayList(MatchImport).init(c.allocator);
+ defer ambiguous_results.clearAndFree();
+ var result: MatchImport = MatchImport{};
+ const named_imports = c.graph.ast.items(.named_imports);
+
+ loop: while (true) {
+ // Make sure we avoid infinite loops trying to resolve cycles:
+ //
+ // // foo.js
+ // export {a as b} from './foo.js'
+ // export {b as c} from './foo.js'
+ // export {c as a} from './foo.js'
+ //
+ // This uses a O(n^2) array scan instead of a O(n) map because the vast
+ // majority of cases have one or two elements
+ for (c.cycle_detector.items) |prev_tracker| {
+ if (std.meta.eql(tracker.*, prev_tracker)) {
+ result = .{ .kind = .cycle };
+ break :loop;
+ }
+ }
+
+ const prev_import_ref = tracker.import_ref;
+ const prev_source_index = tracker.source_index.get();
+ c.cycle_detector.append(tracker.*) catch unreachable;
+
+ // Resolve the import by one step
+ var advanced = c.advanceImportTracker(tracker);
+ advanced.tracker.* = advanced.value;
+ const next_tracker = advanced.tracker.*;
+ const status = advanced.status;
+ const potentially_ambiguous_export_star_refs = advanced.import_data;
+ const other_id = advanced.value.source_index.get();
+
+ switch (status) {
+ .cjs, .cjs_without_exports, .disabled, .external => {
+ if (status == .external and c.options.output_format.keepES6ImportExportSyntax()) {
+ // Imports from external modules should not be converted to CommonJS
+ // if the output format preserves the original ES6 import statements
+ break;
+ }
+
+ // If it's a CommonJS or external file, rewrite the import to a
+ // property access. Don't do this if the namespace reference is invalid
+ // though. This is the case for star imports, where the import is the
+ // namespace.
+ const named_import: js_ast.NamedImport = named_imports[prev_source_index].get(prev_import_ref).?;
+
+ if (named_import.namespace_ref != null and named_import.namespace_ref.?.isValid()) {
+ if (result.kind == .normal) {
+ result.kind = .normal_and_namespace;
+ result.namespace_ref = named_import.namespace_ref.?;
+ result.alias = named_import.alias.?;
+ } else {
+ result = .{
+ .kind = .namespace,
+ .namespace_ref = named_import.namespace_ref.?,
+ .alias = named_import.alias.?,
+ };
+ }
+ }
+
+ // Warn about importing from a file that is known to not have any exports
+ if (status == .cjs_without_exports) {
+ const source = c.source_(tracker.source_index.get());
+ c.log.addRangeWarningFmt(
+ source,
+ source.rangeOfIdentifier(named_import.alias_loc.?),
+ c.allocator,
+ "Import \"{s}\" will always be undefined because the file \"{s}\" has no exports",
+ .{
+ named_import.alias.?,
+ source.path.pretty,
+ },
+ ) catch unreachable;
+ }
+ },
+
+ .dynamic_fallback => {
+ // If it's a file with dynamic export fallback, rewrite the import to a property access
+ const named_import: js_ast.NamedImport = named_imports[prev_source_index].get(prev_import_ref).?;
+ if (named_import.namespace_ref != null and named_import.namespace_ref.?.isValid()) {
+ if (result.kind == .normal) {
+ result.kind = .normal_and_namespace;
+ result.namespace_ref = named_import.namespace_ref.?;
+ result.alias = named_import.alias.?;
+ } else {
+ result = .{
+ .kind = .namespace,
+ .namespace_ref = named_import.namespace_ref.?,
+ .alias = named_import.alias.?,
+ };
+ }
+ }
+ },
+ .no_match => {
+ // Report mismatched imports and exports
+ const symbol = c.graph.symbols.get(prev_import_ref).?;
+ const named_import: js_ast.NamedImport = named_imports[prev_source_index].get(prev_import_ref).?;
+ const source = c.source_(prev_source_index);
+
+ const next_source = c.source_(next_tracker.source_index.get());
+ const r = source.rangeOfIdentifier(named_import.alias_loc.?);
+
+ // Report mismatched imports and exports
+ if (symbol.import_item_status == .generated) {
+ // This is a debug message instead of an error because although it
+ // appears to be a named import, it's actually an automatically-
+ // generated named import that was originally a property access on an
+ // import star namespace object. Normally this property access would
+ // just resolve to undefined at run-time instead of failing at binding-
+ // time, so we emit a debug message and rewrite the value to the literal
+ // "undefined" instead of emitting an error.
+ symbol.import_item_status = .missing;
+ c.log.addRangeWarningFmt(
+ source,
+ r,
+ c.allocator,
+ "Import \"{s}\" will always be undefined because there is no matching export in \"{s}\"",
+ .{
+ named_import.alias.?,
+ next_source.path.pretty,
+ },
+ ) catch unreachable;
+ } else {
+ c.log.addRangeErrorFmt(
+ source,
+ r,
+ c.allocator,
+ "No matching export \"{s}\" in \"{s}\" for import \"{s}\"",
+ .{
+ named_import.alias.?,
+ next_source.path.pretty,
+ named_import.alias.?,
+ },
+ ) catch unreachable;
+ }
+ },
+ .probably_typescript_type => {
+ // Omit this import from any namespace export code we generate for
+ // import star statements (i.e. "import * as ns from 'path'")
+ result = .{ .kind = .probably_typescript_type };
+ },
+ .found => {
+
+ // If there are multiple ambiguous results due to use of "export * from"
+ // statements, trace them all to see if they point to different things.
+ for (potentially_ambiguous_export_star_refs) |*ambiguous_tracker| {
+ // If this is a re-export of another import, follow the import
+ if (named_imports[ambiguous_tracker.data.source_index.get()].contains(ambiguous_tracker.data.import_ref)) {
+ c.cycle_detector.clearRetainingCapacity();
+ c.swap_cycle_detector.clearRetainingCapacity();
+
+ var old_cycle_detector = c.cycle_detector;
+ c.cycle_detector = c.swap_cycle_detector;
+ var ambig = c.matchImportWithExport(&ambiguous_tracker.data, re_exports);
+ c.cycle_detector.clearRetainingCapacity();
+ c.swap_cycle_detector = c.cycle_detector;
+ c.cycle_detector = old_cycle_detector;
+ ambiguous_results.append(ambig) catch unreachable;
+ } else {
+ ambiguous_results.append(.{
+ .kind = .normal,
+ .source_index = ambiguous_tracker.data.source_index.get(),
+ .ref = ambiguous_tracker.data.import_ref,
+ .name_loc = ambiguous_tracker.data.name_loc,
+ }) catch unreachable;
+ }
+ }
+
+ // Defer the actual binding of this import until after we generate
+ // namespace export code for all files. This has to be done for all
+ // import-to-export matches, not just the initial import to the final
+ // export, since all imports and re-exports must be merged together
+ // for correctness.
+ result = .{
+ .kind = .normal,
+ .source_index = next_tracker.source_index.get(),
+ .ref = next_tracker.import_ref,
+ .name_loc = next_tracker.name_loc,
+ };
+
+ // Depend on the statement(s) that declared this import symbol in the
+ // original file
+ {
+ var deps = c.topLevelSymbolsToParts(other_id, tracker.import_ref);
+ re_exports.ensureUnusedCapacity(deps.len) catch unreachable;
+ for (deps) |dep| {
+ re_exports.appendAssumeCapacity(
+ .{
+ .part_index = dep,
+ .source_index = tracker.source_index,
+ },
+ );
+ }
+ }
+
+ // If this is a re-export of another import, continue for another
+ // iteration of the loop to resolve that import as well
+ const next_id = next_tracker.source_index.get();
+ if (named_imports[next_id].contains(next_tracker.import_ref)) {
+ tracker.* = next_tracker;
+ continue :loop;
+ }
+ },
+ }
+
+ break :loop;
+ }
+
+ // If there is a potential ambiguity, all results must be the same
+ for (ambiguous_results.items) |ambig| {
+ if (!std.meta.eql(ambig, result)) {
+ if (result.kind == ambig.kind and
+ ambig.kind == .normal and
+ ambig.name_loc.start != 0 and
+ result.name_loc.start != 0)
+ {
+ return .{
+ .kind = .ambiguous,
+ .source_index = result.source_index,
+ .name_loc = result.name_loc,
+ .other_source_index = ambig.source_index,
+ .other_name_loc = ambig.name_loc,
+ };
+ }
+
+ return .{ .kind = .ambiguous };
+ }
+ }
+
+ return result;
+ }
+
+ pub fn topLevelSymbolsToParts(c: *LinkerContext, id: u32, ref: Ref) []u32 {
+ return c.graph.topLevelSymbolToParts(id, ref);
+ }
+
+ pub fn topLevelSymbolsToPartsForRuntime(c: *LinkerContext, ref: Ref) []u32 {
+ return topLevelSymbolsToParts(c, Index.runtime.get(), ref);
+ }
+
+ pub fn createWrapperForFile(
+ c: *LinkerContext,
+ wrap: WrapKind,
+ wrapper_ref: Ref,
+ wrapper_part_index: *Index,
+ source_index: Index.Int,
+ ) void {
+ switch (wrap) {
+ // If this is a CommonJS file, we're going to need to generate a wrapper
+ // for the CommonJS closure. That will end up looking something like this:
+ //
+ // var require_foo = __commonJS((exports, module) => {
+ // ...
+ // });
+ //
+ // However, that generation is special-cased for various reasons and is
+ // done later on. Still, we're going to need to ensure that this file
+ // both depends on the "__commonJS" symbol and declares the "require_foo"
+ // symbol. Instead of special-casing this during the reachablity analysis
+ // below, we just append a dummy part to the end of the file with these
+ // dependencies and let the general-purpose reachablity analysis take care
+ // of it.
+ .cjs => {
+ const common_js_parts = c.topLevelSymbolsToPartsForRuntime(c.cjs_runtime_ref);
+
+ var total_dependencies_count = common_js_parts.len;
+ var runtime_parts = c.graph.ast.items(.parts)[Index.runtime.get()].slice();
+
+ for (common_js_parts) |part_id| {
+ var part: *js_ast.Part = &runtime_parts[part_id];
+ var symbol_refs = part.symbol_uses.keys();
+ for (symbol_refs) |ref| {
+ if (ref.eql(c.cjs_runtime_ref)) continue;
+ total_dependencies_count += c.topLevelSymbolsToPartsForRuntime(ref).len;
+ }
+ }
+
+ // generate a dummy part that depends on the "__commonJS" symbol
+ var dependencies = c.allocator.alloc(js_ast.Dependency, common_js_parts.len) catch unreachable;
+ for (common_js_parts, dependencies) |part, *cjs| {
+ cjs.* = .{
+ .part_index = part,
+ .source_index = Index.runtime,
+ };
+ }
+ const part_index = c.graph.addPartToFile(
+ source_index,
+ .{
+ .stmts = &.{},
+ .symbol_uses = bun.from(
+ js_ast.Part.SymbolUseMap,
+ c.allocator,
+ .{
+ .{ wrapper_ref, .{ .count_estimate = 1 } },
+ },
+ ) catch unreachable,
+ .declared_symbols = js_ast.DeclaredSymbol.List.fromSlice(
+ c.allocator,
+ &[_]js_ast.DeclaredSymbol{
+ .{ .ref = c.graph.ast.items(.exports_ref)[source_index], .is_top_level = true },
+ .{ .ref = c.graph.ast.items(.module_ref)[source_index].?, .is_top_level = true },
+ .{ .ref = c.graph.ast.items(.wrapper_ref)[source_index].?, .is_top_level = true },
+ },
+ ) catch unreachable,
+ .dependencies = Dependency.List.init(dependencies),
+ },
+ ) catch unreachable;
+ std.debug.assert(part_index != js_ast.namespace_export_part_index);
+ wrapper_part_index.* = Index.part(part_index);
+ c.graph.generateSymbolImportAndUse(
+ source_index,
+ part_index,
+ c.cjs_runtime_ref,
+ 1,
+ Index.runtime,
+ ) catch unreachable;
+ },
+
+ .esm => {
+ // If this is a lazily-initialized ESM file, we're going to need to
+ // generate a wrapper for the ESM closure. That will end up looking
+ // something like this:
+ //
+ // var init_foo = __esm(() => {
+ // ...
+ // });
+ //
+ // This depends on the "__esm" symbol and declares the "init_foo" symbol
+ // for similar reasons to the CommonJS closure above.
+ const esm_parts = c.topLevelSymbolsToPartsForRuntime(c.esm_runtime_ref);
+
+ // generate a dummy part that depends on the "__esm" symbol
+ var dependencies = c.allocator.alloc(js_ast.Dependency, esm_parts.len) catch unreachable;
+ for (esm_parts, dependencies) |part, *esm| {
+ esm.* = .{
+ .part_index = part,
+ .source_index = Index.runtime,
+ };
+ }
+
+ const part_index = c.graph.addPartToFile(
+ source_index,
+ .{
+ .symbol_uses = bun.from(
+ js_ast.Part.SymbolUseMap,
+ c.allocator,
+ .{
+ .{ wrapper_ref, .{ .count_estimate = 1 } },
+ },
+ ) catch unreachable,
+ .declared_symbols = js_ast.DeclaredSymbol.List.fromSlice(c.allocator, &[_]js_ast.DeclaredSymbol{
+ .{ .ref = wrapper_ref, .is_top_level = true },
+ }) catch unreachable,
+ .dependencies = Dependency.List.init(dependencies),
+ },
+ ) catch unreachable;
+ std.debug.assert(part_index != js_ast.namespace_export_part_index);
+ wrapper_part_index.* = Index.part(part_index);
+ c.graph.generateSymbolImportAndUse(
+ source_index,
+ part_index,
+ c.esm_runtime_ref,
+ 1,
+ Index.runtime,
+ ) catch unreachable;
+ },
+ else => {},
+ }
+ }
+
+ pub fn advanceImportTracker(c: *LinkerContext, tracker: *ImportTracker) ImportTracker.Iterator {
+ const id = tracker.source_index.get();
+ var named_imports: *JSAst.NamedImports = &c.graph.ast.items(.named_imports)[id];
+ var import_records = c.graph.ast.items(.import_records)[id];
+ const exports_kind: []js_ast.ExportsKind = c.graph.ast.items(.exports_kind);
+
+ const named_import: js_ast.NamedImport = named_imports.get(tracker.import_ref) orelse
+ // TODO: investigate if this is a bug
+ // It implies there are imports being added without being resolved
+ return .{
+ .value = .{},
+ .status = .external,
+ .tracker = tracker,
+ };
+
+ // Is this an external file?
+ const record: *const ImportRecord = import_records.at(named_import.import_record_index);
+ if (!record.source_index.isValid()) {
+ return .{
+ .value = .{},
+ .status = .external,
+ .tracker = tracker,
+ };
+ }
+
+ // Is this a disabled file?
+ const other_source_index = record.source_index.get();
+ const other_id = other_source_index;
+
+ if (other_id > c.graph.ast.len or c.parse_graph.input_files.items(.source)[other_source_index].key_path.is_disabled) {
+ return .{
+ .value = .{
+ .source_index = record.source_index,
+ },
+ .status = .disabled,
+ .tracker = tracker,
+ };
+ }
+
+ // Is this a named import of a file without any exports?
+ if (!named_import.alias_is_star and
+ // TODO hasLazyExport
+
+ // CommonJS exports
+ c.graph.ast.items(.export_keyword)[other_id].len == 0 and !strings.eqlComptime(named_import.alias orelse "", "default") and
+ // ESM exports
+ !c.graph.ast.items(.uses_exports_ref)[other_id] and !c.graph.ast.items(.uses_module_ref)[other_id])
+ {
+ // Just warn about it and replace the import with "undefined"
+ return .{
+ .value = .{
+ .source_index = Index.source(other_source_index),
+ .import_ref = Ref.None,
+ },
+ .status = .cjs_without_exports,
+ .tracker = tracker,
+ };
+ }
+ const other_kind = exports_kind[other_id];
+ // Is this a CommonJS file?
+ if (other_kind == .cjs) {
+ return .{
+ .value = .{
+ .source_index = Index.source(other_source_index),
+ .import_ref = Ref.None,
+ },
+ .status = .cjs,
+ .tracker = tracker,
+ };
+ }
+
+ // Match this import star with an export star from the imported file
+ if (named_import.alias_is_star) {
+ const matching_export = c.graph.meta.items(.resolved_export_star)[other_id];
+ if (matching_export.data.import_ref.isValid()) {
+ // Check to see if this is a re-export of another import
+ return .{
+ .value = matching_export.data,
+ .status = .found,
+ .import_data = matching_export.potentially_ambiguous_export_star_refs.slice(),
+ .tracker = tracker,
+ };
+ }
+ }
+
+ // Match this import up with an export from the imported file
+ if (c.graph.meta.items(.resolved_exports)[other_id].get(named_import.alias.?)) |matching_export| {
+ // Check to see if this is a re-export of another import
+ return .{
+ .value = .{
+ .source_index = matching_export.data.source_index,
+ .import_ref = matching_export.data.import_ref,
+ .name_loc = matching_export.data.name_loc,
+ },
+ .status = .found,
+ .import_data = matching_export.potentially_ambiguous_export_star_refs.slice(),
+ .tracker = tracker,
+ };
+ }
+
+ // Is this a file with dynamic exports?
+ if (other_kind == .esm_with_dynamic_fallback) {
+ return .{
+ .value = .{
+ .source_index = Index.source(other_source_index),
+ .import_ref = c.graph.ast.items(.exports_ref)[other_id],
+ },
+ .status = .dynamic_fallback,
+ .tracker = tracker,
+ };
+ }
+
+ // Missing re-exports in TypeScript files are indistinguishable from types
+ if (named_import.is_exported and c.parse_graph.input_files.items(.loader)[other_source_index].isTypeScript()) {
+ return .{
+ .value = .{},
+ .status = .probably_typescript_type,
+ .tracker = tracker,
+ };
+ }
+
+ return .{
+ .value = .{
+ .source_index = Index.source(other_source_index),
+ },
+ .status = .no_match,
+ .tracker = tracker,
+ };
+ }
+
+ pub fn matchImportsWithExportsForFile(
+ c: *LinkerContext,
+ named_imports_ptr: *JSAst.NamedImports,
+ imports_to_bind: *RefImportData,
+ source_index: Index.Int,
+ ) void {
+ var named_imports = named_imports_ptr.cloneWithAllocator(c.allocator) catch unreachable;
+ defer named_imports_ptr.* = named_imports;
+
+ const Sorter = struct {
+ imports: *JSAst.NamedImports,
+
+ pub fn lessThan(self: @This(), a_index: usize, b_index: usize) bool {
+ const a_ref = self.imports.keys()[a_index];
+ const b_ref = self.imports.keys()[b_index];
+
+ return std.math.order(a_ref.innerIndex(), b_ref.innerIndex()) == .lt;
+ }
+ };
+ var sorter = Sorter{
+ .imports = &named_imports,
+ };
+ named_imports.sort(sorter);
+
+ for (named_imports.keys(), named_imports.values()) |ref, named_import| {
+ // Re-use memory for the cycle detector
+ c.cycle_detector.clearRetainingCapacity();
+
+ const import_ref = ref;
+
+ var import_tracker = ImportData{
+ .data = .{
+ .source_index = Index.source(source_index),
+ .import_ref = import_ref,
+ },
+ };
+ var re_exports = std.ArrayList(js_ast.Dependency).init(c.allocator);
+ var result = c.matchImportWithExport(
+ &import_tracker.data,
+ &re_exports,
+ );
+
+ switch (result.kind) {
+ .normal => {
+ imports_to_bind.put(
+ c.allocator,
+ import_ref,
+ .{
+ .re_exports = bun.BabyList(js_ast.Dependency).init(re_exports.items),
+ .data = .{
+ .source_index = Index.source(result.source_index),
+ .import_ref = result.ref,
+ },
+ },
+ ) catch unreachable;
+ },
+ .namespace => {
+ c.graph.symbols.get(import_ref).?.namespace_alias = js_ast.G.NamespaceAlias{
+ .namespace_ref = result.namespace_ref,
+ .alias = result.alias,
+ };
+ },
+ .normal_and_namespace => {
+ imports_to_bind.put(
+ c.allocator,
+ import_ref,
+ .{
+ .re_exports = bun.BabyList(js_ast.Dependency).init(re_exports.items),
+ .data = .{
+ .source_index = Index.source(result.source_index),
+ .import_ref = result.ref,
+ },
+ },
+ ) catch unreachable;
+
+ c.graph.symbols.get(import_ref).?.namespace_alias = js_ast.G.NamespaceAlias{
+ .namespace_ref = result.namespace_ref,
+ .alias = result.alias,
+ };
+ },
+ .cycle => {
+ const source = &c.parse_graph.input_files.items(.source)[source_index];
+ const r = lex.rangeOfIdentifier(source, named_import.alias_loc orelse Logger.Loc{});
+ c.log.addRangeErrorFmt(
+ source,
+ r,
+ c.allocator,
+ "Detected cycle while resolving import {s}",
+ .{
+ named_import.alias.?,
+ },
+ ) catch unreachable;
+ },
+ .probably_typescript_type => {
+ c.graph.meta.items(.probably_typescript_type)[source_index].put(
+ c.allocator,
+ import_ref,
+ void{},
+ ) catch unreachable;
+ },
+ .ambiguous => {
+ const source = &c.parse_graph.input_files.items(.source)[source_index];
+
+ const r = lex.rangeOfIdentifier(source, named_import.alias_loc orelse Logger.Loc{});
+
+ // if (result.name_loc.start != 0)
+ // TODO: better error
+ c.log.addRangeErrorFmt(
+ source,
+ r,
+ c.allocator,
+ "Ambiguous import: {s}",
+ .{
+ named_import.alias.?,
+ },
+ ) catch unreachable;
+ },
+ .ignore => {},
+ }
+ }
+ }
+
+ const ExportStarContext = struct {
+ import_records_list: []const ImportRecord.List,
+ source_index_stack: std.ArrayList(Index.Int),
+ exports_kind: []js_ast.ExportsKind,
+ named_exports: []js_ast.Ast.NamedExports,
+ resolved_exports: []ResolvedExports,
+ imports_to_bind: []RefImportData,
+ export_star_records: []const []const Index.Int,
+ allocator: std.mem.Allocator,
+
+ pub fn addExports(
+ this: *ExportStarContext,
+ resolved_exports: *ResolvedExports,
+ source_index: Index.Int,
+ ) void {
+ // Avoid infinite loops due to cycles in the export star graph
+ for (this.source_index_stack.items) |i| {
+ if (i == source_index)
+ return;
+ }
+
+ this.source_index_stack.append(source_index) catch unreachable;
+ const stack_end_pos = this.source_index_stack.items.len;
+ const id = source_index;
+
+ const import_records = this.import_records_list[id].slice();
+
+ for (this.export_star_records[id]) |import_id| {
+ const other_source_index = import_records[import_id].source_index.get();
+
+ const other_id = other_source_index;
+ if (other_id >= this.named_exports.len)
+ // this AST was empty or it wasn't a JS AST
+ continue;
+
+ // Export stars from a CommonJS module don't work because they can't be
+ // statically discovered. Just silently ignore them in this case.
+ //
+ // We could attempt to check whether the imported file still has ES6
+ // exports even though it still uses CommonJS features. However, when
+ // doing this we'd also have to rewrite any imports of these export star
+ // re-exports as property accesses off of a generated require() call.
+ if (this.exports_kind[other_id] == .cjs)
+ continue;
+ var iter = this.named_exports[other_id].iterator();
+ next_export: while (iter.next()) |entry| {
+ const alias = entry.key_ptr.*;
+
+ // ES6 export star statements ignore exports named "default"
+ if (strings.eqlComptime(alias, "default"))
+ continue;
+
+ // This export star is shadowed if any file in the stack has a matching real named export
+ for (this.source_index_stack.items[stack_end_pos..]) |prev| {
+ if (this.named_exports[prev].contains(alias)) {
+ continue :next_export;
+ }
+ }
+ const ref = entry.value_ptr.ref;
+ var resolved = resolved_exports.getOrPut(this.allocator, entry.key_ptr.*) catch unreachable;
+ if (!resolved.found_existing) {
+ resolved.value_ptr.* = .{
+ .data = .{
+ .import_ref = ref,
+ .source_index = Index.source(other_source_index),
+ .name_loc = entry.value_ptr.alias_loc,
+ },
+ };
+
+ // Make sure the symbol is marked as imported so that code splitting
+ // imports it correctly if it ends up being shared with another chunk
+ this.imports_to_bind[id].put(this.allocator, entry.value_ptr.ref, .{
+ .data = .{
+ .import_ref = ref,
+ .source_index = Index.source(other_source_index),
+ },
+ }) catch unreachable;
+ } else if (resolved.value_ptr.data.source_index.get() != other_source_index) {
+ // Two different re-exports colliding makes it potentially ambiguous
+ resolved.value_ptr.potentially_ambiguous_export_star_refs.push(this.allocator, .{
+ .data = .{
+ .source_index = Index.source(other_source_index),
+ .import_ref = ref,
+ .name_loc = entry.value_ptr.alias_loc,
+ },
+ }) catch unreachable;
+ }
+ }
+
+ // Search further through this file's export stars
+ this.addExports(resolved_exports, other_source_index);
+ }
+ }
+ };
+
+ pub fn breakOutputIntoPieces(
+ c: *LinkerContext,
+ allocator: std.mem.Allocator,
+ j: *bun.Joiner,
+ has_any_cross_chunk_code: bool,
+ count: u32,
+ ) !Chunk.IntermediateOutput {
+ // Optimization: If there can be no substitutions, just reuse the initial
+ // joiner that was used when generating the intermediate chunk output
+ // instead of creating another one and copying the whole file into it.
+ if (!has_any_cross_chunk_code) {
+ return Chunk.IntermediateOutput{
+ .joiner = j.*,
+ };
+ }
+
+ var pieces = try std.ArrayList(Chunk.OutputPiece).initCapacity(allocator, count);
+ const complete_output = try j.done(allocator);
+ var output = complete_output;
+
+ const prefix = c.unique_key_prefix;
+
+ while (true) {
+ const invalid_boundary = std.math.maxInt(usize);
+ // Scan for the next piece boundary
+ var boundary = strings.indexOf(output, prefix) orelse invalid_boundary;
+
+ var output_piece_index = Chunk.OutputPieceIndex{};
+ var index: usize = 0;
+
+ // Try to parse the piece boundary
+ if (boundary != invalid_boundary) {
+ const start = boundary + prefix.len;
+ if (start + 9 > output.len) {
+ // Not enough bytes to parse the piece index
+ boundary = invalid_boundary;
+ } else {
+ switch (output[start]) {
+ 'A' => {
+ output_piece_index.kind = .asset;
+ },
+ 'C' => {
+ output_piece_index.kind = .chunk;
+ },
+ else => {},
+ }
+
+ for (output[start..][1..9].*) |char| {
+ if (char < '0' or char > '9') {
+ boundary = invalid_boundary;
+ break;
+ }
+
+ index = (index * 10) + (@as(usize, char) - '0');
+ }
+ }
+ }
+
+ // Validate the boundary
+ switch (output_piece_index.kind) {
+ .asset => {
+ if (index >= c.graph.files.len) {
+ boundary = invalid_boundary;
+ }
+ },
+ .chunk => {
+ if (index >= count) {
+ boundary = invalid_boundary;
+ }
+ },
+ else => {
+ boundary = invalid_boundary;
+ },
+ }
+
+ output_piece_index.index = @intCast(u30, index);
+
+ // If we're at the end, generate one final piece
+ if (boundary == invalid_boundary) {
+ try pieces.append(Chunk.OutputPiece{
+ .index = output_piece_index,
+ .data_ptr = output.ptr,
+ .data_len = @truncate(u32, output.len),
+ });
+ break;
+ }
+
+ // Otherwise, generate an interior piece and continue
+ try pieces.append(Chunk.OutputPiece{
+ .index = output_piece_index,
+ .data_ptr = output.ptr,
+
+ // sliced this way to panic if out of bounds
+ .data_len = @truncate(u32, output[0..boundary].len),
+ });
+ output = output[boundary + prefix.len + 9 ..];
+ }
+
+ return Chunk.IntermediateOutput{
+ .pieces = bun.BabyList(Chunk.OutputPiece).init(pieces.items),
+ };
+ }
+
+ const DependencyWrapper = struct {
+ linker: *LinkerContext,
+ flags: []JSMeta.Flags,
+ exports_kind: []js_ast.ExportsKind,
+ import_records: []ImportRecord.List,
+ export_star_map: std.AutoHashMap(Index.Int, void),
+ entry_point_kinds: []EntryPoint.Kind,
+ export_star_records: [][]u32,
+ output_format: options.OutputFormat,
+
+ pub fn hasDynamicExportsDueToExportStar(this: *DependencyWrapper, source_index: Index.Int) bool {
+ // Terminate the traversal now if this file already has dynamic exports
+ const export_kind = this.exports_kind[source_index];
+ switch (export_kind) {
+ .cjs, .esm_with_dynamic_fallback => return true,
+ else => {},
+ }
+
+ // Avoid infinite loops due to cycles in the export star graph
+ const has_visited = this.export_star_map.getOrPut(source_index) catch unreachable;
+ if (has_visited.found_existing) {
+ return false;
+ }
+
+ for (this.export_star_records[source_index]) |id| {
+ const records: []const ImportRecord = this.import_records[id].slice();
+ for (records) |record| {
+ // This file has dynamic exports if the exported imports are from a file
+ // that either has dynamic exports directly or transitively by itself
+ // having an export star from a file with dynamic exports.
+ const kind = this.entry_point_kinds[record.source_index.get()];
+ if ((record.source_index.get() >= this.import_records.len and (!kind.isEntryPoint() or !this.output_format.keepES6ImportExportSyntax())) or
+ (record.source_index.get() < this.import_records.len and record.source_index.get() != source_index and this.hasDynamicExportsDueToExportStar(record.source_index.get())))
+ {
+ this.exports_kind[source_index] = .esm_with_dynamic_fallback;
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ pub fn wrap(this: *DependencyWrapper, source_index: Index.Int) void {
+
+ // Never wrap the runtime file since it always comes first
+ if (source_index == Index.runtime.get()) {
+ return;
+ }
+
+ this.flags[source_index] = brk: {
+ var flags = this.flags[source_index];
+
+ if (flags.did_wrap_dependencies) return;
+ flags.did_wrap_dependencies = true;
+
+ // This module must be wrapped
+ if (flags.wrap == .none) {
+ flags.wrap = switch (this.exports_kind[source_index]) {
+ .cjs => .cjs,
+ else => .esm,
+ };
+ }
+ break :brk flags;
+ };
+
+ const records = this.import_records[source_index].slice();
+ for (records) |record| {
+ if (!record.source_index.isValid()) {
+ continue;
+ }
+ this.wrap(record.source_index.get());
+ }
+ }
+ };
+};
+
+pub const PartRange = struct {
+ source_index: Index = Index.invalid,
+ part_index_begin: u32 = 0,
+ part_index_end: u32 = 0,
+};
+
+const StableRef = packed struct {
+ stable_source_index: Index.Int,
+ ref: Ref,
+
+ pub fn isLessThan(_: void, a: StableRef, b: StableRef) bool {
+ return a.stable_source_index < b.stable_source_index or
+ (a.stable_source_index == b.stable_source_index and a.ref.innerIndex() < b.ref.innerIndex());
+ }
+};
+
+pub const ImportTracker = struct {
+ source_index: Index = Index.invalid,
+ name_loc: Logger.Loc = Logger.Loc.Empty,
+ import_ref: Ref = Ref.None,
+
+ pub const Status = enum {
+ /// The imported file has no matching export
+ no_match,
+
+ /// The imported file has a matching export
+ found,
+
+ /// The imported file is CommonJS and has unknown exports
+ cjs,
+
+ /// The import is missing but there is a dynamic fallback object
+ dynamic_fallback,
+
+ /// The import was treated as a CommonJS import but the file is known to have no exports
+ cjs_without_exports,
+
+ /// The imported file was disabled by mapping it to false in the "browser"
+ /// field of package.json
+ disabled,
+
+ /// The imported file is external and has unknown exports
+ external,
+
+ /// This is a missing re-export in a TypeScript file, so it's probably a type
+ probably_typescript_type,
+ };
+
+ pub const Iterator = struct {
+ status: Status = Status.no_match,
+ value: ImportTracker = .{},
+ import_data: []ImportData = &.{},
+ tracker: *ImportTracker,
+ };
+};
+
+const PathTemplate = options.PathTemplate;
+
+pub const Chunk = struct {
+ /// This is a random string and is used to represent the output path of this
+ /// chunk before the final output path has been computed.
+ unique_key: string = "",
+
+ files_with_parts_in_chunk: std.AutoArrayHashMapUnmanaged(Index.Int, void) = .{},
+
+ /// We must not keep pointers to this type until all chunks have been allocated.
+ entry_bits: AutoBitSet = undefined,
+
+ final_rel_path: string = "",
+ template: PathTemplate = .{},
+
+ /// For code splitting
+ cross_chunk_imports: BabyList(ChunkImport) = .{},
+
+ content: Content,
+
+ entry_point: Chunk.EntryPoint = .{},
+
+ is_executable: bool = false,
+
+ intermediate_output: IntermediateOutput = .{ .empty = {} },
+ isolated_hash: u64 = std.math.maxInt(u64),
+
+ pub inline fn isEntryPoint(this: *const Chunk) bool {
+ return this.entry_point.is_entry_point;
+ }
+
+ pub inline fn entryBits(this: *const Chunk) *const AutoBitSet {
+ return &this.entry_bits;
+ }
+
+ pub const Order = struct {
+ source_index: Index.Int = 0,
+ distance: u32 = 0,
+ tie_breaker: u32 = 0,
+
+ pub fn lessThan(_: @This(), a: Order, b: Order) bool {
+ if (a.distance < b.distance) return true;
+
+ return a.tie_breaker < b.tie_breaker;
+ }
+
+ /// Sort so files closest to an entry point come first. If two files are
+ /// equidistant to an entry point, then break the tie by sorting on the
+ /// stable source index derived from the DFS over all entry points.
+ pub fn sort(a: []Order) void {
+ std.sort.sort(Order, a, Order{}, lessThan);
+ }
+ };
+
+ /// TODO: rewrite this
+ /// This implementation is just slow.
+ /// Can we make the JSPrinter itself track this without increasing
+ /// complexity a lot?
+ pub const IntermediateOutput = union(enum) {
+ /// If the chunk has references to other chunks, then "pieces" contains the
+ /// contents of the chunk. Another joiner
+ /// will have to be constructed later when merging the pieces together.
+ pieces: bun.BabyList(OutputPiece),
+
+ /// If the chunk doesn't have any references to other chunks, then
+ /// `joiner` contains the contents of the chunk. This is more efficient
+ /// because it avoids doing a join operation twice.
+ joiner: bun.Joiner,
+
+ empty: void,
+
+ pub fn code(this: IntermediateOutput, allocator: std.mem.Allocator, chunk: *Chunk, chunks: []Chunk) ![]const u8 {
+ switch (this) {
+ .pieces => |*pieces| {
+ var count: usize = 0;
+ var file_path_buf: [4096]u8 = undefined;
+ _ = file_path_buf;
+ var from_chunk_dir = std.fs.path.dirname(chunk.final_rel_path) orelse "";
+ if (strings.eqlComptime(from_chunk_dir, "."))
+ from_chunk_dir = "";
+
+ for (pieces.slice()) |piece| {
+ count += piece.data_len;
+ if (piece.index.kind != .none) {
+ const file_path = chunks[piece.index.index].final_rel_path;
+ count += if (from_chunk_dir.len == 0) file_path.len else bun.path.relative(from_chunk_dir, file_path).len;
+ }
+ }
+
+ var total_buf = try allocator.alloc(u8, count);
+ var remain = total_buf;
+
+ for (pieces.slice()) |piece| {
+ const data = piece.data();
+
+ if (data.len > 0)
+ @memcpy(remain.ptr, data.ptr, data.len);
+
+ remain = remain[data.len..];
+ const index = piece.index.index;
+
+ if (piece.index.kind != .none) {
+ const file_path = chunks[index].final_rel_path;
+ const relative_path = if (from_chunk_dir.len > 0)
+ bun.path.relative(from_chunk_dir, file_path)
+ else
+ file_path;
+
+ if (relative_path.len > 0)
+ @memcpy(remain.ptr, relative_path.ptr, relative_path.len);
+
+ remain = remain[relative_path.len..];
+ }
+ }
+
+ std.debug.assert(remain.len == 0);
+ std.debug.assert(total_buf.len == count);
+
+ return total_buf;
+ },
+ .joiner => |joiner_| {
+ // TODO: make this safe
+ var joiny = joiner_;
+ return joiny.done(allocator);
+ },
+ .empty => return "",
+ }
+ }
+ };
+
+ pub const OutputPiece = struct {
+ // layed out like this so it takes up the same amount of space as a []const u8
+ data_ptr: [*]const u8 = undefined,
+ data_len: u32 = 0,
+
+ index: OutputPieceIndex = .{},
+
+ pub inline fn data(this: OutputPiece) []const u8 {
+ return this.data_ptr[0..this.data_len];
+ }
+ };
+
+ pub const OutputPieceIndex = packed struct {
+ index: u30 = 0,
+
+ kind: Kind = Kind.none,
+
+ pub const Kind = enum(u2) {
+ /// The "kind" may be "none" in which case there is one piece
+ /// with data and no chunk index. For example, the chunk may not contain any
+ /// imports.
+ none,
+
+ asset,
+ chunk,
+ };
+ };
+
+ pub const EntryPoint = packed struct(u64) {
+ source_index: Index.Int = 0,
+ entry_point_id: ID = 0,
+ is_entry_point: bool = false,
+
+ // so it fits in a 64-bit integer
+ pub const ID = u31;
+ };
+
+ pub const JavaScriptChunk = struct {
+ files_in_chunk_order: []const Index.Int = &.{},
+ parts_in_chunk_in_order: []const PartRange = &.{},
+
+ // for code splitting
+ exports_to_other_chunks: std.ArrayHashMapUnmanaged(Ref, string, Ref.ArrayHashCtx, false) = .{},
+ imports_from_other_chunks: ImportsFromOtherChunks = .{},
+ cross_chunk_prefix_stmts: BabyList(Stmt) = .{},
+ cross_chunk_suffix_stmts: BabyList(Stmt) = .{},
+ };
+
+ pub const ImportsFromOtherChunks = std.AutoArrayHashMapUnmanaged(Index.Int, CrossChunkImport.Item.List);
+
+ pub const Content = union(enum) {
+ javascript: JavaScriptChunk,
+ };
+};
+
+pub const ChunkImport = struct {
+ chunk_index: u32,
+ import_kind: ImportKind,
+};
+
+pub const CrossChunkImport = struct {
+ chunk_index: Index.Int = 0,
+ sorted_import_items: CrossChunkImport.Item.List = undefined,
+
+ pub const Item = struct {
+ export_alias: string = "",
+ ref: Ref = Ref.None,
+
+ pub const List = bun.BabyList(Item);
+
+ pub fn lessThan(_: void, a: CrossChunkImport.Item, b: CrossChunkImport.Item) bool {
+ return strings.order(a.export_alias, b.export_alias) == .lt;
+ }
+ };
+
+ pub fn lessThan(_: void, a: CrossChunkImport, b: CrossChunkImport) bool {
+ return std.math.order(a.chunk_index, b.chunk_index) == .lt;
+ }
+
+ pub const List = std.ArrayList(CrossChunkImport);
+
+ pub fn sortedCrossChunkImports(
+ list: *List,
+ chunks: []Chunk,
+ imports_from_other_chunks: *Chunk.ImportsFromOtherChunks,
+ ) !void {
+ var result = list.*;
+ defer {
+ list.* = result;
+ }
+
+ try result.ensureTotalCapacity(imports_from_other_chunks.count());
+
+ var import_items_list = imports_from_other_chunks.values();
+ var chunk_indices = imports_from_other_chunks.keys();
+ for (chunk_indices, import_items_list) |chunk_index, import_items| {
+ var chunk = &chunks[chunk_index];
+
+ // Sort imports from a single chunk by alias for determinism
+ const exports_to_other_chunks = &chunk.content.javascript.exports_to_other_chunks;
+ // TODO: do we need to clone this array?
+ for (import_items.slice()) |*item| {
+ item.export_alias = exports_to_other_chunks.get(item.ref).?;
+ std.debug.assert(item.export_alias.len > 0);
+ }
+ std.sort.sort(CrossChunkImport.Item, import_items.slice(), void{}, CrossChunkImport.Item.lessThan);
+
+ result.append(CrossChunkImport{
+ .chunk_index = chunk_index,
+ .sorted_import_items = import_items,
+ }) catch unreachable;
+ }
+
+ std.sort.sort(CrossChunkImport, result.items, void{}, CrossChunkImport.lessThan);
+ }
+};
+
+const CompileResult = union(enum) {
+ javascript: struct {
+ source_index: Index.Int,
+ result: js_printer.PrintResult,
+ },
+
+ pub const empty = CompileResult{
+ .javascript = .{
+ .source_index = 0,
+ .result = js_printer.PrintResult{
+ .result = .{
+ .code = "",
+ },
+ },
+ },
+ };
+
+ pub fn code(this: *const CompileResult) []const u8 {
+ return switch (this.*) {
+ .javascript => |r| switch (r.result) {
+ .result => |r2| r2.code,
+ else => "",
+ },
+ // else => "",
+ };
+ }
+
+ pub fn sourceIndex(this: *const CompileResult) Index.Int {
+ return switch (this.*) {
+ .javascript => |r| r.source_index,
+ // else => 0,
+ };
+ }
+};
+
+const ContentHasher = struct {
+ hasher: std.hash.XxHash64 = std.hash.XxHash64.init(0),
+
+ pub fn write(self: *ContentHasher, bytes: []const u8) void {
+ self.hasher.update(std.mem.asBytes(&bytes.len));
+ self.hasher.update(bytes);
+ }
+
+ pub fn writeInts(self: *ContentHasher, i: []const u32) void {
+ // TODO: BigEndian
+ self.hasher.update(std.mem.sliceAsBytes(i));
+ }
+
+ pub fn digest(self: *ContentHasher) u64 {
+ return self.hasher.final();
+ }
+};
diff --git a/src/bundler/generate_node_modules_bundle.zig b/src/bundler/generate_node_modules_bundle.zig
index 69216ae72..25cfe912d 100644
--- a/src/bundler/generate_node_modules_bundle.zig
+++ b/src/bundler/generate_node_modules_bundle.zig
@@ -184,9 +184,7 @@ pub const ThreadPool = struct {
pub fn run(this: *Worker) void {
Output.Source.configureThread();
this.thread_id = std.Thread.getCurrentId();
- if (Environment.isDebug) {
- Output.prettyln("Thread started.\n", .{});
- }
+
js_ast.Expr.Data.Store.create(this.generator.allocator);
js_ast.Stmt.Data.Store.create(this.generator.allocator);
this.data = this.generator.allocator.create(WorkerData) catch unreachable;
@@ -1310,7 +1308,7 @@ pub fn processFile(this: *GenerateNodeModuleBundle, worker: *ThreadPool.Worker,
opts.transform_require_to_import = false;
opts.features.dynamic_require = bundler.options.platform.isBun();
- opts.enable_bundling = true;
+ opts.enable_legacy_bundling = true;
opts.warn_about_unbundled_modules = false;
opts.macro_context = &worker.data.macro_context;
opts.features.auto_import_jsx = jsx.parse;
@@ -1358,7 +1356,7 @@ pub fn processFile(this: *GenerateNodeModuleBundle, worker: *ThreadPool.Worker,
}
var path = _resolved_import.path() orelse {
import_record.path.is_disabled = true;
- import_record.is_bundled = true;
+
continue;
};
@@ -1366,7 +1364,7 @@ pub fn processFile(this: *GenerateNodeModuleBundle, worker: *ThreadPool.Worker,
if (!loader_.isJavaScriptLikeOrJSON()) {
import_record.path.is_disabled = true;
- import_record.is_bundled = true;
+
continue;
}
@@ -1384,13 +1382,12 @@ pub fn processFile(this: *GenerateNodeModuleBundle, worker: *ThreadPool.Worker,
// we just silently disable it
// because...we need some kind of hook to say "don't bundle this"
import_record.path.is_disabled = true;
- import_record.is_bundled = false;
+ import_record.tag = .macro;
continue;
};
import_record.module_id = _module_data.module_id;
std.debug.assert(import_record.module_id != 0);
- import_record.is_bundled = true;
path.* = try path.dupeAlloc(this.allocator);
@@ -1526,7 +1523,7 @@ pub fn processFile(this: *GenerateNodeModuleBundle, worker: *ThreadPool.Worker,
ast.runtime_imports = runtime.Runtime.Imports{};
ast.runtime_imports.@"$$m" = .{ .ref = Ref.atIndex(0), .primary = Ref.None, .backup = Ref.None };
ast.runtime_imports.__export = .{ .ref = Ref.atIndex(1), .primary = Ref.None, .backup = Ref.None };
- ast.symbols = &json_ast_symbols;
+ ast.symbols = js_ast.Symbol.List.init(&json_ast_symbols);
ast.module_ref = Ref.atIndex(2);
ast.exports_ref = ast.runtime_imports.__export.?.ref;
ast.bundle_export_ref = Ref.atIndex(3);
@@ -1676,7 +1673,6 @@ pub fn processFile(this: *GenerateNodeModuleBundle, worker: *ThreadPool.Worker,
&source,
false,
js_printer.Options{
- .to_module_ref = Ref.RuntimeRef,
.bundle_export_ref = ast.runtime_imports.@"$$m".?.ref,
.source_path = file_path,
.externals = ast.externals,
@@ -1704,7 +1700,6 @@ pub fn processFile(this: *GenerateNodeModuleBundle, worker: *ThreadPool.Worker,
&source,
true,
js_printer.Options{
- .to_module_ref = Ref.RuntimeRef,
.bundle_export_ref = ast.runtime_imports.@"$$m".?.ref,
.source_path = file_path,
.externals = ast.externals,
diff --git a/src/bunfig.zig b/src/bunfig.zig
index c6ecb7c10..0bdb20889 100644
--- a/src/bunfig.zig
+++ b/src/bunfig.zig
@@ -428,7 +428,7 @@ pub const Bunfig = struct {
}
if (json.get("bundle")) |_bun| {
- if (comptime cmd == .DevCommand or cmd == .BuildCommand or cmd == .RunCommand or cmd == .AutoCommand or cmd == .BunCommand) {
+ if (comptime cmd == .DevCommand or cmd == .BuildCommand or cmd == .RunCommand or cmd == .AutoCommand or cmd == .BuildCommand) {
if (_bun.get("saveTo")) |file| {
try this.expect(file, .e_string);
this.bunfig.node_modules_bundle_path = try file.data.e_string.string(allocator);
@@ -440,7 +440,7 @@ pub const Bunfig = struct {
}
}
- if (comptime cmd == .BunCommand) {
+ if (comptime cmd == .BuildCommand) {
if (_bun.get("logLevel")) |expr2| {
try this.loadLogLevel(expr2);
}
@@ -555,7 +555,7 @@ pub const Bunfig = struct {
}
switch (comptime cmd) {
- .AutoCommand, .DevCommand, .BuildCommand, .BunCommand => {
+ .AutoCommand, .DevCommand, .BuildCommand => {
if (json.get("publicDir")) |public_dir| {
try this.expect(public_dir, .e_string);
this.bunfig.router = Api.RouteConfig{
diff --git a/src/c.zig b/src/c.zig
index 3e9193069..2423d176d 100644
--- a/src/c.zig
+++ b/src/c.zig
@@ -38,6 +38,9 @@ pub extern "c" fn truncate([*:0]const u8, i64) c_int; // note: truncate64 is not
pub extern "c" fn lutimes(path: [*:0]const u8, times: *const [2]std.os.timeval) c_int;
pub extern "c" fn mkdtemp(template: [*c]u8) ?[*:0]u8;
+pub extern "c" fn memcmp(s1: [*c]const u8, s2: [*c]const u8, n: usize) c_int;
+pub extern "c" fn memchr(s: [*]const u8, c: u8, n: usize) ?[*]const u8;
+
pub const lstat = lstat64;
pub const fstat = fstat64;
pub const stat = stat64;
diff --git a/src/cache.zig b/src/cache.zig
index 284ca254b..a5d73e0fd 100644
--- a/src/cache.zig
+++ b/src/cache.zig
@@ -148,7 +148,7 @@ pub const Fs = struct {
var file_handle: std.fs.File = if (_file_handle) |__file| std.fs.File{ .handle = __file } else undefined;
if (_file_handle == null) {
- if (FeatureFlags.store_file_descriptors and dirname_fd > 0) {
+ if (FeatureFlags.store_file_descriptors and dirname_fd != bun.invalid_fd and dirname_fd > 0) {
file_handle = std.fs.Dir.openFile(std.fs.Dir{ .fd = dirname_fd }, std.fs.path.basename(path), .{ .mode = .read_only }) catch |err| brk: {
switch (err) {
error.FileNotFound => {
diff --git a/src/cli.zig b/src/cli.zig
index 530dc5e30..2e4f900b5 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -36,27 +36,8 @@ const Router = @import("./router.zig");
const NodeModuleBundle = @import("./node_module_bundle.zig").NodeModuleBundle;
-const AddCommand = @import("./cli/add_command.zig").AddCommand;
-const BuildCommand = @import("./cli/build_command.zig").BuildCommand;
-const BunCommand = @import("./cli/bun_command.zig").BunCommand;
-const CreateCommand = @import("./cli/create_command.zig").CreateCommand;
-const CreateListExamplesCommand = @import("./cli/create_command.zig").CreateListExamplesCommand;
-const DevCommand = @import("./cli/dev_command.zig").DevCommand;
-const DiscordCommand = @import("./cli/discord_command.zig").DiscordCommand;
-const InstallCommand = @import("./cli/install_command.zig").InstallCommand;
-const LinkCommand = @import("./cli/link_command.zig").LinkCommand;
-const UnlinkCommand = @import("./cli/unlink_command.zig").UnlinkCommand;
-const InstallCompletionsCommand = @import("./cli/install_completions_command.zig").InstallCompletionsCommand;
-const PackageManagerCommand = @import("./cli/package_manager_command.zig").PackageManagerCommand;
-const RemoveCommand = @import("./cli/remove_command.zig").RemoveCommand;
-const RunCommand = @import("./cli/run_command.zig").RunCommand;
-const ShellCompletions = @import("./cli/shell_completions.zig");
-const TestCommand = @import("./cli/test_command.zig").TestCommand;
-const UpgradeCommand = @import("./cli/upgrade_command.zig").UpgradeCommand;
-const BunxCommand = @import("./cli/bunx_command.zig").BunxCommand;
-
const MacroMap = @import("./resolver/package_json.zig").MacroMap;
-
+const TestCommand = @import("./cli/test_command.zig").TestCommand;
const Reporter = @import("./report.zig");
pub var start_time: i128 = undefined;
const Bunfig = @import("./bunfig.zig").Bunfig;
@@ -213,6 +194,10 @@ pub const Arguments = struct {
const build_only_params = [_]ParamType{
clap.parseParam("--sourcemap <STR>? Build with sourcemaps - 'inline', 'external', or 'none'") catch unreachable,
clap.parseParam("--outdir <STR> Default to \"dist\" if multiple files") catch unreachable,
+ clap.parseParam("--entry-names <STR> Pattern to use for entry point filenames") catch unreachable,
+ clap.parseParam("--outfile <STR> Write to a file") catch unreachable,
+ clap.parseParam("--server-components Enable React Server Components (experimental)") catch unreachable,
+ clap.parseParam("--splitting Split up code!") catch unreachable,
};
// TODO: update test completions
@@ -437,7 +422,6 @@ pub const Arguments = struct {
}
opts.serve = cmd == .DevCommand;
opts.main_fields = args.options("--main-fields");
- opts.generate_node_module_bundle = cmd == .BunCommand;
// we never actually supported inject.
// opts.inject = args.options("--inject");
opts.extension_order = args.options("--extension-order");
@@ -510,11 +494,30 @@ pub const Arguments = struct {
// var output_dir = args.option("--outdir");
var output_dir: ?string = null;
const production = false;
+ var output_file: ?string = null;
if (cmd == .BuildCommand) {
if (args.option("--outdir")) |outdir| {
if (outdir.len > 0) {
- output_dir = outdir;
+ ctx.bundler_options.outdir = outdir;
+ }
+ } else if (args.option("--outfile")) |outfile| {
+ if (outfile.len > 0) {
+ ctx.bundler_options.outfile = outfile;
+ }
+ }
+
+ if (args.flag("--splitting")) {
+ ctx.bundler_options.code_splitting = true;
+ }
+
+ if (args.option("--entry-names")) |entry_names| {
+ ctx.bundler_options.entry_names = entry_names;
+ }
+
+ if (comptime FeatureFlags.react_server_components) {
+ if (args.flag("--server-components")) {
+ ctx.bundler_options.react_server_components = true;
}
}
@@ -536,11 +539,11 @@ pub const Arguments = struct {
var entry_points = ctx.positionals;
switch (comptime cmd) {
- .BunCommand => {
+ .BuildCommand => {
if (entry_points.len > 0 and (strings.eqlComptime(
entry_points[0],
- "bun",
- ))) {
+ "build",
+ ) or strings.eqlComptime(entry_points[0], "bun"))) {
entry_points = entry_points[1..];
}
},
@@ -555,24 +558,6 @@ pub const Arguments = struct {
entry_points = entry_points[1..];
}
},
- .BuildCommand => {
- if (entry_points.len > 0 and (strings.eqlComptime(
- entry_points[0],
- "build",
- ) or strings.eqlComptime(
- entry_points[0],
- "b",
- ))) {
- entry_points = entry_points[1..];
- }
-
- opts.write = entry_points.len > 1 or
- output_dir != null or
- @enumToInt(opts.source_map orelse Api.SourceMapMode._none) > 0;
- if ((opts.write orelse false) and (output_dir orelse "").len == 0) {
- output_dir = "out";
- }
- },
.RunCommand => {
if (entry_points.len > 0 and (strings.eqlComptime(
entry_points[0],
@@ -596,7 +581,7 @@ pub const Arguments = struct {
var jsx_runtime = args.option("--jsx-runtime");
var jsx_production = args.flag("--jsx-production");
const react_fast_refresh = switch (comptime cmd) {
- .BunCommand, .DevCommand => !(args.flag("--disable-react-fast-refresh") or jsx_production),
+ .BuildCommand, .DevCommand => !(args.flag("--disable-react-fast-refresh") or jsx_production),
else => true,
};
@@ -615,7 +600,10 @@ pub const Arguments = struct {
}
switch (comptime cmd) {
- .AutoCommand, .DevCommand, .BuildCommand, .BunCommand => {
+ .AutoCommand,
+ .DevCommand,
+ .BuildCommand,
+ => {
if (args.option("--public-dir")) |public_dir| {
if (public_dir.len > 0) {
opts.router = Api.RouteConfig{ .extensions = &.{}, .dir = &.{}, .static_dir = public_dir };
@@ -710,7 +698,7 @@ pub const Arguments = struct {
};
}
- if (cmd == .BunCommand or !FeatureFlags.dev_only) {
+ if (cmd == .BuildCommand) {
if (opts.entry_points.len == 0 and opts.framework == null and opts.node_modules_bundle_path == null) {
return error.MissingEntryPoint;
}
@@ -727,6 +715,9 @@ pub const Arguments = struct {
}
opts.output_dir = output_dir;
+ if (output_file != null)
+ ctx.debug.output_file = output_file.?;
+
return opts;
}
};
@@ -778,25 +769,25 @@ pub const HelpCommand = struct {
pub fn printWithReason(comptime reason: Reason) void {
// the spacing between commands here is intentional
const fmt =
- \\> <r> <b><magenta>run <r><d> ./my-script.ts <r>Run JavaScript with bun, a package.json script, or a bin<r>
- \\> <r> <b><green>x <r> <d>bun-repl <r> Install and execute a package bin <d>(bunx)<r>
+ \\> <r><b><magenta>run<r> <d>./my-script.ts<r> Run JavaScript with bun, a package.json script, or a bin
+ \\> <b><magenta>build<r> <d>./a.ts ./b.jsx<r> Bundle TypeScript & JavaScript into a single file
+ \\> <b><green>x<r> <d>bun-repl<r> Install and execute a package bin <d>(bunx)<r>
\\
- \\> <r> <b><cyan>init<r> Start an empty Bun project from a blank template<r>
- \\> <r> <b><cyan>create <r><d>next ./app<r> Create a new project from a template <d>(bun c)<r>
- \\> <r> <b><green>install<r> Install dependencies for a package.json <d>(bun i)<r>
- \\> <r> <b><blue>add <r><d> {s:<16}<r> Add a dependency to package.json <d>(bun a)<r>
- \\> <r> <b><blue>link <r> Link an npm package globally<r>
- \\> <r> remove <r><d> {s:<16}<r> Remove a dependency from package.json <d>(bun rm)<r>
- \\> <r> unlink <r> Globally unlink an npm package
- \\> <r> pm <r> More commands for managing packages
+ \\> <b><cyan>init<r> Start an empty Bun project from a blank template
+ \\> <b><cyan>create<r> <d>next ./app<r> Create a new project from a template <d>(bun c)<r>
+ \\> <b><green>install<r> Install dependencies for a package.json <d>(bun i)<r>
+ \\> <b><blue>add<r> <d>{s:<16}<r> Add a dependency to package.json <d>(bun a)<r>
+ \\> <b><blue>link<r> Link an npm package globally
+ \\> remove<r> <d>{s:<16}<r> Remove a dependency from package.json <d>(bun rm)<r>
+ \\> unlink<r> Globally unlink an npm package
+ \\> pm<r> More commands for managing packages
\\
- \\> <r> <b><green>dev <r><d> ./a.ts ./b.jsx<r> Start a bun (frontend) Dev Server
- \\> <r> <b><magenta>bun <r><d> ./a.ts ./b.jsx<r> Bundle dependencies of input files into a <r><magenta>.bun<r>
+ \\> <b><green>dev<r> <d>./a.ts ./b.jsx<r> Start a bun (frontend) Dev Server
\\
- \\> <r> <b><blue>upgrade <r> Get the latest version of bun
- \\> <r> <b><d>completions<r> Install shell completions for tab-completion
- \\> <r> <b><d>discord <r> Open bun's Discord server
- \\> <r> <b><d>help <r> Print this help menu
+ \\> <b><blue>upgrade<r> Get the latest version of bun
+ \\> <b><d>completions<r> Install shell completions for tab-completion
+ \\> <b><d>discord<r> Open bun's Discord server
+ \\> <b><d>help<r> Print this help menu
\\
;
@@ -882,6 +873,7 @@ pub const Command = struct {
package_bundle_map: bun.StringArrayHashMapUnmanaged(options.BundlePackage) = bun.StringArrayHashMapUnmanaged(options.BundlePackage){},
test_directory: []const u8 = "",
+ output_file: []const u8 = "",
};
pub const HotReload = enum {
@@ -906,10 +898,19 @@ pub const Command = struct {
debug: DebugOptions = DebugOptions{},
test_options: TestOptions = TestOptions{},
+ bundler_options: BundlerOptions = BundlerOptions{},
preloads: []const string = &[_]string{},
has_loaded_global_config: bool = false,
+ pub const BundlerOptions = struct {
+ outdir: []const u8 = "",
+ outfile: []const u8 = "",
+ entry_names: []const u8 = "./[name].[ext]",
+ react_server_components: bool = false,
+ code_splitting: bool = false,
+ };
+
const _ctx = Command.Context{
.args = std.mem.zeroes(Api.TransformOptions),
.log = undefined,
@@ -976,7 +977,7 @@ pub const Command = struct {
return switch (RootCommandMatcher.match(first_arg_name)) {
RootCommandMatcher.case("init") => .InitCommand,
- RootCommandMatcher.case("bun") => .BunCommand,
+ RootCommandMatcher.case("build"), RootCommandMatcher.case("bun") => .BuildCommand,
RootCommandMatcher.case("discord") => .DiscordCommand,
RootCommandMatcher.case("upgrade") => .UpgradeCommand,
RootCommandMatcher.case("completions") => .InstallCompletionsCommand,
@@ -1004,7 +1005,6 @@ pub const Command = struct {
RootCommandMatcher.case("add"), RootCommandMatcher.case("update"), RootCommandMatcher.case("a") => .AddCommand,
RootCommandMatcher.case("r"), RootCommandMatcher.case("remove"), RootCommandMatcher.case("rm"), RootCommandMatcher.case("uninstall") => .RemoveCommand,
- RootCommandMatcher.case("b"), RootCommandMatcher.case("build") => .BuildCommand,
RootCommandMatcher.case("run") => .RunCommand,
RootCommandMatcher.case("d"), RootCommandMatcher.case("dev") => .DevCommand,
@@ -1037,84 +1037,130 @@ pub const Command = struct {
};
pub fn start(allocator: std.mem.Allocator, log: *logger.Log) !void {
+ const BuildCommand = @import("./cli/build_command.zig").BuildCommand;
+
+ const AddCommand = @import("./cli/add_command.zig").AddCommand;
+ const CreateCommand = @import("./cli/create_command.zig").CreateCommand;
+ const CreateListExamplesCommand = @import("./cli/create_command.zig").CreateListExamplesCommand;
+ const DevCommand = @import("./cli/dev_command.zig").DevCommand;
+ const DiscordCommand = @import("./cli/discord_command.zig").DiscordCommand;
+ const InstallCommand = @import("./cli/install_command.zig").InstallCommand;
+ const LinkCommand = @import("./cli/link_command.zig").LinkCommand;
+ const UnlinkCommand = @import("./cli/unlink_command.zig").UnlinkCommand;
+ const InstallCompletionsCommand = @import("./cli/install_completions_command.zig").InstallCompletionsCommand;
+ const PackageManagerCommand = @import("./cli/package_manager_command.zig").PackageManagerCommand;
+ const RemoveCommand = @import("./cli/remove_command.zig").RemoveCommand;
+ const RunCommand = @import("./cli/run_command.zig").RunCommand;
+ const ShellCompletions = @import("./cli/shell_completions.zig");
+
+ const UpgradeCommand = @import("./cli/upgrade_command.zig").UpgradeCommand;
+ const BunxCommand = @import("./cli/bunx_command.zig").BunxCommand;
+
+ if (comptime bun.fast_debug_build_mode) {
+ // _ = AddCommand;
+ // _ = BuildCommand;
+ // _ = CreateCommand;
+ _ = CreateListExamplesCommand;
+ // _ = DevCommand;
+ _ = DiscordCommand;
+ // _ = InstallCommand;
+ // _ = LinkCommand;
+ // _ = UnlinkCommand;
+ // _ = InstallCompletionsCommand;
+ // _ = PackageManagerCommand;
+ // _ = RemoveCommand;
+ // _ = RunCommand;
+ // _ = ShellCompletions;
+ // _ = TestCommand;
+ // _ = UpgradeCommand;
+ // _ = BunxCommand;
+ }
+
const tag = which();
switch (tag) {
- .DiscordCommand => return try DiscordCommand.exec(allocator),
- .HelpCommand => return try HelpCommand.exec(allocator),
- .InitCommand => return try InitCommand.exec(allocator, std.os.argv),
+ // .DiscordCommand => return try DiscordCommand.exec(allocator),
+ // .HelpCommand => return try HelpCommand.exec(allocator),
+ // .InitCommand => return try InitCommand.exec(allocator, std.os.argv),
else => {},
}
switch (tag) {
- .BunCommand => {
- const ctx = try Command.Context.create(allocator, log, .BunCommand);
+ .BuildCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .BuildCommand) unreachable;
+ const ctx = try Command.Context.create(allocator, log, .BuildCommand);
- try BunCommand.exec(ctx);
+ try BuildCommand.exec(ctx);
},
.DevCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .DevCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .DevCommand);
try DevCommand.exec(ctx);
},
- .BuildCommand => {
- const ctx = try Command.Context.create(allocator, log, .BuildCommand);
-
- try BuildCommand.exec(ctx);
- },
.InstallCompletionsCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .InstallCompletionsCommand) unreachable;
try InstallCompletionsCommand.exec(allocator);
return;
},
.InstallCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .InstallCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .InstallCommand);
try InstallCommand.exec(ctx);
return;
},
.AddCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .AddCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .AddCommand);
try AddCommand.exec(ctx);
return;
},
.BunxCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .BunxCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .BunxCommand);
try BunxCommand.exec(ctx);
return;
},
.RemoveCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .RemoveCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .RemoveCommand);
try RemoveCommand.exec(ctx);
return;
},
.LinkCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .LinkCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .LinkCommand);
try LinkCommand.exec(ctx);
return;
},
.UnlinkCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .UnlinkCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .UnlinkCommand);
try UnlinkCommand.exec(ctx);
return;
},
.PackageManagerCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .PackageManagerCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .PackageManagerCommand);
try PackageManagerCommand.exec(ctx);
return;
},
.TestCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .TestCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .TestCommand);
try TestCommand.exec(ctx);
return;
},
.GetCompletionsCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .GetCompletionsCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .GetCompletionsCommand);
var filter = ctx.positionals;
@@ -1201,6 +1247,7 @@ pub const Command = struct {
return;
},
.CreateCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .CreateCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .CreateCommand);
var positionals: [2]string = undefined;
var positional_i: usize = 0;
@@ -1224,6 +1271,7 @@ pub const Command = struct {
return;
},
.RunCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .RunCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .RunCommand);
if (ctx.positionals.len > 0) {
if (try RunCommand.exec(ctx, false, true)) {
@@ -1234,11 +1282,13 @@ pub const Command = struct {
}
},
.UpgradeCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .UpgradeCommand) unreachable;
const ctx = try Command.Context.create(allocator, log, .UpgradeCommand);
try UpgradeCommand.exec(ctx);
return;
},
.AutoCommand => {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .AutoCommand) unreachable;
var ctx = Command.Context.create(allocator, log, .AutoCommand) catch |e| {
switch (e) {
error.MissingEntryPoint => {
@@ -1434,7 +1484,6 @@ pub const Command = struct {
AddCommand,
AutoCommand,
BuildCommand,
- BunCommand,
BunxCommand,
CreateCommand,
DevCommand,
@@ -1476,8 +1525,7 @@ pub const Command = struct {
pub const cares_about_bun_file: std.EnumArray(Tag, bool) = std.EnumArray(Tag, bool).initDefault(false, .{
.AutoCommand = true,
- .BuildCommand = true,
- .BunCommand = true,
+ .BuildCommand = false,
.DevCommand = true,
.RunCommand = true,
.TestCommand = true,
@@ -1495,7 +1543,6 @@ pub const Command = struct {
};
pub const always_loads_config: std.EnumArray(Tag, bool) = std.EnumArray(Tag, bool).initDefault(false, .{
.BuildCommand = true,
- .BunCommand = true,
.DevCommand = true,
.TestCommand = true,
.InstallCommand = true,
diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig
index 92d2d5b3a..1b8e5c632 100644
--- a/src/cli/build_command.zig
+++ b/src/cli/build_command.zig
@@ -1,167 +1,237 @@
+const std = @import("std");
+const Command = @import("../cli.zig").Command;
const bun = @import("bun");
const string = bun.string;
const Output = bun.Output;
const Global = bun.Global;
const Environment = bun.Environment;
-const FeatureFlags = bun.FeatureFlags;
const strings = bun.strings;
const MutableString = bun.MutableString;
const stringZ = bun.stringZ;
const default_allocator = bun.default_allocator;
const C = bun.C;
-const std = @import("std");
const lex = bun.js_lexer;
const logger = @import("bun").logger;
const options = @import("../options.zig");
const js_parser = bun.js_parser;
+const json_parser = bun.JSON;
+const js_printer = bun.js_printer;
const js_ast = bun.JSAst;
const linker = @import("../linker.zig");
-const allocators = @import("../allocators.zig");
const sync = @import("../sync.zig");
const Api = @import("../api/schema.zig").Api;
const resolve_path = @import("../resolver/resolve_path.zig");
const configureTransformOptionsForBun = @import("../bun.js/config.zig").configureTransformOptionsForBun;
-const Command = @import("../cli.zig").Command;
const bundler = bun.bundler;
const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
+const GenerateNodeModuleBundle = @import("../bundler/generate_node_modules_bundle.zig");
+const DotEnv = @import("../env_loader.zig");
+
const fs = @import("../fs.zig");
-const constStrToU8 = bun.constStrToU8;
+const Router = @import("../router.zig");
+const BundleV2 = @import("../bundler/bundle_v2.zig").BundleV2;
+var estimated_input_lines_of_code_: usize = undefined;
pub const BuildCommand = struct {
- pub fn exec(ctx: Command.Context) !void {
- var result: options.TransformResult = undefined;
- switch (ctx.args.resolve orelse Api.ResolveMode.dev) {
- .lazy => {
- result = try bundler.Bundler.bundle(
- ctx.allocator,
- ctx.log,
- ctx.args,
- );
- },
- else => {
- result = try bundler.Bundler.bundle(
- ctx.allocator,
- ctx.log,
- ctx.args,
- );
- },
- }
- var did_write = false;
+ pub fn exec(
+ ctx: Command.Context,
+ ) !void {
+ Global.configureAllocator(.{ .long_running = true });
+ var allocator = ctx.allocator;
+ var log = ctx.log;
+ estimated_input_lines_of_code_ = 0;
+
+ var this_bundler = try bundler.Bundler.init(allocator, log, ctx.args, null, null);
+ this_bundler.options.entry_names = ctx.bundler_options.entry_names;
+ this_bundler.resolver.opts.entry_names = ctx.bundler_options.entry_names;
+ this_bundler.options.output_dir = ctx.bundler_options.outdir;
+ this_bundler.resolver.opts.output_dir = ctx.bundler_options.outdir;
+ this_bundler.options.react_server_components = ctx.bundler_options.react_server_components;
+ this_bundler.resolver.opts.react_server_components = ctx.bundler_options.react_server_components;
+ this_bundler.options.code_splitting = ctx.bundler_options.code_splitting;
+ this_bundler.resolver.opts.code_splitting = ctx.bundler_options.code_splitting;
+
+ this_bundler.configureLinker();
+
+ // This step is optional
+ // If it fails for any reason, ignore it and continue bundling
+ // This is partially a workaround for the 'error.MissingRoutesDir' error
+ this_bundler.configureRouter(true) catch {
+ this_bundler.options.routes.routes_enabled = false;
+ this_bundler.options.framework = null;
+ if (this_bundler.router) |*router| {
+ router.config.routes_enabled = false;
+ router.config.single_page_app_routing = false;
+ router.config.static_dir_enabled = false;
+ this_bundler.router = null;
+ }
+ this_bundler.options.node_modules_bundle = null;
+ this_bundler.options.node_modules_bundle_pretty_path = "";
+ this_bundler.options.node_modules_bundle_url = "";
+ };
- defer Output.flush();
- var writer = Output.errorWriter();
- var err_writer = writer;
+ if (ctx.debug.macros) |macros| {
+ this_bundler.options.macro_remap = macros;
+ }
- var open_file_limit: usize = fs.FileSystem.RealFS.Limit.handles;
- if (ctx.args.write) |write| {
- if (write) {
- const root_dir = result.root_dir orelse unreachable;
+ // var env_loader = this_bundler.env;
- var all_paths = try ctx.allocator.alloc([]const u8, result.output_files.len);
- var max_path_len: usize = 0;
- for (result.output_files, 0..) |f, i| {
- all_paths[i] = f.input.text;
- }
+ if (ctx.debug.dump_environment_variables) {
+ this_bundler.dumpEnvironmentVariables();
+ return;
+ }
- var from_path = resolve_path.longestCommonPath(all_paths);
+ if (ctx.debug.dump_limits) {
+ fs.FileSystem.printLimits();
+ Global.exit(0);
+ return;
+ }
- for (result.output_files) |f| {
- max_path_len = std.math.max(
- std.math.max(from_path.len, f.input.text.len) + 2 - from_path.len,
- max_path_len,
- );
+ // var generated_server = false;
+ // if (this_bundler.options.framework) |*framework| {
+ // if (framework.toAPI(allocator, this_bundler.fs.top_level_dir) catch null) |_server_conf| {
+ // ServerBundleGeneratorThread.generate(
+ // log,
+ // env_loader,
+ // ctx,
+ // server_bundle_filepath,
+ // _server_conf,
+ // loaded_route_config,
+ // this_bundler.router,
+ // );
+ // generated_server = true;
+
+ // if (log.msgs.items.len > 0) {
+ // try log.printForLogLevel(Output.errorWriter());
+ // log.* = logger.Log.init(allocator);
+ // Output.flush();
+ // }
+ // }
+ // }
+
+ {
+
+ // Always generate the client-only bundle
+ // we can revisit this decision if people ask
+ const output_files = BundleV2.generate(
+ &this_bundler,
+ allocator,
+ &estimated_input_lines_of_code_,
+ ctx.debug.package_bundle_map,
+ bun.JSC.AnyEventLoop.init(ctx.allocator),
+ std.crypto.random.int(u64),
+ ctx.debug.hot_reload == .watch,
+ ) catch |err| {
+ if (log.msgs.items.len > 0) {
+ try log.printForLogLevel(Output.errorWriter());
+ } else {
+ try Output.errorWriter().print("error: {s}", .{@errorName(err)});
}
- did_write = true;
-
- // On posix, file handles automatically close on process exit by the OS
- // Closing files shows up in profiling.
- // So don't do that unless we actually need to.
- // const do_we_need_to_close = !FeatureFlags.store_file_descriptors or (@intCast(usize, root_dir.fd) + open_file_limit) < result.output_files.len;
-
- var filepath_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
- filepath_buf[0] = '.';
- filepath_buf[1] = '/';
-
- for (result.output_files) |f| {
- var rel_path: []const u8 = undefined;
- switch (f.value) {
- // easy mode: write the buffer
- .buffer => |value| {
- rel_path = resolve_path.relative(from_path, f.input.text);
-
- try root_dir.writeFile(rel_path, value);
- },
- .move => |value| {
- // const primary = f.input.text[from_path.len..];
- // bun.copy(u8, filepath_buf[2..], primary);
- // rel_path = filepath_buf[0 .. primary.len + 2];
- rel_path = value.pathname;
-
- // try f.moveTo(result.outbase, constStrToU8(rel_path), root_dir.fd);
- },
- .copy => |value| {
- rel_path = value.pathname;
-
- try f.copyTo(result.outbase, constStrToU8(rel_path), root_dir.fd);
- },
- .noop => {},
- .pending => unreachable,
+ Output.flush();
+ exitOrWatch(1, ctx.debug.hot_reload == .watch);
+ unreachable;
+ };
+
+ {
+ dump: {
+ defer Output.flush();
+ var writer = Output.errorWriter();
+ var output_dir = this_bundler.options.output_dir;
+ if (ctx.bundler_options.outfile.len > 0 and output_files.items.len == 1 and output_files.items[0].value == .buffer) {
+ output_dir = std.fs.path.dirname(ctx.bundler_options.outfile) orelse ".";
+ output_files.items[0].input.text = std.fs.path.basename(ctx.bundler_options.outfile);
}
- // Print summary
- _ = try writer.write("\n");
- const padding_count = 2 + (std.math.max(rel_path.len, max_path_len) - rel_path.len);
- try writer.writeByteNTimes(' ', 2);
- try writer.writeAll(rel_path);
- try writer.writeByteNTimes(' ', padding_count);
- const size = @intToFloat(f64, f.size) / 1000.0;
- try std.fmt.formatFloatDecimal(size, .{ .precision = 2 }, writer);
- try writer.writeAll(" KB\n");
- }
- }
- }
+ if (output_dir.len == 0 and output_files.items.len == 1 and output_files.items[0].value == .buffer) {
+ try writer.writeAll(output_files.items[0].value.buffer);
+ break :dump;
+ }
- if (Environment.isDebug) {
- err_writer.print("\nExpr count: {d}\n", .{js_ast.Expr.icount}) catch {};
- err_writer.print("Stmt count: {d}\n", .{js_ast.Stmt.icount}) catch {};
- err_writer.print("Binding count: {d}\n", .{js_ast.Binding.icount}) catch {};
- err_writer.print("File Descriptors: {d} / {d}\n", .{
- fs.FileSystem.max_fd,
- open_file_limit,
- }) catch {};
- }
+ const root_path = output_dir;
+ const root_dir = try std.fs.cwd().makeOpenPathIterable(root_path, .{});
+ var all_paths = try ctx.allocator.alloc([]const u8, output_files.items.len);
+ var max_path_len: usize = 0;
+ for (all_paths, output_files.items) |*dest, src| {
+ dest.* = src.input.text;
+ }
- if (Output.enable_ansi_colors) {
- for (result.errors) |err| {
- try err.writeFormat(err_writer, true);
- _ = try err_writer.write("\n");
- }
+ var from_path = resolve_path.longestCommonPath(all_paths);
- for (result.warnings) |err| {
- try err.writeFormat(err_writer, true);
- _ = try err_writer.write("\n");
- }
- } else {
- for (result.errors) |err| {
- try err.writeFormat(err_writer, false);
- _ = try err_writer.write("\n");
- }
+ for (output_files.items) |f| {
+ max_path_len = std.math.max(
+ std.math.max(from_path.len, f.input.text.len) + 2 - from_path.len,
+ max_path_len,
+ );
+ }
- for (result.warnings) |err| {
- try err.writeFormat(err_writer, false);
- _ = try err_writer.write("\n");
+ // On posix, file handles automatically close on process exit by the OS
+ // Closing files shows up in profiling.
+ // So don't do that unless we actually need to.
+ // const do_we_need_to_close = !FeatureFlags.store_file_descriptors or (@intCast(usize, root_dir.fd) + open_file_limit) < output_files.items.len;
+
+ var filepath_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
+ filepath_buf[0] = '.';
+ filepath_buf[1] = '/';
+
+ for (output_files.items) |f| {
+ var rel_path: []const u8 = undefined;
+ switch (f.value) {
+ // easy mode: write the buffer
+ .buffer => |value| {
+ rel_path = f.input.text;
+ if (f.input.text.len > from_path.len) {
+ rel_path = resolve_path.relative(from_path, f.input.text);
+ if (std.fs.path.dirname(rel_path)) |parent| {
+ if (parent.len > root_path.len) {
+ try root_dir.dir.makePath(parent);
+ }
+ }
+ }
+ try root_dir.dir.writeFile(rel_path, value);
+ },
+ .move => |value| {
+ // const primary = f.input.text[from_path.len..];
+ // bun.copy(u8, filepath_buf[2..], primary);
+ // rel_path = filepath_buf[0 .. primary.len + 2];
+ rel_path = value.pathname;
+
+ // try f.moveTo(result.outbase, constStrToU8(rel_path), root_dir.fd);
+ },
+ .copy => |value| {
+ rel_path = value.pathname;
+
+ try f.copyTo(root_path, bun.constStrToU8(rel_path), root_dir.dir.fd);
+ },
+ .noop => {},
+ .pending => unreachable,
+ }
+
+ // Print summary
+ _ = try writer.write("\n");
+ const padding_count = 2 + (std.math.max(rel_path.len, max_path_len) - rel_path.len);
+ try writer.writeByteNTimes(' ', 2);
+ try writer.writeAll(rel_path);
+ try writer.writeByteNTimes(' ', padding_count);
+ const size = @intToFloat(f64, f.size) / 1000.0;
+ try std.fmt.formatFloatDecimal(size, .{ .precision = 2 }, writer);
+ try writer.writeAll(" KB\n");
+ }
+ }
}
- }
-
- const duration = std.time.nanoTimestamp() - ctx.start_time;
-
- if (did_write and duration < @as(i128, @as(i128, std.time.ns_per_s) * @as(i128, 2))) {
- var elapsed = @divTrunc(duration, @as(i128, std.time.ns_per_ms));
- try err_writer.print("\nCompleted in {d}ms", .{elapsed});
+ try log.printForLogLevel(Output.errorWriter());
+ exitOrWatch(0, ctx.debug.hot_reload == .watch);
}
}
};
+
+fn exitOrWatch(code: u8, watch: bool) void {
+ if (watch) {
+ // the watcher thread will exit the process
+ std.time.sleep(std.math.maxInt(u64) - 1);
+ }
+ Global.exit(code);
+}
diff --git a/src/cli/bun_command.zig b/src/cli/bun_command.zig
deleted file mode 100644
index 0a8894905..000000000
--- a/src/cli/bun_command.zig
+++ /dev/null
@@ -1,242 +0,0 @@
-const std = @import("std");
-const Command = @import("../cli.zig").Command;
-const bun = @import("bun");
-const string = bun.string;
-const Output = bun.Output;
-const Global = bun.Global;
-const Environment = bun.Environment;
-const strings = bun.strings;
-const MutableString = bun.MutableString;
-const stringZ = bun.stringZ;
-const default_allocator = bun.default_allocator;
-const C = bun.C;
-
-const lex = bun.js_lexer;
-const logger = @import("bun").logger;
-
-const options = @import("../options.zig");
-const js_parser = bun.js_parser;
-const json_parser = bun.JSON;
-const js_printer = bun.js_printer;
-const js_ast = bun.JSAst;
-const linker = @import("../linker.zig");
-
-const sync = @import("../sync.zig");
-const Api = @import("../api/schema.zig").Api;
-const resolve_path = @import("../resolver/resolve_path.zig");
-const configureTransformOptionsForBun = @import("../bun.js/config.zig").configureTransformOptionsForBun;
-const bundler = bun.bundler;
-const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle;
-const GenerateNodeModuleBundle = @import("../bundler/generate_node_modules_bundle.zig");
-const DotEnv = @import("../env_loader.zig");
-
-const fs = @import("../fs.zig");
-const Router = @import("../router.zig");
-
-var estimated_input_lines_of_code_: usize = undefined;
-const ServerBundleGeneratorThread = struct {
- inline fn _generate(
- logs: *logger.Log,
- env_loader_: *DotEnv.Loader,
- allocator_: std.mem.Allocator,
- ctx: Command.Context,
- _filepath: [*:0]const u8,
- server_conf: Api.LoadedFramework,
- route_conf_: ?Api.LoadedRouteConfig,
- router: ?Router,
- ) anyerror!void {
- var server_bundler = try bundler.Bundler.init(
- allocator_,
- logs,
- try configureTransformOptionsForBun(allocator_, ctx.args),
- null,
- env_loader_,
- );
- server_bundler.configureLinker();
- server_bundler.options.jsx.supports_fast_refresh = false;
-
- server_bundler.router = router;
- server_bundler.configureDefines() catch |err| {
- Output.prettyErrorln("<r><red>{s}<r> loading --define or .env values for node_modules.server.bun\n", .{@errorName(err)});
- return err;
- };
-
- if (ctx.debug.macros) |macros| {
- server_bundler.options.macro_remap = macros;
- }
-
- var estimated_input_lines_of_code: usize = 0;
- _ = try GenerateNodeModuleBundle.generate(
- &server_bundler,
- allocator_,
- server_conf,
- route_conf_,
- _filepath,
- &estimated_input_lines_of_code,
- ctx.debug.package_bundle_map,
- );
- std.mem.doNotOptimizeAway(&server_bundler);
- }
- pub fn generate(
- logs: *logger.Log,
- env_loader_: *DotEnv.Loader,
- ctx: Command.Context,
- _filepath: [*:0]const u8,
- server_conf: Api.LoadedFramework,
- route_conf_: ?Api.LoadedRouteConfig,
- router: ?Router,
- ) void {
- defer Output.flush();
-
- _generate(logs, env_loader_, default_allocator, ctx, _filepath, server_conf, route_conf_, router) catch return;
- }
-};
-
-pub const BunCommand = struct {
- pub fn exec(
- ctx: Command.Context,
- ) !void {
- Global.configureAllocator(.{ .long_running = true });
- var allocator = ctx.allocator;
- var log = ctx.log;
- estimated_input_lines_of_code_ = 0;
-
- var this_bundler = try bundler.Bundler.init(allocator, log, ctx.args, null, null);
- this_bundler.configureLinker();
- var filepath: [*:0]const u8 = "node_modules.bun";
- var server_bundle_filepath: [*:0]const u8 = "node_modules.server.bun";
-
- // This step is optional
- // If it fails for any reason, ignore it and continue bundling
- // This is partially a workaround for the 'error.MissingRoutesDir' error
- this_bundler.configureRouter(true) catch {
- this_bundler.options.routes.routes_enabled = false;
- this_bundler.options.framework = null;
- if (this_bundler.router) |*router| {
- router.config.routes_enabled = false;
- router.config.single_page_app_routing = false;
- router.config.static_dir_enabled = false;
- this_bundler.router = null;
- }
- this_bundler.options.node_modules_bundle = null;
- this_bundler.options.node_modules_bundle_pretty_path = "";
- this_bundler.options.node_modules_bundle_url = "";
- };
-
- if (ctx.debug.macros) |macros| {
- this_bundler.options.macro_remap = macros;
- }
-
- var loaded_route_config: ?Api.LoadedRouteConfig = brk: {
- if (this_bundler.options.routes.routes_enabled) {
- break :brk this_bundler.options.routes.toAPI();
- }
- break :brk null;
- };
- var loaded_framework: ?Api.LoadedFramework = brk: {
- if (this_bundler.options.framework) |*conf| {
- break :brk try conf.toAPI(allocator, this_bundler.fs.top_level_dir);
- }
- break :brk null;
- };
- var env_loader = this_bundler.env;
-
- if (ctx.debug.dump_environment_variables) {
- this_bundler.dumpEnvironmentVariables();
- return;
- }
-
- if (ctx.debug.dump_limits) {
- fs.FileSystem.printLimits();
- Global.exit(0);
- return;
- }
-
- var generated_server = false;
- if (this_bundler.options.framework) |*framework| {
- if (framework.toAPI(allocator, this_bundler.fs.top_level_dir) catch null) |_server_conf| {
- ServerBundleGeneratorThread.generate(
- log,
- env_loader,
- ctx,
- server_bundle_filepath,
- _server_conf,
- loaded_route_config,
- this_bundler.router,
- );
- generated_server = true;
-
- if (log.msgs.items.len > 0) {
- try log.printForLogLevel(Output.errorWriter());
- log.* = logger.Log.init(allocator);
- Output.flush();
- }
- }
- }
-
- {
-
- // Always generate the client-only bundle
- // we can revisit this decision if people ask
- var node_modules_ = try GenerateNodeModuleBundle.generate(
- &this_bundler,
- allocator,
- loaded_framework,
- loaded_route_config,
- filepath,
- &estimated_input_lines_of_code_,
- ctx.debug.package_bundle_map,
- );
-
- const estimated_input_lines_of_code = estimated_input_lines_of_code_;
-
- if (node_modules_) |node_modules| {
- if (log.errors > 0) {
- try log.printForLogLevel(Output.errorWriter());
- } else {
- var elapsed = @divTrunc(@truncate(i64, std.time.nanoTimestamp() - ctx.start_time), @as(i64, std.time.ns_per_ms));
- const print_summary = !(ctx.args.no_summary orelse false);
- if (print_summary) {
- var bundle = NodeModuleBundle.init(node_modules, allocator);
- bundle.printSummary();
- }
- const indent = comptime " ";
-
- switch (estimated_input_lines_of_code) {
- 0...99999 => {
- if (generated_server) {
- Output.prettyln(indent ++ "<d>{d:<5} LOC parsed x2", .{estimated_input_lines_of_code});
- } else {
- Output.prettyln(indent ++ "<d>{d:<5} LOC parsed", .{estimated_input_lines_of_code});
- }
- },
- else => {
- const formatted_loc: f32 = @floatCast(f32, @intToFloat(f64, estimated_input_lines_of_code) / 1000);
- if (generated_server) {
- Output.prettyln(indent ++ "<d>{d:<5.2}k LOC parsed x2", .{formatted_loc});
- } else {
- Output.prettyln(indent ++ "<d>{d:<5.2}k LOC parsed", .{
- formatted_loc,
- });
- }
- },
- }
-
- Output.prettyln(indent ++ "<d>{d:6}ms elapsed", .{@intCast(u32, elapsed)});
-
- if (generated_server) {
- Output.prettyln(indent ++ "<r>Saved to ./{s}, ./{s}", .{ filepath, server_bundle_filepath });
- } else {
- Output.prettyln(indent ++ "<r>Saved to ./{s}", .{filepath});
- }
-
- Output.flush();
-
- try log.printForLogLevel(Output.errorWriter());
- }
- } else {
- try log.printForLogLevel(Output.errorWriter());
- }
- }
- }
-};
diff --git a/src/comptime_string_map.zig b/src/comptime_string_map.zig
index ce29679ba..1963fc8de 100644
--- a/src/comptime_string_map.zig
+++ b/src/comptime_string_map.zig
@@ -69,6 +69,18 @@ pub fn ComptimeStringMapWithKeyType(comptime KeyType: type, comptime V: type, co
const len_indexes = precomputed.len_indexes;
pub const kvs = precomputed.sorted_kvs;
+ const keys_list: []const []const KeyType = blk: {
+ var k: [kvs.len][]const KeyType = undefined;
+ for (kvs, 0..) |kv, i| {
+ k[i] = kv.key;
+ }
+ break :blk k[0..];
+ };
+
+ pub fn keys() []const []const KeyType {
+ return keys_list;
+ }
+
pub fn has(str: []const KeyType) bool {
return get(str) != null;
}
diff --git a/src/defines-table.zig b/src/defines-table.zig
index 4c458006f..b4d7eed49 100644
--- a/src/defines-table.zig
+++ b/src/defines-table.zig
@@ -8,6 +8,8 @@ const MutableString = bun.MutableString;
const stringZ = bun.stringZ;
const default_allocator = bun.default_allocator;
const C = bun.C;
+const std = @import("std");
+const defines = @import("./defines.zig");
// If something is in this list, then a direct identifier expression or property
// access chain matching this will be assumed to have no side effects and will
@@ -24,18 +26,6 @@ const C = bun.C;
// these functions has any side effects. It only says something about
// referencing these function without calling them.
pub const GlobalDefinesKey = [_][]const string{
- // These global identifiers should exist in all JavaScript environments. This
- // deliberately omits "NaN", "Infinity", and "undefined" because these are
- // treated as automatically-inlined constants instead of identifiers.
- &[_]string{"Array"},
- &[_]string{"Boolean"},
- &[_]string{"Function"},
- &[_]string{"Math"},
- &[_]string{"Number"},
- &[_]string{"Object"},
- &[_]string{"RegExp"},
- &[_]string{"String"},
-
// Object: Static methods
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#Static_methods
&[_]string{ "Object", "assign" },
@@ -124,68 +114,24 @@ pub const GlobalDefinesKey = [_][]const string{
&[_]string{ "Math", "tanh" },
&[_]string{ "Math", "trunc" },
- // Other globals present in both the browser and node (except "eval" because
- // it has special behavior)
- &[_]string{"AbortController"},
- &[_]string{"AbortSignal"},
- &[_]string{"AggregateError"},
- &[_]string{"ArrayBuffer"},
- &[_]string{"BigInt"},
- &[_]string{"DataView"},
- &[_]string{"Date"},
- &[_]string{"Error"},
- &[_]string{"EvalError"},
- &[_]string{"Event"},
- &[_]string{"EventTarget"},
- &[_]string{"Float32Array"},
- &[_]string{"Float64Array"},
- &[_]string{"Int16Array"},
- &[_]string{"Int32Array"},
- &[_]string{"Int8Array"},
- &[_]string{"Intl"},
- &[_]string{"JSON"},
- &[_]string{"Map"},
- &[_]string{"MessageChannel"},
- &[_]string{"MessageEvent"},
- &[_]string{"MessagePort"},
- &[_]string{"Promise"},
- &[_]string{"Proxy"},
- &[_]string{"RangeError"},
- &[_]string{"ReferenceError"},
- &[_]string{"Reflect"},
- &[_]string{"Set"},
- &[_]string{"Symbol"},
- &[_]string{"SyntaxError"},
- &[_]string{"TextDecoder"},
- &[_]string{"TextEncoder"},
- &[_]string{"TypeError"},
- &[_]string{"URIError"},
- &[_]string{"URL"},
- &[_]string{"URLSearchParams"},
- &[_]string{"Uint16Array"},
- &[_]string{"Uint32Array"},
- &[_]string{"Uint8Array"},
- &[_]string{"Uint8ClampedArray"},
- &[_]string{"WeakMap"},
- &[_]string{"WeakSet"},
- &[_]string{"WebAssembly"},
- &[_]string{"clearInterval"},
- &[_]string{"clearTimeout"},
- &[_]string{"console"},
- &[_]string{"decodeURI"},
- &[_]string{"decodeURIComponent"},
- &[_]string{"encodeURI"},
- &[_]string{"encodeURIComponent"},
- &[_]string{"escape"},
- &[_]string{"globalThis"},
- &[_]string{"isFinite"},
- &[_]string{"isNaN"},
- &[_]string{"parseFloat"},
- &[_]string{"parseInt"},
- &[_]string{"queueMicrotask"},
- &[_]string{"setInterval"},
- &[_]string{"setTimeout"},
- &[_]string{"unescape"},
+ &[_]string{ "Symbol", "for" },
+ &[_]string{ "Symbol", "keyFor" },
+
+ // Reflect: Static methods
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect#static_methods
+ &[_]string{ "Reflect", "apply" },
+ &[_]string{ "Reflect", "construct" },
+ &[_]string{ "Reflect", "defineProperty" },
+ &[_]string{ "Reflect", "deleteProperty" },
+ &[_]string{ "Reflect", "get" },
+ &[_]string{ "Reflect", "getOwnPropertyDescriptor" },
+ &[_]string{ "Reflect", "getPrototypeOf" },
+ &[_]string{ "Reflect", "has" },
+ &[_]string{ "Reflect", "isExtensible" },
+ &[_]string{ "Reflect", "ownKeys" },
+ &[_]string{ "Reflect", "preventExtensions" },
+ &[_]string{ "Reflect", "set" },
+ &[_]string{ "Reflect", "setPrototypeOf" },
// Console method references are assumed to have no side effects
// https://developer.mozilla.org/en-US/docs/Web/API/console
@@ -208,122 +154,229 @@ pub const GlobalDefinesKey = [_][]const string{
&[_]string{ "console", "timeLog" },
&[_]string{ "console", "trace" },
&[_]string{ "console", "warn" },
+};
+
+const pure_global_identifier_define = defines.IdentifierDefine{
+ .valueless = true,
+ .can_be_removed_if_unused = true,
+ .value = .{ .e_undefined = .{} },
+};
+const js_ast = bun.JSAst;
+
+const identifiers = struct {
+ const nan_val = js_ast.E.Number{ .value = std.math.nan_f64 };
+
+ const inf_val = js_ast.E.Number{ .value = std.math.inf_f64 };
+
+ // Step 2. Swap in certain literal values because those can be constant folded
+ pub const @"undefined" = defines.IdentifierDefine{
+ .value = js_ast.Expr.Data{ .e_undefined = .{} },
+ .valueless = false,
+ .can_be_removed_if_unused = true,
+ };
+ pub const NaN = defines.IdentifierDefine{
+ .value = js_ast.Expr.Data{ .e_number = nan_val },
+ };
+ pub const Infinity = defines.IdentifierDefine{
+ .value = js_ast.Expr.Data{ .e_number = inf_val },
+ };
+};
+
+pub const pure_global_identifiers = .{
+ .{ "NaN", identifiers.NaN },
+ .{ "Infinity", identifiers.Infinity },
+ .{ "undefined", identifiers.undefined },
+
+ // These global identifiers should exist in all JavaScript environments. This
+ // deliberately omits "NaN", "Infinity", and "undefined" because these are
+ // treated as automatically-inlined constants instead of identifiers.
+ .{ "Array", pure_global_identifier_define },
+ .{ "Boolean", pure_global_identifier_define },
+ .{ "Function", pure_global_identifier_define },
+ .{ "Math", pure_global_identifier_define },
+ .{ "Number", pure_global_identifier_define },
+ .{ "Object", pure_global_identifier_define },
+ .{ "RegExp", pure_global_identifier_define },
+ .{ "String", pure_global_identifier_define },
+
+ // Other globals present in both the browser and node (except "eval" because
+ // it has special behavior)
+ .{ "AbortController", pure_global_identifier_define },
+ .{ "AbortSignal", pure_global_identifier_define },
+ .{ "AggregateError", pure_global_identifier_define },
+ .{ "ArrayBuffer", pure_global_identifier_define },
+ .{ "BigInt", pure_global_identifier_define },
+ .{ "DataView", pure_global_identifier_define },
+ .{ "Date", pure_global_identifier_define },
+ .{ "Error", pure_global_identifier_define },
+ .{ "EvalError", pure_global_identifier_define },
+ .{ "Event", pure_global_identifier_define },
+ .{ "EventTarget", pure_global_identifier_define },
+ .{ "Float32Array", pure_global_identifier_define },
+ .{ "Float64Array", pure_global_identifier_define },
+ .{ "Int16Array", pure_global_identifier_define },
+ .{ "Int32Array", pure_global_identifier_define },
+ .{ "Int8Array", pure_global_identifier_define },
+ .{ "Intl", pure_global_identifier_define },
+ .{ "JSON", pure_global_identifier_define },
+ .{ "Map", pure_global_identifier_define },
+ .{ "MessageChannel", pure_global_identifier_define },
+ .{ "MessageEvent", pure_global_identifier_define },
+ .{ "MessagePort", pure_global_identifier_define },
+ .{ "Promise", pure_global_identifier_define },
+ .{ "Proxy", pure_global_identifier_define },
+ .{ "RangeError", pure_global_identifier_define },
+ .{ "ReferenceError", pure_global_identifier_define },
+ .{ "Reflect", pure_global_identifier_define },
+ .{ "Set", pure_global_identifier_define },
+ .{ "Symbol", pure_global_identifier_define },
+ .{ "SyntaxError", pure_global_identifier_define },
+ .{ "TextDecoder", pure_global_identifier_define },
+ .{ "TextEncoder", pure_global_identifier_define },
+ .{ "TypeError", pure_global_identifier_define },
+ .{ "URIError", pure_global_identifier_define },
+ .{ "URL", pure_global_identifier_define },
+ .{ "URLSearchParams", pure_global_identifier_define },
+ .{ "Uint16Array", pure_global_identifier_define },
+ .{ "Uint32Array", pure_global_identifier_define },
+ .{ "Uint8Array", pure_global_identifier_define },
+ .{ "Uint8ClampedArray", pure_global_identifier_define },
+ .{ "WeakMap", pure_global_identifier_define },
+ .{ "WeakSet", pure_global_identifier_define },
+ .{ "WebAssembly", pure_global_identifier_define },
+ .{ "clearInterval", pure_global_identifier_define },
+ .{ "clearTimeout", pure_global_identifier_define },
+ .{ "console", pure_global_identifier_define },
+ .{ "decodeURI", pure_global_identifier_define },
+ .{ "decodeURIComponent", pure_global_identifier_define },
+ .{ "encodeURI", pure_global_identifier_define },
+ .{ "encodeURIComponent", pure_global_identifier_define },
+ .{ "escape", pure_global_identifier_define },
+ .{ "globalThis", pure_global_identifier_define },
+ .{ "isFinite", pure_global_identifier_define },
+ .{ "isNaN", pure_global_identifier_define },
+ .{ "parseFloat", pure_global_identifier_define },
+ .{ "parseInt", pure_global_identifier_define },
+ .{ "queueMicrotask", pure_global_identifier_define },
+ .{ "setInterval", pure_global_identifier_define },
+ .{ "setTimeout", pure_global_identifier_define },
+ .{ "unescape", pure_global_identifier_define },
// CSSOM APIs
- &[_]string{"CSSAnimation"},
- &[_]string{"CSSFontFaceRule"},
- &[_]string{"CSSImportRule"},
- &[_]string{"CSSKeyframeRule"},
- &[_]string{"CSSKeyframesRule"},
- &[_]string{"CSSMediaRule"},
- &[_]string{"CSSNamespaceRule"},
- &[_]string{"CSSPageRule"},
- &[_]string{"CSSRule"},
- &[_]string{"CSSRuleList"},
- &[_]string{"CSSStyleDeclaration"},
- &[_]string{"CSSStyleRule"},
- &[_]string{"CSSStyleSheet"},
- &[_]string{"CSSSupportsRule"},
- &[_]string{"CSSTransition"},
+ .{ "CSSAnimation", pure_global_identifier_define },
+ .{ "CSSFontFaceRule", pure_global_identifier_define },
+ .{ "CSSImportRule", pure_global_identifier_define },
+ .{ "CSSKeyframeRule", pure_global_identifier_define },
+ .{ "CSSKeyframesRule", pure_global_identifier_define },
+ .{ "CSSMediaRule", pure_global_identifier_define },
+ .{ "CSSNamespaceRule", pure_global_identifier_define },
+ .{ "CSSPageRule", pure_global_identifier_define },
+ .{ "CSSRule", pure_global_identifier_define },
+ .{ "CSSRuleList", pure_global_identifier_define },
+ .{ "CSSStyleDeclaration", pure_global_identifier_define },
+ .{ "CSSStyleRule", pure_global_identifier_define },
+ .{ "CSSStyleSheet", pure_global_identifier_define },
+ .{ "CSSSupportsRule", pure_global_identifier_define },
+ .{ "CSSTransition", pure_global_identifier_define },
// SVG DOM
- &[_]string{"SVGAElement"},
- &[_]string{"SVGAngle"},
- &[_]string{"SVGAnimateElement"},
- &[_]string{"SVGAnimateMotionElement"},
- &[_]string{"SVGAnimateTransformElement"},
- &[_]string{"SVGAnimatedAngle"},
- &[_]string{"SVGAnimatedBoolean"},
- &[_]string{"SVGAnimatedEnumeration"},
- &[_]string{"SVGAnimatedInteger"},
- &[_]string{"SVGAnimatedLength"},
- &[_]string{"SVGAnimatedLengthList"},
- &[_]string{"SVGAnimatedNumber"},
- &[_]string{"SVGAnimatedNumberList"},
- &[_]string{"SVGAnimatedPreserveAspectRatio"},
- &[_]string{"SVGAnimatedRect"},
- &[_]string{"SVGAnimatedString"},
- &[_]string{"SVGAnimatedTransformList"},
- &[_]string{"SVGAnimationElement"},
- &[_]string{"SVGCircleElement"},
- &[_]string{"SVGClipPathElement"},
- &[_]string{"SVGComponentTransferFunctionElement"},
- &[_]string{"SVGDefsElement"},
- &[_]string{"SVGDescElement"},
- &[_]string{"SVGElement"},
- &[_]string{"SVGEllipseElement"},
- &[_]string{"SVGFEBlendElement"},
- &[_]string{"SVGFEColorMatrixElement"},
- &[_]string{"SVGFEComponentTransferElement"},
- &[_]string{"SVGFECompositeElement"},
- &[_]string{"SVGFEConvolveMatrixElement"},
- &[_]string{"SVGFEDiffuseLightingElement"},
- &[_]string{"SVGFEDisplacementMapElement"},
- &[_]string{"SVGFEDistantLightElement"},
- &[_]string{"SVGFEDropShadowElement"},
- &[_]string{"SVGFEFloodElement"},
- &[_]string{"SVGFEFuncAElement"},
- &[_]string{"SVGFEFuncBElement"},
- &[_]string{"SVGFEFuncGElement"},
- &[_]string{"SVGFEFuncRElement"},
- &[_]string{"SVGFEGaussianBlurElement"},
- &[_]string{"SVGFEImageElement"},
- &[_]string{"SVGFEMergeElement"},
- &[_]string{"SVGFEMergeNodeElement"},
- &[_]string{"SVGFEMorphologyElement"},
- &[_]string{"SVGFEOffsetElement"},
- &[_]string{"SVGFEPointLightElement"},
- &[_]string{"SVGFESpecularLightingElement"},
- &[_]string{"SVGFESpotLightElement"},
- &[_]string{"SVGFETileElement"},
- &[_]string{"SVGFETurbulenceElement"},
- &[_]string{"SVGFilterElement"},
- &[_]string{"SVGForeignObjectElement"},
- &[_]string{"SVGGElement"},
- &[_]string{"SVGGeometryElement"},
- &[_]string{"SVGGradientElement"},
- &[_]string{"SVGGraphicsElement"},
- &[_]string{"SVGImageElement"},
- &[_]string{"SVGLength"},
- &[_]string{"SVGLengthList"},
- &[_]string{"SVGLineElement"},
- &[_]string{"SVGLinearGradientElement"},
- &[_]string{"SVGMPathElement"},
- &[_]string{"SVGMarkerElement"},
- &[_]string{"SVGMaskElement"},
- &[_]string{"SVGMatrix"},
- &[_]string{"SVGMetadataElement"},
- &[_]string{"SVGNumber"},
- &[_]string{"SVGNumberList"},
- &[_]string{"SVGPathElement"},
- &[_]string{"SVGPatternElement"},
- &[_]string{"SVGPoint"},
- &[_]string{"SVGPointList"},
- &[_]string{"SVGPolygonElement"},
- &[_]string{"SVGPolylineElement"},
- &[_]string{"SVGPreserveAspectRatio"},
- &[_]string{"SVGRadialGradientElement"},
- &[_]string{"SVGRect"},
- &[_]string{"SVGRectElement"},
- &[_]string{"SVGSVGElement"},
- &[_]string{"SVGScriptElement"},
- &[_]string{"SVGSetElement"},
- &[_]string{"SVGStopElement"},
- &[_]string{"SVGStringList"},
- &[_]string{"SVGStyleElement"},
- &[_]string{"SVGSwitchElement"},
- &[_]string{"SVGSymbolElement"},
- &[_]string{"SVGTSpanElement"},
- &[_]string{"SVGTextContentElement"},
- &[_]string{"SVGTextElement"},
- &[_]string{"SVGTextPathElement"},
- &[_]string{"SVGTextPositioningElement"},
- &[_]string{"SVGTitleElement"},
- &[_]string{"SVGTransform"},
- &[_]string{"SVGTransformList"},
- &[_]string{"SVGUnitTypes"},
- &[_]string{"SVGUseElement"},
- &[_]string{"SVGViewElement"},
+ .{ "SVGAElement", pure_global_identifier_define },
+ .{ "SVGAngle", pure_global_identifier_define },
+ .{ "SVGAnimateElement", pure_global_identifier_define },
+ .{ "SVGAnimateMotionElement", pure_global_identifier_define },
+ .{ "SVGAnimateTransformElement", pure_global_identifier_define },
+ .{ "SVGAnimatedAngle", pure_global_identifier_define },
+ .{ "SVGAnimatedBoolean", pure_global_identifier_define },
+ .{ "SVGAnimatedEnumeration", pure_global_identifier_define },
+ .{ "SVGAnimatedInteger", pure_global_identifier_define },
+ .{ "SVGAnimatedLength", pure_global_identifier_define },
+ .{ "SVGAnimatedLengthList", pure_global_identifier_define },
+ .{ "SVGAnimatedNumber", pure_global_identifier_define },
+ .{ "SVGAnimatedNumberList", pure_global_identifier_define },
+ .{ "SVGAnimatedPreserveAspectRatio", pure_global_identifier_define },
+ .{ "SVGAnimatedRect", pure_global_identifier_define },
+ .{ "SVGAnimatedString", pure_global_identifier_define },
+ .{ "SVGAnimatedTransformList", pure_global_identifier_define },
+ .{ "SVGAnimationElement", pure_global_identifier_define },
+ .{ "SVGCircleElement", pure_global_identifier_define },
+ .{ "SVGClipPathElement", pure_global_identifier_define },
+ .{ "SVGComponentTransferFunctionElement", pure_global_identifier_define },
+ .{ "SVGDefsElement", pure_global_identifier_define },
+ .{ "SVGDescElement", pure_global_identifier_define },
+ .{ "SVGElement", pure_global_identifier_define },
+ .{ "SVGEllipseElement", pure_global_identifier_define },
+ .{ "SVGFEBlendElement", pure_global_identifier_define },
+ .{ "SVGFEColorMatrixElement", pure_global_identifier_define },
+ .{ "SVGFEComponentTransferElement", pure_global_identifier_define },
+ .{ "SVGFECompositeElement", pure_global_identifier_define },
+ .{ "SVGFEConvolveMatrixElement", pure_global_identifier_define },
+ .{ "SVGFEDiffuseLightingElement", pure_global_identifier_define },
+ .{ "SVGFEDisplacementMapElement", pure_global_identifier_define },
+ .{ "SVGFEDistantLightElement", pure_global_identifier_define },
+ .{ "SVGFEDropShadowElement", pure_global_identifier_define },
+ .{ "SVGFEFloodElement", pure_global_identifier_define },
+ .{ "SVGFEFuncAElement", pure_global_identifier_define },
+ .{ "SVGFEFuncBElement", pure_global_identifier_define },
+ .{ "SVGFEFuncGElement", pure_global_identifier_define },
+ .{ "SVGFEFuncRElement", pure_global_identifier_define },
+ .{ "SVGFEGaussianBlurElement", pure_global_identifier_define },
+ .{ "SVGFEImageElement", pure_global_identifier_define },
+ .{ "SVGFEMergeElement", pure_global_identifier_define },
+ .{ "SVGFEMergeNodeElement", pure_global_identifier_define },
+ .{ "SVGFEMorphologyElement", pure_global_identifier_define },
+ .{ "SVGFEOffsetElement", pure_global_identifier_define },
+ .{ "SVGFEPointLightElement", pure_global_identifier_define },
+ .{ "SVGFESpecularLightingElement", pure_global_identifier_define },
+ .{ "SVGFESpotLightElement", pure_global_identifier_define },
+ .{ "SVGFETileElement", pure_global_identifier_define },
+ .{ "SVGFETurbulenceElement", pure_global_identifier_define },
+ .{ "SVGFilterElement", pure_global_identifier_define },
+ .{ "SVGForeignObjectElement", pure_global_identifier_define },
+ .{ "SVGGElement", pure_global_identifier_define },
+ .{ "SVGGeometryElement", pure_global_identifier_define },
+ .{ "SVGGradientElement", pure_global_identifier_define },
+ .{ "SVGGraphicsElement", pure_global_identifier_define },
+ .{ "SVGImageElement", pure_global_identifier_define },
+ .{ "SVGLength", pure_global_identifier_define },
+ .{ "SVGLengthList", pure_global_identifier_define },
+ .{ "SVGLineElement", pure_global_identifier_define },
+ .{ "SVGLinearGradientElement", pure_global_identifier_define },
+ .{ "SVGMPathElement", pure_global_identifier_define },
+ .{ "SVGMarkerElement", pure_global_identifier_define },
+ .{ "SVGMaskElement", pure_global_identifier_define },
+ .{ "SVGMatrix", pure_global_identifier_define },
+ .{ "SVGMetadataElement", pure_global_identifier_define },
+ .{ "SVGNumber", pure_global_identifier_define },
+ .{ "SVGNumberList", pure_global_identifier_define },
+ .{ "SVGPathElement", pure_global_identifier_define },
+ .{ "SVGPatternElement", pure_global_identifier_define },
+ .{ "SVGPoint", pure_global_identifier_define },
+ .{ "SVGPointList", pure_global_identifier_define },
+ .{ "SVGPolygonElement", pure_global_identifier_define },
+ .{ "SVGPolylineElement", pure_global_identifier_define },
+ .{ "SVGPreserveAspectRatio", pure_global_identifier_define },
+ .{ "SVGRadialGradientElement", pure_global_identifier_define },
+ .{ "SVGRect", pure_global_identifier_define },
+ .{ "SVGRectElement", pure_global_identifier_define },
+ .{ "SVGSVGElement", pure_global_identifier_define },
+ .{ "SVGScriptElement", pure_global_identifier_define },
+ .{ "SVGSetElement", pure_global_identifier_define },
+ .{ "SVGStopElement", pure_global_identifier_define },
+ .{ "SVGStringList", pure_global_identifier_define },
+ .{ "SVGStyleElement", pure_global_identifier_define },
+ .{ "SVGSwitchElement", pure_global_identifier_define },
+ .{ "SVGSymbolElement", pure_global_identifier_define },
+ .{ "SVGTSpanElement", pure_global_identifier_define },
+ .{ "SVGTextContentElement", pure_global_identifier_define },
+ .{ "SVGTextElement", pure_global_identifier_define },
+ .{ "SVGTextPathElement", pure_global_identifier_define },
+ .{ "SVGTextPositioningElement", pure_global_identifier_define },
+ .{ "SVGTitleElement", pure_global_identifier_define },
+ .{ "SVGTransform", pure_global_identifier_define },
+ .{ "SVGTransformList", pure_global_identifier_define },
+ .{ "SVGUnitTypes", pure_global_identifier_define },
+ .{ "SVGUseElement", pure_global_identifier_define },
+ .{ "SVGViewElement", pure_global_identifier_define },
// Other browser APIs
//
@@ -345,463 +398,465 @@ pub const GlobalDefinesKey = [_][]const string{
// - localStorage
// - sessionStorage
//
- &[_]string{"AnalyserNode"},
- &[_]string{"Animation"},
- &[_]string{"AnimationEffect"},
- &[_]string{"AnimationEvent"},
- &[_]string{"AnimationPlaybackEvent"},
- &[_]string{"AnimationTimeline"},
- &[_]string{"Attr"},
- &[_]string{"Audio"},
- &[_]string{"AudioBuffer"},
- &[_]string{"AudioBufferSourceNode"},
- &[_]string{"AudioDestinationNode"},
- &[_]string{"AudioListener"},
- &[_]string{"AudioNode"},
- &[_]string{"AudioParam"},
- &[_]string{"AudioProcessingEvent"},
- &[_]string{"AudioScheduledSourceNode"},
- &[_]string{"BarProp"},
- &[_]string{"BeforeUnloadEvent"},
- &[_]string{"BiquadFilterNode"},
- &[_]string{"Blob"},
- &[_]string{"BlobEvent"},
- &[_]string{"ByteLengthQueuingStrategy"},
- &[_]string{"CDATASection"},
- &[_]string{"CSS"},
- &[_]string{"CanvasGradient"},
- &[_]string{"CanvasPattern"},
- &[_]string{"CanvasRenderingContext2D"},
- &[_]string{"ChannelMergerNode"},
- &[_]string{"ChannelSplitterNode"},
- &[_]string{"CharacterData"},
- &[_]string{"ClipboardEvent"},
- &[_]string{"CloseEvent"},
- &[_]string{"Comment"},
- &[_]string{"CompositionEvent"},
- &[_]string{"ConvolverNode"},
- &[_]string{"CountQueuingStrategy"},
- &[_]string{"Crypto"},
- &[_]string{"CustomElementRegistry"},
- &[_]string{"CustomEvent"},
- &[_]string{"DOMException"},
- &[_]string{"DOMImplementation"},
- &[_]string{"DOMMatrix"},
- &[_]string{"DOMMatrixReadOnly"},
- &[_]string{"DOMParser"},
- &[_]string{"DOMPoint"},
- &[_]string{"DOMPointReadOnly"},
- &[_]string{"DOMQuad"},
- &[_]string{"DOMRect"},
- &[_]string{"DOMRectList"},
- &[_]string{"DOMRectReadOnly"},
- &[_]string{"DOMStringList"},
- &[_]string{"DOMStringMap"},
- &[_]string{"DOMTokenList"},
- &[_]string{"DataTransfer"},
- &[_]string{"DataTransferItem"},
- &[_]string{"DataTransferItemList"},
- &[_]string{"DelayNode"},
- &[_]string{"Document"},
- &[_]string{"DocumentFragment"},
- &[_]string{"DocumentTimeline"},
- &[_]string{"DocumentType"},
- &[_]string{"DragEvent"},
- &[_]string{"DynamicsCompressorNode"},
- &[_]string{"Element"},
- &[_]string{"ErrorEvent"},
- &[_]string{"EventSource"},
- &[_]string{"File"},
- &[_]string{"FileList"},
- &[_]string{"FileReader"},
- &[_]string{"FocusEvent"},
- &[_]string{"FontFace"},
- &[_]string{"FormData"},
- &[_]string{"GainNode"},
- &[_]string{"Gamepad"},
- &[_]string{"GamepadButton"},
- &[_]string{"GamepadEvent"},
- &[_]string{"Geolocation"},
- &[_]string{"GeolocationPositionError"},
- &[_]string{"HTMLAllCollection"},
- &[_]string{"HTMLAnchorElement"},
- &[_]string{"HTMLAreaElement"},
- &[_]string{"HTMLAudioElement"},
- &[_]string{"HTMLBRElement"},
- &[_]string{"HTMLBaseElement"},
- &[_]string{"HTMLBodyElement"},
- &[_]string{"HTMLButtonElement"},
- &[_]string{"HTMLCanvasElement"},
- &[_]string{"HTMLCollection"},
- &[_]string{"HTMLDListElement"},
- &[_]string{"HTMLDataElement"},
- &[_]string{"HTMLDataListElement"},
- &[_]string{"HTMLDetailsElement"},
- &[_]string{"HTMLDirectoryElement"},
- &[_]string{"HTMLDivElement"},
- &[_]string{"HTMLDocument"},
- &[_]string{"HTMLElement"},
- &[_]string{"HTMLEmbedElement"},
- &[_]string{"HTMLFieldSetElement"},
- &[_]string{"HTMLFontElement"},
- &[_]string{"HTMLFormControlsCollection"},
- &[_]string{"HTMLFormElement"},
- &[_]string{"HTMLFrameElement"},
- &[_]string{"HTMLFrameSetElement"},
- &[_]string{"HTMLHRElement"},
- &[_]string{"HTMLHeadElement"},
- &[_]string{"HTMLHeadingElement"},
- &[_]string{"HTMLHtmlElement"},
- &[_]string{"HTMLIFrameElement"},
- &[_]string{"HTMLImageElement"},
- &[_]string{"HTMLInputElement"},
- &[_]string{"HTMLLIElement"},
- &[_]string{"HTMLLabelElement"},
- &[_]string{"HTMLLegendElement"},
- &[_]string{"HTMLLinkElement"},
- &[_]string{"HTMLMapElement"},
- &[_]string{"HTMLMarqueeElement"},
- &[_]string{"HTMLMediaElement"},
- &[_]string{"HTMLMenuElement"},
- &[_]string{"HTMLMetaElement"},
- &[_]string{"HTMLMeterElement"},
- &[_]string{"HTMLModElement"},
- &[_]string{"HTMLOListElement"},
- &[_]string{"HTMLObjectElement"},
- &[_]string{"HTMLOptGroupElement"},
- &[_]string{"HTMLOptionElement"},
- &[_]string{"HTMLOptionsCollection"},
- &[_]string{"HTMLOutputElement"},
- &[_]string{"HTMLParagraphElement"},
- &[_]string{"HTMLParamElement"},
- &[_]string{"HTMLPictureElement"},
- &[_]string{"HTMLPreElement"},
- &[_]string{"HTMLProgressElement"},
- &[_]string{"HTMLQuoteElement"},
- &[_]string{"HTMLScriptElement"},
- &[_]string{"HTMLSelectElement"},
- &[_]string{"HTMLSlotElement"},
- &[_]string{"HTMLSourceElement"},
- &[_]string{"HTMLSpanElement"},
- &[_]string{"HTMLStyleElement"},
- &[_]string{"HTMLTableCaptionElement"},
- &[_]string{"HTMLTableCellElement"},
- &[_]string{"HTMLTableColElement"},
- &[_]string{"HTMLTableElement"},
- &[_]string{"HTMLTableRowElement"},
- &[_]string{"HTMLTableSectionElement"},
- &[_]string{"HTMLTemplateElement"},
- &[_]string{"HTMLTextAreaElement"},
- &[_]string{"HTMLTimeElement"},
- &[_]string{"HTMLTitleElement"},
- &[_]string{"HTMLTrackElement"},
- &[_]string{"HTMLUListElement"},
- &[_]string{"HTMLUnknownElement"},
- &[_]string{"HTMLVideoElement"},
- &[_]string{"HashChangeEvent"},
- &[_]string{"Headers"},
- &[_]string{"History"},
- &[_]string{"IDBCursor"},
- &[_]string{"IDBCursorWithValue"},
- &[_]string{"IDBDatabase"},
- &[_]string{"IDBFactory"},
- &[_]string{"IDBIndex"},
- &[_]string{"IDBKeyRange"},
- &[_]string{"IDBObjectStore"},
- &[_]string{"IDBOpenDBRequest"},
- &[_]string{"IDBRequest"},
- &[_]string{"IDBTransaction"},
- &[_]string{"IDBVersionChangeEvent"},
- &[_]string{"Image"},
- &[_]string{"ImageData"},
- &[_]string{"InputEvent"},
- &[_]string{"IntersectionObserver"},
- &[_]string{"IntersectionObserverEntry"},
- &[_]string{"KeyboardEvent"},
- &[_]string{"KeyframeEffect"},
- &[_]string{"Location"},
- &[_]string{"MediaCapabilities"},
- &[_]string{"MediaElementAudioSourceNode"},
- &[_]string{"MediaEncryptedEvent"},
- &[_]string{"MediaError"},
- &[_]string{"MediaList"},
- &[_]string{"MediaQueryList"},
- &[_]string{"MediaQueryListEvent"},
- &[_]string{"MediaRecorder"},
- &[_]string{"MediaSource"},
- &[_]string{"MediaStream"},
- &[_]string{"MediaStreamAudioDestinationNode"},
- &[_]string{"MediaStreamAudioSourceNode"},
- &[_]string{"MediaStreamTrack"},
- &[_]string{"MediaStreamTrackEvent"},
- &[_]string{"MimeType"},
- &[_]string{"MimeTypeArray"},
- &[_]string{"MouseEvent"},
- &[_]string{"MutationEvent"},
- &[_]string{"MutationObserver"},
- &[_]string{"MutationRecord"},
- &[_]string{"NamedNodeMap"},
- &[_]string{"Navigator"},
- &[_]string{"Node"},
- &[_]string{"NodeFilter"},
- &[_]string{"NodeIterator"},
- &[_]string{"NodeList"},
- &[_]string{"Notification"},
- &[_]string{"OfflineAudioCompletionEvent"},
- &[_]string{"Option"},
- &[_]string{"OscillatorNode"},
- &[_]string{"PageTransitionEvent"},
- &[_]string{"Path2D"},
- &[_]string{"Performance"},
- &[_]string{"PerformanceEntry"},
- &[_]string{"PerformanceMark"},
- &[_]string{"PerformanceMeasure"},
- &[_]string{"PerformanceNavigation"},
- &[_]string{"PerformanceObserver"},
- &[_]string{"PerformanceObserverEntryList"},
- &[_]string{"PerformanceResourceTiming"},
- &[_]string{"PerformanceTiming"},
- &[_]string{"PeriodicWave"},
- &[_]string{"Plugin"},
- &[_]string{"PluginArray"},
- &[_]string{"PointerEvent"},
- &[_]string{"PopStateEvent"},
- &[_]string{"ProcessingInstruction"},
- &[_]string{"ProgressEvent"},
- &[_]string{"PromiseRejectionEvent"},
- &[_]string{"RTCCertificate"},
- &[_]string{"RTCDTMFSender"},
- &[_]string{"RTCDTMFToneChangeEvent"},
- &[_]string{"RTCDataChannel"},
- &[_]string{"RTCDataChannelEvent"},
- &[_]string{"RTCIceCandidate"},
- &[_]string{"RTCPeerConnection"},
- &[_]string{"RTCPeerConnectionIceEvent"},
- &[_]string{"RTCRtpReceiver"},
- &[_]string{"RTCRtpSender"},
- &[_]string{"RTCRtpTransceiver"},
- &[_]string{"RTCSessionDescription"},
- &[_]string{"RTCStatsReport"},
- &[_]string{"RTCTrackEvent"},
- &[_]string{"RadioNodeList"},
- &[_]string{"Range"},
- &[_]string{"ReadableStream"},
- &[_]string{"Request"},
- &[_]string{"ResizeObserver"},
- &[_]string{"ResizeObserverEntry"},
- &[_]string{"Response"},
- &[_]string{"Screen"},
- &[_]string{"ScriptProcessorNode"},
- &[_]string{"SecurityPolicyViolationEvent"},
- &[_]string{"Selection"},
- &[_]string{"ShadowRoot"},
- &[_]string{"SourceBuffer"},
- &[_]string{"SourceBufferList"},
- &[_]string{"SpeechSynthesisEvent"},
- &[_]string{"SpeechSynthesisUtterance"},
- &[_]string{"StaticRange"},
- &[_]string{"Storage"},
- &[_]string{"StorageEvent"},
- &[_]string{"StyleSheet"},
- &[_]string{"StyleSheetList"},
- &[_]string{"Text"},
- &[_]string{"TextMetrics"},
- &[_]string{"TextTrack"},
- &[_]string{"TextTrackCue"},
- &[_]string{"TextTrackCueList"},
- &[_]string{"TextTrackList"},
- &[_]string{"TimeRanges"},
- &[_]string{"TrackEvent"},
- &[_]string{"TransitionEvent"},
- &[_]string{"TreeWalker"},
- &[_]string{"UIEvent"},
- &[_]string{"VTTCue"},
- &[_]string{"ValidityState"},
- &[_]string{"VisualViewport"},
- &[_]string{"WaveShaperNode"},
- &[_]string{"WebGLActiveInfo"},
- &[_]string{"WebGLBuffer"},
- &[_]string{"WebGLContextEvent"},
- &[_]string{"WebGLFramebuffer"},
- &[_]string{"WebGLProgram"},
- &[_]string{"WebGLQuery"},
- &[_]string{"WebGLRenderbuffer"},
- &[_]string{"WebGLRenderingContext"},
- &[_]string{"WebGLSampler"},
- &[_]string{"WebGLShader"},
- &[_]string{"WebGLShaderPrecisionFormat"},
- &[_]string{"WebGLSync"},
- &[_]string{"WebGLTexture"},
- &[_]string{"WebGLUniformLocation"},
- &[_]string{"WebKitCSSMatrix"},
- &[_]string{"WebSocket"},
- &[_]string{"WheelEvent"},
- &[_]string{"Window"},
- &[_]string{"Worker"},
- &[_]string{"XMLDocument"},
- &[_]string{"XMLHttpRequest"},
- &[_]string{"XMLHttpRequestEventTarget"},
- &[_]string{"XMLHttpRequestUpload"},
- &[_]string{"XMLSerializer"},
- &[_]string{"XPathEvaluator"},
- &[_]string{"XPathExpression"},
- &[_]string{"XPathResult"},
- &[_]string{"XSLTProcessor"},
- &[_]string{"alert"},
- &[_]string{"atob"},
- &[_]string{"blur"},
- &[_]string{"btoa"},
- &[_]string{"cancelAnimationFrame"},
- &[_]string{"captureEvents"},
- &[_]string{"close"},
- &[_]string{"closed"},
- &[_]string{"confirm"},
- &[_]string{"customElements"},
- &[_]string{"devicePixelRatio"},
- &[_]string{"document"},
- &[_]string{"event"},
- &[_]string{"fetch"},
- &[_]string{"find"},
- &[_]string{"focus"},
- &[_]string{"frameElement"},
- &[_]string{"frames"},
- &[_]string{"getComputedStyle"},
- &[_]string{"getSelection"},
- &[_]string{"history"},
- &[_]string{"indexedDB"},
- &[_]string{"isSecureContext"},
- &[_]string{"length"},
- &[_]string{"location"},
- &[_]string{"locationbar"},
- &[_]string{"matchMedia"},
- &[_]string{"menubar"},
- &[_]string{"moveBy"},
- &[_]string{"moveTo"},
- &[_]string{"name"},
- &[_]string{"navigator"},
- &[_]string{"onabort"},
- &[_]string{"onafterprint"},
- &[_]string{"onanimationend"},
- &[_]string{"onanimationiteration"},
- &[_]string{"onanimationstart"},
- &[_]string{"onbeforeprint"},
- &[_]string{"onbeforeunload"},
- &[_]string{"onblur"},
- &[_]string{"oncanplay"},
- &[_]string{"oncanplaythrough"},
- &[_]string{"onchange"},
- &[_]string{"onclick"},
- &[_]string{"oncontextmenu"},
- &[_]string{"oncuechange"},
- &[_]string{"ondblclick"},
- &[_]string{"ondrag"},
- &[_]string{"ondragend"},
- &[_]string{"ondragenter"},
- &[_]string{"ondragleave"},
- &[_]string{"ondragover"},
- &[_]string{"ondragstart"},
- &[_]string{"ondrop"},
- &[_]string{"ondurationchange"},
- &[_]string{"onemptied"},
- &[_]string{"onended"},
- &[_]string{"onerror"},
- &[_]string{"onfocus"},
- &[_]string{"ongotpointercapture"},
- &[_]string{"onhashchange"},
- &[_]string{"oninput"},
- &[_]string{"oninvalid"},
- &[_]string{"onkeydown"},
- &[_]string{"onkeypress"},
- &[_]string{"onkeyup"},
- &[_]string{"onlanguagechange"},
- &[_]string{"onload"},
- &[_]string{"onloadeddata"},
- &[_]string{"onloadedmetadata"},
- &[_]string{"onloadstart"},
- &[_]string{"onlostpointercapture"},
- &[_]string{"onmessage"},
- &[_]string{"onmousedown"},
- &[_]string{"onmouseenter"},
- &[_]string{"onmouseleave"},
- &[_]string{"onmousemove"},
- &[_]string{"onmouseout"},
- &[_]string{"onmouseover"},
- &[_]string{"onmouseup"},
- &[_]string{"onoffline"},
- &[_]string{"ononline"},
- &[_]string{"onpagehide"},
- &[_]string{"onpageshow"},
- &[_]string{"onpause"},
- &[_]string{"onplay"},
- &[_]string{"onplaying"},
- &[_]string{"onpointercancel"},
- &[_]string{"onpointerdown"},
- &[_]string{"onpointerenter"},
- &[_]string{"onpointerleave"},
- &[_]string{"onpointermove"},
- &[_]string{"onpointerout"},
- &[_]string{"onpointerover"},
- &[_]string{"onpointerup"},
- &[_]string{"onpopstate"},
- &[_]string{"onprogress"},
- &[_]string{"onratechange"},
- &[_]string{"onrejectionhandled"},
- &[_]string{"onreset"},
- &[_]string{"onresize"},
- &[_]string{"onscroll"},
- &[_]string{"onseeked"},
- &[_]string{"onseeking"},
- &[_]string{"onselect"},
- &[_]string{"onstalled"},
- &[_]string{"onstorage"},
- &[_]string{"onsubmit"},
- &[_]string{"onsuspend"},
- &[_]string{"ontimeupdate"},
- &[_]string{"ontoggle"},
- &[_]string{"ontransitioncancel"},
- &[_]string{"ontransitionend"},
- &[_]string{"ontransitionrun"},
- &[_]string{"ontransitionstart"},
- &[_]string{"onunhandledrejection"},
- &[_]string{"onunload"},
- &[_]string{"onvolumechange"},
- &[_]string{"onwaiting"},
- &[_]string{"onwebkitanimationend"},
- &[_]string{"onwebkitanimationiteration"},
- &[_]string{"onwebkitanimationstart"},
- &[_]string{"onwebkittransitionend"},
- &[_]string{"onwheel"},
- &[_]string{"open"},
- &[_]string{"opener"},
- &[_]string{"origin"},
- &[_]string{"outerHeight"},
- &[_]string{"outerWidth"},
- &[_]string{"parent"},
- &[_]string{"performance"},
- &[_]string{"personalbar"},
- &[_]string{"postMessage"},
- &[_]string{"print"},
- &[_]string{"prompt"},
- &[_]string{"releaseEvents"},
- &[_]string{"requestAnimationFrame"},
- &[_]string{"resizeBy"},
- &[_]string{"resizeTo"},
- &[_]string{"screen"},
- &[_]string{"screenLeft"},
- &[_]string{"screenTop"},
- &[_]string{"screenX"},
- &[_]string{"screenY"},
- &[_]string{"scroll"},
- &[_]string{"scrollBy"},
- &[_]string{"scrollTo"},
- &[_]string{"scrollbars"},
- &[_]string{"self"},
- &[_]string{"speechSynthesis"},
- &[_]string{"status"},
- &[_]string{"statusbar"},
- &[_]string{"stop"},
- &[_]string{"toolbar"},
- &[_]string{"top"},
- &[_]string{"webkitURL"},
- &[_]string{"window"},
+ .{ "AnalyserNode", pure_global_identifier_define },
+ .{ "Animation", pure_global_identifier_define },
+ .{ "AnimationEffect", pure_global_identifier_define },
+ .{ "AnimationEvent", pure_global_identifier_define },
+ .{ "AnimationPlaybackEvent", pure_global_identifier_define },
+ .{ "AnimationTimeline", pure_global_identifier_define },
+ .{ "Attr", pure_global_identifier_define },
+ .{ "Audio", pure_global_identifier_define },
+ .{ "AudioBuffer", pure_global_identifier_define },
+ .{ "AudioBufferSourceNode", pure_global_identifier_define },
+ .{ "AudioDestinationNode", pure_global_identifier_define },
+ .{ "AudioListener", pure_global_identifier_define },
+ .{ "AudioNode", pure_global_identifier_define },
+ .{ "AudioParam", pure_global_identifier_define },
+ .{ "AudioProcessingEvent", pure_global_identifier_define },
+ .{ "AudioScheduledSourceNode", pure_global_identifier_define },
+ .{ "BarProp", pure_global_identifier_define },
+ .{ "BeforeUnloadEvent", pure_global_identifier_define },
+ .{ "BiquadFilterNode", pure_global_identifier_define },
+ .{ "Blob", pure_global_identifier_define },
+ .{ "BlobEvent", pure_global_identifier_define },
+ .{ "ByteLengthQueuingStrategy", pure_global_identifier_define },
+ .{ "CDATASection", pure_global_identifier_define },
+ .{ "CSS", pure_global_identifier_define },
+ .{ "CanvasGradient", pure_global_identifier_define },
+ .{ "CanvasPattern", pure_global_identifier_define },
+ .{ "CanvasRenderingContext2D", pure_global_identifier_define },
+ .{ "ChannelMergerNode", pure_global_identifier_define },
+ .{ "ChannelSplitterNode", pure_global_identifier_define },
+ .{ "CharacterData", pure_global_identifier_define },
+ .{ "ClipboardEvent", pure_global_identifier_define },
+ .{ "CloseEvent", pure_global_identifier_define },
+ .{ "Comment", pure_global_identifier_define },
+ .{ "CompositionEvent", pure_global_identifier_define },
+ .{ "ConvolverNode", pure_global_identifier_define },
+ .{ "CountQueuingStrategy", pure_global_identifier_define },
+ .{ "Crypto", pure_global_identifier_define },
+ .{ "CustomElementRegistry", pure_global_identifier_define },
+ .{ "CustomEvent", pure_global_identifier_define },
+ .{ "DOMException", pure_global_identifier_define },
+ .{ "DOMImplementation", pure_global_identifier_define },
+ .{ "DOMMatrix", pure_global_identifier_define },
+ .{ "DOMMatrixReadOnly", pure_global_identifier_define },
+ .{ "DOMParser", pure_global_identifier_define },
+ .{ "DOMPoint", pure_global_identifier_define },
+ .{ "DOMPointReadOnly", pure_global_identifier_define },
+ .{ "DOMQuad", pure_global_identifier_define },
+ .{ "DOMRect", pure_global_identifier_define },
+ .{ "DOMRectList", pure_global_identifier_define },
+ .{ "DOMRectReadOnly", pure_global_identifier_define },
+ .{ "DOMStringList", pure_global_identifier_define },
+ .{ "DOMStringMap", pure_global_identifier_define },
+ .{ "DOMTokenList", pure_global_identifier_define },
+ .{ "DataTransfer", pure_global_identifier_define },
+ .{ "DataTransferItem", pure_global_identifier_define },
+ .{ "DataTransferItemList", pure_global_identifier_define },
+ .{ "DelayNode", pure_global_identifier_define },
+ .{ "Document", pure_global_identifier_define },
+ .{ "DocumentFragment", pure_global_identifier_define },
+ .{ "DocumentTimeline", pure_global_identifier_define },
+ .{ "DocumentType", pure_global_identifier_define },
+ .{ "DragEvent", pure_global_identifier_define },
+ .{ "DynamicsCompressorNode", pure_global_identifier_define },
+ .{ "Element", pure_global_identifier_define },
+ .{ "ErrorEvent", pure_global_identifier_define },
+ .{ "EventSource", pure_global_identifier_define },
+ .{ "File", pure_global_identifier_define },
+ .{ "FileList", pure_global_identifier_define },
+ .{ "FileReader", pure_global_identifier_define },
+ .{ "FocusEvent", pure_global_identifier_define },
+ .{ "FontFace", pure_global_identifier_define },
+ .{ "FormData", pure_global_identifier_define },
+ .{ "GainNode", pure_global_identifier_define },
+ .{ "Gamepad", pure_global_identifier_define },
+ .{ "GamepadButton", pure_global_identifier_define },
+ .{ "GamepadEvent", pure_global_identifier_define },
+ .{ "Geolocation", pure_global_identifier_define },
+ .{ "GeolocationPositionError", pure_global_identifier_define },
+ .{ "HTMLAllCollection", pure_global_identifier_define },
+ .{ "HTMLAnchorElement", pure_global_identifier_define },
+ .{ "HTMLAreaElement", pure_global_identifier_define },
+ .{ "HTMLAudioElement", pure_global_identifier_define },
+ .{ "HTMLBRElement", pure_global_identifier_define },
+ .{ "HTMLBaseElement", pure_global_identifier_define },
+ .{ "HTMLBodyElement", pure_global_identifier_define },
+ .{ "HTMLButtonElement", pure_global_identifier_define },
+ .{ "HTMLCanvasElement", pure_global_identifier_define },
+ .{ "HTMLCollection", pure_global_identifier_define },
+ .{ "HTMLDListElement", pure_global_identifier_define },
+ .{ "HTMLDataElement", pure_global_identifier_define },
+ .{ "HTMLDataListElement", pure_global_identifier_define },
+ .{ "HTMLDetailsElement", pure_global_identifier_define },
+ .{ "HTMLDirectoryElement", pure_global_identifier_define },
+ .{ "HTMLDivElement", pure_global_identifier_define },
+ .{ "HTMLDocument", pure_global_identifier_define },
+ .{ "HTMLElement", pure_global_identifier_define },
+ .{ "HTMLEmbedElement", pure_global_identifier_define },
+ .{ "HTMLFieldSetElement", pure_global_identifier_define },
+ .{ "HTMLFontElement", pure_global_identifier_define },
+ .{ "HTMLFormControlsCollection", pure_global_identifier_define },
+ .{ "HTMLFormElement", pure_global_identifier_define },
+ .{ "HTMLFrameElement", pure_global_identifier_define },
+ .{ "HTMLFrameSetElement", pure_global_identifier_define },
+ .{ "HTMLHRElement", pure_global_identifier_define },
+ .{ "HTMLHeadElement", pure_global_identifier_define },
+ .{ "HTMLHeadingElement", pure_global_identifier_define },
+ .{ "HTMLHtmlElement", pure_global_identifier_define },
+ .{ "HTMLIFrameElement", pure_global_identifier_define },
+ .{ "HTMLImageElement", pure_global_identifier_define },
+ .{ "HTMLInputElement", pure_global_identifier_define },
+ .{ "HTMLLIElement", pure_global_identifier_define },
+ .{ "HTMLLabelElement", pure_global_identifier_define },
+ .{ "HTMLLegendElement", pure_global_identifier_define },
+ .{ "HTMLLinkElement", pure_global_identifier_define },
+ .{ "HTMLMapElement", pure_global_identifier_define },
+ .{ "HTMLMarqueeElement", pure_global_identifier_define },
+ .{ "HTMLMediaElement", pure_global_identifier_define },
+ .{ "HTMLMenuElement", pure_global_identifier_define },
+ .{ "HTMLMetaElement", pure_global_identifier_define },
+ .{ "HTMLMeterElement", pure_global_identifier_define },
+ .{ "HTMLModElement", pure_global_identifier_define },
+ .{ "HTMLOListElement", pure_global_identifier_define },
+ .{ "HTMLObjectElement", pure_global_identifier_define },
+ .{ "HTMLOptGroupElement", pure_global_identifier_define },
+ .{ "HTMLOptionElement", pure_global_identifier_define },
+ .{ "HTMLOptionsCollection", pure_global_identifier_define },
+ .{ "HTMLOutputElement", pure_global_identifier_define },
+ .{ "HTMLParagraphElement", pure_global_identifier_define },
+ .{ "HTMLParamElement", pure_global_identifier_define },
+ .{ "HTMLPictureElement", pure_global_identifier_define },
+ .{ "HTMLPreElement", pure_global_identifier_define },
+ .{ "HTMLProgressElement", pure_global_identifier_define },
+ .{ "HTMLQuoteElement", pure_global_identifier_define },
+ .{ "HTMLScriptElement", pure_global_identifier_define },
+ .{ "HTMLSelectElement", pure_global_identifier_define },
+ .{ "HTMLSlotElement", pure_global_identifier_define },
+ .{ "HTMLSourceElement", pure_global_identifier_define },
+ .{ "HTMLSpanElement", pure_global_identifier_define },
+ .{ "HTMLStyleElement", pure_global_identifier_define },
+ .{ "HTMLTableCaptionElement", pure_global_identifier_define },
+ .{ "HTMLTableCellElement", pure_global_identifier_define },
+ .{ "HTMLTableColElement", pure_global_identifier_define },
+ .{ "HTMLTableElement", pure_global_identifier_define },
+ .{ "HTMLTableRowElement", pure_global_identifier_define },
+ .{ "HTMLTableSectionElement", pure_global_identifier_define },
+ .{ "HTMLTemplateElement", pure_global_identifier_define },
+ .{ "HTMLTextAreaElement", pure_global_identifier_define },
+ .{ "HTMLTimeElement", pure_global_identifier_define },
+ .{ "HTMLTitleElement", pure_global_identifier_define },
+ .{ "HTMLTrackElement", pure_global_identifier_define },
+ .{ "HTMLUListElement", pure_global_identifier_define },
+ .{ "HTMLUnknownElement", pure_global_identifier_define },
+ .{ "HTMLVideoElement", pure_global_identifier_define },
+ .{ "HashChangeEvent", pure_global_identifier_define },
+ .{ "Headers", pure_global_identifier_define },
+ .{ "History", pure_global_identifier_define },
+ .{ "IDBCursor", pure_global_identifier_define },
+ .{ "IDBCursorWithValue", pure_global_identifier_define },
+ .{ "IDBDatabase", pure_global_identifier_define },
+ .{ "IDBFactory", pure_global_identifier_define },
+ .{ "IDBIndex", pure_global_identifier_define },
+ .{ "IDBKeyRange", pure_global_identifier_define },
+ .{ "IDBObjectStore", pure_global_identifier_define },
+ .{ "IDBOpenDBRequest", pure_global_identifier_define },
+ .{ "IDBRequest", pure_global_identifier_define },
+ .{ "IDBTransaction", pure_global_identifier_define },
+ .{ "IDBVersionChangeEvent", pure_global_identifier_define },
+ .{ "Image", pure_global_identifier_define },
+ .{ "ImageData", pure_global_identifier_define },
+ .{ "InputEvent", pure_global_identifier_define },
+ .{ "IntersectionObserver", pure_global_identifier_define },
+ .{ "IntersectionObserverEntry", pure_global_identifier_define },
+ .{ "KeyboardEvent", pure_global_identifier_define },
+ .{ "KeyframeEffect", pure_global_identifier_define },
+ .{ "Location", pure_global_identifier_define },
+ .{ "MediaCapabilities", pure_global_identifier_define },
+ .{ "MediaElementAudioSourceNode", pure_global_identifier_define },
+ .{ "MediaEncryptedEvent", pure_global_identifier_define },
+ .{ "MediaError", pure_global_identifier_define },
+ .{ "MediaList", pure_global_identifier_define },
+ .{ "MediaQueryList", pure_global_identifier_define },
+ .{ "MediaQueryListEvent", pure_global_identifier_define },
+ .{ "MediaRecorder", pure_global_identifier_define },
+ .{ "MediaSource", pure_global_identifier_define },
+ .{ "MediaStream", pure_global_identifier_define },
+ .{ "MediaStreamAudioDestinationNode", pure_global_identifier_define },
+ .{ "MediaStreamAudioSourceNode", pure_global_identifier_define },
+ .{ "MediaStreamTrack", pure_global_identifier_define },
+ .{ "MediaStreamTrackEvent", pure_global_identifier_define },
+ .{ "MimeType", pure_global_identifier_define },
+ .{ "MimeTypeArray", pure_global_identifier_define },
+ .{ "MouseEvent", pure_global_identifier_define },
+ .{ "MutationEvent", pure_global_identifier_define },
+ .{ "MutationObserver", pure_global_identifier_define },
+ .{ "MutationRecord", pure_global_identifier_define },
+ .{ "NamedNodeMap", pure_global_identifier_define },
+ .{ "Navigator", pure_global_identifier_define },
+ .{ "Node", pure_global_identifier_define },
+ .{ "NodeFilter", pure_global_identifier_define },
+ .{ "NodeIterator", pure_global_identifier_define },
+ .{ "NodeList", pure_global_identifier_define },
+ .{ "Notification", pure_global_identifier_define },
+ .{ "OfflineAudioCompletionEvent", pure_global_identifier_define },
+ .{ "Option", pure_global_identifier_define },
+ .{ "OscillatorNode", pure_global_identifier_define },
+ .{ "PageTransitionEvent", pure_global_identifier_define },
+ .{ "Path2D", pure_global_identifier_define },
+ .{ "Performance", pure_global_identifier_define },
+ .{ "PerformanceEntry", pure_global_identifier_define },
+ .{ "PerformanceMark", pure_global_identifier_define },
+ .{ "PerformanceMeasure", pure_global_identifier_define },
+ .{ "PerformanceNavigation", pure_global_identifier_define },
+ .{ "PerformanceObserver", pure_global_identifier_define },
+ .{ "PerformanceObserverEntryList", pure_global_identifier_define },
+ .{ "PerformanceResourceTiming", pure_global_identifier_define },
+ .{ "PerformanceTiming", pure_global_identifier_define },
+ .{ "PeriodicWave", pure_global_identifier_define },
+ .{ "Plugin", pure_global_identifier_define },
+ .{ "PluginArray", pure_global_identifier_define },
+ .{ "PointerEvent", pure_global_identifier_define },
+ .{ "PopStateEvent", pure_global_identifier_define },
+ .{ "ProcessingInstruction", pure_global_identifier_define },
+ .{ "ProgressEvent", pure_global_identifier_define },
+ .{ "PromiseRejectionEvent", pure_global_identifier_define },
+ .{ "RTCCertificate", pure_global_identifier_define },
+ .{ "RTCDTMFSender", pure_global_identifier_define },
+ .{ "RTCDTMFToneChangeEvent", pure_global_identifier_define },
+ .{ "RTCDataChannel", pure_global_identifier_define },
+ .{ "RTCDataChannelEvent", pure_global_identifier_define },
+ .{ "RTCIceCandidate", pure_global_identifier_define },
+ .{ "RTCPeerConnection", pure_global_identifier_define },
+ .{ "RTCPeerConnectionIceEvent", pure_global_identifier_define },
+ .{ "RTCRtpReceiver", pure_global_identifier_define },
+ .{ "RTCRtpSender", pure_global_identifier_define },
+ .{ "RTCRtpTransceiver", pure_global_identifier_define },
+ .{ "RTCSessionDescription", pure_global_identifier_define },
+ .{ "RTCStatsReport", pure_global_identifier_define },
+ .{ "RTCTrackEvent", pure_global_identifier_define },
+ .{ "RadioNodeList", pure_global_identifier_define },
+ .{ "Range", pure_global_identifier_define },
+ .{ "ReadableStream", pure_global_identifier_define },
+ .{ "Request", pure_global_identifier_define },
+ .{ "ResizeObserver", pure_global_identifier_define },
+ .{ "ResizeObserverEntry", pure_global_identifier_define },
+ .{ "Response", pure_global_identifier_define },
+ .{ "Screen", pure_global_identifier_define },
+ .{ "ScriptProcessorNode", pure_global_identifier_define },
+ .{ "SecurityPolicyViolationEvent", pure_global_identifier_define },
+ .{ "Selection", pure_global_identifier_define },
+ .{ "ShadowRoot", pure_global_identifier_define },
+ .{ "SourceBuffer", pure_global_identifier_define },
+ .{ "SourceBufferList", pure_global_identifier_define },
+ .{ "SpeechSynthesisEvent", pure_global_identifier_define },
+ .{ "SpeechSynthesisUtterance", pure_global_identifier_define },
+ .{ "StaticRange", pure_global_identifier_define },
+ .{ "Storage", pure_global_identifier_define },
+ .{ "StorageEvent", pure_global_identifier_define },
+ .{ "StyleSheet", pure_global_identifier_define },
+ .{ "StyleSheetList", pure_global_identifier_define },
+ .{ "Text", pure_global_identifier_define },
+ .{ "TextMetrics", pure_global_identifier_define },
+ .{ "TextTrack", pure_global_identifier_define },
+ .{ "TextTrackCue", pure_global_identifier_define },
+ .{ "TextTrackCueList", pure_global_identifier_define },
+ .{ "TextTrackList", pure_global_identifier_define },
+ .{ "TimeRanges", pure_global_identifier_define },
+ .{ "TrackEvent", pure_global_identifier_define },
+ .{ "TransitionEvent", pure_global_identifier_define },
+ .{ "TreeWalker", pure_global_identifier_define },
+ .{ "UIEvent", pure_global_identifier_define },
+ .{ "VTTCue", pure_global_identifier_define },
+ .{ "ValidityState", pure_global_identifier_define },
+ .{ "VisualViewport", pure_global_identifier_define },
+ .{ "WaveShaperNode", pure_global_identifier_define },
+ .{ "WebGLActiveInfo", pure_global_identifier_define },
+ .{ "WebGLBuffer", pure_global_identifier_define },
+ .{ "WebGLContextEvent", pure_global_identifier_define },
+ .{ "WebGLFramebuffer", pure_global_identifier_define },
+ .{ "WebGLProgram", pure_global_identifier_define },
+ .{ "WebGLQuery", pure_global_identifier_define },
+ .{ "WebGLRenderbuffer", pure_global_identifier_define },
+ .{ "WebGLRenderingContext", pure_global_identifier_define },
+ .{ "WebGLSampler", pure_global_identifier_define },
+ .{ "WebGLShader", pure_global_identifier_define },
+ .{ "WebGLShaderPrecisionFormat", pure_global_identifier_define },
+ .{ "WebGLSync", pure_global_identifier_define },
+ .{ "WebGLTexture", pure_global_identifier_define },
+ .{ "WebGLUniformLocation", pure_global_identifier_define },
+ .{ "WebKitCSSMatrix", pure_global_identifier_define },
+ .{ "WebSocket", pure_global_identifier_define },
+ .{ "WheelEvent", pure_global_identifier_define },
+ .{ "Window", pure_global_identifier_define },
+ .{ "Worker", pure_global_identifier_define },
+ .{ "XMLDocument", pure_global_identifier_define },
+ .{ "XMLHttpRequest", pure_global_identifier_define },
+ .{ "XMLHttpRequestEventTarget", pure_global_identifier_define },
+ .{ "XMLHttpRequestUpload", pure_global_identifier_define },
+ .{ "XMLSerializer", pure_global_identifier_define },
+ .{ "XPathEvaluator", pure_global_identifier_define },
+ .{ "XPathExpression", pure_global_identifier_define },
+ .{ "XPathResult", pure_global_identifier_define },
+ .{ "XSLTProcessor", pure_global_identifier_define },
+ .{ "alert", pure_global_identifier_define },
+ .{ "atob", pure_global_identifier_define },
+ .{ "blur", pure_global_identifier_define },
+ .{ "btoa", pure_global_identifier_define },
+ .{ "cancelAnimationFrame", pure_global_identifier_define },
+ .{ "captureEvents", pure_global_identifier_define },
+ .{ "close", pure_global_identifier_define },
+ .{ "closed", pure_global_identifier_define },
+ .{ "confirm", pure_global_identifier_define },
+ .{ "customElements", pure_global_identifier_define },
+ .{ "devicePixelRatio", pure_global_identifier_define },
+ .{ "document", pure_global_identifier_define },
+ .{ "event", pure_global_identifier_define },
+ .{ "fetch", pure_global_identifier_define },
+ .{ "find", pure_global_identifier_define },
+ .{ "focus", pure_global_identifier_define },
+ .{ "frameElement", pure_global_identifier_define },
+ .{ "frames", pure_global_identifier_define },
+ .{ "getComputedStyle", pure_global_identifier_define },
+ .{ "getSelection", pure_global_identifier_define },
+ .{ "history", pure_global_identifier_define },
+ .{ "indexedDB", pure_global_identifier_define },
+ .{ "isSecureContext", pure_global_identifier_define },
+ .{ "length", pure_global_identifier_define },
+ .{ "location", pure_global_identifier_define },
+ .{ "locationbar", pure_global_identifier_define },
+ .{ "matchMedia", pure_global_identifier_define },
+ .{ "menubar", pure_global_identifier_define },
+ .{ "moveBy", pure_global_identifier_define },
+ .{ "moveTo", pure_global_identifier_define },
+ .{ "name", pure_global_identifier_define },
+ .{ "navigator", pure_global_identifier_define },
+ .{ "onabort", pure_global_identifier_define },
+ .{ "onafterprint", pure_global_identifier_define },
+ .{ "onanimationend", pure_global_identifier_define },
+ .{ "onanimationiteration", pure_global_identifier_define },
+ .{ "onanimationstart", pure_global_identifier_define },
+ .{ "onbeforeprint", pure_global_identifier_define },
+ .{ "onbeforeunload", pure_global_identifier_define },
+ .{ "onblur", pure_global_identifier_define },
+ .{ "oncanplay", pure_global_identifier_define },
+ .{ "oncanplaythrough", pure_global_identifier_define },
+ .{ "onchange", pure_global_identifier_define },
+ .{ "onclick", pure_global_identifier_define },
+ .{ "oncontextmenu", pure_global_identifier_define },
+ .{ "oncuechange", pure_global_identifier_define },
+ .{ "ondblclick", pure_global_identifier_define },
+ .{ "ondrag", pure_global_identifier_define },
+ .{ "ondragend", pure_global_identifier_define },
+ .{ "ondragenter", pure_global_identifier_define },
+ .{ "ondragleave", pure_global_identifier_define },
+ .{ "ondragover", pure_global_identifier_define },
+ .{ "ondragstart", pure_global_identifier_define },
+ .{ "ondrop", pure_global_identifier_define },
+ .{ "ondurationchange", pure_global_identifier_define },
+ .{ "onemptied", pure_global_identifier_define },
+ .{ "onended", pure_global_identifier_define },
+ .{ "onerror", pure_global_identifier_define },
+ .{ "onfocus", pure_global_identifier_define },
+ .{ "ongotpointercapture", pure_global_identifier_define },
+ .{ "onhashchange", pure_global_identifier_define },
+ .{ "oninput", pure_global_identifier_define },
+ .{ "oninvalid", pure_global_identifier_define },
+ .{ "onkeydown", pure_global_identifier_define },
+ .{ "onkeypress", pure_global_identifier_define },
+ .{ "onkeyup", pure_global_identifier_define },
+ .{ "onlanguagechange", pure_global_identifier_define },
+ .{ "onload", pure_global_identifier_define },
+ .{ "onloadeddata", pure_global_identifier_define },
+ .{ "onloadedmetadata", pure_global_identifier_define },
+ .{ "onloadstart", pure_global_identifier_define },
+ .{ "onlostpointercapture", pure_global_identifier_define },
+ .{ "onmessage", pure_global_identifier_define },
+ .{ "onmousedown", pure_global_identifier_define },
+ .{ "onmouseenter", pure_global_identifier_define },
+ .{ "onmouseleave", pure_global_identifier_define },
+ .{ "onmousemove", pure_global_identifier_define },
+ .{ "onmouseout", pure_global_identifier_define },
+ .{ "onmouseover", pure_global_identifier_define },
+ .{ "onmouseup", pure_global_identifier_define },
+ .{ "onoffline", pure_global_identifier_define },
+ .{ "ononline", pure_global_identifier_define },
+ .{ "onpagehide", pure_global_identifier_define },
+ .{ "onpageshow", pure_global_identifier_define },
+ .{ "onpause", pure_global_identifier_define },
+ .{ "onplay", pure_global_identifier_define },
+ .{ "onplaying", pure_global_identifier_define },
+ .{ "onpointercancel", pure_global_identifier_define },
+ .{ "onpointerdown", pure_global_identifier_define },
+ .{ "onpointerenter", pure_global_identifier_define },
+ .{ "onpointerleave", pure_global_identifier_define },
+ .{ "onpointermove", pure_global_identifier_define },
+ .{ "onpointerout", pure_global_identifier_define },
+ .{ "onpointerover", pure_global_identifier_define },
+ .{ "onpointerup", pure_global_identifier_define },
+ .{ "onpopstate", pure_global_identifier_define },
+ .{ "onprogress", pure_global_identifier_define },
+ .{ "onratechange", pure_global_identifier_define },
+ .{ "onrejectionhandled", pure_global_identifier_define },
+ .{ "onreset", pure_global_identifier_define },
+ .{ "onresize", pure_global_identifier_define },
+ .{ "onscroll", pure_global_identifier_define },
+ .{ "onseeked", pure_global_identifier_define },
+ .{ "onseeking", pure_global_identifier_define },
+ .{ "onselect", pure_global_identifier_define },
+ .{ "onstalled", pure_global_identifier_define },
+ .{ "onstorage", pure_global_identifier_define },
+ .{ "onsubmit", pure_global_identifier_define },
+ .{ "onsuspend", pure_global_identifier_define },
+ .{ "ontimeupdate", pure_global_identifier_define },
+ .{ "ontoggle", pure_global_identifier_define },
+ .{ "ontransitioncancel", pure_global_identifier_define },
+ .{ "ontransitionend", pure_global_identifier_define },
+ .{ "ontransitionrun", pure_global_identifier_define },
+ .{ "ontransitionstart", pure_global_identifier_define },
+ .{ "onunhandledrejection", pure_global_identifier_define },
+ .{ "onunload", pure_global_identifier_define },
+ .{ "onvolumechange", pure_global_identifier_define },
+ .{ "onwaiting", pure_global_identifier_define },
+ .{ "onwebkitanimationend", pure_global_identifier_define },
+ .{ "onwebkitanimationiteration", pure_global_identifier_define },
+ .{ "onwebkitanimationstart", pure_global_identifier_define },
+ .{ "onwebkittransitionend", pure_global_identifier_define },
+ .{ "onwheel", pure_global_identifier_define },
+ .{ "open", pure_global_identifier_define },
+ .{ "opener", pure_global_identifier_define },
+ .{ "origin", pure_global_identifier_define },
+ .{ "outerHeight", pure_global_identifier_define },
+ .{ "outerWidth", pure_global_identifier_define },
+ .{ "parent", pure_global_identifier_define },
+ .{ "performance", pure_global_identifier_define },
+ .{ "personalbar", pure_global_identifier_define },
+ .{ "postMessage", pure_global_identifier_define },
+ .{ "print", pure_global_identifier_define },
+ .{ "prompt", pure_global_identifier_define },
+ .{ "releaseEvents", pure_global_identifier_define },
+ .{ "requestAnimationFrame", pure_global_identifier_define },
+ .{ "resizeBy", pure_global_identifier_define },
+ .{ "resizeTo", pure_global_identifier_define },
+ .{ "screen", pure_global_identifier_define },
+ .{ "screenLeft", pure_global_identifier_define },
+ .{ "screenTop", pure_global_identifier_define },
+ .{ "screenX", pure_global_identifier_define },
+ .{ "screenY", pure_global_identifier_define },
+ .{ "scroll", pure_global_identifier_define },
+ .{ "scrollBy", pure_global_identifier_define },
+ .{ "scrollTo", pure_global_identifier_define },
+ .{ "scrollbars", pure_global_identifier_define },
+ .{ "self", pure_global_identifier_define },
+ .{ "speechSynthesis", pure_global_identifier_define },
+ .{ "status", pure_global_identifier_define },
+ .{ "statusbar", pure_global_identifier_define },
+ .{ "stop", pure_global_identifier_define },
+ .{ "toolbar", pure_global_identifier_define },
+ .{ "top", pure_global_identifier_define },
+ .{ "webkitURL", pure_global_identifier_define },
+ .{ "window", pure_global_identifier_define },
};
+
+pub const pure_global_identifier_map = bun.ComptimeStringMap(defines.IdentifierDefine, pure_global_identifiers);
diff --git a/src/defines.zig b/src/defines.zig
index c1026a7d2..8bc57d8c0 100644
--- a/src/defines.zig
+++ b/src/defines.zig
@@ -17,6 +17,7 @@ const C = bun.C;
const Ref = @import("ast/base.zig").Ref;
const GlobalDefinesKey = @import("./defines-table.zig").GlobalDefinesKey;
+const table = @import("./defines-table.zig");
const Globals = struct {
pub const Undefined = js_ast.E.Undefined{};
@@ -37,13 +38,6 @@ pub const RawDefines = bun.StringArrayHashMap(string);
pub const UserDefines = bun.StringHashMap(DefineData);
pub const UserDefinesArray = bun.StringArrayHashMap(DefineData);
-const Rewrites = struct {
- pub const global = "global";
- pub const globalThis = "globalThis";
-};
-
-var globalThisIdentifier = js_ast.E.Identifier{};
-
pub const DefineData = struct {
value: js_ast.Expr.Data,
valueless: bool = false,
@@ -193,16 +187,24 @@ pub const DotDefine = struct {
};
// var nan_val = try allocator.create(js_ast.E.Number);
-var nan_val = js_ast.E.Number{ .value = std.math.nan_f64 };
-var inf_val = js_ast.E.Number{ .value = std.math.inf_f64 };
+const nan_val = js_ast.E.Number{ .value = std.math.nan_f64 };
+const inf_val = js_ast.E.Number{ .value = std.math.inf_f64 };
pub const Define = struct {
identifiers: bun.StringHashMap(IdentifierDefine),
dots: bun.StringHashMap([]DotDefine),
allocator: std.mem.Allocator,
+ pub fn forIdentifier(this: *const Define, name: []const u8) ?IdentifierDefine {
+ if (this.identifiers.get(name)) |data| {
+ return data;
+ }
+
+ return table.pure_global_identifier_map.get(name);
+ }
+
pub fn insertFromIterator(define: *Define, allocator: std.mem.Allocator, comptime Iterator: type, iter: Iterator) !void {
- while (iter.next()) |user_define| {
+ outer: while (iter.next()) |user_define| {
const user_define_key = user_define.key_ptr.*;
// If it has a dot, then it's a DotDefine.
// e.g. process.env.NODE_ENV
@@ -217,36 +219,34 @@ pub const Define = struct {
parts[i] = split;
}
parts[i] = tail;
- var didFind = false;
var initial_values: []DotDefine = &([_]DotDefine{});
// "NODE_ENV"
- if (define.dots.getEntry(tail)) |entry| {
- for (entry.value_ptr.*) |*part| {
+ var gpe_entry = try define.dots.getOrPut(tail);
+
+ if (gpe_entry.found_existing) {
+ for (gpe_entry.value_ptr.*) |*part| {
// ["process", "env"] === ["process", "env"] (if that actually worked)
if (arePartsEqual(part.parts, parts)) {
part.data = part.data.merge(user_define.value_ptr.*);
- didFind = true;
- break;
+ continue :outer;
}
}
- initial_values = entry.value_ptr.*;
+ initial_values = gpe_entry.value_ptr.*;
}
- if (!didFind) {
- var list = try std.ArrayList(DotDefine).initCapacity(allocator, initial_values.len + 1);
- if (initial_values.len > 0) {
- list.appendSliceAssumeCapacity(initial_values);
- }
-
- list.appendAssumeCapacity(DotDefine{
- .data = user_define.value_ptr.*,
- // TODO: do we need to allocate this?
- .parts = parts,
- });
- try define.dots.put(tail, try list.toOwnedSlice());
+ var list = try std.ArrayList(DotDefine).initCapacity(allocator, initial_values.len + 1);
+ if (initial_values.len > 0) {
+ list.appendSliceAssumeCapacity(initial_values);
}
+
+ list.appendAssumeCapacity(DotDefine{
+ .data = user_define.value_ptr.*,
+ // TODO: do we need to allocate this?
+ .parts = parts,
+ });
+ gpe_entry.value_ptr.* = try list.toOwnedSlice();
} else {
// e.g. IS_BROWSER
@@ -260,55 +260,37 @@ pub const Define = struct {
define.allocator = allocator;
define.identifiers = bun.StringHashMap(IdentifierDefine).init(allocator);
define.dots = bun.StringHashMap([]DotDefine).init(allocator);
- try define.identifiers.ensureTotalCapacity(641 + 2 + 1);
- try define.dots.ensureTotalCapacity(64);
+ try define.dots.ensureTotalCapacity(124);
- var val = js_ast.Expr.Data{
- .e_undefined = .{},
+ const value_define = DefineData{
+ .value = .{ .e_undefined = .{} },
+ .valueless = true,
+ .can_be_removed_if_unused = true,
};
-
- var value_define = DefineData{ .value = val, .valueless = true };
// Step 1. Load the globals into the hash tables
for (GlobalDefinesKey) |global| {
- if (global.len == 1) {
- define.identifiers.putAssumeCapacityNoClobber(global[0], value_define);
+ const key = global[global.len - 1];
+ var gpe = try define.dots.getOrPut(key);
+ if (gpe.found_existing) {
+ var list = try std.ArrayList(DotDefine).initCapacity(allocator, gpe.value_ptr.*.len + 1);
+ list.appendSliceAssumeCapacity(gpe.value_ptr.*);
+ list.appendAssumeCapacity(DotDefine{
+ .parts = global[0..global.len],
+ .data = value_define,
+ });
+
+ gpe.value_ptr.* = try list.toOwnedSlice();
} else {
- const key = global[global.len - 1];
- // TODO: move this to comptime
- if (define.dots.getEntry(key)) |entry| {
- var list = try std.ArrayList(DotDefine).initCapacity(allocator, entry.value_ptr.*.len + 1);
- list.appendSliceAssumeCapacity(entry.value_ptr.*);
- list.appendAssumeCapacity(DotDefine{
- .parts = global[0..global.len],
- .data = value_define,
- });
-
- define.dots.putAssumeCapacity(key, try list.toOwnedSlice());
- } else {
- var list = try std.ArrayList(DotDefine).initCapacity(allocator, 1);
- list.appendAssumeCapacity(DotDefine{
- .parts = global[0..global.len],
- .data = value_define,
- });
+ var list = try std.ArrayList(DotDefine).initCapacity(allocator, 1);
+ list.appendAssumeCapacity(DotDefine{
+ .parts = global[0..global.len],
+ .data = value_define,
+ });
- define.dots.putAssumeCapacity(key, try list.toOwnedSlice());
- }
+ gpe.value_ptr.* = try list.toOwnedSlice();
}
}
- // Step 2. Swap in certain literal values because those can be constant folded
- define.identifiers.putAssumeCapacity("undefined", .{
- .value = val,
- .valueless = false,
- .can_be_removed_if_unused = true,
- });
- define.identifiers.putAssumeCapacity("NaN", DefineData{
- .value = js_ast.Expr.Data{ .e_number = nan_val },
- });
- define.identifiers.putAssumeCapacity("Infinity", DefineData{
- .value = js_ast.Expr.Data{ .e_number = inf_val },
- });
-
// Step 3. Load user data into hash tables
// At this stage, user data has already been validated.
if (_user_defines) |user_defines| {
@@ -323,13 +305,6 @@ pub const Define = struct {
try define.insertFromIterator(allocator, @TypeOf(&iter), &iter);
}
- {
- var global_entry = define.identifiers.getOrPutAssumeCapacity(Rewrites.global);
- if (!global_entry.found_existing) {
- global_entry.value_ptr.* = DefineData{ .value = js_ast.Expr.Data{ .e_identifier = globalThisIdentifier }, .original_name = Rewrites.globalThis };
- }
- }
-
return define;
}
};
diff --git a/src/feature_flags.zig b/src/feature_flags.zig
index f626b725b..a0db75f79 100644
--- a/src/feature_flags.zig
+++ b/src/feature_flags.zig
@@ -113,3 +113,24 @@ pub const hardcode_localhost_to_127_0_0_1 = true;
pub const support_jsxs_in_jsx_transform = false;
pub const use_simdutf = !@import("bun").JSC.is_bindgen;
+
+pub const inline_properties_in_transpiler = true;
+
+pub const same_target_becomes_destructuring = true;
+
+pub const react_server_components = true;
+
+pub const help_catch_memory_issues = @import("bun").Environment.allow_assert;
+
+/// Disabled because we need to handle module scope for CJS better.
+///
+/// The current bugs are:
+/// - We need to handle name collisions in the top-level due to hoisted functions
+/// It breaks when multiple modules bundled together have functions with the
+/// same name at the top-level scope.
+/// - Cyclical requires need to be a de-optimization.
+///
+/// Once fixed, it's a very meaningful bundle size improvement
+pub const commonjs_to_esm = false;
+
+pub const boundary_based_chunking = true;
diff --git a/src/fs.zig b/src/fs.zig
index ac5175784..79377d2fd 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -1092,6 +1092,25 @@ pub const PathName = struct {
ext: string,
filename: string,
+ pub fn nonUniqueNameStringBase(self: *const PathName) string {
+ // /bar/foo/index.js -> foo
+ if (self.dir.len > 0 and strings.eqlComptime(self.base, "index")) {
+ // "/index" -> "index"
+ return Fs.PathName.init(self.dir).base;
+ }
+
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(!strings.includes(self.base, "/"));
+ }
+
+ // /bar/foo.js -> foo
+ return self.base;
+ }
+
+ pub fn fmtIdentifier(self: *const PathName) strings.FormatValidIdentifier {
+ return strings.fmtIdentifier(self.nonUniqueNameStringBase());
+ }
+
// For readability, the names of certain automatically-generated symbols are
// derived from the file name. For example, instead of the CommonJS wrapper for
// a file being called something like "require273" it can be called something
@@ -1104,13 +1123,7 @@ pub const PathName = struct {
// through the renaming logic that all other symbols go through to avoid name
// collisions.
pub fn nonUniqueNameString(self: *const PathName, allocator: std.mem.Allocator) !string {
- if (strings.eqlComptime(self.base, "index")) {
- if (self.dir.len > 0) {
- return MutableString.ensureValidIdentifier(PathName.init(self.dir).base, allocator);
- }
- }
-
- return MutableString.ensureValidIdentifier(self.base, allocator);
+ return MutableString.ensureValidIdentifier(self.nonUniqueNameStringBase(), allocator);
}
pub inline fn dirWithTrailingSlash(this: *const PathName) string {
diff --git a/src/import_record.zig b/src/import_record.zig
index c2db96b09..8d2fd9b7f 100644
--- a/src/import_record.zig
+++ b/src/import_record.zig
@@ -1,7 +1,9 @@
-const fs = @import("fs.zig");
+const fs = @import("bun").fs;
+const bun = @import("bun");
const logger = @import("bun").logger;
const std = @import("std");
const Ref = @import("ast/base.zig").Ref;
+const Index = @import("ast/base.zig").Index;
const Api = @import("./api/schema.zig").Api;
pub const ImportKind = enum(u8) {
@@ -34,7 +36,7 @@ pub const ImportKind = enum(u8) {
pub const Label = std.EnumArray(ImportKind, []const u8);
pub const all_labels: Label = brk: {
- var labels = Label.initFill("internal");
+ var labels = Label.initFill("");
labels.set(ImportKind.entry_point, "entry-point");
labels.set(ImportKind.stmt, "import-statement");
labels.set(ImportKind.require, "require-call");
@@ -85,7 +87,7 @@ pub const ImportRecord = struct {
/// 0 is invalid
module_id: u32 = 0,
- source_index: Ref.Int = std.math.maxInt(Ref.Int),
+ source_index: Index = Index.invalid,
print_mode: PrintMode = .normal,
@@ -103,6 +105,8 @@ pub const ImportRecord = struct {
is_internal: bool = false,
+ calls_runtime_require: bool = false,
+
/// This tells the printer that we should print as export var $moduleID = ...
/// Instead of using the path.
is_bundled: bool = false,
@@ -121,9 +125,11 @@ pub const ImportRecord = struct {
/// either via the "import x from" or "import {default as x} from" syntax.
contains_default_alias: bool = false,
+ contains_es_module_alias: bool = false,
+
/// If true, this "export * from 'path'" statement is evaluated at run-time by
/// calling the "__reExport()" helper function
- calls_run_time_re_export_fn: bool = false,
+ calls_runtime_re_export_fn: bool = false,
/// Tell the printer to use runtime code to resolve this import/export
do_commonjs_transform_in_printer: bool = false,
@@ -140,6 +146,9 @@ pub const ImportRecord = struct {
/// If a macro used <import>, it will be tracked here.
was_injected_by_macro: bool = false,
+ /// If true, this import can be removed if it's unused
+ is_external_without_side_effects: bool = false,
+
kind: ImportKind,
tag: Tag = Tag.none,
@@ -150,14 +159,60 @@ pub const ImportRecord = struct {
/// Used to prevent running resolve plugins multiple times for the same path
print_namespace_in_path: bool = false,
+ wrap_with_to_esm: bool = false,
+ wrap_with_to_commonjs: bool = false,
+
+ pub const List = bun.BabyList(ImportRecord);
+
pub const Tag = enum {
none,
+ /// JSX auto-import for React Fast Refresh
react_refresh,
+ /// JSX auto-import for jsxDEV or jsx
jsx_import,
+ /// JSX auto-import for Fragment or createElement
jsx_classic,
+ /// Uses the `bun` import specifier
+ /// import {foo} from "bun";
bun,
+ /// Uses the `bun:test` import specifier
+ /// import {expect} from "bun:test";
bun_test,
+ runtime,
hardcoded,
+ /// A macro: import specifier OR a macro import
+ macro,
+ internal,
+
+ /// Referenced "use client"; at the start of the file
+ react_client_component,
+
+ /// A file starting with "use client"; imported a server entry point
+ /// We don't actually support this right now.
+ react_server_component,
+
+ pub fn isReactReference(this: Tag) bool {
+ return switch (this) {
+ .react_client_component, .react_server_component => true,
+ else => false,
+ };
+ }
+
+ pub inline fn isRuntime(this: Tag) bool {
+ return this == .runtime;
+ }
+
+ pub inline fn isInternal(this: Tag) bool {
+ return @enumToInt(this) >= @enumToInt(Tag.runtime);
+ }
+
+ pub fn useDirective(this: Tag) bun.JSAst.UseDirective {
+ return switch (this) {
+ .react_client_component => .@"use client",
+ .react_server_component => .@"use server",
+ else => .none,
+ };
+ }
};
pub const PrintMode = enum {
diff --git a/src/install/install.zig b/src/install/install.zig
index 69a39fd7a..0ae273f79 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -44,7 +44,7 @@ const Integrity = @import("./integrity.zig").Integrity;
const clap = bun.clap;
const ExtractTarball = @import("./extract_tarball.zig");
const Npm = @import("./npm.zig");
-const Bitset = @import("./bit_set.zig").DynamicBitSetUnmanaged;
+const Bitset = bun.bit_set.DynamicBitSetUnmanaged;
const z_allocator = @import("../memory_allocator.zig").z_allocator;
const Syscall = bun.JSC.Node.Syscall;
const RunCommand = @import("../cli/run_command.zig").RunCommand;
diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig
index b2997899f..93cd15fb2 100644
--- a/src/install/lockfile.zig
+++ b/src/install/lockfile.zig
@@ -46,7 +46,7 @@ const Integrity = @import("./integrity.zig").Integrity;
const clap = bun.clap;
const ExtractTarball = @import("./extract_tarball.zig");
const Npm = @import("./npm.zig");
-const Bitset = @import("./bit_set.zig").DynamicBitSetUnmanaged;
+const Bitset = bun.bit_set.DynamicBitSetUnmanaged;
const z_allocator = @import("../memory_allocator.zig").z_allocator;
const Lockfile = @This();
diff --git a/src/install/semver.zig b/src/install/semver.zig
index e96b1cddc..928fb9227 100644
--- a/src/install/semver.zig
+++ b/src/install/semver.zig
@@ -96,7 +96,7 @@ pub const String = extern struct {
lhs_buf: []const u8,
rhs_buf: []const u8,
) std.math.Order {
- return std.mem.order(u8, lhs.slice(lhs_buf), rhs.slice(rhs_buf));
+ return strings.order(lhs.slice(lhs_buf), rhs.slice(rhs_buf));
}
pub inline fn canInline(buf: []const u8) bool {
diff --git a/src/js_ast.zig b/src/js_ast.zig
index dd5efd65b..f8adaa953 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -13,6 +13,7 @@ const stringZ = bun.stringZ;
const default_allocator = bun.default_allocator;
const C = bun.C;
const Ref = @import("ast/base.zig").Ref;
+const Index = @import("ast/base.zig").Index;
const RefHashCtx = @import("ast/base.zig").RefHashCtx;
const ObjectPool = @import("./pool.zig").ObjectPool;
const ImportRecord = @import("import_record.zig").ImportRecord;
@@ -23,7 +24,16 @@ const RefCtx = @import("./ast/base.zig").RefCtx;
const JSONParser = bun.JSON;
const is_bindgen = std.meta.globalOption("bindgen", bool) orelse false;
const ComptimeStringMap = bun.ComptimeStringMap;
-const JSPrinter = bun.js_printer;
+const JSPrinter = @import("./js_printer.zig");
+const ThreadlocalArena = @import("./mimalloc_arena.zig").Arena;
+
+/// This is the index to the automatically-generated part containing code that
+/// calls "__export(exports, { ... getters ... })". This is used to generate
+/// getters on an exports object for ES6 export statements, and is both for
+/// ES6 star imports and CommonJS-style modules. All files have one of these,
+/// although it may contain no statements if there is nothing to export.
+pub const namespace_export_part_index = 0;
+
pub fn NewBaseStore(comptime Union: anytype, comptime count: usize) type {
var max_size = 0;
var max_align = 1;
@@ -99,21 +109,38 @@ pub fn NewBaseStore(comptime Union: anytype, comptime count: usize) type {
pub threadlocal var _self: *Self = undefined;
pub fn reclaim() []*Block {
- if (_self.overflow.used == 0) return &[_]*Block{};
+ var overflow = &_self.overflow;
+
+ if (overflow.used == 0) {
+ if (overflow.allocated == 0 or overflow.ptrs[0].used == 0) {
+ return &.{};
+ }
+ }
+
+ var to_move = overflow.ptrs[0..overflow.allocated][overflow.used..];
- var used = _self.overflow.allocator.dupe(*Block, _self.overflow.slice()) catch unreachable;
- var new_head = _self.overflow.allocator.create(Block) catch unreachable;
- new_head.* = .{};
+ // This returns the list of maxed out blocks
+ var used_list = overflow.slice();
- var to_move = _self.overflow.ptrs[0.._self.overflow.allocated][_self.overflow.used..];
- if (to_move.len > 0) {
+ // The last block may be partially used.
+ if (overflow.allocated > overflow.used and to_move.len > 0 and to_move.ptr[0].used > 0) {
to_move = to_move[1..];
+ used_list.len += 1;
}
- bun.copy(*Block, _self.overflow.ptrs[1..], to_move);
- _self.overflow.ptrs[0] = new_head;
- _self.overflow.allocated = 1 + @truncate(Overflow.UsedSize, to_move.len);
- reset();
+ var used = overflow.allocator.dupe(*Block, used_list) catch unreachable;
+
+ for (to_move, overflow.ptrs[0..to_move.len]) |b, *out| {
+ b.* = Block{
+ .items = undefined,
+ .used = 0,
+ };
+ out.* = b;
+ }
+
+ overflow.allocated = @truncate(Overflow.UsedSize, to_move.len);
+ overflow.used = 0;
+
return used;
}
@@ -150,25 +177,27 @@ pub fn NewBaseStore(comptime Union: anytype, comptime count: usize) type {
fn deinit() void {
var sliced = _self.overflow.slice();
+ var allocator = _self.overflow.allocator;
if (sliced.len > 1) {
var i: usize = 1;
const end = sliced.len;
while (i < end) {
var ptrs = @ptrCast(*[2]Block, sliced[i]);
- default_allocator.free(ptrs);
+ allocator.free(ptrs);
i += 2;
}
_self.overflow.allocated = 1;
}
var base_store = @fieldParentPtr(WithBase, "store", _self);
if (_self.overflow.ptrs[0] == &base_store.head) {
- default_allocator.destroy(base_store);
+ allocator.destroy(base_store);
}
_self = undefined;
}
- pub fn append(comptime ValueType: type, value: ValueType) *ValueType {
+ pub fn append(comptime Disabler: type, comptime ValueType: type, value: ValueType) *ValueType {
+ Disabler.assert();
return _self._append(ValueType, value);
}
@@ -219,7 +248,7 @@ pub fn NewBaseStore(comptime Union: anytype, comptime count: usize) type {
pub const BindingNodeIndex = Binding;
pub const StmtNodeIndex = Stmt;
pub const ExprNodeIndex = Expr;
-pub const BabyList = @import("./baby_list.zig").BabyList;
+pub const BabyList = bun.BabyList;
/// Slice that stores capacity and length in the same space as a regular slice.
pub const ExprNodeList = BabyList(Expr);
@@ -249,7 +278,7 @@ pub const AssignTarget = enum(u2) {
}
};
-pub const LocRef = struct { loc: logger.Loc, ref: ?Ref = null };
+pub const LocRef = struct { loc: logger.Loc = logger.Loc.Empty, ref: ?Ref = null };
pub const Flags = struct {
pub const JSXElement = enum {
@@ -337,7 +366,7 @@ pub const Binding = struct {
}
pub fn toExpr(binding: *const Binding, wrapper: anytype) Expr {
- var loc = binding.loc;
+ const loc = binding.loc;
switch (binding.data) {
.b_missing => {
@@ -370,24 +399,26 @@ pub const Binding = struct {
var properties = wrapper
.allocator
.alloc(G.Property, b.properties.len) catch unreachable;
- var i: usize = 0;
- while (i < properties.len) : (i += 1) {
- const item = b.properties[i];
- properties[i] = G.Property{
+ for (properties, b.properties) |*property, item| {
+ property.* = .{
.flags = item.flags,
.key = item.key,
.kind = if (item.flags.contains(.is_spread))
- G.Property.Kind.spread
+ .spread
else
- G.Property.Kind.normal,
+ .normal,
.value = toExpr(&item.value, wrapper),
.initializer = item.default_value,
};
}
- return Expr.init(E.Object, E.Object{
- .properties = G.Property.List.init(properties),
- .is_single_line = b.is_single_line,
- }, loc);
+ return Expr.init(
+ E.Object,
+ E.Object{
+ .properties = G.Property.List.init(properties),
+ .is_single_line = b.is_single_line,
+ },
+ loc,
+ );
},
else => {
Global.panic("Interanl error", .{});
@@ -498,8 +529,8 @@ pub const B = union(Binding.Tag) {
};
pub const ClauseItem = struct {
- alias: string,
- alias_loc: logger.Loc,
+ alias: string = "",
+ alias_loc: logger.Loc = logger.Loc.Empty,
name: LocRef,
/// This is the original name of the symbol stored in "Name". It's needed for
@@ -510,7 +541,7 @@ pub const ClauseItem = struct {
/// In this case both "foo" and "bar" are aliases because it's a re-export.
/// We need to preserve both aliases in case the symbol is renamed. In this
/// example, "foo" is "OriginalName" and "bar" is "Alias".
- original_name: string,
+ original_name: string = "",
pub const default_alias: string = "default";
};
@@ -623,131 +654,191 @@ pub const G = struct {
};
pub const Symbol = struct {
- // This is the name that came from the parser. Printed names may be renamed
- // during minification or to avoid name collisions. Do not use the original
- // name during printing.
+ /// This is the name that came from the parser. Printed names may be renamed
+ /// during minification or to avoid name collisions. Do not use the original
+ /// name during printing.
original_name: string,
- // This is used for symbols that represent items in the import clause of an
- // ES6 import statement. These should always be referenced by EImportIdentifier
- // instead of an EIdentifier. When this is present, the expression should
- // be printed as a property access off the namespace instead of as a bare
- // identifier.
- //
- // For correctness, this must be stored on the symbol instead of indirectly
- // associated with the Ref for the symbol somehow. In ES6 "flat bundling"
- // mode, re-exported symbols are collapsed using MergeSymbols() and renamed
- // symbols from other files that end up at this symbol must be able to tell
- // if it has a namespace alias.
+ /// This is used for symbols that represent items in the import clause of an
+ /// ES6 import statement. These should always be referenced by EImportIdentifier
+ /// instead of an EIdentifier. When this is present, the expression should
+ /// be printed as a property access off the namespace instead of as a bare
+ /// identifier.
+ ///
+ /// For correctness, this must be stored on the symbol instead of indirectly
+ /// associated with the Ref for the symbol somehow. In ES6 "flat bundling"
+ /// mode, re-exported symbols are collapsed using MergeSymbols() and renamed
+ /// symbols from other files that end up at this symbol must be able to tell
+ /// if it has a namespace alias.
namespace_alias: ?G.NamespaceAlias = null,
- // Used by the parser for single pass parsing.
+ /// Used by the parser for single pass parsing.
link: Ref = Ref.None,
- // An estimate of the number of uses of this symbol. This is used to detect
- // whether a symbol is used or not. For example, TypeScript imports that are
- // unused must be removed because they are probably type-only imports. This
- // is an estimate and may not be completely accurate due to oversights in the
- // code. But it should always be non-zero when the symbol is used.
+ /// An estimate of the number of uses of this symbol. This is used to detect
+ /// whether a symbol is used or not. For example, TypeScript imports that are
+ /// unused must be removed because they are probably type-only imports. This
+ /// is an estimate and may not be completely accurate due to oversights in the
+ /// code. But it should always be non-zero when the symbol is used.
use_count_estimate: u32 = 0,
- // This is for generating cross-chunk imports and exports for code splitting.
- chunk_index: ?u32 = null,
-
- // This is used for minification. Symbols that are declared in sibling scopes
- // can share a name. A good heuristic (from Google Closure Compiler) is to
- // assign names to symbols from sibling scopes in declaration order. That way
- // local variable names are reused in each global function like this, which
- // improves gzip compression:
- //
- // function x(a, b) { ... }
- // function y(a, b, c) { ... }
- //
- // The parser fills this in for symbols inside nested scopes. There are three
- // slot namespaces: regular symbols, label symbols, and private symbols.
- nested_scope_slot: ?u32 = null,
+ /// This is for generating cross-chunk imports and exports for code splitting.
+ ///
+ /// Do not use this directly. Use `chunkIndex()` instead.
+ chunk_index: u32 = invalid_chunk_index,
+
+ /// This is used for minification. Symbols that are declared in sibling scopes
+ /// can share a name. A good heuristic (from Google Closure Compiler) is to
+ /// assign names to symbols from sibling scopes in declaration order. That way
+ /// local variable names are reused in each global function like this, which
+ /// improves gzip compression:
+ ///
+ /// function x(a, b) { ... }
+ /// function y(a, b, c) { ... }
+ ///
+ /// The parser fills this in for symbols inside nested scopes. There are three
+ /// slot namespaces: regular symbols, label symbols, and private symbols.
+ ///
+ /// Do not use this directly. Use `nestedScopeSlot()` instead.
+ nested_scope_slot: u32 = invalid_nested_scope_slot,
+ /// The kind of symbol. This is used to determine how to print the symbol
+ /// and how to deal with conflicts, renaming, etc.
kind: Kind = Kind.other,
- // Certain symbols must not be renamed or minified. For example, the
- // "arguments" variable is declared by the runtime for every function.
- // Renaming can also break any identifier used inside a "with" statement.
+ /// Certain symbols must not be renamed or minified. For example, the
+ /// "arguments" variable is declared by the runtime for every function.
+ /// Renaming can also break any identifier used inside a "with" statement.
must_not_be_renamed: bool = false,
- // We automatically generate import items for property accesses off of
- // namespace imports. This lets us remove the expensive namespace imports
- // while bundling in many cases, replacing them with a cheap import item
- // instead:
- //
- // import * as ns from 'path'
- // ns.foo()
- //
- // That can often be replaced by this, which avoids needing the namespace:
- //
- // import {foo} from 'path'
- // foo()
- //
- // However, if the import is actually missing then we don't want to report a
- // compile-time error like we do for real import items. This status lets us
- // avoid this. We also need to be able to replace such import items with
- // undefined, which this status is also used for.
+ /// We automatically generate import items for property accesses off of
+ /// namespace imports. This lets us remove the expensive namespace imports
+ /// while bundling in many cases, replacing them with a cheap import item
+ /// instead:
+ ///
+ /// import * as ns from 'path'
+ /// ns.foo()
+ ///
+ /// That can often be replaced by this, which avoids needing the namespace:
+ ///
+ /// import {foo} from 'path'
+ /// foo()
+ ///
+ /// However, if the import is actually missing then we don't want to report a
+ /// compile-time error like we do for real import items. This status lets us
+ /// avoid this. We also need to be able to replace such import items with
+ /// undefined, which this status is also used for.
import_item_status: ImportItemStatus = ImportItemStatus.none,
- // Sometimes we lower private symbols even if they are supported. For example,
- // consider the following TypeScript code:
- //
- // class Foo {
- // #foo = 123
- // bar = this.#foo
- // }
- //
- // If "useDefineForClassFields: false" is set in "tsconfig.json", then "bar"
- // must use assignment semantics instead of define semantics. We can compile
- // that to this code:
- //
- // class Foo {
- // constructor() {
- // this.#foo = 123;
- // this.bar = this.#foo;
- // }
- // #foo;
- // }
- //
- // However, we can't do the same for static fields:
- //
- // class Foo {
- // static #foo = 123
- // static bar = this.#foo
- // }
- //
- // Compiling these static fields to something like this would be invalid:
- //
- // class Foo {
- // static #foo;
- // }
- // Foo.#foo = 123;
- // Foo.bar = Foo.#foo;
- //
- // Thus "#foo" must be lowered even though it's supported. Another case is
- // when we're converting top-level class declarations to class expressions
- // to avoid the TDZ and the class shadowing symbol is referenced within the
- // class body:
- //
- // class Foo {
- // static #foo = Foo
- // }
- //
- // This cannot be converted into something like this:
- //
- // var Foo = class {
- // static #foo;
- // };
- // Foo.#foo = Foo;
- //
+ /// --- Not actually used yet -----------------------------------------------
+ /// Sometimes we lower private symbols even if they are supported. For example,
+ /// consider the following TypeScript code:
+ ///
+ /// class Foo {
+ /// #foo = 123
+ /// bar = this.#foo
+ /// }
+ ///
+ /// If "useDefineForClassFields: false" is set in "tsconfig.json", then "bar"
+ /// must use assignment semantics instead of define semantics. We can compile
+ /// that to this code:
+ ///
+ /// class Foo {
+ /// constructor() {
+ /// this.#foo = 123;
+ /// this.bar = this.#foo;
+ /// }
+ /// #foo;
+ /// }
+ ///
+ /// However, we can't do the same for static fields:
+ ///
+ /// class Foo {
+ /// static #foo = 123
+ /// static bar = this.#foo
+ /// }
+ ///
+ /// Compiling these static fields to something like this would be invalid:
+ ///
+ /// class Foo {
+ /// static #foo;
+ /// }
+ /// Foo.#foo = 123;
+ /// Foo.bar = Foo.#foo;
+ ///
+ /// Thus "#foo" must be lowered even though it's supported. Another case is
+ /// when we're converting top-level class declarations to class expressions
+ /// to avoid the TDZ and the class shadowing symbol is referenced within the
+ /// class body:
+ ///
+ /// class Foo {
+ /// static #foo = Foo
+ /// }
+ ///
+ /// This cannot be converted into something like this:
+ ///
+ /// var Foo = class {
+ /// static #foo;
+ /// };
+ /// Foo.#foo = Foo;
+ ///
+ /// --- Not actually used yet -----------------------------------------------
private_symbol_must_be_lowered: bool = false,
+ remove_overwritten_function_declaration: bool = false,
+
+ /// In debug mode, sometimes its helpful to know what source file
+ /// A symbol came from. This is used for that.
+ ///
+ /// We don't want this in non-debug mode because it increases the size of
+ /// the symbol table.
+ debug_mode_source_index: if (Environment.allow_assert)
+ Index.Int
+ else
+ u0 = 0,
+
+ const invalid_chunk_index = std.math.maxInt(u32);
+ const invalid_nested_scope_slot = std.math.maxInt(u32);
+
+ pub const SlotNamespace = enum {
+ default,
+ label,
+ private_name,
+ mangled_prop,
+ must_not_be_renamed,
+ };
+
+ /// This is for generating cross-chunk imports and exports for code splitting.
+ pub inline fn chunkIndex(this: *const Symbol) ?u32 {
+ const i = this.chunk_index;
+ return if (i == invalid_chunk_index) null else i;
+ }
+
+ pub inline fn nestedScopeSlot(this: *const Symbol) ?u32 {
+ const i = this.nested_scope_slot;
+ return if (i == invalid_nested_scope_slot) null else i;
+ }
+
+ pub fn slotNamespace(this: *const Symbol) SlotNamespace {
+ const kind = this.kind;
+
+ if (kind == .unbound or this.must_not_be_renamed) {
+ return .must_not_be_renamed;
+ }
+
+ if (kind.isPrivate()) {
+ return .private_name;
+ }
+
+ return switch (kind) {
+ // .mangled_prop => .mangled_prop,
+ .label => .label,
+ else => .default,
+ };
+ }
+
pub inline fn hasLink(this: *const Symbol) bool {
- return !this.link.isNull();
+ return this.link.tag != .invalid;
}
pub const Kind = enum {
@@ -835,12 +926,55 @@ pub const Symbol = struct {
pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
}
+
+ pub inline fn isPrivate(kind: Symbol.Kind) bool {
+ return @enumToInt(kind) >= @enumToInt(Symbol.Kind.private_field) and @enumToInt(kind) <= @enumToInt(Symbol.Kind.private_static_get_set_pair);
+ }
+
+ pub inline fn isHoisted(kind: Symbol.Kind) bool {
+ return switch (kind) {
+ .hoisted, .hoisted_function => true,
+ else => false,
+ };
+ }
+
+ pub inline fn isHoistedOrFunction(kind: Symbol.Kind) bool {
+ return switch (kind) {
+ .hoisted, .hoisted_function, .generator_or_async_function => true,
+ else => false,
+ };
+ }
+
+ pub inline fn isFunction(kind: Symbol.Kind) bool {
+ return switch (kind) {
+ .hoisted_function, .generator_or_async_function => true,
+ else => false,
+ };
+ }
};
+ pub const isKindPrivate = Symbol.Kind.isPrivate;
+ pub const isKindHoisted = Symbol.Kind.isHoisted;
+ pub const isKindHoistedOrFunction = Symbol.Kind.isHoistedOrFunction;
+ pub const isKindFunction = Symbol.Kind.isFunction;
+
pub const Use = struct {
count_estimate: u32 = 0,
};
+ pub const List = BabyList(Symbol);
+ pub const NestedList = BabyList(List);
+
+ pub fn mergeContentsWith(this: *Symbol, old: *Symbol) void {
+ this.use_count_estimate += old.use_count_estimate;
+ if (old.must_not_be_renamed) {
+ this.original_name = old.original_name;
+ this.must_not_be_renamed = true;
+ }
+
+ // TODO: MustStartWithCapitalLetterForJSX
+ }
+
pub const Map = struct {
// This could be represented as a "map[Ref]Symbol" but a two-level array was
// more efficient in profiles. This appears to be because it doesn't involve
@@ -849,34 +983,94 @@ pub const Symbol = struct {
// single inner array, so you can join the maps together by just make a
// single outer array containing all of the inner arrays. See the comment on
// "Ref" for more detail.
- symbols_for_source: [][]Symbol,
+ symbols_for_source: NestedList = NestedList{},
- pub fn get(self: *Map, ref: Ref) ?*Symbol {
+ pub fn dump(this: Map) void {
+ defer Output.flush();
+ for (this.symbols_for_source.slice(), 0..) |symbols, i| {
+ Output.prettyln("\n\n-- Source ID: {d} ({d} symbols) --\n\n", .{ i, symbols.len });
+ for (symbols.slice(), 0..) |symbol, inner_index| {
+ Output.prettyln(
+ " name: {s}\n tag: {s}\n {any}\n",
+ .{
+ symbol.original_name, @tagName(symbol.kind),
+ if (symbol.hasLink()) symbol.link else Ref{
+ .source_index = @truncate(Ref.Int, i),
+ .inner_index = @truncate(Ref.Int, inner_index),
+ .tag = .symbol,
+ },
+ },
+ );
+ }
+ }
+ }
+
+ pub fn assignChunkIndex(this: *Map, decls_: DeclaredSymbol.List, chunk_index: u32) void {
+ const Iterator = struct {
+ map: *Map,
+ chunk_index: u32,
+
+ pub fn next(self: @This(), ref: Ref) void {
+ var symbol = self.map.get(ref).?;
+ symbol.chunk_index = self.chunk_index;
+ }
+ };
+ var decls = decls_;
+
+ DeclaredSymbol.forEachTopLevelSymbol(&decls, Iterator{ .map = this, .chunk_index = chunk_index }, Iterator.next);
+ }
+
+ pub fn merge(this: *Map, old: Ref, new: Ref) Ref {
+ if (old.eql(new)) {
+ return new;
+ }
+
+ var old_symbol = this.get(old).?;
+ if (old_symbol.hasLink()) {
+ const old_link = old_symbol.link;
+ old_symbol.link = this.merge(old_link, new);
+ return old_symbol.link;
+ }
+
+ var new_symbol = this.get(new).?;
+
+ if (new_symbol.hasLink()) {
+ const new_link = new_symbol.link;
+ new_symbol.link = this.merge(old, new_link);
+ return new_symbol.link;
+ }
+
+ old_symbol.link = new;
+ new_symbol.mergeContentsWith(old_symbol);
+ return new;
+ }
+
+ pub fn get(self: *const Map, ref: Ref) ?*Symbol {
if (Ref.isSourceIndexNull(ref.sourceIndex()) or ref.isSourceContentsSlice()) {
return null;
}
- return &self.symbols_for_source[ref.sourceIndex()][ref.innerIndex()];
+ return self.symbols_for_source.at(ref.sourceIndex()).mut(ref.innerIndex());
}
- pub fn getConst(self: *Map, ref: Ref) ?*const Symbol {
+ pub fn getConst(self: *const Map, ref: Ref) ?*const Symbol {
if (Ref.isSourceIndexNull(ref.sourceIndex()) or ref.isSourceContentsSlice()) {
return null;
}
- return &self.symbols_for_source[ref.sourceIndex()][ref.innerIndex()];
+ return self.symbols_for_source.at(ref.sourceIndex()).at(ref.innerIndex());
}
pub fn init(sourceCount: usize, allocator: std.mem.Allocator) !Map {
- var symbols_for_source: [][]Symbol = try allocator.alloc([]Symbol, sourceCount);
+ var symbols_for_source: NestedList = NestedList.init(try allocator.alloc([]Symbol, sourceCount));
return Map{ .symbols_for_source = symbols_for_source };
}
- pub fn initList(list: [][]Symbol) Map {
+ pub fn initList(list: NestedList) Map {
return Map{ .symbols_for_source = list };
}
- pub fn getWithLink(symbols: *Map, ref: Ref) ?*Symbol {
+ pub fn getWithLink(symbols: *const Map, ref: Ref) ?*Symbol {
var symbol: *Symbol = symbols.get(ref) orelse return null;
if (symbol.hasLink()) {
return symbols.get(symbol.link) orelse symbol;
@@ -892,52 +1086,35 @@ pub const Symbol = struct {
return symbol;
}
- pub fn follow(symbols: *Map, ref: Ref) Ref {
- if (symbols.get(ref)) |symbol| {
- const link = symbol.link;
- if (link.isNull())
- return ref;
-
- if (link.eql(ref)) {
- symbol.link = ref;
+ pub fn followAll(symbols: *Map) void {
+ for (symbols.symbols_for_source.slice()) |list| {
+ for (list.slice()) |*symbol| {
+ if (!symbol.hasLink()) continue;
+ symbol.link = follow(symbols, symbol.link);
}
+ }
+ }
- return symbol.link;
- } else {
+ pub fn follow(symbols: *const Map, ref: Ref) Ref {
+ var symbol = symbols.get(ref) orelse return ref;
+ if (!symbol.hasLink()) {
return ref;
}
- }
- };
- pub inline fn isKindPrivate(kind: Symbol.Kind) bool {
- return @enumToInt(kind) >= @enumToInt(Symbol.Kind.private_field) and @enumToInt(kind) <= @enumToInt(Symbol.Kind.private_static_get_set_pair);
- }
+ const link = follow(symbols, symbol.link);
- pub inline fn isKindHoisted(kind: Symbol.Kind) bool {
- return switch (kind) {
- .hoisted, .hoisted_function => true,
- else => false,
- };
- }
+ if (!symbol.link.eql(link)) {
+ symbol.link = link;
+ }
+
+ return link;
+ }
+ };
pub inline fn isHoisted(self: *const Symbol) bool {
return Symbol.isKindHoisted(self.kind);
}
- pub inline fn isKindHoistedOrFunction(kind: Symbol.Kind) bool {
- return switch (kind) {
- .hoisted, .hoisted_function, .generator_or_async_function => true,
- else => false,
- };
- }
-
- pub inline fn isKindFunction(kind: Symbol.Kind) bool {
- return switch (kind) {
- .hoisted_function, .generator_or_async_function => true,
- else => false,
- };
- }
-
pub fn isReactComponentishName(symbol: *const Symbol) bool {
switch (symbol.kind) {
.hoisted, .hoisted_function, .cconst, .class, .other => {
@@ -1095,13 +1272,13 @@ pub const E = struct {
target: ExprNodeIndex,
optional_chain: ?OptionalChain = null,
- pub fn hasSameFlagsAs(a: *Index, b: *Index) bool {
+ pub fn hasSameFlagsAs(a: *E.Index, b: *E.Index) bool {
return (a.optional_chain == b.optional_chain);
}
};
pub const Arrow = struct {
- args: []G.Arg,
+ args: []G.Arg = &[_]G.Arg{},
body: G.FnBody,
is_async: bool = false,
@@ -1140,34 +1317,38 @@ pub const E = struct {
}
};
- // This is similar to an EIdentifier but it represents a reference to an ES6
- // import item.
- //
- // Depending on how the code is linked, the file containing this EImportIdentifier
- // may or may not be in the same module group as the file it was imported from.
- //
- // If it's the same module group than we can just merge the import item symbol
- // with the corresponding symbol that was imported, effectively renaming them
- // to be the same thing and statically binding them together.
- //
- // But if it's a different module group, then the import must be dynamically
- // evaluated using a property access off the corresponding namespace symbol,
- // which represents the result of a require() call.
- //
- // It's stored as a separate type so it's not easy to confuse with a plain
- // identifier. For example, it'd be bad if code trying to convert "{x: x}" into
- // "{x}" shorthand syntax wasn't aware that the "x" in this case is actually
- // "{x: importedNamespace.x}". This separate type forces code to opt-in to
- // doing this instead of opt-out.
+ /// This is similar to an `Identifier` but it represents a reference to an ES6
+ /// import item.
+ ///
+ /// Depending on how the code is linked, the file containing this EImportIdentifier
+ /// may or may not be in the same module group as the file it was imported from.
+ ///
+ /// If it's the same module group than we can just merge the import item symbol
+ /// with the corresponding symbol that was imported, effectively renaming them
+ /// to be the same thing and statically binding them together.
+ ///
+ /// But if it's a different module group, then the import must be dynamically
+ /// evaluated using a property access off the corresponding namespace symbol,
+ /// which represents the result of a require() call.
+ ///
+ /// It's stored as a separate type so it's not easy to confuse with a plain
+ /// identifier. For example, it'd be bad if code trying to convert "{x: x}" into
+ /// "{x}" shorthand syntax wasn't aware that the "x" in this case is actually
+ /// "{x: importedNamespace.x}". This separate type forces code to opt-in to
+ /// doing this instead of opt-out.
pub const ImportIdentifier = struct {
ref: Ref = Ref.None,
- // If true, this was originally an identifier expression such as "foo". If
- // false, this could potentially have been a member access expression such
- // as "ns.foo" off of an imported namespace object.
+ /// If true, this was originally an identifier expression such as "foo". If
+ /// false, this could potentially have been a member access expression such
+ /// as "ns.foo" off of an imported namespace object.
was_originally_identifier: bool = false,
};
+ pub const CommonJSExportIdentifier = struct {
+ ref: Ref = Ref.None,
+ };
+
// This is similar to EIdentifier but it represents class-private fields and
// methods. It can be used where computed properties can be used, such as
// EIndex and Property.
@@ -1914,15 +2095,19 @@ pub const E = struct {
expr: ExprNodeIndex,
import_record_index: u32,
- // Comments inside "import()" expressions have special meaning for Webpack.
- // Preserving comments inside these expressions makes it possible to use
- // esbuild as a TypeScript-to-JavaScript frontend for Webpack to improve
- // performance. We intentionally do not interpret these comments in esbuild
- // because esbuild is not Webpack. But we do preserve them since doing so is
- // harmless, easy to maintain, and useful to people. See the Webpack docs for
- // more info: https://webpack.js.org/api/module-methods/#magic-comments.
- // TODO:
+ /// Comments inside "import()" expressions have special meaning for Webpack.
+ /// Preserving comments inside these expressions makes it possible to use
+ /// esbuild as a TypeScript-to-JavaScript frontend for Webpack to improve
+ /// performance. We intentionally do not interpret these comments in esbuild
+ /// because esbuild is not Webpack. But we do preserve them since doing so is
+ /// harmless, easy to maintain, and useful to people. See the Webpack docs for
+ /// more info: https://webpack.js.org/api/module-methods/#magic-comments.
+ /// TODO:
leading_interior_comments: []G.Comment = &([_]G.Comment{}),
+
+ pub fn isImportRecordNull(this: *const Import) bool {
+ return this.import_record_index == std.math.maxInt(u32);
+ }
};
};
@@ -1930,6 +2115,18 @@ pub const Stmt = struct {
loc: logger.Loc,
data: Data,
+ pub const Batcher = bun.Batcher(Stmt);
+
+ pub fn assign(a: Expr, b: Expr, allocator: std.mem.Allocator) Stmt {
+ return Stmt.alloc(
+ S.SExpr,
+ S.SExpr{
+ .value = Expr.assign(a, b, allocator),
+ },
+ a.loc,
+ );
+ }
+
const Serializable = struct {
type: Tag,
object: string,
@@ -1963,6 +2160,7 @@ pub const Stmt = struct {
pub var icount: usize = 0;
pub fn init(comptime StatementType: type, origData: *StatementType, loc: logger.Loc) Stmt {
icount += 1;
+
return switch (comptime StatementType) {
S.Empty => Stmt{ .loc = loc, .data = Data{ .s_empty = S.Empty{} } },
S.Block => Stmt.comptime_init("s_block", S.Block, origData, loc),
@@ -2002,7 +2200,24 @@ pub const Stmt = struct {
};
}
inline fn comptime_alloc(comptime tag_name: string, comptime typename: type, origData: anytype, loc: logger.Loc) Stmt {
- return Stmt{ .loc = loc, .data = @unionInit(Data, tag_name, Data.Store.append(typename, origData)) };
+ return Stmt{
+ .loc = loc,
+ .data = @unionInit(
+ Data,
+ tag_name,
+ Data.Store.append(
+ typename,
+ origData,
+ ),
+ ),
+ };
+ }
+
+ fn allocateData(allocator: std.mem.Allocator, comptime tag_name: string, comptime typename: type, origData: anytype, loc: logger.Loc) Stmt {
+ var value = allocator.create(@TypeOf(origData)) catch unreachable;
+ value.* = origData;
+
+ return comptime_init(tag_name, *typename, value, loc);
}
inline fn comptime_init(comptime tag_name: string, comptime TypeName: type, origData: TypeName, loc: logger.Loc) Stmt {
@@ -2010,6 +2225,8 @@ pub const Stmt = struct {
}
pub fn alloc(comptime StatementData: type, origData: StatementData, loc: logger.Loc) Stmt {
+ Stmt.Data.Store.assert();
+
icount += 1;
return switch (StatementData) {
S.Block => Stmt.comptime_alloc("s_block", S.Block, origData, loc),
@@ -2049,6 +2266,53 @@ pub const Stmt = struct {
};
}
+ pub const Disabler = bun.DebugOnlyDisabler(@This());
+
+ /// When the lifetime of an Stmt.Data's pointer must exist longer than reset() is called, use this function.
+ /// Be careful to free the memory (or use an allocator that does it for you)
+ /// Also, prefer Stmt.init or Stmt.alloc when possible. This will be slower.
+ pub fn allocate(allocator: std.mem.Allocator, comptime StatementData: type, origData: StatementData, loc: logger.Loc) Stmt {
+ Stmt.Data.Store.assert();
+
+ icount += 1;
+ return switch (StatementData) {
+ S.Block => Stmt.allocateData(allocator, "s_block", S.Block, origData, loc),
+ S.Break => Stmt.allocateData(allocator, "s_break", S.Break, origData, loc),
+ S.Class => Stmt.allocateData(allocator, "s_class", S.Class, origData, loc),
+ S.Comment => Stmt.allocateData(allocator, "s_comment", S.Comment, origData, loc),
+ S.Continue => Stmt.allocateData(allocator, "s_continue", S.Continue, origData, loc),
+ S.Debugger => Stmt{ .loc = loc, .data = .{ .s_debugger = origData } },
+ S.Directive => Stmt.allocateData(allocator, "s_directive", S.Directive, origData, loc),
+ S.DoWhile => Stmt.allocateData(allocator, "s_do_while", S.DoWhile, origData, loc),
+ S.Empty => Stmt{ .loc = loc, .data = Data{ .s_empty = S.Empty{} } },
+ S.Enum => Stmt.allocateData(allocator, "s_enum", S.Enum, origData, loc),
+ S.ExportClause => Stmt.allocateData(allocator, "s_export_clause", S.ExportClause, origData, loc),
+ S.ExportDefault => Stmt.allocateData(allocator, "s_export_default", S.ExportDefault, origData, loc),
+ S.ExportEquals => Stmt.allocateData(allocator, "s_export_equals", S.ExportEquals, origData, loc),
+ S.ExportFrom => Stmt.allocateData(allocator, "s_export_from", S.ExportFrom, origData, loc),
+ S.ExportStar => Stmt.allocateData(allocator, "s_export_star", S.ExportStar, origData, loc),
+ S.SExpr => Stmt.allocateData(allocator, "s_expr", S.SExpr, origData, loc),
+ S.ForIn => Stmt.allocateData(allocator, "s_for_in", S.ForIn, origData, loc),
+ S.ForOf => Stmt.allocateData(allocator, "s_for_of", S.ForOf, origData, loc),
+ S.For => Stmt.allocateData(allocator, "s_for", S.For, origData, loc),
+ S.Function => Stmt.allocateData(allocator, "s_function", S.Function, origData, loc),
+ S.If => Stmt.allocateData(allocator, "s_if", S.If, origData, loc),
+ S.Import => Stmt.allocateData(allocator, "s_import", S.Import, origData, loc),
+ S.Label => Stmt.allocateData(allocator, "s_label", S.Label, origData, loc),
+ S.LazyExport => Stmt.allocateData(allocator, "s_lazy_export", S.LazyExport, origData, loc),
+ S.Local => Stmt.allocateData(allocator, "s_local", S.Local, origData, loc),
+ S.Namespace => Stmt.allocateData(allocator, "s_namespace", S.Namespace, origData, loc),
+ S.Return => Stmt.allocateData(allocator, "s_return", S.Return, origData, loc),
+ S.Switch => Stmt.allocateData(allocator, "s_switch", S.Switch, origData, loc),
+ S.Throw => Stmt.allocateData(allocator, "s_throw", S.Throw, origData, loc),
+ S.Try => Stmt.allocateData(allocator, "s_try", S.Try, origData, loc),
+ S.TypeScript => Stmt{ .loc = loc, .data = Data{ .s_type_script = S.TypeScript{} } },
+ S.While => Stmt.allocateData(allocator, "s_while", S.While, origData, loc),
+ S.With => Stmt.allocateData(allocator, "s_with", S.With, origData, loc),
+ else => @compileError("Invalid type in Stmt.init"),
+ };
+ }
+
pub const Tag = enum(u6) {
s_block,
s_break,
@@ -2166,12 +2430,13 @@ pub const Stmt = struct {
S.While,
S.With,
};
- pub const All = NewBaseStore(Union, 128);
+ const All = NewBaseStore(Union, 128);
+ pub threadlocal var memory_allocator: ?*ASTMemoryAllocator = null;
threadlocal var has_inited = false;
pub threadlocal var disable_reset = false;
pub fn create(allocator: std.mem.Allocator) void {
- if (has_inited) {
+ if (has_inited or memory_allocator != null) {
return;
}
@@ -2180,25 +2445,29 @@ pub const Stmt = struct {
}
pub fn reset() void {
- if (disable_reset) return;
+ if (disable_reset or memory_allocator != null) return;
All.reset();
}
pub fn deinit() void {
- if (!has_inited) return;
+ if (!has_inited or memory_allocator != null) return;
All.deinit();
has_inited = false;
}
- pub fn assert() void {
+ pub inline fn assert() void {
if (comptime Environment.allow_assert) {
- if (!has_inited)
+ if (!has_inited and memory_allocator == null)
bun.unreachablePanic("Store must be init'd", .{});
}
}
pub fn append(comptime ValueType: type, value: anytype) *ValueType {
- return All.append(ValueType, value);
+ if (memory_allocator) |allocator| {
+ return allocator.append(ValueType, value);
+ }
+
+ return All.append(Disabler, ValueType, value);
}
pub fn toOwnedSlice() []*Store.All.Block {
@@ -2228,6 +2497,15 @@ pub const Expr = struct {
loc: logger.Loc,
data: Data,
+ pub fn isAnonymousNamed(expr: Expr) bool {
+ return switch (expr.data) {
+ .e_arrow => true,
+ .e_function => |func| func.func.name == null,
+ .e_class => |class| class.class_name == null,
+ else => false,
+ };
+ }
+
pub fn clone(this: Expr, allocator: std.mem.Allocator) !Expr {
return .{
.loc = this.loc,
@@ -2563,39 +2841,449 @@ pub const Expr = struct {
return [2]f64{ left.e_number.value, right.e_number.value };
}
- pub fn isAnonymousNamed(e: *Expr) bool {
- switch (e.data) {
- .e_arrow => {
- return true;
+ pub var icount: usize = 0;
+
+ // We don't need to dynamically allocate booleans
+ var true_bool = E.Boolean{ .value = true };
+ var false_bool = E.Boolean{ .value = false };
+ var bool_values = [_]*E.Boolean{ &false_bool, &true_bool };
+
+ /// When the lifetime of an Expr.Data's pointer must exist longer than reset() is called, use this function.
+ /// Be careful to free the memory (or use an allocator that does it for you)
+ /// Also, prefer Expr.init or Expr.alloc when possible. This will be slower.
+ pub fn allocate(allocator: std.mem.Allocator, comptime Type: type, st: Type, loc: logger.Loc) Expr {
+ icount += 1;
+ Data.Store.assert();
+
+ switch (Type) {
+ E.Array => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_array = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
},
- .e_function => |func| {
- return func.func.name == null;
+ E.Class => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_class = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
},
- .e_class => |class| {
- return class.class_name == null;
+ E.Unary => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_unary = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
},
+ E.Binary => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_binary = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.This => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_this = st,
+ },
+ };
+ },
+ E.Boolean => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_boolean = st,
+ },
+ };
+ },
+ E.Super => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_super = st,
+ },
+ };
+ },
+ E.Null => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_null = st,
+ },
+ };
+ },
+ E.Undefined => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_undefined = st,
+ },
+ };
+ },
+ E.New => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_new = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.NewTarget => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_new_target = st,
+ },
+ };
+ },
+ E.Function => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_function = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.ImportMeta => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_import_meta = st,
+ },
+ };
+ },
+ E.Call => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_call = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Dot => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_dot = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Index => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_index = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Arrow => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_arrow = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Identifier => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_identifier = E.Identifier{
+ .ref = st.ref,
+ .must_keep_due_to_with_stmt = st.must_keep_due_to_with_stmt,
+ .can_be_removed_if_unused = st.can_be_removed_if_unused,
+ .call_can_be_unwrapped_if_unused = st.call_can_be_unwrapped_if_unused,
+ },
+ },
+ };
+ },
+ E.ImportIdentifier => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_import_identifier = .{
+ .ref = st.ref,
+ .was_originally_identifier = st.was_originally_identifier,
+ },
+ },
+ };
+ },
+ E.CommonJSExportIdentifier => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_commonjs_export_identifier = .{
+ .ref = st.ref,
+ },
+ },
+ };
+ },
+
+ E.PrivateIdentifier => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_private_identifier = st,
+ },
+ };
+ },
+ E.JSXElement => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_jsx_element = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Missing => {
+ return Expr{ .loc = loc, .data = Data{ .e_missing = E.Missing{} } };
+ },
+ E.Number => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_number = st,
+ },
+ };
+ },
+ E.BigInt => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_big_int = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Object => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_object = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Spread => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_spread = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.String => {
+ if (comptime Environment.isDebug) {
+ // Sanity check: assert string is not a null ptr
+ if (st.data.len > 0 and st.isUTF8()) {
+ std.debug.assert(@ptrToInt(st.data.ptr) > 0);
+ std.debug.assert(st.data[0] > 0);
+ }
+ }
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_string = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.TemplatePart => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_template_part = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Template => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_template = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.RegExp => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_reg_exp = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Await => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_await = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Yield => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_yield = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.If => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_if = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.RequireOrRequireResolve => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_require_or_require_resolve = st,
+ },
+ };
+ },
+ E.Import => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_import = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st;
+ break :brk item;
+ },
+ },
+ };
+ },
+ E.Require => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_require = st,
+ },
+ };
+ },
+ *E.String => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_string = brk: {
+ var item = allocator.create(Type) catch unreachable;
+ item.* = st.*;
+ break :brk item;
+ },
+ },
+ };
+ },
+
else => {
- return false;
+ @compileError("Invalid type passed to Expr.init: " ++ @typeName(Type));
},
}
}
- pub var icount: usize = 0;
-
- // We don't need to dynamically allocate booleans
- var true_bool = E.Boolean{ .value = true };
- var false_bool = E.Boolean{ .value = false };
- var bool_values = [_]*E.Boolean{ &false_bool, &true_bool };
+ pub const Disabler = bun.DebugOnlyDisabler(@This());
pub fn init(comptime Type: type, st: Type, loc: logger.Loc) Expr {
icount += 1;
+ Data.Store.assert();
switch (Type) {
E.Array => {
return Expr{
.loc = loc,
.data = Data{
- .e_array = Data.Store.All.append(Type, st),
+ .e_array = Data.Store.append(Type, st),
},
};
},
@@ -2603,7 +3291,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_class = Data.Store.All.append(Type, st),
+ .e_class = Data.Store.append(Type, st),
},
};
},
@@ -2611,7 +3299,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_unary = Data.Store.All.append(Type, st),
+ .e_unary = Data.Store.append(Type, st),
},
};
},
@@ -2619,7 +3307,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_binary = Data.Store.All.append(Type, st),
+ .e_binary = Data.Store.append(Type, st),
},
};
},
@@ -2667,7 +3355,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_new = Data.Store.All.append(Type, st),
+ .e_new = Data.Store.append(Type, st),
},
};
},
@@ -2683,7 +3371,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_function = Data.Store.All.append(Type, st),
+ .e_function = Data.Store.append(Type, st),
},
};
},
@@ -2699,7 +3387,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_call = Data.Store.All.append(Type, st),
+ .e_call = Data.Store.append(Type, st),
},
};
},
@@ -2707,7 +3395,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_dot = Data.Store.All.append(Type, st),
+ .e_dot = Data.Store.append(Type, st),
},
};
},
@@ -2715,7 +3403,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_index = Data.Store.All.append(Type, st),
+ .e_index = Data.Store.append(Type, st),
},
};
},
@@ -2723,7 +3411,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_arrow = Data.Store.All.append(Type, st),
+ .e_arrow = Data.Store.append(Type, st),
},
};
},
@@ -2751,6 +3439,16 @@ pub const Expr = struct {
},
};
},
+ E.CommonJSExportIdentifier => {
+ return Expr{
+ .loc = loc,
+ .data = Data{
+ .e_commonjs_export_identifier = .{
+ .ref = st.ref,
+ },
+ },
+ };
+ },
E.PrivateIdentifier => {
return Expr{
.loc = loc,
@@ -2763,7 +3461,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_jsx_element = Data.Store.All.append(Type, st),
+ .e_jsx_element = Data.Store.append(Type, st),
},
};
},
@@ -2782,7 +3480,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_big_int = Data.Store.All.append(Type, st),
+ .e_big_int = Data.Store.append(Type, st),
},
};
},
@@ -2790,7 +3488,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_object = Data.Store.All.append(Type, st),
+ .e_object = Data.Store.append(Type, st),
},
};
},
@@ -2798,7 +3496,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_spread = Data.Store.All.append(Type, st),
+ .e_spread = Data.Store.append(Type, st),
},
};
},
@@ -2813,7 +3511,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_string = Data.Store.All.append(Type, st),
+ .e_string = Data.Store.append(Type, st),
},
};
},
@@ -2821,7 +3519,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_template_part = Data.Store.All.append(Type, st),
+ .e_template_part = Data.Store.append(Type, st),
},
};
},
@@ -2829,7 +3527,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_template = Data.Store.All.append(Type, st),
+ .e_template = Data.Store.append(Type, st),
},
};
},
@@ -2837,7 +3535,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_reg_exp = Data.Store.All.append(Type, st),
+ .e_reg_exp = Data.Store.append(Type, st),
},
};
},
@@ -2845,7 +3543,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_await = Data.Store.All.append(Type, st),
+ .e_await = Data.Store.append(Type, st),
},
};
},
@@ -2853,7 +3551,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_yield = Data.Store.All.append(Type, st),
+ .e_yield = Data.Store.append(Type, st),
},
};
},
@@ -2861,7 +3559,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_if = Data.Store.All.append(Type, st),
+ .e_if = Data.Store.append(Type, st),
},
};
},
@@ -2877,7 +3575,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_import = Data.Store.All.append(Type, st),
+ .e_import = Data.Store.append(Type, st),
},
};
},
@@ -2893,7 +3591,7 @@ pub const Expr = struct {
return Expr{
.loc = loc,
.data = Data{
- .e_string = Data.Store.All.append(@TypeOf(st.*), st.*),
+ .e_string = Data.Store.append(@TypeOf(st.*), st.*),
},
};
},
@@ -2942,6 +3640,8 @@ pub const Expr = struct {
e_class,
e_require,
+ e_commonjs_export_identifier,
+
// This should never make it to the printer
inline_identifier,
@@ -3504,16 +4204,6 @@ pub const Expr = struct {
return null;
}
- pub fn assignStmt(a: Expr, b: Expr, allocator: std.mem.Allocator) Stmt {
- return Stmt.alloc(
- S.SExpr,
- S.SExpr{
- .value = Expr.assign(a, b, allocator),
- },
- a.loc,
- );
- }
-
pub fn isOptionalChain(self: *const @This()) bool {
return switch (self.data) {
.e_dot => self.data.e_dot.optional_chain != null,
@@ -3594,6 +4284,7 @@ pub const Expr = struct {
e_identifier: E.Identifier,
e_import_identifier: E.ImportIdentifier,
e_private_identifier: E.PrivateIdentifier,
+ e_commonjs_export_identifier: E.CommonJSExportIdentifier,
e_boolean: E.Boolean,
e_number: E.Number,
@@ -3955,7 +4646,7 @@ pub const Expr = struct {
const medium = 256;
const rare = 24;
- pub const All = NewBaseStore(
+ const All = NewBaseStore(
&([_]type{
E.Array,
E.Unary,
@@ -3986,10 +4677,12 @@ pub const Expr = struct {
512,
);
+ pub threadlocal var memory_allocator: ?*ASTMemoryAllocator = null;
+
threadlocal var has_inited = false;
pub threadlocal var disable_reset = false;
pub fn create(allocator: std.mem.Allocator) void {
- if (has_inited) {
+ if (has_inited or memory_allocator != null) {
return;
}
@@ -3997,34 +4690,34 @@ pub const Expr = struct {
_ = All.init(allocator);
}
- pub fn assert() void {
- if (comptime Environment.allow_assert) {
- if (!has_inited)
- bun.unreachablePanic("Store must be init'd", .{});
- }
- }
-
pub fn reset() void {
- if (disable_reset) return;
+ if (disable_reset or memory_allocator != null) return;
All.reset();
}
pub fn deinit() void {
- if (!has_inited) return;
+ if (!has_inited or memory_allocator != null) return;
All.deinit();
has_inited = false;
}
+ pub inline fn assert() void {
+ if (comptime Environment.allow_assert) {
+ if (!has_inited and memory_allocator == null)
+ bun.unreachablePanic("Store must be init'd", .{});
+ }
+ }
+
pub fn append(comptime ValueType: type, value: anytype) *ValueType {
- if (ValueType == E.Identifier) {
- return E.Identifier.append(ValueType, value);
- } else {
- return All.append(ValueType, value);
+ if (memory_allocator) |allocator| {
+ return allocator.append(ValueType, value);
}
+
+ return All.append(Disabler, ValueType, value);
}
pub fn toOwnedSlice() []*Store.All.Block {
- if (!has_inited or Store.All._self.overflow.used == 0 or disable_reset) return &[_]*Store.All.Block{};
+ if (!has_inited or Store.All._self.overflow.used == 0 or disable_reset or memory_allocator != null) return &[_]*Store.All.Block{};
return Store.All.reclaim();
}
};
@@ -4534,9 +5227,11 @@ pub const ArrayBinding = struct {
};
pub const Ast = struct {
+ pub const TopLevelSymbolToParts = std.ArrayHashMapUnmanaged(Ref, BabyList(u32), Ref.ArrayHashCtx, false);
+
approximate_newline_count: usize = 0,
has_lazy_export: bool = false,
- runtime_imports: Runtime.Imports,
+ runtime_imports: Runtime.Imports = .{},
runtime_import_record_id: ?u32 = null,
needs_runtime: bool = false,
@@ -4554,22 +5249,23 @@ pub const Ast = struct {
// This is a list of ES6 features. They are ranges instead of booleans so
// that they can be used in log messages. Check to see if "Len > 0".
- import_keyword: ?logger.Range = null, // Does not include TypeScript-specific syntax or "import()"
- export_keyword: ?logger.Range = null, // Does not include TypeScript-specific syntax
- top_level_await_keyword: ?logger.Range = null,
+ import_keyword: logger.Range = logger.Range.None, // Does not include TypeScript-specific syntax or "import()"
+ export_keyword: logger.Range = logger.Range.None, // Does not include TypeScript-specific syntax
+ top_level_await_keyword: logger.Range = logger.Range.None,
// These are stored at the AST level instead of on individual AST nodes so
// they can be manipulated efficiently without a full AST traversal
- import_records: []ImportRecord = &([_]ImportRecord{}),
+ import_records: ImportRecord.List = .{},
hashbang: ?string = null,
directive: ?string = null,
url_for_css: ?string = null,
- parts: []Part,
- symbols: []Symbol = &([_]Symbol{}),
- module_scope: ?Scope = null,
+ parts: Part.List = Part.List{},
+ // This list may be mutated later, so we should store the capacity
+ symbols: Symbol.List = Symbol.List{},
+ module_scope: Scope = Scope{},
// char_freq: *CharFreq,
- exports_ref: ?Ref = null,
+ exports_ref: Ref = Ref.None,
module_ref: ?Ref = null,
wrapper_ref: ?Ref = null,
require_ref: Ref = Ref.None,
@@ -4583,21 +5279,38 @@ pub const Ast = struct {
// These are used when bundling. They are filled in during the parser pass
// since we already have to traverse the AST then anyway and the parser pass
// is conveniently fully parallelized.
- named_imports: NamedImports = undefined,
- named_exports: NamedExports = undefined,
+ named_imports: NamedImports = NamedImports.init(bun.failing_allocator),
+ named_exports: NamedExports = NamedExports.init(bun.failing_allocator),
export_star_import_records: []u32 = &([_]u32{}),
+ allocator: std.mem.Allocator,
+ top_level_symbols_to_parts: TopLevelSymbolToParts = .{},
+
+ commonjs_named_exports: CommonJSNamedExports = .{},
+
+ redirect_import_record_index: ?u32 = null,
+
+ /// Only populated when bundling
+ platform: bun.options.Platform = .browser,
+
+ pub const CommonJSNamedExport = struct {
+ loc_ref: LocRef,
+ needs_decl: bool = true,
+ };
+ pub const CommonJSNamedExports = bun.StringArrayHashMapUnmanaged(CommonJSNamedExport);
+
pub const NamedImports = std.ArrayHashMap(Ref, NamedImport, RefHashCtx, true);
pub const NamedExports = bun.StringArrayHashMap(NamedExport);
pub fn initTest(parts: []Part) Ast {
return Ast{
- .parts = parts,
+ .parts = Part.List.init(parts),
+ .allocator = bun.default_allocator,
.runtime_imports = .{},
};
}
- pub const empty = Ast{ .parts = &[_]Part{}, .runtime_imports = undefined };
+ pub const empty = Ast{ .parts = Part.List{}, .runtime_imports = .{}, .allocator = bun.default_allocator };
pub fn toJSON(self: *const Ast, _: std.mem.Allocator, stream: anytype) !void {
const opts = std.json.StringifyOptions{ .whitespace = std.json.StringifyOptions.Whitespace{
@@ -4609,16 +5322,16 @@ pub const Ast = struct {
/// Do not call this if it wasn't globally allocated!
pub fn deinit(this: *Ast) void {
// TODO: assert mimalloc-owned memory
- if (this.parts.len > 0) bun.default_allocator.free(this.parts);
+ if (this.parts.len > 0) this.parts.deinitWithAllocator(bun.default_allocator);
if (this.externals.len > 0) bun.default_allocator.free(this.externals);
- if (this.symbols.len > 0) bun.default_allocator.free(this.symbols);
- if (this.import_records.len > 0) bun.default_allocator.free(this.import_records);
+ if (this.symbols.len > 0) this.symbols.deinitWithAllocator(bun.default_allocator);
+ if (this.import_records.len > 0) this.import_records.deinitWithAllocator(bun.default_allocator);
}
};
pub const Span = struct {
- text: string,
- range: logger.Range,
+ text: string = "",
+ range: logger.Range = .{},
};
pub const ExportsKind = enum {
@@ -4646,7 +5359,11 @@ pub const ExportsKind = enum {
// "exports") with getters for the export names. All named imports to this
// module are allowed. Direct named imports reference the corresponding export
// directly. Other imports go through property accesses on "exports".
- esm_with_dyn,
+ esm_with_dynamic_fallback,
+
+ pub fn isDynamic(self: ExportsKind) bool {
+ return self == .esm_with_dynamic_fallback or self == .cjs;
+ }
pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
@@ -4656,11 +5373,103 @@ pub const ExportsKind = enum {
pub const DeclaredSymbol = struct {
ref: Ref,
is_top_level: bool = false,
+
+ pub const List = struct {
+ entries: bun.MultiArrayList(DeclaredSymbol) = .{},
+
+ pub fn refs(this: *const List) []Ref {
+ return this.entries.items(.ref);
+ }
+
+ pub fn toOwnedSlice(this: *List) List {
+ var new = this.*;
+
+ this.* = .{};
+ return new;
+ }
+
+ pub fn clone(this: *const List, allocator: std.mem.Allocator) !List {
+ return List{ .entries = try this.entries.clone(allocator) };
+ }
+
+ pub inline fn len(this: List) usize {
+ return this.entries.len;
+ }
+
+ pub fn append(this: *List, allocator: std.mem.Allocator, entry: DeclaredSymbol) !void {
+ try this.ensureUnusedCapacity(allocator, 1);
+ this.appendAssumeCapacity(entry);
+ }
+
+ pub fn appendList(this: *List, allocator: std.mem.Allocator, other: List) !void {
+ try this.ensureUnusedCapacity(allocator, other.len());
+ this.appendListAssumeCapacity(other);
+ }
+
+ pub fn appendListAssumeCapacity(this: *List, other: List) void {
+ this.entries.appendListAssumeCapacity(other.entries);
+ }
+
+ pub fn appendAssumeCapacity(this: *List, entry: DeclaredSymbol) void {
+ this.entries.appendAssumeCapacity(entry);
+ }
+
+ pub fn ensureTotalCapacity(this: *List, allocator: std.mem.Allocator, count: usize) !void {
+ try this.entries.ensureTotalCapacity(allocator, count);
+ }
+
+ pub fn ensureUnusedCapacity(this: *List, allocator: std.mem.Allocator, count: usize) !void {
+ try this.entries.ensureUnusedCapacity(allocator, count);
+ }
+
+ pub fn clearRetainingCapacity(this: *List) void {
+ this.entries.clearRetainingCapacity();
+ }
+
+ pub fn deinit(this: *List, allocator: std.mem.Allocator) void {
+ this.entries.deinit(allocator);
+ }
+
+ pub fn initCapacity(allocator: std.mem.Allocator, capacity: usize) !List {
+ var entries = bun.MultiArrayList(DeclaredSymbol){};
+ try entries.ensureUnusedCapacity(allocator, capacity);
+ return List{ .entries = entries };
+ }
+
+ pub fn fromSlice(allocator: std.mem.Allocator, entries: []const DeclaredSymbol) !List {
+ var this = try List.initCapacity(allocator, entries.len);
+ errdefer this.deinit(allocator);
+ for (entries) |entry| {
+ this.appendAssumeCapacity(entry);
+ }
+
+ return this;
+ }
+ };
+
+ fn forEachTopLevelSymbolWithType(decls: *List, comptime Ctx: type, ctx: Ctx, comptime Fn: fn (Ctx, Ref) void) void {
+ var entries = decls.entries.slice();
+ const is_top_level = entries.items(.is_top_level);
+ const refs = entries.items(.ref);
+
+ // TODO: SIMD
+ for (is_top_level, refs) |top, ref| {
+ if (top) {
+ @call(.always_inline, Fn, .{ ctx, ref });
+ }
+ }
+ }
+
+ pub fn forEachTopLevelSymbol(decls: *List, ctx: anytype, comptime Fn: anytype) void {
+ forEachTopLevelSymbolWithType(decls, @TypeOf(ctx), ctx, Fn);
+ }
};
-pub const Dependency = packed struct {
- source_index: u32 = 0,
- part_index: u32 = 0,
+pub const Dependency = struct {
+ source_index: Index = Index.invalid,
+ part_index: Index.Int = 0,
+
+ pub const List = BabyList(Dependency);
};
pub const ExprList = std.ArrayList(Expr);
@@ -4673,24 +5482,27 @@ pub const BindingList = std.ArrayList(Binding);
// shaking and can be assigned to separate chunks (i.e. output files) by code
// splitting.
pub const Part = struct {
- stmts: []Stmt,
+ pub const ImportRecordIndices = BabyList(u32);
+ pub const List = BabyList(Part);
+
+ stmts: []Stmt = &([_]Stmt{}),
scopes: []*Scope = &([_]*Scope{}),
// Each is an index into the file-level import record list
- import_record_indices: []u32 = &([_]u32{}),
+ import_record_indices: ImportRecordIndices = .{},
// All symbols that are declared in this part. Note that a given symbol may
// have multiple declarations, and so may end up being declared in multiple
// parts (e.g. multiple "var" declarations with the same name). Also note
// that this list isn't deduplicated and may contain duplicates.
- declared_symbols: []DeclaredSymbol = &([_]DeclaredSymbol{}),
+ declared_symbols: DeclaredSymbol.List = .{},
// An estimate of the number of uses of all symbols used within this part.
symbol_uses: SymbolUseMap = SymbolUseMap{},
// The indices of the other parts in this file that are needed if this part
// is needed.
- dependencies: []Dependency = &([_]Dependency{}),
+ dependencies: Dependency.List = .{},
// If true, this part can be removed if none of the declared symbols are
// used. If the file containing this part is imported, then all parts that
@@ -4708,6 +5520,8 @@ pub const Part = struct {
tag: Tag = Tag.none,
+ valid_in_development: if (bun.Environment.allow_assert) bool else void = bun.DebugOnlyDefault(true),
+
pub const Tag = enum {
none,
jsx_import,
@@ -4737,10 +5551,10 @@ pub const StmtOrExpr = union(enum) {
pub const NamedImport = struct {
// Parts within this file that use this import
- local_parts_with_uses: []u32 = &([_]u32{}),
+ local_parts_with_uses: BabyList(u32) = BabyList(u32){},
alias: ?string,
- alias_loc: ?logger.Loc,
+ alias_loc: ?logger.Loc = null,
namespace_ref: ?Ref,
import_record_index: u32,
@@ -4760,7 +5574,7 @@ pub const NamedExport = struct {
alias_loc: logger.Loc,
};
-pub const StrictModeKind = enum(u7) {
+pub const StrictModeKind = enum(u4) {
sloppy_mode,
explicit_strict_mode,
implicit_strict_mode_import,
@@ -4777,10 +5591,10 @@ pub const Scope = struct {
id: usize = 0,
kind: Kind = Kind.block,
- parent: ?*Scope,
- children: std.ArrayListUnmanaged(*Scope) = .{},
+ parent: ?*Scope = null,
+ children: BabyList(*Scope) = .{},
members: MemberHashMap = .{},
- generated: std.ArrayListUnmanaged(Ref) = .{},
+ generated: BabyList(Ref) = .{},
// This is used to store the ref of the label symbol for ScopeLabel scopes.
label_ref: ?Ref = null,
@@ -4798,6 +5612,8 @@ pub const Scope = struct {
is_after_const_local_prefix: bool = false,
+ pub const NestedScopeMap = std.AutoArrayHashMap(u32, bun.BabyList(*Scope));
+
pub fn getMemberHash(name: []const u8) u64 {
return bun.StringHashMapContext.hash(.{}, name);
}
@@ -4900,10 +5716,12 @@ pub const Scope = struct {
// "var foo; function foo() {}"
// "function foo() {} var foo;"
// "function *foo() {} function *foo() {}" but not "{ function *foo() {} function *foo() {} }"
- if (Symbol.isKindHoistedOrFunction(new) and Symbol.isKindHoistedOrFunction(existing) and (scope.kind == .entry or scope.kind == .function_body or
- (Symbol.isKindHoisted(new) and Symbol.isKindHoisted(existing))))
+ if (Symbol.isKindHoistedOrFunction(new) and
+ Symbol.isKindHoistedOrFunction(existing) and
+ (scope.kind == .entry or scope.kind == .function_body or scope.kind == .function_args or
+ (new == existing and Symbol.isKindHoisted(existing))))
{
- return .keep_existing;
+ return .replace_with_new;
}
// "get #foo() {} set #foo() {}"
@@ -4958,7 +5776,7 @@ pub const Scope = struct {
pub fn recursiveSetStrictMode(s: *Scope, kind: StrictModeKind) void {
if (s.strict_mode == .sloppy_mode) {
s.strict_mode = kind;
- for (s.children.items) |child| {
+ for (s.children.slice()) |child| {
child.recursiveSetStrictMode(kind);
}
}
@@ -8337,6 +9155,116 @@ pub const Macro = struct {
};
};
+pub const ASTMemoryAllocator = struct {
+ stack_allocator: std.heap.StackFallbackAllocator(8096) = undefined,
+ bump_allocator: std.mem.Allocator = undefined,
+ allocator: std.mem.Allocator,
+ previous: ?*ASTMemoryAllocator = null,
+
+ pub fn push(this: *ASTMemoryAllocator) void {
+ if (Stmt.Data.Store.memory_allocator == this) {
+ return;
+ }
+ this.stack_allocator.fallback_allocator = this.allocator;
+ this.bump_allocator = this.stack_allocator.get();
+ var prev = Stmt.Data.Store.memory_allocator;
+ if (this.previous) |other| {
+ other.previous = prev;
+ } else {
+ this.previous = prev;
+ }
+ Stmt.Data.Store.memory_allocator = this;
+ Expr.Data.Store.memory_allocator = this;
+ }
+
+ pub fn pop(this: *ASTMemoryAllocator) void {
+ var prev = this.previous;
+ std.debug.assert(prev != this);
+ Stmt.Data.Store.memory_allocator = prev;
+ Expr.Data.Store.memory_allocator = prev;
+ this.previous = null;
+ }
+
+ pub fn append(this: ASTMemoryAllocator, comptime ValueType: type, value: anytype) *ValueType {
+ const ptr = this.bump_allocator.create(ValueType) catch unreachable;
+ ptr.* = value;
+ return ptr;
+ }
+};
+
+pub const UseDirective = enum {
+ none,
+ @"use client",
+ @"use server",
+
+ pub const Flags = struct {
+ is_client: bool = false,
+ is_server: bool = false,
+ };
+
+ pub fn isBoundary(this: UseDirective, other: UseDirective) bool {
+ if (this == other or other == .none)
+ return false;
+
+ return true;
+ }
+
+ pub fn boundering(this: UseDirective, other: UseDirective) ?UseDirective {
+ if (this == other or other == .none)
+ return null;
+
+ return other;
+ }
+
+ pub const EntryPoint = struct {
+ source_index: Index.Int,
+ use_directive: UseDirective,
+ };
+
+ pub const List = std.MultiArrayList(UseDirective.EntryPoint);
+
+ // TODO: remove this, add an onModuleDirective() callback to the parser
+ pub fn parse(contents: []const u8) UseDirective {
+ const truncated = std.mem.trimLeft(u8, contents, " \t\n\r;");
+
+ if (truncated.len < "'use client';".len)
+ return .none;
+
+ const directive_string = truncated[0.."'use client';".len].*;
+
+ const first_quote = directive_string[0];
+ const last_quote = directive_string[directive_string.len - 2];
+ if (first_quote != last_quote or (first_quote != '"' and first_quote != '\'' and first_quote != '`'))
+ return .none;
+
+ const unquoted = directive_string[1 .. directive_string.len - 2];
+
+ if (strings.eqlComptime(
+ unquoted,
+ "use client",
+ )) {
+ return .@"use client";
+ }
+
+ if (strings.eqlComptime(
+ unquoted,
+ "use server",
+ )) {
+ return .@"use server";
+ }
+
+ return .none;
+ }
+
+ pub fn platform(this: UseDirective, default: bun.options.Platform) bun.options.Platform {
+ return switch (this) {
+ .none => default,
+ .@"use client" => .browser,
+ .@"use server" => .bun,
+ };
+ }
+};
+
// test "Binding.init" {
// var binding = Binding.alloc(
// std.heap.page_allocator,
@@ -8525,3 +9453,4 @@ pub const Macro = struct {
// Stmt | 192
// STry | 384
// -- ESBuild bit sizes
+
diff --git a/src/js_lexer.zig b/src/js_lexer.zig
index 3205a0822..da445235a 100644
--- a/src/js_lexer.zig
+++ b/src/js_lexer.zig
@@ -1069,6 +1069,7 @@ fn NewLexer_(
pub fn next(lexer: *LexerType) !void {
lexer.has_newline_before = lexer.end == 0;
+ lexer.has_pure_comment_before = false;
while (true) {
lexer.start = lexer.end;
@@ -1784,16 +1785,17 @@ fn NewLexer_(
fn scanCommentText(lexer: *LexerType) void {
const text = lexer.source.contents[lexer.start..lexer.end];
- const has_preserve_annotation = text.len > 2 and text[2] == '!';
- const is_multiline_comment = text[1] == '*';
+ const has_legal_annotation = text.len > 2 and text[2] == '!';
+ const is_multiline_comment = text.len > 1 and text[1] == '*';
// Omit the trailing "*/" from the checks below
- var endCommentText = text.len;
- if (is_multiline_comment) {
- endCommentText -= 2;
- }
+ const end_comment_text =
+ if (is_multiline_comment)
+ text.len - 2
+ else
+ text.len;
- if (has_preserve_annotation or lexer.preserve_all_comments_before) {
+ if (has_legal_annotation or lexer.preserve_all_comments_before) {
if (is_multiline_comment) {
// text = lexer.removeMultilineCommentIndent(lexer.source.contents[0..lexer.start], text);
}
@@ -1803,10 +1805,98 @@ fn NewLexer_(
.loc = lexer.loc(),
}) catch unreachable;
}
+
+ // tsconfig.json doesn't care about annotations
+ if (comptime is_json)
+ return;
+
+ // TODO: @jsx annotations
+ if (lexer.has_pure_comment_before)
+ return;
+
+ var rest = text[0..end_comment_text];
+ const end = rest.ptr + rest.len;
+
+ if (comptime Environment.enableSIMD) {
+ const wrapped_len = rest.len - (rest.len % strings.ascii_vector_size);
+ const comment_end = rest.ptr + wrapped_len;
+ while (rest.ptr != comment_end) {
+ const vec: strings.AsciiVector = rest.ptr[0..strings.ascii_vector_size].*;
+
+ // lookahead for any # or @ characters
+ const hashtag = @bitCast(strings.AsciiVectorU1, vec == @splat(strings.ascii_vector_size, @as(u8, '#')));
+ const at = @bitCast(strings.AsciiVectorU1, vec == @splat(strings.ascii_vector_size, @as(u8, '@')));
+
+ if (@reduce(.Max, hashtag + at) == 1) {
+ rest.len = @ptrToInt(end) - @ptrToInt(rest.ptr);
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(
+ strings.containsChar(&@as([strings.ascii_vector_size]u8, vec), '#') or
+ strings.containsChar(&@as([strings.ascii_vector_size]u8, vec), '@'),
+ );
+ }
+
+ for (@as([strings.ascii_vector_size]u8, vec), 0..) |c, i| {
+ switch (c) {
+ '@', '#' => {
+ if (!lexer.has_pure_comment_before) {
+ if (strings.indexOf(rest[i + 1 ..], "__PURE__")) |pure_i| {
+ const pure_prefix = rest[i + 1 ..][0..pure_i];
+ const pure_suffix = rest[i + 1 ..][pure_i + "__PURE__".len ..];
+ const has_prefix = pure_prefix.len == 0 or (strings.isAllASCII(pure_prefix) and !isIdentifierStart(pure_prefix[pure_prefix.len - 1]));
+
+ // TODO: unicode whitespace for pure comments
+ // This misses non-ascii whitespace, but that's fine for now
+ const has_suffix = pure_suffix.len == 0 or !isIdentifierContinue(pure_suffix[0]);
+ lexer.has_pure_comment_before = has_prefix and has_suffix;
+
+ // TODO: handle JSX annotations
+ if (lexer.has_pure_comment_before)
+ return;
+ }
+ }
+ },
+ else => {},
+ }
+ }
+ }
+
+ rest.ptr += strings.ascii_vector_size;
+ }
+ rest.len = @ptrToInt(end) - @ptrToInt(rest.ptr);
+ }
+
+ if (comptime Environment.allow_assert)
+ std.debug.assert(rest.len == 0 or bun.isSliceInBuffer(rest, text));
+
+ while (rest.len > 0) {
+ const c = rest[0];
+ rest = rest[1..];
+ switch (c) {
+ '@', '#' => {
+ if (!lexer.has_pure_comment_before) {
+ if (strings.indexOf(rest, "__PURE__")) |pure_i| {
+ const pure_prefix = rest[0..pure_i];
+ const pure_suffix = rest[pure_i + "__PURE__".len ..];
+ const has_prefix = pure_prefix.len == 0 or (strings.isAllASCII(pure_prefix) and !isIdentifierStart(pure_prefix[pure_prefix.len - 1]));
+
+ // TODO: unicode whitespace for pure comments
+ // This misses non-ascii whitespace, but that's fine for now
+ const has_suffix = pure_suffix.len == 0 or !isIdentifierContinue(pure_suffix[0]);
+ lexer.has_pure_comment_before = (has_prefix and has_suffix);
+
+ // TODO: handle JSX annotations
+ if (lexer.has_pure_comment_before)
+ return;
+ }
+ }
+ },
+ else => {},
+ }
+ }
}
// TODO: implement this
- // it's too complicated to handle all the edgecases right now given the state of Zig's standard library
pub fn removeMultilineCommentIndent(_: *LexerType, _: string, text: string) string {
return text;
}
@@ -3079,6 +3169,7 @@ fn indexOfInterestingCharacterInStringLiteral(text_: []const u8, quote: u8) ?usi
return null;
}
+
test "isIdentifier" {
const expect = std.testing.expect;
try expect(!isIdentifierStart(0x2029));
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 33b051ab0..587e29f62 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -37,6 +37,7 @@ pub const ExprNodeIndex = js_ast.ExprNodeIndex;
pub const ExprNodeList = js_ast.ExprNodeList;
pub const StmtNodeList = js_ast.StmtNodeList;
pub const BindingNodeList = js_ast.BindingNodeList;
+const DeclaredSymbol = js_ast.DeclaredSymbol;
const ComptimeStringMap = @import("./comptime_string_map.zig").ComptimeStringMap;
const JSC = @import("bun").JSC;
@@ -46,6 +47,7 @@ fn _disabledAssert(_: bool) void {
}
const assert = if (Environment.allow_assert) std.debug.assert else _disabledAssert;
+const debug = Output.scoped(.JSParser, false);
const ExprListLoc = struct {
list: ExprNodeList,
loc: logger.Loc,
@@ -67,13 +69,92 @@ const Ref = @import("./ast/base.zig").Ref;
const RefHashCtx = @import("./ast/base.zig").RefHashCtx;
pub const StringHashMap = bun.StringHashMap;
-pub const AutoHashMap = bun.AutoHashMap;
+pub const AutoHashMap = std.AutoHashMap;
const StringHashMapUnamanged = bun.StringHashMapUnmanaged;
const ObjectPool = @import("./pool.zig").ObjectPool;
const NodeFallbackModules = @import("./node_fallbacks.zig");
const RefExprMap = std.ArrayHashMapUnmanaged(Ref, Expr, RefHashCtx, false);
+const JSXImport = enum {
+ jsx,
+ jsxDEV,
+ jsxs,
+ Fragment,
+ createElement,
+
+ pub const Symbols = struct {
+ jsx: ?LocRef = null,
+ jsxDEV: ?LocRef = null,
+ jsxs: ?LocRef = null,
+ Fragment: ?LocRef = null,
+ createElement: ?LocRef = null,
+
+ pub fn get(this: *const Symbols, name: []const u8) ?Ref {
+ if (strings.eqlComptime(name, "jsx")) return if (this.jsx) |jsx| jsx.ref.? else null;
+ if (strings.eqlComptime(name, "jsxDEV")) return if (this.jsxDEV) |jsx| jsx.ref.? else null;
+ if (strings.eqlComptime(name, "jsxs")) return if (this.jsxs) |jsxs| jsxs.ref.? else null;
+ if (strings.eqlComptime(name, "Fragment")) return if (this.Fragment) |Fragment| Fragment.ref.? else null;
+ if (strings.eqlComptime(name, "createElement")) return if (this.createElement) |createElement| createElement.ref.? else null;
+ return null;
+ }
+
+ const Runtime = struct {
+ pub const full: []const string = &[_]string{ "jsx", "jsxs" };
+ pub const jsxs_: []const string = &[_]string{"jsxs"};
+ pub const jsx_: []const string = &[_]string{"jsx"};
+ };
+
+ const DevRuntime = struct {
+ pub const full: []const string = &[_]string{ "jsxDEV", "jsxs" };
+ pub const jsxs_: []const string = &[_]string{"jsxs"};
+ pub const jsx_: []const string = &[_]string{"jsxDEV"};
+ };
+ pub fn runtimeImportNames(this: *const Symbols) []const string {
+ if (this.jsxDEV != null) {
+ std.debug.assert(this.jsx == null); // we should never end up with this in the same file
+
+ if (this.jsxs != null)
+ return DevRuntime.full;
+
+ return DevRuntime.jsx_;
+ }
+
+ if (this.jsx != null and this.jsxs != null)
+ return Runtime.full;
+
+ if (this.jsxs != null)
+ return Runtime.jsxs_;
+
+ if (this.jsx != null)
+ return Runtime.jsx_;
+
+ return &[_]string{};
+ }
+
+ const Legacy = struct {
+ pub const full: []const string = &[_]string{ "createElement", "Fragment" };
+ pub const createElement_: []const string = &[_]string{"createElement"};
+ pub const Fragment_: []const string = &[_]string{"Fragment"};
+ };
+
+ pub fn legacyImportNames(this: *const Symbols) []const string {
+ if (this.Fragment != null and this.createElement != null)
+ return Legacy.full;
+
+ if (this.createElement != null)
+ return Legacy.createElement_;
+
+ if (this.Fragment != null)
+ return Legacy.Fragment_;
+
+ return &[_]string{};
+ }
+ };
+};
+
+const arguments_str: string = "arguments";
+
// Dear reader,
// There are some things you should know about this file to make it easier for humans to read
// "P" is the internal parts of the parser
@@ -119,7 +200,9 @@ fn foldStringAddition(lhs: Expr, rhs: Expr) ?Expr {
if (rhs.data == .e_string and left.isUTF8() and rhs.data.e_string.isUTF8()) {
var orig = lhs.data.e_string.*;
const rhs_clone = Expr.init(E.String, rhs.data.e_string.*, rhs.loc);
- orig.push(rhs_clone.data.e_string);
+ orig.push(
+ rhs_clone.data.e_string,
+ );
return Expr.init(E.String, orig, lhs.loc);
}
@@ -185,9 +268,15 @@ pub fn ExpressionTransposer(
pub fn maybeTransposeIf(self: *This, arg: Expr, state: anytype) Expr {
switch (arg.data) {
.e_if => |ex| {
- ex.yes = self.maybeTransposeIf(ex.yes, state);
- ex.no = self.maybeTransposeIf(ex.no, state);
- return arg;
+ return Expr.init(
+ E.If,
+ E.If{
+ .yes = self.maybeTransposeIf(ex.yes, state),
+ .no = self.maybeTransposeIf(ex.no, state),
+ .test_ = ex.test_,
+ },
+ arg.loc,
+ );
},
else => {
return visitor(self.context, arg, state);
@@ -651,7 +740,7 @@ pub const ImportScanner = struct {
}
const namespace_ref = st.namespace_ref;
- const convert_star_to_clause = !p.options.enable_bundling and !p.options.can_import_from_bundle and p.symbols.items[namespace_ref.innerIndex()].use_count_estimate == 0;
+ const convert_star_to_clause = !p.options.bundle or (!p.options.enable_legacy_bundling and !p.options.can_import_from_bundle and p.symbols.items[namespace_ref.innerIndex()].use_count_estimate == 0);
if (convert_star_to_clause and !keep_unused_imports) {
st.star_name_loc = null;
@@ -662,51 +751,140 @@ pub const ImportScanner = struct {
const existing_items: ImportItemForNamespaceMap = p.import_items_for_namespace.get(namespace_ref) orelse
ImportItemForNamespaceMap.init(allocator);
- // ESM requires live bindings
- // CommonJS does not require live bindings
- // We load ESM in browsers & in Bun.js
- // We have to simulate live bindings for cases where the code is bundled
- // We do not know at this stage whether or not the import statement is bundled
- // This keeps track of the `namespace_alias` incase, at printing time, we determine that we should print it with the namespace
- for (st.items) |item| {
- const is_default = strings.eqlComptime(item.alias, "default");
- record.contains_default_alias = record.contains_default_alias or is_default;
+ if (p.options.bundle) {
+ if (st.star_name_loc != null and existing_items.count() > 0) {
+ var sorted = try allocator.alloc(string, existing_items.count());
+ defer allocator.free(sorted);
+ for (sorted, existing_items.keys()) |*result, alias| {
+ result.* = alias;
+ }
+ strings.sortDesc(sorted);
+ p.named_imports.ensureUnusedCapacity(sorted.len) catch unreachable;
- const name: LocRef = item.name;
- const name_ref = name.ref.?;
+ // Create named imports for these property accesses. This will
+ // cause missing imports to generate useful warnings.
+ //
+ // It will also improve bundling efficiency for internal imports
+ // by still converting property accesses off the namespace into
+ // bare identifiers even if the namespace is still needed.
+ for (sorted) |alias| {
+ const item = existing_items.get(alias).?;
+ p.named_imports.put(
+ item.ref.?,
+ js_ast.NamedImport{
+ .alias = alias,
+ .alias_loc = item.loc,
+ .namespace_ref = namespace_ref,
+ .import_record_index = st.import_record_index,
+ },
+ ) catch unreachable;
- try p.named_imports.put(name_ref, js_ast.NamedImport{
- .alias = item.alias,
- .alias_loc = name.loc,
- .namespace_ref = namespace_ref,
- .import_record_index = st.import_record_index,
- });
+ const name: LocRef = item;
+ const name_ref = name.ref.?;
- // Make sure the printer prints this as a property access
- var symbol: *Symbol = &p.symbols.items[name_ref.innerIndex()];
+ // Make sure the printer prints this as a property access
+ var symbol: *Symbol = &p.symbols.items[name_ref.innerIndex()];
- symbol.namespace_alias = G.NamespaceAlias{
- .namespace_ref = namespace_ref,
- .alias = item.alias,
- .import_record_index = st.import_record_index,
- .was_originally_property_access = st.star_name_loc != null and existing_items.contains(symbol.original_name),
- };
+ symbol.namespace_alias = G.NamespaceAlias{
+ .namespace_ref = namespace_ref,
+ .alias = alias,
+ .import_record_index = st.import_record_index,
+ .was_originally_property_access = st.star_name_loc != null and existing_items.contains(symbol.original_name),
+ };
+
+ // Also record these automatically-generated top-level namespace alias symbols
+ p.declared_symbols.append(p.allocator, .{
+ .ref = name_ref,
+ .is_top_level = true,
+ }) catch unreachable;
+ }
+ }
+
+ p.named_imports.ensureUnusedCapacity(
+ st.items.len + @as(
+ usize,
+ @boolToInt(st.default_name != null),
+ ),
+ ) catch unreachable;
+
+ if (st.default_name) |default| {
+ p.named_imports.putAssumeCapacity(
+ default.ref.?,
+ .{
+ .alias = "default",
+ .alias_loc = default.loc,
+ .namespace_ref = namespace_ref,
+ .import_record_index = st.import_record_index,
+ },
+ );
+ }
+
+ for (st.items) |item| {
+ const name: LocRef = item.name;
+ const name_ref = name.ref.?;
+
+ p.named_imports.putAssumeCapacity(
+ name_ref,
+ js_ast.NamedImport{
+ .alias = item.alias,
+ .alias_loc = name.loc,
+ .namespace_ref = namespace_ref,
+ .import_record_index = st.import_record_index,
+ },
+ );
+ }
+ } else {
+
+ // ESM requires live bindings
+ // CommonJS does not require live bindings
+ // We load ESM in browsers & in Bun.js
+ // We have to simulate live bindings for cases where the code is bundled
+ // We do not know at this stage whether or not the import statement is bundled
+ // This keeps track of the `namespace_alias` incase, at printing time, we determine that we should print it with the namespace
+ for (st.items) |item| {
+ const is_default = strings.eqlComptime(item.alias, "default");
+ record.contains_default_alias = record.contains_default_alias or is_default;
+
+ const name: LocRef = item.name;
+ const name_ref = name.ref.?;
+
+ try p.named_imports.put(name_ref, js_ast.NamedImport{
+ .alias = item.alias,
+ .alias_loc = name.loc,
+ .namespace_ref = namespace_ref,
+ .import_record_index = st.import_record_index,
+ });
+
+ // Make sure the printer prints this as a property access
+ var symbol: *Symbol = &p.symbols.items[name_ref.innerIndex()];
+ if (record.contains_import_star or st.star_name_loc != null)
+ symbol.namespace_alias = G.NamespaceAlias{
+ .namespace_ref = namespace_ref,
+ .alias = item.alias,
+ .import_record_index = st.import_record_index,
+ .was_originally_property_access = st.star_name_loc != null and existing_items.contains(symbol.original_name),
+ };
+ }
+
+ if (record.was_originally_require) {
+ var symbol = &p.symbols.items[namespace_ref.innerIndex()];
+ symbol.namespace_alias = G.NamespaceAlias{
+ .namespace_ref = namespace_ref,
+ .alias = "",
+ .import_record_index = st.import_record_index,
+ .was_originally_property_access = false,
+ };
+ }
}
try p.import_records_for_current_part.append(allocator, st.import_record_index);
- if (st.star_name_loc != null) {
- record.contains_import_star = true;
- }
+ record.contains_import_star = record.contains_import_star or st.star_name_loc != null;
+ record.contains_default_alias = record.contains_default_alias or st.default_name != null;
- if (record.was_originally_require) {
- var symbol = &p.symbols.items[namespace_ref.innerIndex()];
- symbol.namespace_alias = G.NamespaceAlias{
- .namespace_ref = namespace_ref,
- .alias = "",
- .import_record_index = st.import_record_index,
- .was_originally_property_access = false,
- };
+ for (st.items) |*item| {
+ record.contains_default_alias = record.contains_default_alias or strings.eqlComptime(item.alias, "default");
+ record.contains_es_module_alias = record.contains_es_module_alias or strings.eqlComptime(item.alias, "__esModule");
}
},
@@ -781,6 +959,11 @@ pub const ImportScanner = struct {
if (p.options.features.hot_module_reloading and st.is_export) {
st.is_export = false;
}
+
+ // when bundling, all top-level variables become var
+ if (p.options.bundle) {
+ st.kind = .k_var;
+ }
},
.s_export_default => |st| {
// This is defer'd so that we still record export default for identifiers
@@ -946,6 +1129,8 @@ pub const ImportScanner = struct {
.is_exported = true,
});
try p.recordExport(alias.loc, alias.original_name, st.namespace_ref);
+ var record = &p.import_records.items[st.import_record_index];
+ record.contains_import_star = true;
} else {
// "export * from 'path'"
try p.export_star_import_records.append(allocator, st.import_record_index);
@@ -953,7 +1138,7 @@ pub const ImportScanner = struct {
},
.s_export_from => |st| {
try p.import_records_for_current_part.append(allocator, st.import_record_index);
-
+ p.named_imports.ensureUnusedCapacity(st.items.len) catch unreachable;
for (st.items) |item| {
const ref = item.name.ref orelse p.panic("Expected export from item to have a name {any}", .{st});
// Note that the imported alias is not item.Alias, which is the
@@ -968,6 +1153,13 @@ pub const ImportScanner = struct {
.is_exported = true,
});
try p.recordExport(item.name.loc, item.alias, ref);
+
+ var record = &p.import_records.items[st.import_record_index];
+ if (strings.eqlComptime(item.original_name, "default")) {
+ record.contains_default_alias = true;
+ } else if (strings.eqlComptime(item.original_name, "__esModule")) {
+ record.contains_es_module_alias = true;
+ }
}
},
else => {},
@@ -1021,7 +1213,6 @@ const StaticSymbolName = struct {
pub const __require = NewStaticSymbol("require");
pub const __cJS2eSM = NewStaticSymbol("__cJS2eSM");
pub const __export = NewStaticSymbol("__export");
- pub const __reExport = NewStaticSymbol("__reExport");
pub const __load = NewStaticSymbol("__load");
pub const @"$$lzy" = NewStaticSymbol("$$lzy");
pub const __HMRModule = NewStaticSymbol("HMR");
@@ -1030,6 +1221,7 @@ const StaticSymbolName = struct {
pub const __FastRefreshRuntime = NewStaticSymbol("FastRefresh");
pub const __decorateClass = NewStaticSymbol("__decorateClass");
pub const __decorateParam = NewStaticSymbol("__decorateParam");
+ pub const @"$$typeof" = NewStaticSymbol("$$typeof");
pub const @"$$m" = NewStaticSymbol("$$m");
@@ -1777,10 +1969,11 @@ const AsyncPrefixExpression = enum(u2) {
}
};
-const IdentifierOpts = struct {
+const IdentifierOpts = packed struct {
assign_target: js_ast.AssignTarget = js_ast.AssignTarget.none,
is_delete_target: bool = false,
was_originally_identifier: bool = false,
+ is_call_target: bool = false,
};
fn statementCaresAboutScope(stmt: Stmt) bool {
@@ -2107,9 +2300,14 @@ const FnOnlyDataVisit = struct {
this_capture_ref: ?Ref = null,
arguments_capture_ref: ?Ref = null,
- // Inside a static class property initializer, "this" expressions should be
- // replaced with the class name.
- this_class_static_ref: ?Ref = null,
+ /// This is a reference to the enclosing class name if there is one. It's used
+ /// to implement "this" and "super" references. A name is automatically generated
+ /// if one is missing so this will always be present inside a class body.
+ class_name_ref: ?*Ref = null,
+
+ /// If true, we're inside a static class context where "this" expressions
+ /// should be replaced with the class name.
+ should_replace_this_with_class_name_ref: bool = false,
// If we're inside an async arrow function and async functions are not
// supported, then we will have to convert that arrow function to a generator
@@ -2171,8 +2369,6 @@ const ImportClause = struct {
had_type_only_imports: bool = false,
};
-const ModuleType = enum { esm };
-
const PropertyOpts = struct {
async_range: logger.Range = logger.Range.None,
declare_range: logger.Range = logger.Range.None,
@@ -2211,7 +2407,7 @@ pub const ScanPassResult = struct {
pub fn reset(scan_pass: *ScanPassResult) void {
scan_pass.named_imports.clearRetainingCapacity();
- scan_pass.import_records.shrinkRetainingCapacity(0);
+ scan_pass.import_records.clearRetainingCapacity();
scan_pass.used_symbols.clearRetainingCapacity();
scan_pass.approximate_newline_count = 0;
}
@@ -2247,16 +2443,17 @@ pub const Parser = struct {
features: RuntimeFeatures = RuntimeFeatures{},
tree_shaking: bool = false,
+ bundle: bool = false,
macro_context: *MacroContextType() = undefined,
warn_about_unbundled_modules: bool = true,
// Used when bundling node_modules
- enable_bundling: bool = false,
+ enable_legacy_bundling: bool = false,
transform_require_to_import: bool = true,
- moduleType: ModuleType = ModuleType.esm,
+ module_type: options.ModuleType = .unknown,
pub fn init(jsx: options.JSX.Pragma, loader: options.Loader) Options {
var opts = Options{
@@ -2317,7 +2514,7 @@ pub const Parser = struct {
import_record.is_unused = import_record.is_unused or
(import_record.kind == .stmt and
!import_record.was_originally_bare_import and
- !import_record.calls_run_time_re_export_fn);
+ !import_record.calls_runtime_re_export_fn);
}
var iter = scan_pass.used_symbols.iterator();
@@ -2442,6 +2639,13 @@ pub const Parser = struct {
var after = ListManaged(js_ast.Part).init(p.allocator);
var parts = ListManaged(js_ast.Part).init(p.allocator);
+ if (p.options.bundle) {
+ // allocate an empty part for the bundle
+ before.append(
+ js_ast.Part{},
+ ) catch unreachable;
+ }
+
if (!p.options.tree_shaking) {
try p.appendPart(&parts, stmts);
} else {
@@ -2468,6 +2672,28 @@ pub const Parser = struct {
try p.appendPart(&parts, sliced.items);
}
},
+ .s_import, .s_export_from, .s_export_star => {
+ var parts_list = if (p.options.bundle)
+ // Move imports (and import-like exports) to the top of the file to
+ // ensure that if they are converted to a require() call, the effects
+ // will take place before any other statements are evaluated.
+ &before
+ else
+ // If we aren't doing any format conversion, just keep these statements
+ // inline where they were. Exports are sorted so order doesn't matter:
+ // https://262.ecma-international.org/6.0/#sec-module-namespace-exotic-objects.
+ // However, this is likely an aesthetic issue that some people will
+ // complain about. In addition, there are code transformation tools
+ // such as TypeScript and Babel with bugs where the order of exports
+ // in the file is incorrectly preserved instead of sorted, so preserving
+ // the order of exports ourselves here may be preferable.
+ &parts;
+
+ var sliced = try ListManaged(Stmt).initCapacity(p.allocator, 1);
+ sliced.items.len = 1;
+ sliced.items[0] = stmt;
+ try p.appendPart(parts_list, sliced.items);
+ },
else => {
var sliced = try ListManaged(Stmt).initCapacity(p.allocator, 1);
sliced.items.len = 1;
@@ -2488,7 +2714,7 @@ pub const Parser = struct {
if (uses_dirname or uses_filename) {
const count = @as(usize, @boolToInt(uses_dirname)) + @as(usize, @boolToInt(uses_filename));
- var declared_symbols = try p.allocator.alloc(js_ast.DeclaredSymbol, count);
+ var declared_symbols = DeclaredSymbol.List.initCapacity(p.allocator, count) catch unreachable;
var decls = p.allocator.alloc(G.Decl, count) catch unreachable;
if (uses_dirname) {
decls[0] = .{
@@ -2499,7 +2725,7 @@ pub const Parser = struct {
logger.Loc.Empty,
),
};
- declared_symbols[0] = .{ .ref = p.dirname_ref, .is_top_level = true };
+ declared_symbols.appendAssumeCapacity(.{ .ref = p.dirname_ref, .is_top_level = true });
}
if (uses_filename) {
decls[@as(usize, @boolToInt(uses_dirname))] = .{
@@ -2509,10 +2735,9 @@ pub const Parser = struct {
logger.Loc.Empty,
),
};
- declared_symbols[@as(usize, @boolToInt(uses_dirname))] = .{ .ref = p.filename_ref, .is_top_level = true };
+ declared_symbols.appendAssumeCapacity(.{ .ref = p.filename_ref, .is_top_level = true });
}
- // TODO: DeclaredSymbol
var part_stmts = p.allocator.alloc(Stmt, 1) catch unreachable;
part_stmts[0] = p.s(S.Local{
.kind = .k_var,
@@ -2526,6 +2751,131 @@ pub const Parser = struct {
}
var did_import_fast_refresh = false;
+ _ = did_import_fast_refresh;
+
+ if (comptime FeatureFlags.commonjs_to_esm) {
+ if (p.commonjs_named_exports.count() > 0) {
+ var export_refs = p.commonjs_named_exports.values();
+ var export_names = p.commonjs_named_exports.keys();
+
+ if (!p.commonjs_named_exports_deoptimized) {
+ // We make this safe by doing toCommonJS() at runtimes
+ for (export_refs, export_names) |*export_ref, alias| {
+ if (export_ref.needs_decl) {
+ var this_stmts = p.allocator.alloc(Stmt, 2) catch unreachable;
+ var decls = p.allocator.alloc(Decl, 1) catch unreachable;
+ const ref = export_ref.loc_ref.ref.?;
+ decls[0] = .{
+ .binding = p.b(B.Identifier{ .ref = ref }, export_ref.loc_ref.loc),
+ .value = null,
+ };
+ var declared_symbols = DeclaredSymbol.List.initCapacity(p.allocator, 1) catch unreachable;
+ declared_symbols.appendAssumeCapacity(.{ .ref = ref, .is_top_level = true });
+ this_stmts[0] = p.s(
+ S.Local{
+ .kind = .k_var,
+ .is_export = false,
+ .decls = decls,
+ },
+ export_ref.loc_ref.loc,
+ );
+
+ var clause_items = p.allocator.alloc(js_ast.ClauseItem, 1) catch unreachable;
+ clause_items[0] = js_ast.ClauseItem{
+ .alias = alias,
+ .alias_loc = export_ref.loc_ref.loc,
+ .name = export_ref.loc_ref,
+ };
+
+ this_stmts[1] = p.s(
+ S.ExportClause{
+ .items = clause_items,
+ .is_single_line = true,
+ },
+ export_ref.loc_ref.loc,
+ );
+ export_ref.needs_decl = false;
+ before.append(.{
+ .stmts = this_stmts,
+ .declared_symbols = declared_symbols,
+ .can_be_removed_if_unused = true,
+ }) catch unreachable;
+ }
+ }
+ }
+
+ if (!p.commonjs_named_exports_deoptimized and p.esm_export_keyword.len == 0) {
+ p.esm_export_keyword.loc = export_refs[0].loc_ref.loc;
+ p.esm_export_keyword.len = 5;
+ }
+ }
+ }
+
+ if (p.options.bundle and parts.items.len == 1) {
+ // Specially handle modules shaped like this:
+ // CommonJS:
+ //
+ // if (process.env.NODE_ENV === 'production')
+ // module.exports = require('./foo.prod.js')
+ // else
+ // module.exports = require('./foo.dev.js')
+ //
+ // ESM:
+ //
+ // export * from 'react';
+ //
+ var part = &parts.items[0];
+ if (part.stmts.len == 1) {
+ var stmt: Stmt = part.stmts[0];
+ if (p.symbols.items[p.module_ref.innerIndex()].use_count_estimate == 1) {
+ if (stmt.data == .s_expr) {
+ const value: Expr = stmt.data.s_expr.value;
+
+ if (value.data == .e_binary) {
+ const bin = value.data.e_binary;
+ const left = bin.left;
+ const right = bin.right;
+ if (bin.op == .bin_assign and
+ right.data == .e_require and
+ left.data == .e_dot and
+ strings.eqlComptime(left.data.e_dot.name, "exports") and
+ left.data.e_dot.target.data == .e_identifier and
+ left.data.e_dot.target.data.e_identifier.ref.eql(p.module_ref))
+ {
+ return js_ast.Result{
+ .ok = true,
+ .ast = js_ast.Ast{
+ .allocator = p.allocator,
+ .import_records = ImportRecord.List.init(p.import_records.items),
+ .redirect_import_record_index = right.data.e_require.import_record_index,
+ .named_imports = p.named_imports,
+ .named_exports = p.named_exports,
+ },
+ };
+ }
+ }
+ }
+ } else if (p.esm_export_keyword.len > 0) {
+ switch (stmt.data) {
+ .s_export_star => |star| {
+ if (star.alias == null) {
+ return js_ast.Result{
+ .ok = true,
+ .ast = .{
+ .allocator = p.allocator,
+ .import_records = ImportRecord.List.init(p.import_records.items),
+ .redirect_import_record_index = star.import_record_index,
+ .named_imports = p.named_imports,
+ .named_exports = p.named_exports,
+ },
+ };
+ }
+ },
+ else => {},
+ }
+ }
+ }
+ }
// Analyze cross-part dependencies for tree shaking and code splitting
var exports_kind = js_ast.ExportsKind.none;
@@ -2534,33 +2884,46 @@ pub const Parser = struct {
var wrapper_expr: ?Expr = null;
- if ((p.es6_export_keyword.len > 0 or p.top_level_await_keyword.len > 0) and !uses_exports_ref) {
+ if (p.esm_export_keyword.len > 0 or p.top_level_await_keyword.len > 0) {
exports_kind = .esm;
} else if (uses_exports_ref or uses_module_ref or p.has_top_level_return) {
exports_kind = .cjs;
- if (p.options.transform_require_to_import or (p.options.features.dynamic_require and !p.options.enable_bundling)) {
- var args = p.allocator.alloc(Expr, 2) catch unreachable;
-
- if (p.runtime_imports.__exportDefault == null and p.has_export_default) {
- p.runtime_imports.__exportDefault = try p.declareGeneratedSymbol(.other, "__exportDefault");
- p.resolveGeneratedSymbol(&p.runtime_imports.__exportDefault.?);
+ if (!p.options.bundle) {
+ if (p.options.transform_require_to_import or (p.options.features.dynamic_require and !p.options.enable_legacy_bundling)) {
+ var args = p.allocator.alloc(Expr, 2) catch unreachable;
+
+ if (p.runtime_imports.__exportDefault == null and p.has_export_default) {
+ p.runtime_imports.__exportDefault = try p.declareGeneratedSymbol(.other, "__exportDefault");
+ p.resolveGeneratedSymbol(&p.runtime_imports.__exportDefault.?);
+ }
+
+ wrapper_expr = p.callRuntime(logger.Loc.Empty, "__cJS2eSM", args);
+ p.resolveGeneratedSymbol(&p.runtime_imports.__cJS2eSM.?);
+
+ // Disable HMR if we're wrapping it in CommonJS
+ // It's technically possible to support this.
+ // But we need to cut scope for the v0.
+ p.options.features.hot_module_reloading = false;
+ p.options.features.react_fast_refresh = false;
+ p.runtime_imports.__HMRModule = null;
+ p.runtime_imports.__FastRefreshModule = null;
+ p.runtime_imports.__FastRefreshRuntime = null;
+ p.runtime_imports.__HMRClient = null;
}
-
- wrapper_expr = p.callRuntime(logger.Loc.Empty, "__cJS2eSM", args);
- p.resolveGeneratedSymbol(&p.runtime_imports.__cJS2eSM.?);
-
- // Disable HMR if we're wrapping it in CommonJS
- // It's technically possible to support this.
- // But we need to cut scope for the v0.
- p.options.features.hot_module_reloading = false;
- p.options.features.react_fast_refresh = false;
- p.runtime_imports.__HMRModule = null;
- p.runtime_imports.__FastRefreshModule = null;
- p.runtime_imports.__FastRefreshRuntime = null;
- p.runtime_imports.__HMRClient = null;
}
} else {
- exports_kind = .esm;
+ switch (p.options.module_type) {
+ // ".cjs" or ".cts" or ("type: commonjs" and (".js" or ".jsx" or ".ts" or ".tsx"))
+ .cjs => {
+ exports_kind = .cjs;
+ },
+ .esm => {
+ exports_kind = .esm;
+ },
+ else => {
+ exports_kind = .esm;
+ },
+ }
}
// Auto inject jest globals into the test file
@@ -2590,7 +2953,8 @@ pub const Parser = struct {
var import_record: *ImportRecord = &p.import_records.items[import_record_id];
import_record.tag = .bun_test;
- var declared_symbols = try p.allocator.alloc(js_ast.DeclaredSymbol, items_count);
+ var declared_symbols = js_ast.DeclaredSymbol.List{};
+ try declared_symbols.ensureTotalCapacity(p.allocator, items_count);
var clauses: []js_ast.ClauseItem = p.allocator.alloc(js_ast.ClauseItem, items_count) catch unreachable;
var clause_i: usize = 0;
inline for (comptime std.meta.fieldNames(Jest)) |symbol_name| {
@@ -2601,7 +2965,7 @@ pub const Parser = struct {
.alias_loc = logger.Loc.Empty,
.original_name = "",
};
- declared_symbols[clause_i] = .{ .ref = @field(jest, symbol_name), .is_top_level = true };
+ declared_symbols.appendAssumeCapacity(.{ .ref = @field(jest, symbol_name), .is_top_level = true });
clause_i += 1;
}
}
@@ -2622,670 +2986,667 @@ pub const Parser = struct {
before.append(js_ast.Part{
.stmts = part_stmts,
.declared_symbols = declared_symbols,
- .import_record_indices = import_record_indices,
+ .import_record_indices = bun.BabyList(u32).init(import_record_indices),
.tag = .bun_test,
}) catch unreachable;
}
// Auto-import & post-process JSX
- switch (comptime ParserType.jsx_transform_type) {
- .react => {
- // const jsx_filename_symbol = if (p.options.jsx.development)
- // p.symbols.items[p.jsx_filename.ref.innerIndex()]
- // else
- // Symbol{ .original_name = "" };
-
- {
- const jsx_symbol = p.symbols.items[p.jsx_runtime.ref.innerIndex()];
-
- const jsx_fragment_symbol = p.symbols.items[p.jsx_fragment.ref.innerIndex()];
- const jsx_factory_symbol = p.symbols.items[p.jsx_factory.ref.innerIndex()];
-
- // Currently, React (and most node_modules) ship a CJS version or a UMD version
- // but we should assume that it'll pretty much always be CJS
- // Given that, we can't directly call import {jsxDEV} from 'react';
- // Instead, we must call require("react").default.jsxDEV
- // So a jsx_symbol usage means a jsx_factory_symbol usage
- // This is kind of a broken way of doing it because it wouldn't work if it was more than one level deep
- if (FeatureFlags.jsx_runtime_is_cjs) {
- if (jsx_symbol.use_count_estimate > 0) {
- p.recordUsage(p.jsx_automatic.ref);
- }
-
- if (FeatureFlags.support_jsxs_in_jsx_transform) {
- const jsx_static_symbol = p.symbols.items[p.jsxs_runtime.ref.innerIndex()];
-
- if (jsx_static_symbol.use_count_estimate > 0) {
- p.recordUsage(p.jsx_automatic.ref);
- }
- }
-
- if (jsx_fragment_symbol.use_count_estimate > 0) {
- p.recordUsage(p.jsx_classic.ref);
- }
-
- if (jsx_factory_symbol.use_count_estimate > 0) {
- p.recordUsage(p.jsx_classic.ref);
- }
- }
- }
-
- p.resolveStaticJSXSymbols();
-
- if (p.options.features.auto_import_jsx) {
- const jsx_classic_symbol = p.symbols.items[p.jsx_classic.ref.innerIndex()];
- const jsx_automatic_symbol = p.symbols.items[p.jsx_automatic.ref.innerIndex()];
- const react_element_symbol = if (p.options.features.jsx_optimization_inline) p.symbols.items[p.react_element_type.ref.innerIndex()] else Symbol{
- .original_name = "IF_YOU_SEE_THIS_ITS_A_BUG_IN_BUN_WHERE_REACT_ELEMENT_SYMBOL_IS_BEING_ADDED_WHEN_IT_SHOULDNT_BE_PLEASE_REPORT_IT",
- };
-
- // JSX auto-imports
- // The classic runtime is a different import than the main import
- // There are cases where you can use both JSX runtimes in the same file.
- // 1. If you use a spread operator like this: <div foo bar key="foo" {...props} baz />
- // 2. If you use a React.Fragment
- // So we have to support both.
- if (jsx_classic_symbol.use_count_estimate > 0 or jsx_automatic_symbol.use_count_estimate > 0 or react_element_symbol.use_count_estimate > 0) {
- // These must unfortunately be copied
- // p.symbols may grow during this scope
- // if it grows, the previous pointers are invalidated
- const jsx_symbol = p.symbols.items[p.jsx_runtime.ref.innerIndex()];
- const jsx_static_symbol: Symbol = if (!FeatureFlags.support_jsxs_in_jsx_transform)
- undefined
- else
- p.symbols.items[p.jsxs_runtime.ref.innerIndex()];
-
- const jsx_fragment_symbol = p.symbols.items[p.jsx_fragment.ref.innerIndex()];
- const jsx_factory_symbol = p.symbols.items[p.jsx_factory.ref.innerIndex()];
-
- const classic_namespace_ref = p.jsx_classic.ref;
- const automatic_namespace_ref = p.jsx_automatic.ref;
-
- const decls_count: u32 =
- // "REACT_ELEMENT_TYPE"
- // "Symbol.for('react.element')"
- @intCast(u32, @boolToInt(react_element_symbol.use_count_estimate > 0)) * 2 +
-
- // "JSX"
- @intCast(u32, @boolToInt(jsx_symbol.use_count_estimate > 0)) * 2 +
- @intCast(u32, @boolToInt(FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0)) * 2 +
- @intCast(u32, @boolToInt(jsx_factory_symbol.use_count_estimate > 0)) +
- @intCast(u32, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0));
- // @intCast(u32, @boolToInt(jsx_filename_symbol.use_count_estimate > 0));
-
- const imports_count =
- @intCast(u32, @boolToInt(jsx_symbol.use_count_estimate > 0)) +
- @intCast(u32, @boolToInt(jsx_classic_symbol.use_count_estimate > 0)) +
- @intCast(u32, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0)) +
- @intCast(u32, @boolToInt(p.options.features.react_fast_refresh)) +
- @intCast(u32, @boolToInt(FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0));
- const stmts_count = imports_count + 1;
- const symbols_count: u32 = imports_count + decls_count;
- const loc = logger.Loc{ .start = 0 };
-
- // Preallocate everything we'll need here
- var declared_symbols = try p.allocator.alloc(js_ast.DeclaredSymbol, symbols_count);
- var decls = try p.allocator.alloc(G.Decl, decls_count);
- var jsx_part_stmts = try p.allocator.alloc(Stmt, stmts_count);
- // Use the same array for storing the require call target of potentially both JSX runtimes
- var require_call_args_base = p.allocator.alloc(Expr, if (p.options.can_import_from_bundle) 0 else imports_count) catch unreachable;
- var import_records = try p.allocator.alloc(u32, imports_count);
-
- var decl_i: usize = 0;
- var declared_symbols_i: usize = 0;
- var import_record_i: usize = 0;
- var require_call_args_i: usize = 0;
- var stmt_i: usize = 0;
-
- if (react_element_symbol.use_count_estimate > 0) {
- declared_symbols[declared_symbols_i] = .{ .ref = p.react_element_type.ref, .is_top_level = true };
- declared_symbols_i += 1;
- p.recordUsage(p.es6_symbol_global.ref);
- var call_args = p.allocator.alloc(Expr, 1) catch unreachable;
- call_args[0] = Expr{ .data = Prefill.Data.REACT_ELEMENT_TYPE, .loc = logger.Loc.Empty };
-
- decls[decl_i] = G.Decl{
- .binding = p.b(
- B.Identifier{
- .ref = p.react_element_type.ref,
- },
- loc,
- ),
- .value = p.newExpr(
- E.Call{
- // Symbol.for
- .target = p.newExpr(
- E.Dot{
- .name = "for",
- .name_loc = logger.Loc.Empty,
- .target = p.newExpr(
- E.Identifier{
- .ref = p.es6_symbol_global.ref,
- .can_be_removed_if_unused = true,
- .call_can_be_unwrapped_if_unused = true,
- },
- logger.Loc.Empty,
- ),
- .can_be_removed_if_unused = true,
- .call_can_be_unwrapped_if_unused = true,
- },
- logger.Loc.Empty,
- ),
- .args = ExprNodeList.init(call_args),
- .close_paren_loc = logger.Loc.Empty,
- .can_be_unwrapped_if_unused = true,
- },
- logger.Loc.Empty,
- ),
- };
- decl_i += 1;
- }
-
- if (jsx_symbol.use_count_estimate > 0 or (FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0)) {
- declared_symbols[declared_symbols_i] = .{ .ref = automatic_namespace_ref, .is_top_level = true };
- declared_symbols_i += 1;
-
- const automatic_identifier = p.newExpr(E.ImportIdentifier{ .ref = automatic_namespace_ref }, loc);
-
- // We do not mark this as .require becuase we are already wrapping it manually.
- // unless it's bun and you're not bundling
- const use_automatic_identifier = (p.options.can_import_from_bundle or p.options.enable_bundling or !p.options.features.allow_runtime);
- const import_record_kind = if (use_automatic_identifier) ImportKind.internal else ImportKind.require;
- const import_record_id = p.addImportRecord(import_record_kind, loc, p.options.jsx.import_source);
-
- const dot_call_target = brk: {
- if (use_automatic_identifier) {
- break :brk automatic_identifier;
- } else if (p.options.features.dynamic_require) {
- break :brk p.newExpr(E.Require{ .import_record_index = import_record_id }, loc);
- } else {
- require_call_args_base[require_call_args_i] = automatic_identifier;
- require_call_args_i += 1;
- break :brk p.callUnbundledRequire(require_call_args_base[0..require_call_args_i]);
- }
- };
-
- if (jsx_symbol.use_count_estimate > 0) {
- declared_symbols[declared_symbols_i] = .{ .ref = p.jsx_runtime.ref, .is_top_level = true };
- declared_symbols_i += 1;
-
- decls[decl_i] = G.Decl{
- .binding = p.b(
- B.Identifier{
- .ref = p.jsx_runtime.ref,
- },
- loc,
- ),
- .value = p.newExpr(
- E.Dot{
- .target = dot_call_target,
- .name = p.options.jsx.jsx,
- .name_loc = loc,
- .can_be_removed_if_unused = true,
- },
- loc,
- ),
- };
- decl_i += 1;
- }
-
- if (FeatureFlags.support_jsxs_in_jsx_transform) {
- if (jsx_static_symbol.use_count_estimate > 0) {
- declared_symbols[declared_symbols_i] = .{ .ref = p.jsxs_runtime.ref, .is_top_level = true };
- declared_symbols_i += 1;
-
- decls[decl_i] = G.Decl{
- .binding = p.b(
- B.Identifier{
- .ref = p.jsxs_runtime.ref,
- },
- loc,
- ),
- .value = p.newExpr(
- E.Dot{
- .target = dot_call_target,
- .name = p.options.jsx.jsx_static,
- .name_loc = loc,
- .can_be_removed_if_unused = true,
- },
- loc,
- ),
- };
-
- decl_i += 1;
- }
- }
- // if (jsx_filename_symbol.use_count_estimate > 0) {
- // declared_symbols[declared_symbols_i] = .{ .ref = p.jsx_filename.ref, .is_top_level = true };
- // declared_symbols_i += 1;
- // decls[decl_i] = G.Decl{
- // .binding = p.b(
- // B.Identifier{
- // .ref = p.jsx_filename.ref,
- // },
- // loc,
- // ),
- // .value = p.newExpr(E.String{ .data = p.source.path.pretty }, loc),
- // };
- // decl_i += 1;
- // }
-
- p.import_records.items[import_record_id].tag = .jsx_import;
- if (dot_call_target.data != .e_require) {
- // When everything is CommonJS
- // We import JSX like this:
- // var {jsxDev} = require("react/jsx-dev")
- jsx_part_stmts[stmt_i] = p.s(S.Import{
- .namespace_ref = automatic_namespace_ref,
- .star_name_loc = loc,
- .is_single_line = true,
- .import_record_index = import_record_id,
- }, loc);
-
- stmt_i += 1;
- }
-
- p.named_imports.put(
- automatic_namespace_ref,
- js_ast.NamedImport{
- .alias = jsx_automatic_symbol.original_name,
- .alias_is_star = true,
- .alias_loc = loc,
- .namespace_ref = automatic_namespace_ref,
- .import_record_index = import_record_id,
- },
- ) catch unreachable;
- p.is_import_item.put(p.allocator, automatic_namespace_ref, {}) catch unreachable;
- import_records[import_record_i] = import_record_id;
- import_record_i += 1;
- }
-
- if (jsx_classic_symbol.use_count_estimate > 0) {
- const classic_identifier = p.newExpr(E.ImportIdentifier{ .ref = classic_namespace_ref }, loc);
- const import_record_id = p.addImportRecord(.require, loc, p.options.jsx.classic_import_source);
- const dot_call_target = brk: {
- // var react = $aopaSD123();
-
- if (p.options.can_import_from_bundle or p.options.enable_bundling or !p.options.features.allow_runtime) {
- break :brk classic_identifier;
- } else if (p.options.features.dynamic_require) {
- break :brk p.newExpr(E.Require{ .import_record_index = import_record_id }, loc);
- } else {
- const require_call_args_start = require_call_args_i;
- require_call_args_base[require_call_args_i] = classic_identifier;
- require_call_args_i += 1;
- break :brk p.callUnbundledRequire(require_call_args_base[require_call_args_start..][0..1]);
- }
- };
+ // if (!p.options.bundle) {
+ // switch (comptime ParserType.jsx_transform_type) {
+ // .react => {
+ // // const jsx_filename_symbol = if (p.options.jsx.development)
+ // // p.symbols.items[p.jsx_filename.ref.innerIndex()]
+ // // else
+ // // Symbol{ .original_name = "" };
+
+ // {
+ // const jsx_symbol = p.symbols.items[p.jsx_runtime.ref.innerIndex()];
+
+ // const jsx_fragment_symbol = p.symbols.items[p.jsx_fragment.ref.innerIndex()];
+ // const jsx_factory_symbol = p.symbols.items[p.jsx_factory.ref.innerIndex()];
+
+ // // Currently, React (and most node_modules) ship a CJS version or a UMD version
+ // // but we should assume that it'll pretty much always be CJS
+ // // Given that, we can't directly call import {jsxDEV} from 'react';
+ // // Instead, we must call require("react").default.jsxDEV
+ // // So a jsx_symbol usage means a jsx_factory_symbol usage
+ // // This is kind of a broken way of doing it because it wouldn't work if it was more than one level deep
+ // if (FeatureFlags.jsx_runtime_is_cjs) {
+ // if (jsx_symbol.use_count_estimate > 0) {
+ // p.recordUsage(p.jsx_automatic.ref);
+ // }
- if (jsx_factory_symbol.use_count_estimate > 0) {
- declared_symbols[declared_symbols_i] = .{ .ref = p.jsx_factory.ref, .is_top_level = true };
- declared_symbols_i += 1;
- decls[decl_i] = G.Decl{
- .binding = p.b(
- B.Identifier{
- .ref = p.jsx_factory.ref,
- },
- loc,
- ),
- .value = p.memberExpression(
- loc,
- dot_call_target,
- if (p.options.jsx.factory.len > 1) p.options.jsx.factory[1..] else p.options.jsx.factory,
- ),
- };
- decl_i += 1;
- }
+ // if (FeatureFlags.support_jsxs_in_jsx_transform) {
+ // const jsx_static_symbol = p.symbols.items[p.jsxs_runtime.ref.innerIndex()];
- if (jsx_fragment_symbol.use_count_estimate > 0) {
- declared_symbols[declared_symbols_i] = .{ .ref = p.jsx_fragment.ref, .is_top_level = true };
- declared_symbols_i += 1;
- decls[decl_i] = G.Decl{
- .binding = p.b(
- B.Identifier{
- .ref = p.jsx_fragment.ref,
- },
- loc,
- ),
- .value = p.memberExpression(
- loc,
- dot_call_target,
- if (p.options.jsx.fragment.len > 1) p.options.jsx.fragment[1..] else p.options.jsx.fragment,
- ),
- };
- decl_i += 1;
- }
-
- if (dot_call_target.data != .e_require) {
- jsx_part_stmts[stmt_i] = p.s(S.Import{
- .namespace_ref = classic_namespace_ref,
- .star_name_loc = loc,
- .is_single_line = true,
- .import_record_index = import_record_id,
- }, loc);
- stmt_i += 1;
- }
+ // if (jsx_static_symbol.use_count_estimate > 0) {
+ // p.recordUsage(p.jsx_automatic.ref);
+ // }
+ // }
- p.import_records.items[import_record_id].tag = .jsx_classic;
+ // if (jsx_fragment_symbol.use_count_estimate > 0) {
+ // p.recordUsage(p.jsx_classic.ref);
+ // }
- p.named_imports.put(
- classic_namespace_ref,
- js_ast.NamedImport{
- .alias = jsx_classic_symbol.original_name,
- .alias_is_star = true,
- .alias_loc = loc,
- .namespace_ref = classic_namespace_ref,
- .import_record_index = import_record_id,
- },
- ) catch unreachable;
- p.is_import_item.put(p.allocator, classic_namespace_ref, {}) catch unreachable;
- import_records[import_record_i] = import_record_id;
- declared_symbols[declared_symbols_i] = .{ .ref = classic_namespace_ref, .is_top_level = true };
- declared_symbols_i += 1;
- }
-
- if (p.options.features.react_fast_refresh) {
- defer did_import_fast_refresh = true;
- p.resolveGeneratedSymbol(&p.jsx_refresh_runtime);
- if (!p.options.jsx.use_embedded_refresh_runtime) {
- const refresh_runtime_symbol: *const Symbol = &p.symbols.items[p.jsx_refresh_runtime.ref.innerIndex()];
-
- declared_symbols[declared_symbols_i] = .{ .ref = p.jsx_refresh_runtime.ref, .is_top_level = true };
- declared_symbols_i += 1;
-
- const import_record_id = p.addImportRecord(.require, loc, p.options.jsx.refresh_runtime);
- p.import_records.items[import_record_id].tag = .react_refresh;
- jsx_part_stmts[stmt_i] = p.s(S.Import{
- .namespace_ref = p.jsx_refresh_runtime.ref,
- .star_name_loc = loc,
- .is_single_line = true,
- .import_record_index = import_record_id,
- }, loc);
+ // if (jsx_factory_symbol.use_count_estimate > 0) {
+ // p.recordUsage(p.jsx_classic.ref);
+ // }
+ // }
+ // }
- stmt_i += 1;
- p.named_imports.put(
- p.jsx_refresh_runtime.ref,
- js_ast.NamedImport{
- .alias = refresh_runtime_symbol.original_name,
- .alias_is_star = true,
- .alias_loc = loc,
- .namespace_ref = p.jsx_refresh_runtime.ref,
- .import_record_index = import_record_id,
- },
- ) catch unreachable;
- p.is_import_item.put(p.allocator, p.jsx_refresh_runtime.ref, {}) catch unreachable;
- import_records[import_record_i] = import_record_id;
- }
- p.recordUsage(p.jsx_refresh_runtime.ref);
- }
+ // p.resolveStaticJSXSymbols();
+
+ // if (p.options.features.auto_import_jsx) {
+ // const jsx_classic_symbol = p.symbols.items[p.jsx_classic.ref.innerIndex()];
+ // const jsx_automatic_symbol = p.symbols.items[p.jsx_automatic.ref.innerIndex()];
+ // const react_element_symbol = if (p.options.features.jsx_optimization_inline) p.symbols.items[p.react_element_type.ref.innerIndex()] else Symbol{
+ // .original_name = "IF_YOU_SEE_THIS_ITS_A_BUG_IN_BUN_WHERE_REACT_ELEMENT_SYMBOL_IS_BEING_ADDED_WHEN_IT_SHOULDNT_BE_PLEASE_REPORT_IT",
+ // };
+
+ // // JSX auto-imports
+ // // The classic runtime is a different import than the main import
+ // // There are cases where you can use both JSX runtimes in the same file.
+ // // 1. If you use a spread operator like this: <div foo bar key="foo" {...props} baz />
+ // // 2. If you use a React.Fragment
+ // // So we have to support both.
+ // if (jsx_classic_symbol.use_count_estimate > 0 or jsx_automatic_symbol.use_count_estimate > 0 or react_element_symbol.use_count_estimate > 0) {
+ // // These must unfortunately be copied
+ // // p.symbols may grow during this scope
+ // // if it grows, the previous pointers are invalidated
+ // const jsx_symbol = p.symbols.items[p.jsx_runtime.ref.innerIndex()];
+ // const jsx_static_symbol: Symbol = if (!FeatureFlags.support_jsxs_in_jsx_transform)
+ // undefined
+ // else
+ // p.symbols.items[p.jsxs_runtime.ref.innerIndex()];
+
+ // const jsx_fragment_symbol = p.symbols.items[p.jsx_fragment.ref.innerIndex()];
+ // const jsx_factory_symbol = p.symbols.items[p.jsx_factory.ref.innerIndex()];
+
+ // const classic_namespace_ref = p.jsx_classic.ref;
+ // const automatic_namespace_ref = p.jsx_automatic.ref;
+
+ // const decls_count: u32 =
+ // // "REACT_ELEMENT_TYPE"
+ // // "Symbol.for('react.element')"
+ // @intCast(u32, @boolToInt(react_element_symbol.use_count_estimate > 0)) * 2 +
+
+ // // "JSX"
+ // @intCast(u32, @boolToInt(jsx_symbol.use_count_estimate > 0)) * 2 +
+ // @intCast(u32, @boolToInt(FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0)) * 2 +
+ // @intCast(u32, @boolToInt(jsx_factory_symbol.use_count_estimate > 0)) +
+ // @intCast(u32, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0));
+ // // @intCast(u32, @boolToInt(jsx_filename_symbol.use_count_estimate > 0));
+
+ // const imports_count =
+ // @intCast(u32, @boolToInt(jsx_symbol.use_count_estimate > 0)) +
+ // @intCast(u32, @boolToInt(jsx_classic_symbol.use_count_estimate > 0)) +
+ // @intCast(u32, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0)) +
+ // @intCast(u32, @boolToInt(p.options.features.react_fast_refresh)) +
+ // @intCast(u32, @boolToInt(FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0));
+ // const stmts_count = imports_count + 1;
+ // const symbols_count: u32 = imports_count + decls_count;
+ // const loc = logger.Loc{ .start = 0 };
+
+ // // Preallocate everything we'll need here
+ // var declared_symbols = DeclaredSymbol.List{};
+ // try declared_symbols.ensureTotalCapacity(p.allocator, symbols_count);
+ // var decls = try p.allocator.alloc(G.Decl, decls_count);
+ // var jsx_part_stmts = try p.allocator.alloc(Stmt, stmts_count);
+ // // Use the same array for storing the require call target of potentially both JSX runtimes
+ // var require_call_args_base = p.allocator.alloc(Expr, if (p.options.can_import_from_bundle) 0 else imports_count) catch unreachable;
+ // var import_records = try p.allocator.alloc(u32, imports_count);
+
+ // var decl_i: usize = 0;
+ // var import_record_i: usize = 0;
+ // var require_call_args_i: usize = 0;
+ // var stmt_i: usize = 0;
+
+ // if (react_element_symbol.use_count_estimate > 0) {
+ // declared_symbols.appendAssumeCapacity(.{ .ref = p.react_element_type.ref, .is_top_level = true });
+ // p.recordUsage(p.es6_symbol_global.ref);
+ // var call_args = p.allocator.alloc(Expr, 1) catch unreachable;
+ // call_args[0] = Expr{ .data = Prefill.Data.REACT_ELEMENT_TYPE, .loc = logger.Loc.Empty };
+
+ // decls[decl_i] = G.Decl{
+ // .binding = p.b(
+ // B.Identifier{
+ // .ref = p.react_element_type.ref,
+ // },
+ // loc,
+ // ),
+ // .value = p.newExpr(
+ // E.Call{
+ // // Symbol.for
+ // .target = p.newExpr(
+ // E.Dot{
+ // .name = "for",
+ // .name_loc = logger.Loc.Empty,
+ // .target = p.newExpr(
+ // E.Identifier{
+ // .ref = p.es6_symbol_global.ref,
+ // .can_be_removed_if_unused = true,
+ // .call_can_be_unwrapped_if_unused = true,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // .can_be_removed_if_unused = true,
+ // .call_can_be_unwrapped_if_unused = true,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // .args = ExprNodeList.init(call_args),
+ // .close_paren_loc = logger.Loc.Empty,
+ // .can_be_unwrapped_if_unused = true,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // };
+ // decl_i += 1;
+ // }
- jsx_part_stmts[stmt_i] = p.s(S.Local{ .kind = .k_var, .decls = decls[0..decl_i] }, loc);
- stmt_i += 1;
+ // if (jsx_symbol.use_count_estimate > 0 or (FeatureFlags.support_jsxs_in_jsx_transform and jsx_static_symbol.use_count_estimate > 0)) {
+ // declared_symbols.appendAssumeCapacity(.{ .ref = automatic_namespace_ref, .is_top_level = true });
+
+ // const automatic_identifier = p.newExpr(E.ImportIdentifier{ .ref = automatic_namespace_ref }, loc);
+
+ // // We do not mark this as .require becuase we are already wrapping it manually.
+ // // unless it's bun and you're not bundling
+ // const use_automatic_identifier = (p.options.can_import_from_bundle or p.options.enable_legacy_bundling or !p.options.features.allow_runtime);
+ // const import_record_kind = if (use_automatic_identifier) ImportKind.internal else ImportKind.require;
+ // const import_record_id = p.addImportRecord(import_record_kind, loc, p.options.jsx.import_source);
+
+ // const dot_call_target = brk: {
+ // if (use_automatic_identifier) {
+ // break :brk automatic_identifier;
+ // } else if (p.options.features.dynamic_require) {
+ // break :brk p.newExpr(E.Require{ .import_record_index = import_record_id }, loc);
+ // } else {
+ // require_call_args_base[require_call_args_i] = automatic_identifier;
+ // require_call_args_i += 1;
+ // break :brk p.callUnbundledRequire(require_call_args_base[0..require_call_args_i]);
+ // }
+ // };
+
+ // if (jsx_symbol.use_count_estimate > 0) {
+ // declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_runtime.ref, .is_top_level = true });
+
+ // decls[decl_i] = G.Decl{
+ // .binding = p.b(
+ // B.Identifier{
+ // .ref = p.jsx_runtime.ref,
+ // },
+ // loc,
+ // ),
+ // .value = p.newExpr(
+ // E.Dot{
+ // .target = dot_call_target,
+ // .name = p.options.jsx.jsx,
+ // .name_loc = loc,
+ // .can_be_removed_if_unused = true,
+ // },
+ // loc,
+ // ),
+ // };
+ // decl_i += 1;
+ // }
- before.append(js_ast.Part{
- .stmts = jsx_part_stmts[0..stmt_i],
- .declared_symbols = declared_symbols,
- .import_record_indices = import_records,
- .tag = .jsx_import,
- }) catch unreachable;
- }
- } else if (p.options.features.jsx_optimization_inline) {
- const react_element_symbol = p.symbols.items[p.react_element_type.ref.innerIndex()];
+ // if (FeatureFlags.support_jsxs_in_jsx_transform) {
+ // if (jsx_static_symbol.use_count_estimate > 0) {
+ // declared_symbols.appendAssumeCapacity(.{ .ref = p.jsxs_runtime.ref, .is_top_level = true });
+
+ // decls[decl_i] = G.Decl{
+ // .binding = p.b(
+ // B.Identifier{
+ // .ref = p.jsxs_runtime.ref,
+ // },
+ // loc,
+ // ),
+ // .value = p.newExpr(
+ // E.Dot{
+ // .target = dot_call_target,
+ // .name = p.options.jsx.jsx_static,
+ // .name_loc = loc,
+ // .can_be_removed_if_unused = true,
+ // },
+ // loc,
+ // ),
+ // };
+
+ // decl_i += 1;
+ // }
+ // }
+ // // if (jsx_filename_symbol.use_count_estimate > 0) {
+ // // declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_filename.ref, .is_top_level = true });
+ // // decls[decl_i] = G.Decl{
+ // // .binding = p.b(
+ // // B.Identifier{
+ // // .ref = p.jsx_filename.ref,
+ // // },
+ // // loc,
+ // // ),
+ // // .value = p.newExpr(E.String{ .data = p.source.path.pretty }, loc),
+ // // };
+ // // decl_i += 1;
+ // // }
+
+ // p.import_records.items[import_record_id].tag = .jsx_import;
+ // if (dot_call_target.data != .e_require) {
+ // // When everything is CommonJS
+ // // We import JSX like this:
+ // // var {jsxDev} = require("react/jsx-dev")
+ // jsx_part_stmts[stmt_i] = p.s(S.Import{
+ // .namespace_ref = automatic_namespace_ref,
+ // .star_name_loc = loc,
+ // .is_single_line = true,
+ // .import_record_index = import_record_id,
+ // }, loc);
+
+ // stmt_i += 1;
+ // }
- if (react_element_symbol.use_count_estimate > 0) {
- var declared_symbols = try p.allocator.alloc(js_ast.DeclaredSymbol, 1);
- var decls = try p.allocator.alloc(G.Decl, 1);
- var part_stmts = try p.allocator.alloc(Stmt, 1);
+ // p.named_imports.put(
+ // automatic_namespace_ref,
+ // js_ast.NamedImport{
+ // .alias = jsx_automatic_symbol.original_name,
+ // .alias_is_star = true,
+ // .alias_loc = loc,
+ // .namespace_ref = automatic_namespace_ref,
+ // .import_record_index = import_record_id,
+ // },
+ // ) catch unreachable;
+ // p.is_import_item.put(p.allocator, automatic_namespace_ref, {}) catch unreachable;
+ // import_records[import_record_i] = import_record_id;
+ // import_record_i += 1;
+ // }
- declared_symbols[0] = .{ .ref = p.react_element_type.ref, .is_top_level = true };
- p.recordUsage(p.es6_symbol_global.ref);
- var call_args = p.allocator.alloc(Expr, 1) catch unreachable;
- call_args[0] = Expr{ .data = Prefill.Data.REACT_ELEMENT_TYPE, .loc = logger.Loc.Empty };
+ // if (jsx_classic_symbol.use_count_estimate > 0) {
+ // const classic_identifier = p.newExpr(E.ImportIdentifier{ .ref = classic_namespace_ref }, loc);
+ // const import_record_id = p.addImportRecord(.require, loc, p.options.jsx.classic_import_source);
+ // const dot_call_target = brk: {
+ // // var react = $aopaSD123();
+
+ // if (p.options.can_import_from_bundle or p.options.enable_legacy_bundling or !p.options.features.allow_runtime) {
+ // break :brk classic_identifier;
+ // } else if (p.options.features.dynamic_require) {
+ // break :brk p.newExpr(E.Require{ .import_record_index = import_record_id }, loc);
+ // } else {
+ // const require_call_args_start = require_call_args_i;
+ // require_call_args_base[require_call_args_i] = classic_identifier;
+ // require_call_args_i += 1;
+ // break :brk p.callUnbundledRequire(require_call_args_base[require_call_args_start..][0..1]);
+ // }
+ // };
+
+ // if (jsx_factory_symbol.use_count_estimate > 0) {
+ // declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_factory.ref, .is_top_level = true });
+ // decls[decl_i] = G.Decl{
+ // .binding = p.b(
+ // B.Identifier{
+ // .ref = p.jsx_factory.ref,
+ // },
+ // loc,
+ // ),
+ // .value = p.memberExpression(
+ // loc,
+ // dot_call_target,
+ // if (p.options.jsx.factory.len > 1) p.options.jsx.factory[1..] else p.options.jsx.factory,
+ // ),
+ // };
+ // decl_i += 1;
+ // }
- decls[0] = G.Decl{
- .binding = p.b(
- B.Identifier{
- .ref = p.react_element_type.ref,
- },
- logger.Loc.Empty,
- ),
- .value = p.newExpr(
- E.Call{
- // Symbol.for
- .target = p.newExpr(
- E.Dot{
- .name = "for",
- .name_loc = logger.Loc.Empty,
- .target = p.newExpr(
- E.Identifier{
- .ref = p.es6_symbol_global.ref,
- .can_be_removed_if_unused = true,
- .call_can_be_unwrapped_if_unused = true,
- },
- logger.Loc.Empty,
- ),
- .can_be_removed_if_unused = true,
- .call_can_be_unwrapped_if_unused = true,
- },
- logger.Loc.Empty,
- ),
- .args = ExprNodeList.init(call_args),
- .close_paren_loc = logger.Loc.Empty,
- .can_be_unwrapped_if_unused = true,
- },
- logger.Loc.Empty,
- ),
- };
- part_stmts[0] = p.s(S.Local{ .kind = .k_var, .decls = decls }, logger.Loc.Empty);
- before.append(js_ast.Part{
- .stmts = part_stmts,
- .declared_symbols = declared_symbols,
- .tag = .jsx_import,
- }) catch unreachable;
- }
- } else {
- const jsx_fragment_symbol: Symbol = p.symbols.items[p.jsx_fragment.ref.innerIndex()];
- const jsx_factory_symbol: Symbol = p.symbols.items[p.jsx_factory.ref.innerIndex()];
-
- // inject
- // var jsxFrag =
- if (jsx_fragment_symbol.use_count_estimate + jsx_factory_symbol.use_count_estimate > 0) {
- const total = @as(usize, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0)) + @as(usize, @boolToInt(jsx_factory_symbol.use_count_estimate > 0));
- var declared_symbols = try std.ArrayList(js_ast.DeclaredSymbol).initCapacity(p.allocator, total);
- var decls = try std.ArrayList(G.Decl).initCapacity(p.allocator, total);
- var part_stmts = try p.allocator.alloc(Stmt, 1);
-
- if (jsx_fragment_symbol.use_count_estimate > 0) declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_fragment.ref, .is_top_level = true });
- if (jsx_factory_symbol.use_count_estimate > 0) declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_factory.ref, .is_top_level = true });
-
- if (jsx_fragment_symbol.use_count_estimate > 0)
- decls.appendAssumeCapacity(G.Decl{
- .binding = p.b(
- B.Identifier{
- .ref = p.jsx_fragment.ref,
- },
- logger.Loc.Empty,
- ),
- .value = try p.jsxStringsToMemberExpression(logger.Loc.Empty, p.options.jsx.fragment),
- });
+ // if (jsx_fragment_symbol.use_count_estimate > 0) {
+ // declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_fragment.ref, .is_top_level = true });
+ // decls[decl_i] = G.Decl{
+ // .binding = p.b(
+ // B.Identifier{
+ // .ref = p.jsx_fragment.ref,
+ // },
+ // loc,
+ // ),
+ // .value = p.memberExpression(
+ // loc,
+ // dot_call_target,
+ // if (p.options.jsx.fragment.len > 1) p.options.jsx.fragment[1..] else p.options.jsx.fragment,
+ // ),
+ // };
+ // decl_i += 1;
+ // }
- if (jsx_factory_symbol.use_count_estimate > 0)
- decls.appendAssumeCapacity(G.Decl{
- .binding = p.b(
- B.Identifier{
- .ref = p.jsx_factory.ref,
- },
- logger.Loc.Empty,
- ),
- .value = try p.jsxStringsToMemberExpression(logger.Loc.Empty, p.options.jsx.factory),
- });
- part_stmts[0] = p.s(S.Local{ .kind = .k_var, .decls = decls.items }, logger.Loc.Empty);
- before.append(js_ast.Part{
- .stmts = part_stmts,
- .declared_symbols = declared_symbols.items,
- .tag = .jsx_import,
- }) catch unreachable;
- }
- }
+ // if (dot_call_target.data != .e_require) {
+ // jsx_part_stmts[stmt_i] = p.s(S.Import{
+ // .namespace_ref = classic_namespace_ref,
+ // .star_name_loc = loc,
+ // .is_single_line = true,
+ // .import_record_index = import_record_id,
+ // }, loc);
+ // stmt_i += 1;
+ // }
- if (!did_import_fast_refresh and p.options.features.react_fast_refresh) {
- p.resolveGeneratedSymbol(&p.jsx_refresh_runtime);
- p.recordUsage(p.jsx_refresh_runtime.ref);
+ // p.import_records.items[import_record_id].tag = .jsx_classic;
+
+ // p.named_imports.put(
+ // classic_namespace_ref,
+ // js_ast.NamedImport{
+ // .alias = jsx_classic_symbol.original_name,
+ // .alias_is_star = true,
+ // .alias_loc = loc,
+ // .namespace_ref = classic_namespace_ref,
+ // .import_record_index = import_record_id,
+ // },
+ // ) catch unreachable;
+ // p.is_import_item.put(p.allocator, classic_namespace_ref, {}) catch unreachable;
+ // import_records[import_record_i] = import_record_id;
+ // declared_symbols.appendAssumeCapacity(.{ .ref = classic_namespace_ref, .is_top_level = true });
+ // }
- if (!p.options.jsx.use_embedded_refresh_runtime) {
- if (comptime Environment.allow_assert)
- assert(!p.options.enable_bundling);
- var declared_symbols = try p.allocator.alloc(js_ast.DeclaredSymbol, 1);
- const loc = logger.Loc.Empty;
- const import_record_id = p.addImportRecord(.require, loc, p.options.jsx.refresh_runtime);
- p.import_records.items[import_record_id].tag = .react_refresh;
-
- var import_stmt = p.s(S.Import{
- .namespace_ref = p.jsx_refresh_runtime.ref,
- .star_name_loc = loc,
- .is_single_line = true,
- .import_record_index = import_record_id,
- }, loc);
+ // if (p.options.features.react_fast_refresh) {
+ // defer did_import_fast_refresh = true;
+ // p.resolveGeneratedSymbol(&p.jsx_refresh_runtime);
+ // if (!p.options.jsx.use_embedded_refresh_runtime) {
+ // const refresh_runtime_symbol: *const Symbol = &p.symbols.items[p.jsx_refresh_runtime.ref.innerIndex()];
+
+ // declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_refresh_runtime.ref, .is_top_level = true });
+
+ // const import_record_id = p.addImportRecord(.require, loc, p.options.jsx.refresh_runtime);
+ // p.import_records.items[import_record_id].tag = .react_refresh;
+ // jsx_part_stmts[stmt_i] = p.s(S.Import{
+ // .namespace_ref = p.jsx_refresh_runtime.ref,
+ // .star_name_loc = loc,
+ // .is_single_line = true,
+ // .import_record_index = import_record_id,
+ // }, loc);
+
+ // stmt_i += 1;
+ // p.named_imports.put(
+ // p.jsx_refresh_runtime.ref,
+ // js_ast.NamedImport{
+ // .alias = refresh_runtime_symbol.original_name,
+ // .alias_is_star = true,
+ // .alias_loc = loc,
+ // .namespace_ref = p.jsx_refresh_runtime.ref,
+ // .import_record_index = import_record_id,
+ // },
+ // ) catch unreachable;
+ // p.is_import_item.put(p.allocator, p.jsx_refresh_runtime.ref, {}) catch unreachable;
+ // import_records[import_record_i] = import_record_id;
+ // }
+ // p.recordUsage(p.jsx_refresh_runtime.ref);
+ // }
- const refresh_runtime_symbol: *const Symbol = &p.symbols.items[p.jsx_refresh_runtime.ref.innerIndex()];
+ // jsx_part_stmts[stmt_i] = p.s(S.Local{ .kind = .k_var, .decls = decls[0..decl_i] }, loc);
+ // stmt_i += 1;
- p.named_imports.put(
- p.jsx_refresh_runtime.ref,
- js_ast.NamedImport{
- .alias = refresh_runtime_symbol.original_name,
- .alias_is_star = true,
- .alias_loc = loc,
- .namespace_ref = p.jsx_refresh_runtime.ref,
- .import_record_index = import_record_id,
- },
- ) catch unreachable;
- p.is_import_item.put(p.allocator, p.jsx_refresh_runtime.ref, {}) catch unreachable;
- var import_records = try p.allocator.alloc(@TypeOf(import_record_id), 1);
- import_records[0] = import_record_id;
- declared_symbols[0] = .{ .ref = p.jsx_refresh_runtime.ref, .is_top_level = true };
- var part_stmts = try p.allocator.alloc(Stmt, 1);
- part_stmts[0] = import_stmt;
-
- before.append(js_ast.Part{
- .stmts = part_stmts,
- .declared_symbols = declared_symbols,
- .import_record_indices = import_records,
- .tag = .react_fast_refresh,
- }) catch unreachable;
- }
- }
- },
- else => {},
- }
+ // before.append(js_ast.Part{
+ // .stmts = jsx_part_stmts[0..stmt_i],
+ // .declared_symbols = declared_symbols,
+ // .import_record_indices = bun.BabyList(u32).init(import_records),
+ // .tag = .jsx_import,
+ // }) catch unreachable;
+ // }
+ // } else if (p.options.features.jsx_optimization_inline) {
+ // const react_element_symbol = p.symbols.items[p.react_element_type.ref.innerIndex()];
+
+ // if (react_element_symbol.use_count_estimate > 0) {
+ // var declared_symbols = DeclaredSymbol.List{};
+ // try declared_symbols.ensureTotalCapacity(p.allocator, 1);
+ // var decls = try p.allocator.alloc(G.Decl, 1);
+ // var part_stmts = try p.allocator.alloc(Stmt, 1);
+
+ // declared_symbols.appendAssumeCapacity(.{ .ref = p.react_element_type.ref, .is_top_level = true });
+ // p.recordUsage(p.es6_symbol_global.ref);
+ // var call_args = p.allocator.alloc(Expr, 1) catch unreachable;
+ // call_args[0] = Expr{ .data = Prefill.Data.REACT_ELEMENT_TYPE, .loc = logger.Loc.Empty };
+
+ // decls[0] = G.Decl{
+ // .binding = p.b(
+ // B.Identifier{
+ // .ref = p.react_element_type.ref,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // .value = p.newExpr(
+ // E.Call{
+ // // Symbol.for
+ // .target = p.newExpr(
+ // E.Dot{
+ // .name = "for",
+ // .name_loc = logger.Loc.Empty,
+ // .target = p.newExpr(
+ // E.Identifier{
+ // .ref = p.es6_symbol_global.ref,
+ // .can_be_removed_if_unused = true,
+ // .call_can_be_unwrapped_if_unused = true,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // .can_be_removed_if_unused = true,
+ // .call_can_be_unwrapped_if_unused = true,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // .args = ExprNodeList.init(call_args),
+ // .close_paren_loc = logger.Loc.Empty,
+ // .can_be_unwrapped_if_unused = true,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // };
+ // part_stmts[0] = p.s(S.Local{ .kind = .k_var, .decls = decls }, logger.Loc.Empty);
+ // before.append(js_ast.Part{
+ // .stmts = part_stmts,
+ // .declared_symbols = declared_symbols,
+ // .tag = .jsx_import,
+ // }) catch unreachable;
+ // }
+ // } else {
+ // const jsx_fragment_symbol: Symbol = p.symbols.items[p.jsx_fragment.ref.innerIndex()];
+ // const jsx_factory_symbol: Symbol = p.symbols.items[p.jsx_factory.ref.innerIndex()];
+
+ // // inject
+ // // var jsxFrag =
+ // if (jsx_fragment_symbol.use_count_estimate + jsx_factory_symbol.use_count_estimate > 0) {
+ // const total = @as(usize, @boolToInt(jsx_fragment_symbol.use_count_estimate > 0)) + @as(usize, @boolToInt(jsx_factory_symbol.use_count_estimate > 0));
+ // var declared_symbols = DeclaredSymbol.List{};
+ // try declared_symbols.ensureTotalCapacity(p.allocator, total);
+ // var decls = try std.ArrayList(G.Decl).initCapacity(p.allocator, total);
+ // var part_stmts = try p.allocator.alloc(Stmt, 1);
+
+ // if (jsx_fragment_symbol.use_count_estimate > 0) declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_fragment.ref, .is_top_level = true });
+ // if (jsx_factory_symbol.use_count_estimate > 0) declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_factory.ref, .is_top_level = true });
+
+ // if (jsx_fragment_symbol.use_count_estimate > 0)
+ // decls.appendAssumeCapacity(G.Decl{
+ // .binding = p.b(
+ // B.Identifier{
+ // .ref = p.jsx_fragment.ref,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // .value = try p.jsxStringsToMemberExpression(logger.Loc.Empty, p.options.jsx.fragment),
+ // });
+
+ // if (jsx_factory_symbol.use_count_estimate > 0)
+ // decls.appendAssumeCapacity(G.Decl{
+ // .binding = p.b(
+ // B.Identifier{
+ // .ref = p.jsx_factory.ref,
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // .value = try p.jsxStringsToMemberExpression(logger.Loc.Empty, p.options.jsx.factory),
+ // });
+ // part_stmts[0] = p.s(S.Local{ .kind = .k_var, .decls = decls.items }, logger.Loc.Empty);
+ // before.append(js_ast.Part{
+ // .stmts = part_stmts,
+ // .declared_symbols = declared_symbols,
+ // .tag = .jsx_import,
+ // }) catch unreachable;
+ // }
+ // }
- if (p.options.enable_bundling) p.resolveBundlingSymbols();
+ // if (!did_import_fast_refresh and p.options.features.react_fast_refresh) {
+ // p.resolveGeneratedSymbol(&p.jsx_refresh_runtime);
+ // p.recordUsage(p.jsx_refresh_runtime.ref);
+
+ // if (!p.options.jsx.use_embedded_refresh_runtime) {
+ // if (comptime Environment.allow_assert)
+ // assert(!p.options.enable_legacy_bundling);
+ // var declared_symbols = DeclaredSymbol.List{};
+ // try declared_symbols.ensureTotalCapacity(p.allocator, 1);
+ // const loc = logger.Loc.Empty;
+ // const import_record_id = p.addImportRecord(.require, loc, p.options.jsx.refresh_runtime);
+ // p.import_records.items[import_record_id].tag = .react_refresh;
+
+ // var import_stmt = p.s(S.Import{
+ // .namespace_ref = p.jsx_refresh_runtime.ref,
+ // .star_name_loc = loc,
+ // .is_single_line = true,
+ // .import_record_index = import_record_id,
+ // }, loc);
+
+ // const refresh_runtime_symbol: *const Symbol = &p.symbols.items[p.jsx_refresh_runtime.ref.innerIndex()];
+
+ // p.named_imports.put(
+ // p.jsx_refresh_runtime.ref,
+ // js_ast.NamedImport{
+ // .alias = refresh_runtime_symbol.original_name,
+ // .alias_is_star = true,
+ // .alias_loc = loc,
+ // .namespace_ref = p.jsx_refresh_runtime.ref,
+ // .import_record_index = import_record_id,
+ // },
+ // ) catch unreachable;
+ // p.is_import_item.put(p.allocator, p.jsx_refresh_runtime.ref, {}) catch unreachable;
+ // var import_records = try p.allocator.alloc(@TypeOf(import_record_id), 1);
+ // import_records[0] = import_record_id;
+ // declared_symbols.appendAssumeCapacity(.{ .ref = p.jsx_refresh_runtime.ref, .is_top_level = true });
+ // var part_stmts = try p.allocator.alloc(Stmt, 1);
+ // part_stmts[0] = import_stmt;
+
+ // before.append(js_ast.Part{
+ // .stmts = part_stmts,
+ // .declared_symbols = declared_symbols,
+ // .import_record_indices = bun.BabyList(u32).init(import_records),
+ // .tag = .react_fast_refresh,
+ // }) catch unreachable;
+ // }
+ // }
+ // },
+ // else => {},
+ // }
- var runtime_imports_iter = p.runtime_imports.iter();
+ // if (p.options.enable_legacy_bundling) p.resolveBundlingSymbols();
+ // }
const has_cjs_imports = p.cjs_import_stmts.items.len > 0 and p.options.transform_require_to_import;
- {
- // "did they actually use require?"
- // well, if they didn't, in the linker later, we might need to inject it
- // but we don't know what name we can use there
- // so instead, we pessimistically assume they did in fact use require _somewhere_
- // and we set the name to something that won't conflict.
- // however, at this stage, we don't want to inject the import statement for the require
- // since it won't be actually used yet.
- const had_require = p.runtime_imports.contains("__require");
- p.resolveCommonJSSymbols();
-
- const copy_of_runtime_require = p.runtime_imports.__require;
- if (!had_require) {
- p.runtime_imports.__require = null;
- }
- defer {
- if (!had_require) {
- p.runtime_imports.__require = copy_of_runtime_require;
- }
- }
+ // if (!p.options.bundle) {
+ // // "did they actually use require?"
+ // // well, if they didn't, in the linker later, we might need to inject it
+ // // but we don't know what name we can use there
+ // // so instead, we pessimistically assume they did in fact use require _somewhere_
+ // // and we set the name to something that won't conflict.
+ // // however, at this stage, we don't want to inject the import statement for the require
+ // // since it won't be actually used yet.
+ // const had_require = p.runtime_imports.contains("__require");
+ // p.resolveCommonJSSymbols();
+
+ // const copy_of_runtime_require = p.runtime_imports.__require;
+ // if (!had_require) {
+ // p.runtime_imports.__require = null;
+ // }
+ // defer {
+ // if (!had_require) {
+ // p.runtime_imports.__require = copy_of_runtime_require;
+ // }
+ // }
- // - don't import runtime if we're bundling, it's already included
- // - when HMR is enabled, we always need to import the runtime for HMRClient and HMRModule.
- // - when HMR is not enabled, we only need any runtime imports if we're importing require()
- if (p.options.features.allow_runtime and
- !p.options.enable_bundling and
- (p.has_called_runtime or p.options.features.hot_module_reloading or has_cjs_imports))
- {
- const before_start = before.items.len;
- if (p.options.features.hot_module_reloading) {
- p.resolveHMRSymbols();
-
- if (runtime_imports_iter.next()) |entry| {
- std.debug.assert(entry.key == 0);
-
- // HMRClient.activate(true)
- var args_list: []Expr = if (Environment.isDebug) &Prefill.HotModuleReloading.DebugEnabledArgs else &Prefill.HotModuleReloading.DebugDisabled;
-
- var hmr_module_class_ident = p.newExpr(E.Identifier{ .ref = p.runtime_imports.__HMRClient.?.ref }, logger.Loc.Empty);
- const imports = [_]u16{entry.key};
- // TODO: remove these unnecessary allocations
- p.generateImportStmt(
- RuntimeImports.Name,
- &imports,
- &before,
- p.runtime_imports,
- p.s(
- S.SExpr{
- .value = p.newExpr(E.Call{
- .target = p.newExpr(E.Dot{
- .target = hmr_module_class_ident,
- .name = "activate",
- .name_loc = logger.Loc.Empty,
- }, logger.Loc.Empty),
- .args = ExprNodeList.init(args_list),
- }, logger.Loc.Empty),
- },
- logger.Loc.Empty,
- ),
- "import_",
- true,
- ) catch unreachable;
- }
- }
+ // // - don't import runtime if we're bundling, it's already included
+ // // - when HMR is enabled, we always need to import the runtime for HMRClient and HMRModule.
+ // // - when HMR is not enabled, we only need any runtime imports if we're importing require()
+ // if (p.options.features.allow_runtime and
+ // !p.options.enable_legacy_bundling and
+ // (p.has_called_runtime or p.options.features.hot_module_reloading or has_cjs_imports))
+ // {
+ // var runtime_imports_iter = p.runtime_imports.iter();
+
+ // const before_start = before.items.len;
+ // if (p.options.features.hot_module_reloading) {
+ // p.resolveHMRSymbols();
+
+ // if (runtime_imports_iter.next()) |entry| {
+ // std.debug.assert(entry.key == 0);
+
+ // // HMRClient.activate(true)
+ // var args_list: []Expr = if (Environment.isDebug) &Prefill.HotModuleReloading.DebugEnabledArgs else &Prefill.HotModuleReloading.DebugDisabled;
+
+ // var hmr_module_class_ident = p.newExpr(E.Identifier{ .ref = p.runtime_imports.__HMRClient.?.ref }, logger.Loc.Empty);
+ // const imports = [_]u16{entry.key};
+ // // TODO: remove these unnecessary allocations
+ // p.generateImportStmt(
+ // RuntimeImports.Name,
+ // &imports,
+ // &before,
+ // p.runtime_imports,
+ // p.s(
+ // S.SExpr{
+ // .value = p.newExpr(E.Call{
+ // .target = p.newExpr(E.Dot{
+ // .target = hmr_module_class_ident,
+ // .name = "activate",
+ // .name_loc = logger.Loc.Empty,
+ // }, logger.Loc.Empty),
+ // .args = ExprNodeList.init(args_list),
+ // }, logger.Loc.Empty),
+ // },
+ // logger.Loc.Empty,
+ // ),
+ // "import_",
+ // true,
+ // ) catch unreachable;
+ // }
+ // }
- while (runtime_imports_iter.next()) |entry| {
- const imports = [_]u16{entry.key};
- // TODO: remove these unnecessary allocations
- p.generateImportStmt(
- RuntimeImports.Name,
- &imports,
- &before,
- p.runtime_imports,
- null,
- "import_",
- true,
- ) catch unreachable;
- }
- // If we import JSX, we might call require.
- // We need to import require before importing JSX.
- // But a runtime import may not be necessary until we import JSX.
- // So we have to swap it after the fact, instead of just moving this above the JSX import.
- if (before_start > 0) {
- var j: usize = 0;
- while (j < before_start) : (j += 1) {
- std.mem.swap(js_ast.Part, &before.items[j], &before.items[before.items.len - j - 1]);
- }
- }
- }
- }
+ // while (runtime_imports_iter.next()) |entry| {
+ // const imports = [_]u16{entry.key};
+ // // TODO: remove these unnecessary allocations
+ // p.generateImportStmt(
+ // RuntimeImports.Name,
+ // &imports,
+ // &before,
+ // p.runtime_imports,
+ // null,
+ // "import_",
+ // true,
+ // ) catch unreachable;
+ // }
+ // // If we import JSX, we might call require.
+ // // We need to import require before importing JSX.
+ // // But a runtime import may not be necessary until we import JSX.
+ // // So we have to swap it after the fact, instead of just moving this above the JSX import.
+ // if (before_start > 0) {
+ // var j: usize = 0;
+ // while (j < before_start) : (j += 1) {
+ // std.mem.swap(js_ast.Part, &before.items[j], &before.items[before.items.len - j - 1]);
+ // }
+ // }
+ // }
+ // }
if (has_cjs_imports) {
- var import_records = try p.allocator.alloc(u32, p.cjs_import_stmts.items.len);
- var declared_symbols = try p.allocator.alloc(js_ast.DeclaredSymbol, p.cjs_import_stmts.items.len);
+ var import_records = try bun.BabyList(u32).initCapacity(p.allocator, p.cjs_import_stmts.items.len);
+ var declared_symbols = DeclaredSymbol.List{};
+ try declared_symbols.ensureTotalCapacity(p.allocator, p.cjs_import_stmts.items.len);
- for (p.cjs_import_stmts.items, 0..) |entry, i| {
+ for (p.cjs_import_stmts.items) |entry| {
const import_statement: *S.Import = entry.data.s_import;
- import_records[i] = import_statement.import_record_index;
- declared_symbols[i] = .{
+ import_records.appendAssumeCapacity(import_statement.import_record_index);
+ declared_symbols.appendAssumeCapacity(.{
.ref = import_statement.namespace_ref,
.is_top_level = true,
- };
+ });
}
before.append(js_ast.Part{
@@ -3296,6 +3657,72 @@ pub const Parser = struct {
}) catch unreachable;
}
+ if (p.has_called_runtime) {
+ var runtime_imports: [RuntimeImports.all.len]u8 = undefined;
+ var iter = p.runtime_imports.iter();
+ var i: usize = 0;
+ while (iter.next()) |entry| {
+ runtime_imports[i] = @intCast(u8, entry.key);
+ i += 1;
+ }
+
+ std.sort.sort(
+ u8,
+ runtime_imports[0..i],
+ {},
+ struct {
+ pub fn isLessThan(_: void, a: u8, b: u8) bool {
+ return std.math.order(
+ RuntimeImports.all_sorted_index[a],
+ RuntimeImports.all_sorted_index[b],
+ ) == .lt;
+ }
+ }.isLessThan,
+ );
+
+ if (i > 0) {
+ p.generateImportStmt(
+ RuntimeImports.Name,
+ runtime_imports[0..i],
+ &before,
+ p.runtime_imports,
+ null,
+ "import_",
+ true,
+ ) catch unreachable;
+ }
+ }
+
+ // handle new way to do automatic JSX imports which fixes symbol collision issues
+ if (p.options.jsx.parse) {
+ const runtime_import_names = p.jsx_imports.runtimeImportNames();
+ const legacy_import_names = p.jsx_imports.legacyImportNames();
+
+ if (runtime_import_names.len > 0) {
+ p.generateImportStmt(
+ p.options.jsx.import_source,
+ runtime_import_names,
+ &before,
+ &p.jsx_imports,
+ null,
+ "jsx",
+ false,
+ ) catch unreachable;
+ }
+
+ if (legacy_import_names.len > 0) {
+ p.generateImportStmt(
+ p.options.jsx.classic_import_source,
+ legacy_import_names,
+ &before,
+ &p.jsx_imports,
+ null,
+ "React",
+ false,
+ ) catch unreachable;
+ }
+ }
+
var parts_slice: []js_ast.Part = &([_]js_ast.Part{});
if (before.items.len > 0 or after.items.len > 0) {
@@ -3478,7 +3905,6 @@ pub const Prefill = struct {
pub var JSXFilename = "__jsxFilename";
pub var MarkAsModule = "__markAsModule";
pub var CommonJS = "__commonJS";
- pub var ReExport = "__reExport";
pub var ToModule = "__toModule";
const JSXShortname = "jsx";
};
@@ -3666,9 +4092,13 @@ fn NewParser_(
has_classic_runtime_warned: bool = false,
macro_call_count: MacroCallCountType = 0,
+ hoisted_ref_for_sloppy_mode_block_fn: RefRefMap = .{},
+
/// Used for transforming export default -> module.exports
has_export_default: bool = false,
+ is_file_considered_to_have_esm_exports: bool = false,
+
hmr_module: GeneratedSymbol = GeneratedSymbol{ .primary = Ref.None, .backup = Ref.None, .ref = Ref.None },
has_called_runtime: bool = false,
@@ -3677,10 +4107,14 @@ fn NewParser_(
injected_define_symbols: List(Ref) = .{},
symbol_uses: js_ast.Part.SymbolUseMap = .{},
- declared_symbols: List(js_ast.DeclaredSymbol) = .{},
- declared_symbols_for_reuse: List(js_ast.DeclaredSymbol) = .{},
+ declared_symbols: DeclaredSymbol.List = .{},
+ declared_symbols_for_reuse: DeclaredSymbol.List = .{},
runtime_imports: RuntimeImports = RuntimeImports{},
+ commonjs_named_exports: js_ast.Ast.CommonJSNamedExports = .{},
+ commonjs_named_exports_deoptimized: bool = false,
+ commonjs_named_exports_needs_conversion: u32 = std.math.maxInt(u32),
+
parse_pass_symbol_uses: ParsePassSymbolUsageType = undefined,
// duplicate_case_checker: void,
// non_bmp_identifiers: StringBoolMap,
@@ -3719,13 +4153,17 @@ fn NewParser_(
react_element_type: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
/// Symbol object
es6_symbol_global: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
- // jsx_filename: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
+
+ // TODO: remove all these
jsx_runtime: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
jsx_factory: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
jsx_fragment: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
jsx_automatic: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
jsxs_runtime: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
jsx_classic: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
+
+ jsx_imports: JSXImport.Symbols = .{},
+
// only applicable when is_react_fast_refresh_enabled
jsx_refresh_runtime: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
@@ -3739,8 +4177,8 @@ fn NewParser_(
export_star_import_records: List(u32) = .{},
// These are for handling ES6 imports and exports
- es6_import_keyword: logger.Range = logger.Range.None,
- es6_export_keyword: logger.Range = logger.Range.None,
+ esm_import_keyword: logger.Range = logger.Range.None,
+ esm_export_keyword: logger.Range = logger.Range.None,
enclosing_class_keyword: logger.Range = logger.Range.None,
import_items_for_namespace: std.AutoHashMapUnmanaged(Ref, ImportItemForNamespaceMap) = .{},
is_import_item: RefMap = .{},
@@ -3920,7 +4358,7 @@ fn NewParser_(
return p.newExpr(E.Import{
.expr = arg,
- .import_record_index = Ref.None.sourceIndex(),
+ .import_record_index = std.math.maxInt(u32),
}, state.loc);
}
@@ -4022,7 +4460,19 @@ fn NewParser_(
// require(import_object_assign)
return p.callRuntime(arg.loc, "__require", args);
},
- else => {},
+ else => {
+ if (p.options.bundle) {
+ const args = p.allocator.alloc(Expr, 1) catch unreachable;
+ args[0] = arg;
+ return p.newExpr(
+ E.Call{
+ .target = p.valueForRequire(arg.loc),
+ .args = ExprNodeList.init(args),
+ },
+ arg.loc,
+ );
+ }
+ },
}
return arg;
@@ -4213,12 +4663,12 @@ fn NewParser_(
var symbol_use_values = part.symbol_uses.values();
var symbols = p.symbols.items;
- for (symbol_use_refs, 0..) |ref, i| {
- symbols[ref.innerIndex()].use_count_estimate -|= symbol_use_values[i].count_estimate;
+ for (symbol_use_refs, symbol_use_values) |ref, prev| {
+ symbols[ref.innerIndex()].use_count_estimate -|= prev.count_estimate;
}
-
- for (part.declared_symbols) |declared| {
- symbols[declared.ref.innerIndex()].use_count_estimate = 0;
+ const declared_refs = part.declared_symbols.refs();
+ for (declared_refs) |declared| {
+ symbols[declared.innerIndex()].use_count_estimate = 0;
// }
}
}
@@ -4334,7 +4784,11 @@ fn NewParser_(
}
pub fn findSymbol(p: *P, loc: logger.Loc, name: string) !FindSymbolResult {
- var declare_loc: logger.Loc = undefined;
+ return findSymbolWithRecordUsage(p, loc, name, true);
+ }
+
+ pub fn findSymbolWithRecordUsage(p: *P, loc: logger.Loc, name: string, comptime record_usage: bool) !FindSymbolResult {
+ var declare_loc: logger.Loc = logger.Loc.Empty;
var is_inside_with_scope = false;
// This function can show up in profiling.
// That's part of why we do this.
@@ -4370,6 +4824,14 @@ fn NewParser_(
// Allocate an "unbound" symbol
p.checkForNonBMPCodePoint(loc, name);
+ if (comptime !record_usage) {
+ return FindSymbolResult{
+ .ref = Ref.None,
+ .declare_loc = loc,
+ .is_inside_with_scope = is_inside_with_scope,
+ };
+ }
+
var gpe = p.module_scope.getOrPutMemberWithHash(allocator, name, hash) catch unreachable;
// I don't think this happens?
@@ -4398,7 +4860,7 @@ fn NewParser_(
}
// Track how many times we've referenced this symbol
- p.recordUsage(ref);
+ if (comptime record_usage) p.recordUsage(ref);
return FindSymbolResult{
.ref = ref,
@@ -4525,6 +4987,11 @@ fn NewParser_(
}) catch unreachable;
}
+ // TODO: TypeScript namespace
+ // if (opts.assign_target == .none and !opts.is_delete_target and p.options.bundle) {
+
+ // }
+
// Substitute an EImportIdentifier now if this is an import item
if (p.is_import_item.contains(ref)) {
return p.newExpr(
@@ -4575,42 +5042,51 @@ fn NewParser_(
const allocator = p.allocator;
const import_record_i = p.addImportRecordByRange(.stmt, logger.Range.None, import_path);
var import_record: *ImportRecord = &p.import_records.items[import_record_i];
- import_record.path.namespace = "runtime";
+ if (comptime is_internal)
+ import_record.path.namespace = "runtime";
import_record.is_internal = is_internal;
var import_path_identifier = try import_record.path.name.nonUniqueNameString(allocator);
var namespace_identifier = try allocator.alloc(u8, import_path_identifier.len + suffix.len);
var clause_items = try allocator.alloc(js_ast.ClauseItem, imports.len);
var stmts = try allocator.alloc(Stmt, 1 + if (additional_stmt != null) @as(usize, 1) else @as(usize, 0));
- var declared_symbols = try allocator.alloc(js_ast.DeclaredSymbol, imports.len);
+ var declared_symbols = DeclaredSymbol.List{};
+ try declared_symbols.ensureTotalCapacity(allocator, imports.len + 1);
bun.copy(u8, namespace_identifier, suffix);
bun.copy(u8, namespace_identifier[suffix.len..], import_path_identifier);
const namespace_ref = try p.newSymbol(.other, namespace_identifier);
- try p.module_scope.generated.append(allocator, namespace_ref);
- for (imports, 0..) |alias, i| {
+ declared_symbols.appendAssumeCapacity(.{
+ .ref = namespace_ref,
+ .is_top_level = true,
+ });
+ try p.module_scope.generated.push(allocator, namespace_ref);
+ for (imports, clause_items) |alias, *clause_item| {
const ref = symbols.get(alias) orelse unreachable;
const alias_name = if (@TypeOf(symbols) == RuntimeImports) RuntimeImports.all[alias] else alias;
- clause_items[i] = js_ast.ClauseItem{
+ clause_item.* = js_ast.ClauseItem{
.alias = alias_name,
.original_name = alias_name,
.alias_loc = logger.Loc{},
.name = LocRef{ .ref = ref, .loc = logger.Loc{} },
};
- declared_symbols[i] = js_ast.DeclaredSymbol{ .ref = ref, .is_top_level = true };
+ declared_symbols.appendAssumeCapacity(.{ .ref = ref, .is_top_level = true });
try p.is_import_item.put(allocator, ref, {});
try p.named_imports.put(ref, js_ast.NamedImport{
.alias = alias_name,
.alias_loc = logger.Loc{},
- .namespace_ref = null,
+ .namespace_ref = namespace_ref,
.import_record_index = import_record_i,
});
}
- stmts[0] = p.s(S.Import{
- .namespace_ref = namespace_ref,
- .items = clause_items,
- .import_record_index = import_record_i,
- }, logger.Loc{});
+ stmts[0] = p.s(
+ S.Import{
+ .namespace_ref = namespace_ref,
+ .items = clause_items,
+ .import_record_index = import_record_i,
+ },
+ logger.Loc{},
+ );
if (additional_stmt) |add| {
stmts[1] = add;
}
@@ -4623,7 +5099,7 @@ fn NewParser_(
parts.append(js_ast.Part{
.stmts = stmts,
.declared_symbols = declared_symbols,
- .import_record_indices = import_records,
+ .import_record_indices = bun.BabyList(u32).init(import_records),
.tag = .runtime,
}) catch unreachable;
}
@@ -5134,16 +5610,20 @@ fn NewParser_(
}
}
+ p.is_file_considered_to_have_esm_exports =
+ !p.top_level_await_keyword.isEmpty() or !p.esm_export_keyword.isEmpty() or
+ p.options.module_type == .esm;
+
try p.pushScopeForVisitPass(js_ast.Scope.Kind.entry, locModuleScope);
p.fn_or_arrow_data_visit.is_outside_fn_or_arrow = true;
p.module_scope = p.current_scope;
- p.has_es_module_syntax = p.es6_import_keyword.len > 0 or p.es6_export_keyword.len > 0 or p.top_level_await_keyword.len > 0;
+ p.has_es_module_syntax = p.esm_import_keyword.len > 0 or p.esm_export_keyword.len > 0 or p.top_level_await_keyword.len > 0;
// ECMAScript modules are always interpreted as strict mode. This has to be
// done before "hoistSymbols" because strict mode can alter hoisting (!).
- if (p.es6_import_keyword.len > 0) {
+ if (p.esm_import_keyword.len > 0) {
p.module_scope.recursiveSetStrictMode(js_ast.StrictModeKind.implicit_strict_mode_import);
- } else if (p.es6_export_keyword.len > 0) {
+ } else if (p.esm_export_keyword.len > 0) {
p.module_scope.recursiveSetStrictMode(js_ast.StrictModeKind.implicit_strict_mode_export);
} else if (p.top_level_await_keyword.len > 0) {
p.module_scope.recursiveSetStrictMode(js_ast.StrictModeKind.implicit_strict_mode_top_level_await);
@@ -5153,7 +5633,7 @@ fn NewParser_(
var generated_symbols_count: u32 = 3;
- if (p.options.enable_bundling) {
+ if (p.options.enable_legacy_bundling) {
generated_symbols_count += 4;
}
@@ -5176,6 +5656,7 @@ fn NewParser_(
p.exports_ref = try p.declareCommonJSSymbol(.hoisted, "exports");
p.module_ref = try p.declareCommonJSSymbol(.hoisted, "module");
+
p.require_ref = try p.declareCommonJSSymbol(.unbound, "require");
p.dirname_ref = try p.declareCommonJSSymbol(.unbound, "__dirname");
p.filename_ref = try p.declareCommonJSSymbol(.unbound, "__filename");
@@ -5191,12 +5672,9 @@ fn NewParser_(
p.jest.afterAll = try p.declareCommonJSSymbol(.unbound, "afterAll");
}
- if (p.options.enable_bundling) {
- p.runtime_imports.__reExport = try p.declareGeneratedSymbol(.other, "__reExport");
+ if (p.options.enable_legacy_bundling) {
p.runtime_imports.@"$$m" = try p.declareGeneratedSymbol(.other, "$$m");
-
p.runtime_imports.@"$$lzy" = try p.declareGeneratedSymbol(.other, "$$lzy");
-
p.runtime_imports.__export = try p.declareGeneratedSymbol(.other, "__export");
p.runtime_imports.__exportValue = try p.declareGeneratedSymbol(.other, "__exportValue");
p.runtime_imports.__exportDefault = try p.declareGeneratedSymbol(.other, "__exportDefault");
@@ -5227,33 +5705,38 @@ fn NewParser_(
switch (comptime jsx_transform_type) {
.react => {
- if (p.options.features.jsx_optimization_inline) {
- p.react_element_type = p.declareGeneratedSymbol(.other, "REACT_ELEMENT_TYPE") catch unreachable;
- p.es6_symbol_global = p.declareGeneratedSymbol(.unbound, "Symbol") catch unreachable;
- }
- p.jsx_fragment = p.declareGeneratedSymbol(.other, "Fragment") catch unreachable;
- p.jsx_runtime = p.declareGeneratedSymbol(.other, "jsx") catch unreachable;
- if (comptime FeatureFlags.support_jsxs_in_jsx_transform)
- p.jsxs_runtime = p.declareGeneratedSymbol(.other, "jsxs") catch unreachable;
- p.jsx_factory = p.declareGeneratedSymbol(.other, "Factory") catch unreachable;
+ if (!p.options.bundle) {
+ if (p.options.features.jsx_optimization_inline) {
+ p.react_element_type = p.declareGeneratedSymbol(.other, "REACT_ELEMENT_TYPE") catch unreachable;
+ p.es6_symbol_global = p.declareGeneratedSymbol(.unbound, "Symbol") catch unreachable;
+ }
- if (p.options.jsx.factory.len > 1 or FeatureFlags.jsx_runtime_is_cjs) {
- p.jsx_classic = p.declareGeneratedSymbol(.other, "ClassicImportSource") catch unreachable;
- }
+ p.jsx_fragment = p.declareGeneratedSymbol(.other, "Fragment") catch unreachable;
+ p.jsx_runtime = p.declareGeneratedSymbol(.other, "jsx") catch unreachable;
+ if (comptime FeatureFlags.support_jsxs_in_jsx_transform)
+ p.jsxs_runtime = p.declareGeneratedSymbol(.other, "jsxs") catch unreachable;
+ p.jsx_factory = p.declareGeneratedSymbol(.other, "Factory") catch unreachable;
+
+ if (p.options.jsx.factory.len > 1 or FeatureFlags.jsx_runtime_is_cjs) {
+ p.jsx_classic = p.declareGeneratedSymbol(.other, "ClassicImportSource") catch unreachable;
+ }
- if (p.options.jsx.import_source.len > 0) {
- p.jsx_automatic = p.declareGeneratedSymbol(.other, "ImportSource") catch unreachable;
+ if (p.options.jsx.import_source.len > 0) {
+ p.jsx_automatic = p.declareGeneratedSymbol(.other, "ImportSource") catch unreachable;
+ }
}
},
.macro => {
- p.bun_jsx_ref = p.declareSymbol(.other, logger.Loc.Empty, "bunJSX") catch unreachable;
- BunJSX.bun_jsx_identifier = E.Identifier{
- .ref = p.bun_jsx_ref,
- .can_be_removed_if_unused = true,
- .call_can_be_unwrapped_if_unused = true,
- };
- p.jsx_fragment = p.declareGeneratedSymbol(.other, "Fragment") catch unreachable;
+ if (!p.options.bundle) {
+ p.bun_jsx_ref = p.declareSymbol(.other, logger.Loc.Empty, "bunJSX") catch unreachable;
+ BunJSX.bun_jsx_identifier = E.Identifier{
+ .ref = p.bun_jsx_ref,
+ .can_be_removed_if_unused = true,
+ .call_can_be_unwrapped_if_unused = true,
+ };
+ p.jsx_fragment = p.declareGeneratedSymbol(.other, "Fragment") catch unreachable;
+ }
},
else => {},
}
@@ -5261,17 +5744,17 @@ fn NewParser_(
// This won't work for adversarial cases
pub fn resolveGeneratedSymbol(p: *P, generated_symbol: *GeneratedSymbol) void {
- if (generated_symbol.ref.isNull()) return;
+ if (generated_symbol.ref.isNull() or p.options.bundle) return;
if (p.symbols.items[generated_symbol.primary.innerIndex()].use_count_estimate == 0 and
- p.symbols.items[generated_symbol.primary.innerIndex()].link.isNull())
+ p.symbols.items[generated_symbol.primary.innerIndex()].hasLink())
{
p.symbols.items[generated_symbol.ref.innerIndex()].original_name = p.symbols.items[generated_symbol.primary.innerIndex()].original_name;
return;
}
if (p.symbols.items[generated_symbol.backup.innerIndex()].use_count_estimate == 0 and
- p.symbols.items[generated_symbol.backup.innerIndex()].link.isNull())
+ p.symbols.items[generated_symbol.backup.innerIndex()].hasLink())
{
p.symbols.items[generated_symbol.ref.innerIndex()].original_name = p.symbols.items[generated_symbol.backup.innerIndex()].original_name;
return;
@@ -5289,17 +5772,19 @@ fn NewParser_(
}
pub fn resolveCommonJSSymbols(p: *P) void {
+ if (!p.options.features.allow_runtime)
+ return;
+
if (p.runtime_imports.__require) |*require| {
p.resolveGeneratedSymbol(require);
}
- if (p.options.features.allow_runtime)
- p.ensureRequireSymbol();
+
+ p.ensureRequireSymbol();
}
pub fn resolveBundlingSymbols(p: *P) void {
p.recordUsage(p.runtime_imports.@"$$m".?.ref);
- p.resolveGeneratedSymbol(&p.runtime_imports.__reExport.?);
p.resolveGeneratedSymbol(&p.runtime_imports.@"$$m".?);
p.resolveGeneratedSymbol(&p.runtime_imports.@"$$lzy".?);
p.resolveGeneratedSymbol(&p.runtime_imports.__export.?);
@@ -5319,6 +5804,9 @@ fn NewParser_(
}
pub fn resolveStaticJSXSymbols(p: *P) void {
+ if (p.options.bundle)
+ return;
+
if (p.options.features.jsx_optimization_inline) {
p.resolveGeneratedSymbol(&p.react_element_type);
p.resolveGeneratedSymbol(&p.es6_symbol_global);
@@ -5326,6 +5814,7 @@ fn NewParser_(
p.resolveGeneratedSymbol(merge);
}
}
+
p.resolveGeneratedSymbol(&p.jsx_runtime);
if (FeatureFlags.support_jsxs_in_jsx_transform)
p.resolveGeneratedSymbol(&p.jsxs_runtime);
@@ -5362,6 +5851,44 @@ fn NewParser_(
var __scope = scope.parent;
if (comptime Environment.allow_assert)
assert(__scope != null);
+
+ var is_sloppy_mode_block_level_fn_stmt = false;
+ const original_member_ref = value.ref;
+
+ if (symbol.kind == .hoisted_function) {
+ // Block-level function declarations behave like "let" in strict mode
+ if (scope.strict_mode != .sloppy_mode) {
+ continue;
+ }
+
+ // In sloppy mode, block level functions behave like "let" except with
+ // an assignment to "var", sort of. This code:
+ //
+ // if (x) {
+ // f();
+ // function f() {}
+ // }
+ // f();
+ //
+ // behaves like this code:
+ //
+ // if (x) {
+ // let f2 = function() {}
+ // var f = f2;
+ // f2();
+ // }
+ // f();
+ //
+ const hoisted_ref = p.newSymbol(.hoisted, symbol.original_name) catch unreachable;
+ symbols = p.symbols.items;
+ scope.generated.push(p.allocator, hoisted_ref) catch unreachable;
+ p.hoisted_ref_for_sloppy_mode_block_fn.put(p.allocator, original_member_ref, hoisted_ref) catch unreachable;
+
+ res.value_ptr.ref = hoisted_ref;
+ symbol = &symbols[hoisted_ref.innerIndex()];
+ is_sloppy_mode_block_level_fn_stmt = true;
+ }
+
const name = symbol.original_name;
const hash: u64 = Scope.getMemberHash(name);
@@ -5406,29 +5933,31 @@ fn NewParser_(
continue :nextMember;
}
- // An identifier binding from a catch statement and a function
- // declaration can both silently shadow another hoisted symbol
-
// Otherwise if this isn't a catch identifier, it's a collision
if (existing_kind != .catch_identifier and existing_kind != .arguments) {
// An identifier binding from a catch statement and a function
// declaration can both silently shadow another hoisted symbol
if (symbol.kind != .catch_identifier and symbol.kind != .hoisted_function) {
- const r = js_lexer.rangeOfIdentifier(p.source, value.loc);
- var notes = allocator.alloc(logger.Data, 1) catch unreachable;
- notes[0] =
- logger.rangeData(
- p.source,
- r,
- std.fmt.allocPrint(
- allocator,
- "{s} was originally declared here",
- .{name},
- ) catch unreachable,
- );
+ if (!is_sloppy_mode_block_level_fn_stmt) {
+ const r = js_lexer.rangeOfIdentifier(p.source, value.loc);
+ var notes = allocator.alloc(logger.Data, 1) catch unreachable;
+ notes[0] =
+ logger.rangeData(
+ p.source,
+ r,
+ std.fmt.allocPrint(
+ allocator,
+ "{s} was originally declared here",
+ .{name},
+ ) catch unreachable,
+ );
- p.log.addRangeErrorFmtWithNotes(p.source, js_lexer.rangeOfIdentifier(p.source, member_in_scope.loc), allocator, notes, "{s} has already been declared", .{name}) catch unreachable;
+ p.log.addRangeErrorFmtWithNotes(p.source, js_lexer.rangeOfIdentifier(p.source, member_in_scope.loc), allocator, notes, "{s} has already been declared", .{name}) catch unreachable;
+ } else if (_scope == scope.parent) {
+ // Never mind about this, turns out it's not needed after all
+ _ = p.hoisted_ref_for_sloppy_mode_block_fn.remove(original_member_ref);
+ }
continue :nextMember;
}
@@ -5451,8 +5980,11 @@ fn NewParser_(
}
}
- for (scope.children.items, 0..) |_, i| {
- p.hoistSymbols(scope.children.items[i]);
+ {
+ const children = scope.children.slice();
+ for (children) |child| {
+ p.hoistSymbols(child);
+ }
}
}
@@ -5493,7 +6025,7 @@ fn NewParser_(
.generated = .{},
};
- try parent.children.append(allocator, scope);
+ try parent.children.push(allocator, scope);
scope.strict_mode = parent.strict_mode;
p.current_scope = scope;
@@ -5803,10 +6335,14 @@ fn NewParser_(
// function foo(): void;
// function foo(): void {}
//
- if (name) |*name_| {
- const kind = if (is_generator or is_async) Symbol.Kind.generator_or_async_function else Symbol.Kind.hoisted_function;
- name_.ref = try p.declareSymbol(kind, name_.loc, nameText);
- func.name = name_.*;
+ if (name != null) {
+ const kind = if (is_generator or is_async)
+ Symbol.Kind.generator_or_async_function
+ else
+ Symbol.Kind.hoisted_function;
+
+ name.?.ref = try p.declareSymbol(kind, name.?.loc, nameText);
+ func.name = name;
}
func.flags.setPresent(.has_if_scope, hasIfScope);
@@ -5834,8 +6370,8 @@ fn NewParser_(
var children = parent.children;
// Remove the last child from the parent scope
- var last = children.items.len - 1;
- if (children.items[last] != to_discard) {
+ var last = children.len - 1;
+ if (children.slice()[last] != to_discard) {
p.panic("Internal error", .{});
}
@@ -6003,7 +6539,7 @@ fn NewParser_(
// this if it wasn't already declared above because arguments are allowed to
// be called "arguments", in which case the real "arguments" is inaccessible.
if (!p.current_scope.members.contains("arguments")) {
- func.arguments_ref = p.declareSymbolMaybeGenerated(.arguments, func.open_parens_loc, "arguments", true) catch unreachable;
+ func.arguments_ref = p.declareSymbolMaybeGenerated(.arguments, func.open_parens_loc, arguments_str, false) catch unreachable;
p.symbols.items[func.arguments_ref.?.innerIndex()].must_not_be_renamed = true;
}
@@ -6674,7 +7210,7 @@ fn NewParser_(
const name = try path_name.nonUniqueNameString(p.allocator);
stmt.namespace_ref = try p.newSymbol(.other, name);
var scope: *Scope = p.current_scope;
- try scope.generated.append(p.allocator, stmt.namespace_ref);
+ try scope.generated.push(p.allocator, stmt.namespace_ref);
}
var item_refs = ImportItemForNamespaceMap.init(p.allocator);
@@ -6838,23 +7374,28 @@ fn NewParser_(
var scope = p.current_scope;
- try scope.generated.append(p.allocator, name.ref.?);
+ try scope.generated.push(p.allocator, name.ref.?);
return name;
}
pub fn newSymbol(p: *P, kind: Symbol.Kind, identifier: string) !Ref {
- const inner_index = Ref.toInt(p.symbols.items.len);
+ const inner_index = @truncate(Ref.Int, p.symbols.items.len);
try p.symbols.append(Symbol{
.kind = kind,
.original_name = identifier,
+ .debug_mode_source_index = if (comptime Environment.allow_assert) p.source.index.get() else 0,
});
if (is_typescript_enabled) {
try p.ts_use_counts.append(p.allocator, 0);
}
- return Ref.init(inner_index, Ref.toInt(p.source.index), false);
+ return Ref{
+ .inner_index = inner_index,
+ .source_index = Ref.toInt(p.source.index.get()),
+ .tag = .symbol,
+ };
}
fn parseLabelName(p: *P) !?js_ast.LocRef {
@@ -7010,9 +7551,9 @@ fn NewParser_(
},
.t_export => {
- var previousExportKeyword = p.es6_export_keyword;
+ var previousExportKeyword = p.esm_export_keyword;
if (opts.is_module_scope) {
- p.es6_export_keyword = p.lexer.range();
+ p.esm_export_keyword = p.lexer.range();
} else if (!opts.is_namespace_scope) {
try p.lexer.unexpected();
return error.SyntaxError;
@@ -7315,7 +7856,7 @@ fn NewParser_(
if (comptime track_symbol_usage_during_parse_pass) {
// In the scan pass, we need _some_ way of knowing *not* to mark as unused
- p.import_records.items[import_record_index].calls_run_time_re_export_fn = true;
+ p.import_records.items[import_record_index].calls_runtime_re_export_fn = true;
}
try p.lexer.expectOrInsertSemicolon();
@@ -7349,15 +7890,32 @@ fn NewParser_(
}
const import_record_index = p.addImportRecord(.stmt, parsedPath.loc, parsedPath.text);
- var path_name = fs.PathName.init(strings.append(p.allocator, "import_", parsedPath.text) catch unreachable);
- const namespace_ref = p.storeNameInRef(path_name.nonUniqueNameString(p.allocator) catch unreachable) catch unreachable;
+ const path_name = fs.PathName.init(parsedPath.text);
+ const namespace_ref = p.storeNameInRef(
+ std.fmt.allocPrint(
+ p.allocator,
+ "import_{any}",
+ .{
+ path_name.fmtIdentifier(),
+ },
+ ) catch unreachable,
+ ) catch unreachable;
if (comptime track_symbol_usage_during_parse_pass) {
// In the scan pass, we need _some_ way of knowing *not* to mark as unused
- p.import_records.items[import_record_index].calls_run_time_re_export_fn = true;
+ p.import_records.items[import_record_index].calls_runtime_re_export_fn = true;
}
+ p.current_scope.is_after_const_local_prefix = true;
- return p.s(S.ExportFrom{ .items = export_clause.clauses, .is_single_line = export_clause.is_single_line, .namespace_ref = namespace_ref, .import_record_index = import_record_index }, loc);
+ return p.s(
+ S.ExportFrom{
+ .items = export_clause.clauses,
+ .is_single_line = export_clause.is_single_line,
+ .namespace_ref = namespace_ref,
+ .import_record_index = import_record_index,
+ },
+ loc,
+ );
}
try p.lexer.expectOrInsertSemicolon();
@@ -7376,7 +7934,7 @@ fn NewParser_(
T.t_equals => {
// "export = value;"
- p.es6_export_keyword = previousExportKeyword; // This wasn't an ESM export statement after all
+ p.esm_export_keyword = previousExportKeyword; // This wasn't an ESM export statement after all
if (is_typescript_enabled) {
try p.lexer.next();
var value = try p.parseExpr(.lowest);
@@ -7824,8 +8382,8 @@ fn NewParser_(
);
},
.t_import => {
- const previous_import_keyword = p.es6_import_keyword;
- p.es6_import_keyword = p.lexer.range();
+ const previous_import_keyword = p.esm_import_keyword;
+ p.esm_import_keyword = p.lexer.range();
try p.lexer.next();
var stmt: S.Import = S.Import{
.namespace_ref = Ref.None,
@@ -7842,7 +8400,7 @@ fn NewParser_(
// "import('path')"
// "import.meta"
.t_open_paren, .t_dot => {
- p.es6_import_keyword = previous_import_keyword; // this wasn't an esm import statement after all
+ p.esm_import_keyword = previous_import_keyword; // this wasn't an esm import statement after all
const expr = try p.parseSuffix(try p.parseImportExpr(loc, .lowest), .lowest, null, Expr.EFlags.none);
try p.lexer.expectOrInsertSemicolon();
return p.s(S.SExpr{
@@ -7962,7 +8520,7 @@ fn NewParser_(
// Parse TypeScript import assignment statements
if (p.lexer.token == .t_equals or opts.is_export or (opts.is_namespace_scope and !opts.is_typescript_declare)) {
- p.es6_import_keyword = previous_import_keyword; // This wasn't an ESM import statement after all;
+ p.esm_import_keyword = previous_import_keyword; // This wasn't an ESM import statement after all;
return p.parseTypeScriptImportEqualsStmt(loc, opts, logger.Loc.Empty, default_name);
}
}
@@ -8253,10 +8811,12 @@ fn NewParser_(
const child = _child orelse continue;
if (child.scope.parent == p.current_scope) {
- var i: usize = children.items.len - 1;
+ var i: usize = children.len - 1;
while (i >= 0) {
- if (children.items[i] == child.scope) {
- _ = children.orderedRemove(i);
+ if (children.mut(i).* == child.scope) {
+ var list = children.listManaged(p.allocator);
+ _ = list.orderedRemove(i);
+ children.update(list);
break;
}
i -= 1;
@@ -8390,7 +8950,7 @@ fn NewParser_(
// run the renamer. For external-facing things the renamer will avoid
// collisions automatically so this isn't important for correctness.
arg_ref = p.newSymbol(.hoisted, strings.cat(p.allocator, "_", name_text) catch unreachable) catch unreachable;
- p.current_scope.generated.append(p.allocator, arg_ref.?) catch unreachable;
+ p.current_scope.generated.push(p.allocator, arg_ref.?) catch unreachable;
} else {
arg_ref = p.newSymbol(.hoisted, name_text) catch unreachable;
}
@@ -9125,7 +9685,7 @@ fn NewParser_(
// run the renamer. For external-facing things the renamer will avoid
// collisions automatically so this isn't important for correctness.
arg_ref = p.newSymbol(.hoisted, strings.cat(p.allocator, "_", name_text) catch unreachable) catch unreachable;
- p.current_scope.generated.append(p.allocator, arg_ref) catch unreachable;
+ p.current_scope.generated.push(p.allocator, arg_ref) catch unreachable;
} else {
arg_ref = p.declareSymbol(.hoisted, name_loc, name_text) catch unreachable;
}
@@ -9338,7 +9898,14 @@ fn NewParser_(
}
// For now, we silently strip import assertions
- if (!p.lexer.has_newline_before and p.lexer.isContextualKeyword("assert")) {
+ if (!p.lexer.has_newline_before and (
+ // Import Assertions are deprecated.
+ // Import Attributes are the new way to do this.
+ // But some code may still use "assert"
+ // We support both and treat them identically.
+ // Once Prettier & TypeScript support import attributes, we will add runtime support
+ p.lexer.isContextualKeyword("assert") or p.lexer.isContextualKeyword("with")))
+ {
try p.lexer.next();
try p.lexer.expect(.t_open_brace);
@@ -9383,7 +9950,7 @@ fn NewParser_(
.text = comment.text,
}, p.lexer.loc()));
}
- p.lexer.comments_to_preserve_before.shrinkRetainingCapacity(0);
+ p.lexer.comments_to_preserve_before.clearRetainingCapacity();
if (p.lexer.token == eend) {
break;
@@ -9414,11 +9981,11 @@ fn NewParser_(
isDirectivePrologue = true;
if (str.eqlComptime("use strict")) {
- skip = p.options.features.dynamic_require or skip;
+ skip = true;
// Track "use strict" directives
p.current_scope.strict_mode = .explicit_strict_mode;
} else if (str.eqlComptime("use asm")) {
- skip = p.options.features.dynamic_require or skip;
+ skip = true;
stmt.data = Prefill.Data.SEmpty;
}
}
@@ -9489,10 +10056,10 @@ fn NewParser_(
var where: logger.Range = logger.Range.None;
switch (scope.strict_mode) {
.implicit_strict_mode_import => {
- where = p.es6_import_keyword;
+ where = p.esm_import_keyword;
},
.implicit_strict_mode_export => {
- where = p.es6_export_keyword;
+ where = p.esm_export_keyword;
},
.implicit_strict_mode_top_level_await => {
where = p.top_level_await_keyword;
@@ -9562,12 +10129,21 @@ fn NewParser_(
// this module will be unable to reference this symbol. However, we must
// still add the symbol to the scope so it gets minified (automatically-
// generated code may still reference the symbol).
- try p.module_scope.generated.append(p.allocator, ref);
+ try p.module_scope.generated.push(p.allocator, ref);
return ref;
}
fn declareGeneratedSymbol(p: *P, kind: Symbol.Kind, comptime name: string) !GeneratedSymbol {
const static = @field(StaticSymbolName.List, name);
+ if (p.options.bundle) {
+ const ref = try declareSymbolMaybeGenerated(p, .other, logger.Loc.Empty, static.primary, true);
+ return GeneratedSymbol{
+ .backup = ref,
+ .primary = ref,
+ .ref = ref,
+ };
+ }
+
return GeneratedSymbol{
.backup = try declareSymbolMaybeGenerated(p, .other, logger.Loc.Empty, static.backup, true),
.primary = try declareSymbolMaybeGenerated(p, .other, logger.Loc.Empty, static.primary, true),
@@ -9585,7 +10161,7 @@ fn NewParser_(
if (comptime !is_generated) {
// Forbid declaring a symbol with a reserved word in strict mode
- if (p.isStrictMode() and js_lexer.StrictModeReservedWords.has(name)) {
+ if (p.isStrictMode() and name.ptr != arguments_str.ptr and js_lexer.StrictModeReservedWords.has(name)) {
try p.markStrictModeFeature(.reserved_word, js_lexer.rangeOfIdentifier(p.source, loc), name);
}
}
@@ -9630,6 +10206,11 @@ fn NewParser_(
},
.replace_with_new => {
symbol.link = ref;
+
+ // If these are both functions, remove the overwritten declaration
+ if (kind.isFunction() and symbol.kind.isFunction()) {
+ symbol.remove_overwritten_function_declaration = true;
+ }
},
.become_private_get_set_pair => {
ref = existing.ref;
@@ -9644,18 +10225,13 @@ fn NewParser_(
// else => unreachable,
}
} else {
- // Ensure that EImportIdentifier is created for the symbol in handleIdentifier
- if (symbol.kind == .import and kind != .import) {
- try p.is_import_item.put(p.allocator, ref, {});
- }
-
p.symbols.items[ref.innerIndex()].link = existing.ref;
}
}
entry.key_ptr.* = name;
entry.value_ptr.* = js_ast.Scope.Member{ .ref = ref, .loc = loc };
if (comptime is_generated) {
- try p.module_scope.generated.append(p.allocator, ref);
+ try p.module_scope.generated.push(p.allocator, ref);
}
return ref;
}
@@ -9801,8 +10377,8 @@ fn NewParser_(
},
.b_array => |bind| {
- for (bind.items, 0..) |_, i| {
- p.declareBinding(kind, &bind.items[i].binding, opts) catch unreachable;
+ for (bind.items) |*item| {
+ p.declareBinding(kind, &item.binding, opts) catch unreachable;
}
},
@@ -9844,24 +10420,21 @@ fn NewParser_(
if (@ptrToInt(p.source.contents.ptr) <= @ptrToInt(name.ptr) and (@ptrToInt(name.ptr) + name.len) <= (@ptrToInt(p.source.contents.ptr) + p.source.contents.len)) {
const start = Ref.toInt(@ptrToInt(name.ptr) - @ptrToInt(p.source.contents.ptr));
const end = Ref.toInt(name.len);
- return Ref.initSourceEnd(.{ .source_index = start, .inner_index = end, .is_source_contents_slice = true });
+ return Ref.initSourceEnd(.{ .source_index = start, .inner_index = end, .tag = .source_contents_slice });
} else {
const inner_index = Ref.toInt(p.allocated_names.items.len);
try p.allocated_names.append(p.allocator, name);
- return Ref.initSourceEnd(.{ .source_index = std.math.maxInt(Ref.Int), .inner_index = inner_index, .is_source_contents_slice = false });
+ return Ref.init(inner_index, p.source.index.get(), false);
}
}
pub fn loadNameFromRef(p: *P, ref: Ref) string {
- if (ref.isSourceContentsSlice()) {
- return p.source.contents[ref.sourceIndex() .. ref.sourceIndex() + ref.innerIndex()];
- } else if (ref.sourceIndex() == std.math.maxInt(Ref.Int)) {
- if (comptime Environment.allow_assert)
- assert(ref.innerIndex() < p.allocated_names.items.len);
- return p.allocated_names.items[ref.innerIndex()];
- } else {
- return p.symbols.items[ref.innerIndex()].original_name;
- }
+ return switch (ref.tag) {
+ .symbol => p.symbols.items[ref.innerIndex()].original_name,
+ .source_contents_slice => p.source.contents[ref.sourceIndex() .. ref.sourceIndex() + ref.innerIndex()],
+ .allocated_name => p.allocated_names.items[ref.innerIndex()],
+ else => @panic("Internal error: JS parser tried to load an invalid name from a Ref"),
+ };
}
// This parses an expression. This assumes we've already parsed the "async"
@@ -10481,12 +11054,11 @@ fn NewParser_(
p.log.addRangeError(p.source, key_range, "Invalid field name \"#constructor\"") catch unreachable;
}
- var declare: js_ast.Symbol.Kind = undefined;
- if (opts.is_static) {
- declare = .private_static_field;
- } else {
- declare = .private_field;
- }
+ const declare: js_ast.Symbol.Kind = if (opts.is_static)
+ .private_static_field
+ else
+ .private_field;
+
private.ref = p.declareSymbol(declare, key.loc, name) catch unreachable;
},
else => {},
@@ -10591,34 +11163,21 @@ fn NewParser_(
// Special-case private identifiers
switch (key.data) {
.e_private_identifier => |*private| {
- var declare: Symbol.Kind = undefined;
- var suffix: string = "";
- switch (kind) {
- .get => {
- if (opts.is_static) {
- declare = .private_static_get;
- } else {
- declare = .private_get;
- }
- suffix = "_get";
- },
- .set => {
- if (opts.is_static) {
- declare = .private_static_set;
- } else {
- declare = .private_set;
- }
- suffix = "_set";
- },
- else => {
- if (opts.is_static) {
- declare = .private_static_method;
- } else {
- declare = .private_method;
- }
- suffix = "_fn";
- },
- }
+ const declare: Symbol.Kind = switch (kind) {
+ .get => if (opts.is_static)
+ .private_static_get
+ else
+ .private_get,
+
+ .set => if (opts.is_static)
+ .private_static_set
+ else
+ .private_set,
+ else => if (opts.is_static)
+ .private_static_method
+ else
+ .private_method,
+ };
const name = p.loadNameFromRef(private.ref);
if (strings.eqlComptime(name, "#constructor")) {
@@ -12341,16 +12900,16 @@ fn NewParser_(
return error.SyntaxError;
}
- // esbuild's version of this function is much more complicated.
- // I'm not sure why defines is strictly relevant for this case
- // do people do <API_URL>?
fn jsxRefToMemberExpression(p: *P, loc: logger.Loc, ref: Ref) Expr {
p.recordUsage(ref);
- return p.newExpr(E.Identifier{
- .ref = ref,
- .can_be_removed_if_unused = true,
- .call_can_be_unwrapped_if_unused = true,
- }, loc);
+ return p.handleIdentifier(
+ loc,
+ E.Identifier{
+ .ref = ref,
+ .can_be_removed_if_unused = true,
+ .call_can_be_unwrapped_if_unused = true,
+ },
+ );
}
fn jsxStringsToMemberExpression(p: *P, loc: logger.Loc, parts: []const []const u8) !Expr {
@@ -12384,7 +12943,12 @@ fn NewParser_(
value,
part,
loc,
- false,
+ .{
+ .is_call_target = false,
+ .assign_target = .none,
+ // .is_template_tag = false,
+ .is_delete_target = false,
+ },
)) |rewrote| {
value = rewrote;
} else {
@@ -12408,7 +12972,7 @@ fn NewParser_(
fn parseImportExpr(p: *P, loc: logger.Loc, level: Level) anyerror!Expr {
// Parse an "import.meta" expression
if (p.lexer.token == .t_dot) {
- p.es6_import_keyword = js_lexer.rangeOfIdentifier(p.source, loc);
+ p.esm_import_keyword = js_lexer.rangeOfIdentifier(p.source, loc);
try p.lexer.next();
if (p.lexer.isContextualKeyword("meta")) {
try p.lexer.next();
@@ -12467,7 +13031,7 @@ fn NewParser_(
}
}
- return p.newExpr(E.Import{ .expr = value, .leading_interior_comments = comments, .import_record_index = 0 }, loc);
+ return p.newExpr(E.Import{ .expr = value, .leading_interior_comments = comments, .import_record_index = std.math.maxInt(u32) }, loc);
}
fn parseJSXPropValueIdentifier(p: *P, previous_string_with_backslash_loc: *logger.Loc) !Expr {
@@ -12588,6 +13152,9 @@ fn NewParser_(
.e_import_identifier => |ident| {
break :brk p.newExpr(E.String{ .data = p.loadNameFromRef(ident.ref) }, expr.loc);
},
+ .e_commonjs_export_identifier => |ident| {
+ break :brk p.newExpr(E.String{ .data = p.loadNameFromRef(ident.ref) }, expr.loc);
+ },
.e_identifier => |ident| {
break :brk p.newExpr(E.String{ .data = p.loadNameFromRef(ident.ref) }, expr.loc);
},
@@ -12809,11 +13376,11 @@ fn NewParser_(
for (p.relocated_top_level_vars.items) |*local| {
// Follow links because "var" declarations may be merged due to hoisting
while (local.ref != null) {
- const link = p.symbols.items[local.ref.?.innerIndex()].link;
- if (link.isNull()) {
+ var symbol = &p.symbols.items[local.ref.?.innerIndex()];
+ if (!symbol.hasLink()) {
break;
}
- local.ref = link;
+ local.ref = symbol.link;
}
const ref = local.ref orelse continue;
var declaration_entry = try already_declared.getOrPut(already_declared_allocator, ref);
@@ -12846,16 +13413,17 @@ fn NewParser_(
for (previous_parts, 0..) |*previous_part, j| {
if (previous_part.stmts.len == 0) continue;
- const declared_symbols = previous_part.declared_symbols;
+ var refs = previous_part.declared_symbols.refs();
- for (declared_symbols) |decl| {
- if (p.symbol_uses.contains(decl.ref)) {
+ for (refs) |ref| {
+ if (p.symbol_uses.contains(ref)) {
// we move this part to our other file
for (previous_parts[0..j]) |*this_part| {
if (this_part.stmts.len == 0) continue;
- const this_declared_symbols = this_part.declared_symbols;
- for (this_declared_symbols) |this_decl| {
- if (previous_part.symbol_uses.contains(this_decl.ref)) {
+ const other_refs = this_part.declared_symbols.refs();
+
+ for (other_refs) |other_ref| {
+ if (previous_part.symbol_uses.contains(other_ref)) {
try p.bun_plugin.hoisted_stmts.appendSlice(p.allocator, this_part.stmts);
this_part.stmts = &.{};
break;
@@ -12872,8 +13440,10 @@ fn NewParser_(
// Single-statement part which uses Bun.plugin()
// It's effectively an unrelated file
- if (p.declared_symbols.items.len > 0 or p.symbol_uses.count() > 0) {
- p.clearSymbolUsagesFromDeadPart(.{ .stmts = undefined, .declared_symbols = p.declared_symbols.items, .symbol_uses = p.symbol_uses });
+ if (p.declared_symbols.len() > 0 or p.symbol_uses.count() > 0) {
+ p.clearSymbolUsagesFromDeadPart(.{ .stmts = undefined, .declared_symbols = p.declared_symbols, .symbol_uses = p.symbol_uses });
+ p.declared_symbols.clearRetainingCapacity();
+ p.import_records_for_current_part.items.len = 0;
}
return;
}
@@ -12883,19 +13453,22 @@ fn NewParser_(
try parts.append(js_ast.Part{
.stmts = _stmts,
.symbol_uses = p.symbol_uses,
- .declared_symbols = try p.declared_symbols.toOwnedSlice(
- p.allocator,
- ),
- .import_record_indices = try p.import_records_for_current_part.toOwnedSlice(
- p.allocator,
+ .declared_symbols = p.declared_symbols.toOwnedSlice(),
+ .import_record_indices = bun.BabyList(u32).init(
+ p.import_records_for_current_part.toOwnedSlice(
+ p.allocator,
+ ) catch unreachable,
),
.scopes = try p.scopes_for_current_part.toOwnedSlice(p.allocator),
.can_be_removed_if_unused = p.stmtsCanBeRemovedIfUnused(_stmts),
});
p.symbol_uses = .{};
- } else if (p.declared_symbols.items.len > 0 or p.symbol_uses.count() > 0) {
+ } else if (p.declared_symbols.len() > 0 or p.symbol_uses.count() > 0) {
+
// if the part is dead, invalidate all the usage counts
- p.clearSymbolUsagesFromDeadPart(.{ .stmts = undefined, .declared_symbols = p.declared_symbols.items, .symbol_uses = p.symbol_uses });
+ p.clearSymbolUsagesFromDeadPart(.{ .stmts = undefined, .declared_symbols = p.declared_symbols, .symbol_uses = p.symbol_uses });
+ p.declared_symbols.clearRetainingCapacity();
+ p.import_records_for_current_part.clearRetainingCapacity();
}
}
@@ -13050,7 +13623,8 @@ fn NewParser_(
}
fn recordDeclaredSymbol(p: *P, ref: Ref) !void {
- try p.declared_symbols.append(p.allocator, js_ast.DeclaredSymbol{
+ std.debug.assert(ref.isSymbol());
+ try p.declared_symbols.append(p.allocator, DeclaredSymbol{
.ref = ref,
.is_top_level = p.current_scope == p.module_scope,
});
@@ -13113,20 +13687,27 @@ fn NewParser_(
return func;
}
+ fn deoptimizeCommonJSNamedExports(p: *P) void {
+ // exists for debugging
+ p.commonjs_named_exports_deoptimized = true;
+ }
+
fn maybeKeepExprSymbolName(p: *P, expr: Expr, original_name: string, was_anonymous_named_expr: bool) Expr {
return if (was_anonymous_named_expr) p.keepExprSymbolName(expr, original_name) else expr;
}
fn valueForThis(p: *P, loc: logger.Loc) ?Expr {
// Substitute "this" if we're inside a static class property initializer
- if (p.fn_only_data_visit.this_class_static_ref) |ref| {
- p.recordUsage(ref);
- return p.newExpr(E.Identifier{ .ref = ref }, loc);
+ if (p.fn_only_data_visit.should_replace_this_with_class_name_ref) {
+ if (p.fn_only_data_visit.class_name_ref) |ref| {
+ p.recordUsage(ref.*);
+ return p.newExpr(E.Identifier{ .ref = ref.* }, loc);
+ }
}
// oroigianlly was !=- modepassthrough
if (!p.fn_only_data_visit.is_this_nested) {
- if (p.has_es_module_syntax) {
+ if (p.has_es_module_syntax and p.commonjs_named_exports.count() == 0) {
// In an ES6 module, "this" is supposed to be undefined. Instead of
// doing this at runtime using "fn.call(undefined)", we do it at
// compile time using expression substitution here.
@@ -13136,6 +13717,7 @@ fn NewParser_(
// Instead of doing this at runtime using "fn.call(module.exports)", we
// do it at compile time using expression substitution here.
p.recordUsage(p.exports_ref);
+ p.deoptimizeCommonJSNamedExports();
return p.newExpr(E.Identifier{ .ref = p.exports_ref }, loc);
}
}
@@ -13197,6 +13779,7 @@ fn NewParser_(
if (p.define.dots.get("meta")) |meta| {
for (meta) |define| {
+ // TODO: clean up how we do define matches
if (p.isDotDefineMatch(expr, define.parts)) {
// Substitute user-specified defines
return p.valueForDefine(expr.loc, in.assign_target, is_delete_target, &define.data);
@@ -13239,8 +13822,8 @@ fn NewParser_(
// Substitute user-specified defines for unbound symbols
if (p.symbols.items[e_.ref.innerIndex()].kind == .unbound and !result.is_inside_with_scope and !is_delete_target) {
- if (p.define.identifiers.get(name)) |def| {
- if (!def.isUndefined()) {
+ if (p.define.forIdentifier(name)) |def| {
+ if (!def.valueless) {
const newvalue = p.valueForDefine(expr.loc, in.assign_target, is_delete_target, &def);
// Don't substitute an identifier for a non-identifier if this is an
@@ -13262,7 +13845,7 @@ fn NewParser_(
}
}
- if (!p.options.enable_bundling and p.options.features.dynamic_require) {
+ if (!p.options.bundle and p.options.features.dynamic_require) {
const is_call_target = @as(Expr.Tag, p.call_target) == .e_identifier and expr.data.e_identifier.ref.eql(p.call_target.e_identifier.ref);
if (!is_call_target and p.require_ref.eql(e_.ref)) {
// Substitute "require" for import.meta.require
@@ -13275,6 +13858,7 @@ fn NewParser_(
return p.handleIdentifier(expr.loc, e_, original_name, IdentifierOpts{
.assign_target = in.assign_target,
.is_delete_target = is_delete_target,
+ .is_call_target = @as(Expr.Tag, p.call_target) == .e_identifier and expr.data.e_identifier.ref.eql(p.call_target.e_identifier.ref),
.was_originally_identifier = true,
});
},
@@ -13291,7 +13875,7 @@ fn NewParser_(
if (e_.tag) |_tag| {
break :tagger p.visitExpr(_tag);
} else {
- break :tagger p.jsxRefToMemberExpression(expr.loc, p.jsx_fragment.ref);
+ break :tagger p.jsxImport(.Fragment, expr.loc);
}
};
@@ -13368,7 +13952,7 @@ fn NewParser_(
// Call createElement()
return p.newExpr(E.Call{
- .target = p.jsxRefToMemberExpression(expr.loc, p.jsx_factory.ref),
+ .target = p.jsxImport(.createElement, expr.loc),
.args = ExprNodeList.init(args[0..i]),
// Enable tree shaking
.can_be_unwrapped_if_unused = !p.options.ignore_dce_annotations,
@@ -13447,7 +14031,8 @@ fn NewParser_(
// _owner: null
// };
//
- p.recordUsage(p.react_element_type.ref);
+ if (!p.options.bundle)
+ p.recordUsage(p.react_element_type.ref);
const key = if (e_.key) |key_| brk: {
// key: void 0 === key ? null : "" + key,
break :brk switch (key_.data) {
@@ -13479,50 +14064,59 @@ fn NewParser_(
},
expr.loc,
);
- var props_expression = props_object;
-
- // we must check for default props
- if (tag.data != .e_string) {
- // We assume defaultProps is supposed to _not_ have side effects
- // We do not support "key" or "ref" in defaultProps.
- const defaultProps = p.newExpr(E.Dot{
- .name = "defaultProps",
- .name_loc = tag.loc,
- .target = tag,
- .can_be_removed_if_unused = true,
- }, tag.loc);
- // props: MyComponent.defaultProps || {}
- if (props.items.len == 0) {
- props_expression = p.newExpr(E.Binary{ .op = Op.Code.bin_logical_or, .left = defaultProps, .right = props_object }, defaultProps.loc);
- } else {
- var call_args = p.allocator.alloc(Expr, 2) catch unreachable;
- call_args[0..2].* = .{
- props_object,
- defaultProps,
- };
- // __merge(props, MyComponent.defaultProps)
- // originally, we always inlined here
- // see https://twitter.com/jarredsumner/status/1534084541236686848
- // but, that breaks for defaultProps
- // we assume that most components do not have defaultProps
- // so __merge quickly checks if it needs to merge any props
- // and if not, it passes along the props object
- // this skips an extra allocation
- props_expression = p.callRuntime(tag.loc, "__merge", call_args);
+ const props_expression = brk: {
+ // we must check for default props
+ if (tag.data != .e_string) {
+ // We assume defaultProps is supposed to _not_ have side effects
+ // We do not support "key" or "ref" in defaultProps.
+ const defaultProps = p.newExpr(
+ E.Dot{
+ .name = "defaultProps",
+ .name_loc = tag.loc,
+ .target = tag,
+ .can_be_removed_if_unused = true,
+ .call_can_be_unwrapped_if_unused = true,
+ },
+ tag.loc,
+ );
+ // props: MyComponent.defaultProps || {}
+ if (props.items.len == 0) {
+ break :brk p.newExpr(E.Binary{ .op = Op.Code.bin_logical_or, .left = defaultProps, .right = props_object }, defaultProps.loc);
+ } else {
+ var call_args = p.allocator.alloc(Expr, 2) catch unreachable;
+ call_args[0..2].* = .{
+ props_object,
+ defaultProps,
+ };
+ // __merge(props, MyComponent.defaultProps)
+ // originally, we always inlined here
+ // see https://twitter.com/jarredsumner/status/1534084541236686848
+ // but, that breaks for defaultProps
+ // we assume that most components do not have defaultProps
+ // so __merge quickly checks if it needs to merge any props
+ // and if not, it passes along the props object
+ // this skips an extra allocation
+ break :brk p.callRuntime(tag.loc, "__merge", call_args);
+ }
}
- }
+
+ break :brk props_object;
+ };
jsx_element[0..6].* =
[_]G.Property{
G.Property{
.key = Expr{ .data = Prefill.Data.@"$$typeof", .loc = tag.loc },
- .value = p.newExpr(
- E.Identifier{
- .ref = p.react_element_type.ref,
- .can_be_removed_if_unused = true,
- },
- tag.loc,
- ),
+ .value = if (p.options.bundle)
+ p.runtimeIdentifier(tag.loc, "$$typeof")
+ else
+ p.newExpr(
+ E.Identifier{
+ .ref = p.react_element_type.ref,
+ .can_be_removed_if_unused = true,
+ },
+ tag.loc,
+ ),
},
G.Property{
.key = Expr{ .data = Prefill.Data.type, .loc = tag.loc },
@@ -13603,7 +14197,7 @@ fn NewParser_(
}
return p.newExpr(E.Call{
- .target = p.jsxRefToMemberExpressionAutomatic(expr.loc, is_static_jsx),
+ .target = p.jsxImportAutomatic(expr.loc, is_static_jsx),
.args = ExprNodeList.init(args),
// Enable tree shaking
.can_be_unwrapped_if_unused = !p.options.ignore_dce_annotations,
@@ -13712,7 +14306,7 @@ fn NewParser_(
const is_call_target = @as(Expr.Tag, p.call_target) == .e_binary and expr.data.e_binary == p.call_target.e_binary;
// const is_stmt_expr = @as(Expr.Tag, p.stmt_expr_value) == .e_binary and expr.data.e_binary == p.stmt_expr_value.e_binary;
- const was_anonymous_named_expr = p.isAnonymousNamedExpr(e_.right);
+ const was_anonymous_named_expr = e_.right.isAnonymousNamed();
if (comptime jsx_transform_type == .macro) {
if (e_.op == Op.Code.bin_instanceof and (e_.right.data == .e_jsx_element or e_.left.data == .e_jsx_element)) {
@@ -14124,7 +14718,6 @@ fn NewParser_(
.has_chain_parent = (e_.optional_chain orelse js_ast.OptionalChain.start) == js_ast.OptionalChain.ccontinue,
});
e_.target = target;
-
switch (e_.index.data) {
.e_private_identifier => |_private| {
var private = _private;
@@ -14166,7 +14759,12 @@ fn NewParser_(
e_.target,
literal,
e_.index.loc,
- is_call_target,
+ .{
+ .is_call_target = is_call_target,
+ // .is_template_tag = is_template_tag,
+ .is_delete_target = is_delete_target,
+ .assign_target = in.assign_target,
+ },
)) |val| {
return val;
}
@@ -14184,7 +14782,7 @@ fn NewParser_(
if (p.define.dots.get(literal)) |parts| {
for (parts) |define| {
if (p.isDotDefineMatch(expr, define.parts)) {
- if (!define.data.isUndefined()) {
+ if (!define.data.valueless) {
return p.valueForDefine(expr.loc, in.assign_target, is_delete_target, &define.data);
}
@@ -14194,12 +14792,37 @@ fn NewParser_(
}
}
// "foo"[2]
- } else if (e_.optional_chain == null and target.data == .e_string and e_.index.data == .e_number and target.data.e_string.isUTF8() and e_.index.data.e_number.value >= 0) {
+ } else if ((comptime FeatureFlags.inline_properties_in_transpiler) and
+ e_.optional_chain == null and
+ target.data == .e_string and
+ e_.index.data == .e_number and
+ target.data.e_string.isUTF8() and
+ e_.index.data.e_number.value >= 0)
+ {
const literal = target.data.e_string.slice(p.allocator);
const index = e_.index.data.e_number.toUsize();
if (literal.len > index) {
return p.newExpr(E.String{ .data = literal[index .. index + 1] }, expr.loc);
}
+ } else if ((comptime FeatureFlags.inline_properties_in_transpiler) and
+ // Input:
+ //
+ // [123][0]
+ //
+ // Output:
+ //
+ // 123
+ in.assign_target == .none and
+ !is_delete_target and
+ !is_call_target and
+ // target should already be on the stack
+ target.data == .e_array and
+ target.data.e_array.items.len == 1 and
+ e_.index.data == .e_number and
+ e_.index.data.e_number.value == 0.0 and
+ e_.optional_chain == null)
+ {
+ return target.data.e_array.items.ptr[0];
}
// Create an error for assigning to an import namespace when bundling. Even
// though this is a run-time error, we make it a compile-time error when
@@ -14329,7 +14952,7 @@ fn NewParser_(
if (p.isDotDefineMatch(expr, define.parts)) {
if (in.assign_target == .none) {
// Substitute user-specified defines
- if (!define.data.isUndefined()) {
+ if (!define.data.valueless) {
return p.valueForDefine(expr.loc, in.assign_target, is_delete_target, &define.data);
}
}
@@ -14364,13 +14987,18 @@ fn NewParser_(
}
e_.target = p.visitExpr(e_.target);
+
if (e_.optional_chain == null) {
if (p.maybeRewritePropertyAccess(
expr.loc,
e_.target,
e_.name,
e_.name_loc,
- is_call_target,
+ .{
+ .is_call_target = is_call_target,
+ .assign_target = in.assign_target,
+ // .is_template_tag = p.template_tag != null,
+ },
)) |_expr| {
return _expr;
}
@@ -14463,7 +15091,7 @@ fn NewParser_(
},
.e_binary => |e2| {
if (in.assign_target != .none and e2.op == .bin_assign) {
- const was_anonymous_named_expr = p.isAnonymousNamedExpr(e2.right);
+ const was_anonymous_named_expr = e2.right.isAnonymousNamed();
e2.left = p.visitExprInOut(e2.left, ExprIn{ .assign_target = .replace });
e2.right = p.visitExpr(e2.right);
@@ -14491,10 +15119,7 @@ fn NewParser_(
var has_spread = false;
var has_proto = false;
- var i: usize = 0;
- while (i < e_.properties.len) : (i += 1) {
- var property = e_.properties.ptr[i];
-
+ for (e_.properties.slice()) |*property| {
if (property.kind != .spread) {
property.key = p.visitExpr(property.key orelse Global.panic("Expected property key", .{}));
const key = property.key.?;
@@ -14537,7 +15162,7 @@ fn NewParser_(
}
if (property.initializer != null) {
- const was_anonymous_named_expr = p.isAnonymousNamedExpr(property.initializer orelse unreachable);
+ const was_anonymous_named_expr = property.initializer.?.isAnonymousNamed();
property.initializer = p.visitExpr(property.initializer.?);
if (property.value) |val| {
@@ -14550,8 +15175,6 @@ fn NewParser_(
}
}
}
-
- e_.properties.ptr[i] = property;
}
},
.e_import => |e_| {
@@ -14614,13 +15237,14 @@ fn NewParser_(
if (is_macro_ref)
p.options.ignore_dce_annotations = true;
- for (e_.args.slice(), 0..) |_, i| {
- const arg = e_.args.ptr[i];
- e_.args.ptr[i] = p.visitExpr(arg);
+ for (e_.args.slice()) |*arg| {
+ arg.* = p.visitExpr(arg.*);
}
}
- if (e_.optional_chain == null and @as(Expr.Tag, e_.target.data) == .e_identifier and e_.target.data.e_identifier.ref.eql(p.require_ref)) {
+ if (e_.optional_chain == null and @as(Expr.Tag, e_.target.data) == .e_identifier and
+ e_.target.data.e_identifier.ref.eql(p.require_ref))
+ {
e_.can_be_unwrapped_if_unused = false;
// Heuristic: omit warnings inside try/catch blocks because presumably
@@ -14651,16 +15275,6 @@ fn NewParser_(
}
p.ignoreUsage(p.require_ref);
- return p.newExpr(
- E.Call{
- .target = p.importMetaRequire(expr.loc),
- .args = e_.args,
- .close_paren_loc = e_.close_paren_loc,
- .optional_chain = e_.optional_chain,
- .can_be_unwrapped_if_unused = e_.can_be_unwrapped_if_unused,
- },
- expr.loc,
- );
}
if (p.options.warn_about_unbundled_modules) {
@@ -14677,7 +15291,7 @@ fn NewParser_(
return p.newExpr(E.Null{}, expr.loc);
}
- if (p.options.features.dynamic_require) {
+ if (p.options.features.dynamic_require and !p.options.bundle) {
p.ignoreUsage(p.require_ref);
// require.resolve(FOO) => import.meta.resolveSync(FOO)
// require.resolve(FOO) => import.meta.resolveSync(FOO, pathsObject)
@@ -14821,14 +15435,21 @@ fn NewParser_(
return expr;
}
- // This might be wrong.
- _ = p.visitClass(expr.loc, e_);
+ _ = p.visitClass(expr.loc, e_, Ref.None);
},
else => {},
}
return expr;
}
+ fn valueForRequire(p: *P, loc: logger.Loc) Expr {
+ if (p.options.features.dynamic_require) {
+ return p.importMetaRequire(loc);
+ } else {
+ return p.runtimeIdentifier(loc, "__require");
+ }
+ }
+
fn visitArgs(p: *P, args: []G.Arg, opts: VisitArgsOpts) void {
const strict_loc = fnBodyContainsUseStrict(opts.body);
const has_simple_args = isSimpleParameterList(args, opts.has_rest_arg);
@@ -14854,28 +15475,26 @@ fn NewParser_(
duplicate_args_check = StringVoidMap.get(bun.default_allocator);
}
- var i: usize = 0;
var duplicate_args_check_ptr: ?*StringVoidMap = if (duplicate_args_check != null)
&duplicate_args_check.?.data
else
null;
- while (i < args.len) : (i += 1) {
- if (args[i].ts_decorators.len > 0) {
- args[i].ts_decorators = p.visitTSDecorators(args[i].ts_decorators);
+ for (args) |*arg| {
+ if (arg.ts_decorators.len > 0) {
+ arg.ts_decorators = p.visitTSDecorators(arg.ts_decorators);
}
- p.visitBinding(args[i].binding, duplicate_args_check_ptr);
- if (args[i].default) |default| {
- args[i].default = p.visitExpr(default);
+ p.visitBinding(arg.binding, duplicate_args_check_ptr);
+ if (arg.default) |default| {
+ arg.default = p.visitExpr(default);
}
}
}
pub fn visitTSDecorators(p: *P, decs: ExprNodeList) ExprNodeList {
- var i: usize = 0;
- while (i < decs.len) : (i += 1) {
- decs.ptr[i] = p.visitExpr(decs.ptr[i]);
+ for (decs.slice()) |*dec| {
+ dec.* = p.visitExpr(dec.*);
}
return decs;
@@ -15021,7 +15640,7 @@ fn NewParser_(
return true;
}
},
- .e_import_identifier => {
+ .e_commonjs_export_identifier, .e_import_identifier => {
// References to an ES6 import item are always side-effect free in an
// ECMAScript environment.
@@ -15426,11 +16045,53 @@ fn NewParser_(
}
}
- fn jsxRefToMemberExpressionAutomatic(p: *P, loc: logger.Loc, is_static: bool) Expr {
- return p.jsxRefToMemberExpression(loc, if (is_static and !p.options.jsx.development and FeatureFlags.support_jsxs_in_jsx_transform)
- p.jsxs_runtime.ref
- else
- p.jsx_runtime.ref);
+ fn jsxImportAutomatic(p: *P, loc: logger.Loc, is_static: bool) Expr {
+ return p.jsxImport(
+ if (is_static and !p.options.jsx.development and FeatureFlags.support_jsxs_in_jsx_transform)
+ .jsxs
+ else if (p.options.jsx.development)
+ .jsxDEV
+ else
+ .jsx,
+ loc,
+ );
+ }
+
+ fn jsxImport(p: *P, kind: JSXImport, loc: logger.Loc) Expr {
+ var jsx_imports = &p.jsx_imports;
+ switch (kind) {
+ inline else => |field| {
+ const ref: Ref = brk: {
+ if (@field(jsx_imports, @tagName(field)) == null) {
+ const loc_ref = LocRef{
+ .loc = loc,
+ .ref = p.newSymbol(.other, @tagName(field)) catch unreachable,
+ };
+
+ p.module_scope.generated.push(p.allocator, loc_ref.ref.?) catch unreachable;
+ p.is_import_item.put(p.allocator, loc_ref.ref.?, {}) catch unreachable;
+ @field(jsx_imports, @tagName(field)) = loc_ref;
+ break :brk loc_ref.ref.?;
+ }
+
+ break :brk @field(jsx_imports, @tagName(field)).?.ref.?;
+ };
+
+ p.recordUsage(ref);
+ return p.handleIdentifier(
+ loc,
+ E.Identifier{
+ .ref = ref,
+ .can_be_removed_if_unused = true,
+ .call_can_be_unwrapped_if_unused = true,
+ },
+ null,
+ .{
+ .was_originally_identifier = true,
+ },
+ );
+ },
+ }
}
fn maybeRelocateVarsToTopLevel(p: *P, decls: []const G.Decl, mode: RelocateVars.Mode) RelocateVars {
@@ -15450,7 +16111,7 @@ fn NewParser_(
}
var value: Expr = Expr{ .loc = logger.Loc.Empty, .data = Expr.Data{ .e_missing = E.Missing{} } };
- var any_initializers = false;
+
for (decls) |decl| {
const binding = Binding.toExpr(
&decl.binding,
@@ -15458,13 +16119,12 @@ fn NewParser_(
);
if (decl.value) |decl_value| {
value = value.joinWithComma(Expr.assign(binding, decl_value, p.allocator), p.allocator);
- any_initializers = true;
} else if (mode == .for_in_or_for_of) {
value = value.joinWithComma(binding, p.allocator);
}
}
- if (std.meta.activeTag(value.data) == .e_missing or !any_initializers) {
+ if (value.data == .e_missing) {
return .{ .ok = true };
}
@@ -15498,17 +16158,130 @@ fn NewParser_(
target: js_ast.Expr,
name: string,
name_loc: logger.Loc,
- is_call_target: bool,
+ identifier_opts: IdentifierOpts,
) ?Expr {
switch (target.data) {
.e_identifier => |id| {
- // Rewrite "module.require()" to "require()" for Webpack compatibility.
- // See https://github.com/webpack/webpack/pull/7750 for more info.
- // This also makes correctness a little easier.
- if (is_call_target and id.ref.eql(p.module_ref) and strings.eqlComptime(name, "require")) {
- p.ignoreUsage(p.module_ref);
- p.recordUsage(p.require_ref);
- return p.newExpr(E.Identifier{ .ref = p.require_ref }, name_loc);
+
+ // Rewrite property accesses on explicit namespace imports as an identifier.
+ // This lets us replace them easily in the printer to rebind them to
+ // something else without paying the cost of a whole-tree traversal during
+ // module linking just to rewrite these EDot expressions.
+ if (p.options.bundle) {
+ if (p.import_items_for_namespace.getPtr(id.ref)) |import_items| {
+ const ref = (import_items.get(name) orelse brk: {
+ // Generate a new import item symbol in the module scope
+ const new_item = LocRef{
+ .loc = name_loc,
+ .ref = p.newSymbol(.import, name) catch unreachable,
+ };
+ p.module_scope.generated.push(p.allocator, new_item.ref.?) catch unreachable;
+
+ import_items.put(name, new_item) catch unreachable;
+ p.is_import_item.put(p.allocator, new_item.ref.?, {}) catch unreachable;
+
+ var symbol = &p.symbols.items[new_item.ref.?.innerIndex()];
+
+ // Mark this as generated in case it's missing. We don't want to
+ // generate errors for missing import items that are automatically
+ // generated.
+ symbol.import_item_status = .generated;
+
+ break :brk new_item;
+ }).ref.?;
+
+ // Undo the usage count for the namespace itself. This is used later
+ // to detect whether the namespace symbol has ever been "captured"
+ // or whether it has just been used to read properties off of.
+ //
+ // The benefit of doing this is that if both this module and the
+ // imported module end up in the same module group and the namespace
+ // symbol has never been captured, then we don't need to generate
+ // any code for the namespace at all.
+ p.ignoreUsage(id.ref);
+
+ // Track how many times we've referenced this symbol
+ p.recordUsage(ref);
+
+ return p.handleIdentifier(
+ name_loc,
+ E.Identifier{ .ref = ref },
+ name,
+ identifier_opts,
+ );
+ }
+ }
+
+ if (!p.is_control_flow_dead and id.ref.eql(p.module_ref)) {
+ // Rewrite "module.require()" to "require()" for Webpack compatibility.
+ // See https://github.com/webpack/webpack/pull/7750 for more info.
+ // This also makes correctness a little easier.
+ if (identifier_opts.is_call_target and strings.eqlComptime(name, "require")) {
+ p.ignoreUsage(p.module_ref);
+ p.recordUsage(p.require_ref);
+ return p.newExpr(E.Identifier{ .ref = p.require_ref }, name_loc);
+ } else if (!p.commonjs_named_exports_deoptimized and strings.eqlComptime(name, "exports")) {
+ // Deoptimizations:
+ // delete module.exports
+ // module.exports();
+
+ if (identifier_opts.is_call_target or identifier_opts.is_delete_target or identifier_opts.assign_target != .none) {
+ p.deoptimizeCommonJSNamedExports();
+ return null;
+ }
+
+ // rewrite `module.exports` to `exports`
+ return p.newExpr(E.Identifier{ .ref = p.exports_ref }, name_loc);
+ } else if (strings.eqlComptime(name, "id") and identifier_opts.assign_target == .none) {
+ // inline module.id
+ p.ignoreUsage(p.module_ref);
+ return p.newExpr(E.String.init(p.source.path.text), name_loc);
+ } else if (strings.eqlComptime(name, "filename") and identifier_opts.assign_target == .none) {
+ // inline module.filename
+ p.ignoreUsage(p.module_ref);
+ return p.newExpr(E.String.init(p.source.path.name.filename), name_loc);
+ } else if (strings.eqlComptime(name, "path") and identifier_opts.assign_target == .none) {
+ // inline module.path
+ p.ignoreUsage(p.module_ref);
+ return p.newExpr(E.String.init(p.source.path.pretty), name_loc);
+ }
+ }
+
+ if (comptime FeatureFlags.commonjs_to_esm) {
+ if (!p.is_control_flow_dead and id.ref.eql(p.exports_ref) and !p.commonjs_named_exports_deoptimized) {
+ if (identifier_opts.is_delete_target) {
+ p.deoptimizeCommonJSNamedExports();
+ return null;
+ }
+
+ var named_export_entry = p.commonjs_named_exports.getOrPut(p.allocator, name) catch unreachable;
+ if (!named_export_entry.found_existing) {
+ const new_ref = p.newSymbol(
+ .other,
+ std.fmt.allocPrint(p.allocator, "${any}", .{strings.fmtIdentifier(name)}) catch unreachable,
+ ) catch unreachable;
+ named_export_entry.value_ptr.* = .{
+ .loc_ref = LocRef{
+ .loc = name_loc,
+ .ref = new_ref,
+ },
+ .needs_decl = true,
+ };
+ if (p.commonjs_named_exports_needs_conversion == std.math.maxInt(u32))
+ p.commonjs_named_exports_needs_conversion = @truncate(u32, p.commonjs_named_exports.count() - 1);
+ }
+
+ const ref = named_export_entry.value_ptr.*.loc_ref.ref.?;
+ p.ignoreUsage(id.ref);
+ p.recordUsage(ref);
+
+ return p.newExpr(
+ E.CommonJSExportIdentifier{
+ .ref = ref,
+ },
+ name_loc,
+ );
+ }
}
// If this is a known enum value, inline the value of the enum
@@ -15530,6 +16303,33 @@ fn NewParser_(
return p.newExpr(E.Number{ .value = @intToFloat(f64, str.len()) }, loc);
}
},
+ .e_object => |obj| {
+ if (comptime FeatureFlags.inline_properties_in_transpiler) {
+ //
+ // Rewrite a property access like this:
+ // { f: () => {} }.f
+ // To:
+ // () => {}
+ //
+ // To avoid thinking too much about edgecases, only do this for:
+ // 1) Objects with a single property
+ // 2) Not a method, not a computed property
+ if (obj.properties.len == 1 and
+ !identifier_opts.is_delete_target and
+ identifier_opts.assign_target == .none and !identifier_opts.is_call_target)
+ {
+ const prop: G.Property = obj.properties.ptr[0];
+ if (prop.value != null and
+ prop.flags.count() == 0 and
+ prop.key != null and
+ prop.key.?.data == .e_string and
+ prop.key.?.data.e_string.eql([]const u8, name))
+ {
+ return prop.value.?;
+ }
+ }
+ }
+ },
else => {},
}
@@ -15668,7 +16468,7 @@ fn NewParser_(
const name = p.loadNameFromRef(data.namespace_ref);
data.namespace_ref = try p.newSymbol(.other, name);
- try p.current_scope.generated.append(p.allocator, data.namespace_ref);
+ try p.current_scope.generated.push(p.allocator, data.namespace_ref);
try p.recordDeclaredSymbol(data.namespace_ref);
if (p.options.features.replace_exports.count() > 0) {
@@ -15688,7 +16488,7 @@ fn NewParser_(
const _name = p.loadNameFromRef(old_ref);
const ref = try p.newSymbol(.other, _name);
- try p.current_scope.generated.append(p.allocator, data.namespace_ref);
+ try p.current_scope.generated.push(p.allocator, data.namespace_ref);
try p.recordDeclaredSymbol(data.namespace_ref);
data.items[j] = item;
data.items[j].name.ref = ref;
@@ -15706,7 +16506,7 @@ fn NewParser_(
for (data.items) |*item| {
const _name = p.loadNameFromRef(item.name.ref.?);
const ref = try p.newSymbol(.other, _name);
- try p.current_scope.generated.append(p.allocator, data.namespace_ref);
+ try p.current_scope.generated.push(p.allocator, data.namespace_ref);
try p.recordDeclaredSymbol(data.namespace_ref);
item.name.ref = ref;
}
@@ -15717,7 +16517,7 @@ fn NewParser_(
// "export * from 'path'"
const name = p.loadNameFromRef(data.namespace_ref);
data.namespace_ref = try p.newSymbol(.other, name);
- try p.current_scope.generated.append(p.allocator, data.namespace_ref);
+ try p.current_scope.generated.push(p.allocator, data.namespace_ref);
try p.recordDeclaredSymbol(data.namespace_ref);
// "export * as ns from 'path'"
@@ -15728,25 +16528,27 @@ fn NewParser_(
return;
}
}
- // "import * as ns from 'path'"
- // "export {ns}"
- // jarred: For now, just always do this transform.
- // because Safari doesn't support it and I've seen cases where this breaks
+ if (!p.options.bundle) {
+ // "import * as ns from 'path'"
+ // "export {ns}"
- p.recordUsage(data.namespace_ref);
- try stmts.ensureTotalCapacity(stmts.items.len + 2);
- stmts.appendAssumeCapacity(p.s(S.Import{ .namespace_ref = data.namespace_ref, .star_name_loc = alias.loc, .import_record_index = data.import_record_index }, stmt.loc));
+ p.recordUsage(data.namespace_ref);
+ try stmts.ensureTotalCapacity(stmts.items.len + 2);
+ stmts.appendAssumeCapacity(p.s(S.Import{ .namespace_ref = data.namespace_ref, .star_name_loc = alias.loc, .import_record_index = data.import_record_index }, stmt.loc));
- var items = try List(js_ast.ClauseItem).initCapacity(p.allocator, 1);
- items.appendAssumeCapacity(js_ast.ClauseItem{ .alias = alias.original_name, .original_name = alias.original_name, .alias_loc = alias.loc, .name = LocRef{ .loc = alias.loc, .ref = data.namespace_ref } });
- stmts.appendAssumeCapacity(p.s(S.ExportClause{ .items = items.toOwnedSlice(p.allocator) catch @panic("TODO"), .is_single_line = true }, stmt.loc));
- return;
+ var items = try List(js_ast.ClauseItem).initCapacity(p.allocator, 1);
+ items.appendAssumeCapacity(js_ast.ClauseItem{ .alias = alias.original_name, .original_name = alias.original_name, .alias_loc = alias.loc, .name = LocRef{ .loc = alias.loc, .ref = data.namespace_ref } });
+ stmts.appendAssumeCapacity(p.s(S.ExportClause{ .items = items.toOwnedSlice(p.allocator) catch @panic("TODO"), .is_single_line = true }, stmt.loc));
+ return;
+ }
}
},
.s_export_default => |data| {
- if (data.default_name.ref) |ref| {
- try p.recordDeclaredSymbol(ref);
+ defer {
+ if (data.default_name.ref) |ref| {
+ p.recordDeclaredSymbol(ref) catch unreachable;
+ }
}
var mark_for_replace: bool = false;
@@ -15765,7 +16567,7 @@ fn NewParser_(
switch (data.value) {
.expr => |expr| {
- const was_anonymous_named_expr = p.isAnonymousNamedExpr(expr);
+ const was_anonymous_named_expr = expr.isAnonymousNamed();
data.value.expr = p.visitExpr(expr);
@@ -15807,13 +16609,17 @@ fn NewParser_(
}
// When bundling, replace ExportDefault with __exportDefault(exportsRef, expr);
- if (p.options.enable_bundling) {
+ if (p.options.enable_legacy_bundling) {
var export_default_args = p.allocator.alloc(Expr, 2) catch unreachable;
export_default_args[0] = p.@"module.exports"(expr.loc);
export_default_args[1] = data.value.expr;
stmts.append(p.s(S.SExpr{ .value = p.callRuntime(expr.loc, "__exportDefault", export_default_args) }, expr.loc)) catch unreachable;
return;
}
+
+ if (data.default_name.ref.?.isSourceContentsSlice()) {
+ data.default_name = createDefaultName(p, data.value.expr.loc) catch unreachable;
+ }
},
.stmt => |s2| {
@@ -15844,14 +16650,14 @@ fn NewParser_(
}
// When bundling, replace ExportDefault with __exportDefault(exportsRef, expr);
- if (p.options.enable_bundling) {
+ if (p.options.enable_legacy_bundling) {
var export_default_args = p.allocator.alloc(Expr, 2) catch unreachable;
export_default_args[0] = p.@"module.exports"(data.value.expr.loc);
export_default_args[1] = data.value.expr;
stmts.append(p.s(S.SExpr{ .value = p.callRuntime(data.value.expr.loc, "__exportDefault", export_default_args) }, data.value.expr.loc)) catch unreachable;
return;
}
- } else if (p.options.enable_bundling) {
+ } else if (p.options.enable_legacy_bundling) {
var export_default_args = p.allocator.alloc(Expr, 2) catch unreachable;
export_default_args[0] = p.@"module.exports"(s2.loc);
@@ -15868,6 +16674,10 @@ fn NewParser_(
return;
}
+ if (data.default_name.ref.?.isSourceContentsSlice()) {
+ data.default_name = createDefaultName(p, stmt.loc) catch unreachable;
+ }
+
stmts.append(stmt.*) catch unreachable;
// if (func.func.name != null and func.func.name.?.ref != null) {
@@ -15877,7 +16687,7 @@ fn NewParser_(
return;
},
.s_class => |class| {
- _ = p.visitClass(s2.loc, &class.class);
+ _ = p.visitClass(s2.loc, &class.class, data.default_name.ref.?);
if (p.is_control_flow_dead)
return;
@@ -15892,14 +16702,14 @@ fn NewParser_(
}
// When bundling, replace ExportDefault with __exportDefault(exportsRef, expr);
- if (p.options.enable_bundling) {
+ if (p.options.enable_legacy_bundling) {
var export_default_args = p.allocator.alloc(Expr, 2) catch unreachable;
export_default_args[0] = p.@"module.exports"(data.value.expr.loc);
export_default_args[1] = data.value.expr;
stmts.append(p.s(S.SExpr{ .value = p.callRuntime(data.value.expr.loc, "__exportDefault", export_default_args) }, data.value.expr.loc)) catch unreachable;
return;
}
- } else if (p.options.enable_bundling) {
+ } else if (p.options.enable_legacy_bundling) {
var export_default_args = p.allocator.alloc(Expr, 2) catch unreachable;
export_default_args[0] = p.@"module.exports"(s2.loc);
@@ -15923,6 +16733,10 @@ fn NewParser_(
return;
}
+ if (data.default_name.ref.?.isSourceContentsSlice()) {
+ data.default_name = createDefaultName(p, stmt.loc) catch unreachable;
+ }
+
stmts.append(stmt.*) catch unreachable;
return;
},
@@ -15932,7 +16746,7 @@ fn NewParser_(
}
},
.s_export_equals => |data| {
- if (p.options.enable_bundling) {
+ if (p.options.enable_legacy_bundling) {
var export_default_args = p.allocator.alloc(Expr, 2) catch unreachable;
export_default_args[0] = p.@"module.exports"(stmt.loc);
export_default_args[1] = data.value;
@@ -15943,7 +16757,7 @@ fn NewParser_(
// "module.exports = value"
stmts.append(
- Expr.assignStmt(
+ Stmt.assign(
p.@"module.exports"(
stmt.loc,
),
@@ -16044,9 +16858,79 @@ fn NewParser_(
},
.s_expr => |data| {
p.stmt_expr_value = data.value.data;
+ const is_top_level = p.current_scope == p.module_scope;
+ if (comptime FeatureFlags.commonjs_to_esm) {
+ p.commonjs_named_exports_needs_conversion = if (is_top_level)
+ std.math.maxInt(u32)
+ else
+ p.commonjs_named_exports_needs_conversion;
+ }
+
data.value = p.visitExpr(data.value);
+
// simplify unused
data.value = SideEffects.simpifyUnusedExpr(p, data.value) orelse data.value.toEmpty();
+
+ if (comptime FeatureFlags.commonjs_to_esm) {
+ if (is_top_level) {
+ if (data.value.data == .e_binary) {
+ const to_convert = p.commonjs_named_exports_needs_conversion;
+ if (to_convert != std.math.maxInt(u32)) {
+ p.commonjs_named_exports_needs_conversion = std.math.maxInt(u32);
+ convert: {
+ const bin: *E.Binary = data.value.data.e_binary;
+ if (bin.op == .bin_assign and bin.left.data == .e_commonjs_export_identifier) {
+ var last = &p.commonjs_named_exports.values()[to_convert];
+ if (!last.needs_decl) break :convert;
+ last.needs_decl = false;
+
+ var decls = p.allocator.alloc(Decl, 1) catch unreachable;
+ const ref = bin.left.data.e_commonjs_export_identifier.ref;
+ decls[0] = .{
+ .binding = p.b(B.Identifier{ .ref = ref }, bin.left.loc),
+ .value = bin.right,
+ };
+ p.recordDeclaredSymbol(ref) catch unreachable;
+ p.ignoreUsage(ref);
+ p.esm_export_keyword.loc = stmt.loc;
+ p.esm_export_keyword.len = 5;
+ var clause_items = p.allocator.alloc(js_ast.ClauseItem, 1) catch unreachable;
+ clause_items[0] = js_ast.ClauseItem{
+ // We want the generated name to not conflict
+ .alias = p.commonjs_named_exports.keys()[to_convert],
+ .alias_loc = bin.left.loc,
+ .name = .{
+ .ref = ref,
+ .loc = last.loc_ref.loc,
+ },
+ };
+ stmts.appendSlice(
+ &[_]Stmt{
+ p.s(
+ S.Local{
+ .kind = .k_var,
+ .is_export = false,
+ .decls = decls,
+ },
+ stmt.loc,
+ ),
+ p.s(
+ S.ExportClause{
+ .items = clause_items,
+ .is_single_line = true,
+ },
+ stmt.loc,
+ ),
+ },
+ ) catch unreachable;
+
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
},
.s_throw => |data| {
data.value = p.visitExpr(data.value);
@@ -16056,8 +16940,8 @@ fn NewParser_(
// Forbid top-level return inside modules with ECMAScript-style exports
if (p.fn_or_arrow_data_visit.is_outside_fn_or_arrow) {
const where = where: {
- if (p.es6_export_keyword.len > 0) {
- break :where p.es6_export_keyword;
+ if (p.esm_export_keyword.len > 0) {
+ break :where p.esm_export_keyword;
} else if (p.top_level_await_keyword.len > 0) {
break :where p.top_level_await_keyword;
} else {
@@ -16344,12 +17228,16 @@ fn NewParser_(
const enclosing_namespace_arg_ref = p.enclosing_namespace_arg_ref orelse unreachable;
stmts.ensureUnusedCapacity(3) catch unreachable;
stmts.appendAssumeCapacity(stmt.*);
- stmts.appendAssumeCapacity(Expr.assignStmt(p.newExpr(E.Dot{
+ stmts.appendAssumeCapacity(Stmt.assign(p.newExpr(E.Dot{
.target = p.newExpr(E.Identifier{ .ref = enclosing_namespace_arg_ref }, stmt.loc),
.name = p.loadNameFromRef(data.func.name.?.ref.?),
.name_loc = data.func.name.?.loc,
}, stmt.loc), p.newExpr(E.Identifier{ .ref = data.func.name.?.ref.? }, data.func.name.?.loc), p.allocator));
} else if (!mark_as_dead) {
+ if (p.symbols.items[data.func.name.?.ref.?.innerIndex()].remove_overwritten_function_declaration) {
+ return;
+ }
+
stmts.append(stmt.*) catch unreachable;
} else if (mark_as_dead) {
const name = data.func.name.?.ref.?;
@@ -16381,7 +17269,7 @@ fn NewParser_(
}
}
- _ = p.visitClass(stmt.loc, &data.class);
+ _ = p.visitClass(stmt.loc, &data.class, Ref.None);
// Remove the export flag inside a namespace
const was_export_inside_namespace = data.is_export and p.enclosing_namespace_arg_ref != null;
@@ -16406,25 +17294,23 @@ fn NewParser_(
// Handle exporting this class from a namespace
if (was_export_inside_namespace) {
stmts.append(
- Stmt.alloc(
- S.SExpr,
- S.SExpr{
- .value = p.newExpr(
- E.Identifier{ .ref = data.class.class_name.?.ref.? },
- data.class.class_name.?.loc,
- ).assign(
- p.newExpr(
- E.Dot{
- .target = p.newExpr(E.Identifier{ .ref = p.enclosing_namespace_arg_ref.? }, stmt.loc),
- .name = p.symbols.items[data.class.class_name.?.ref.?.innerIndex()].original_name,
- .name_loc = data.class.class_name.?.loc,
- },
+ Stmt.assign(
+ p.newExpr(
+ E.Dot{
+ .target = p.newExpr(
+ E.Identifier{ .ref = p.enclosing_namespace_arg_ref.? },
stmt.loc,
),
- p.allocator,
- ),
- },
- stmt.loc,
+ .name = p.symbols.items[data.class.class_name.?.ref.?.innerIndex()].original_name,
+ .name_loc = data.class.class_name.?.loc,
+ },
+ stmt.loc,
+ ),
+ p.newExpr(
+ E.Identifier{ .ref = data.class.class_name.?.ref.? },
+ data.class.class_name.?.loc,
+ ),
+ p.allocator,
),
) catch unreachable;
}
@@ -16615,7 +17501,7 @@ fn NewParser_(
if (decls[i].value != null) {
var val = decls[i].value.?;
- const was_anonymous_named_expr = p.isAnonymousNamedExpr(val);
+ const was_anonymous_named_expr = val.isAnonymousNamed();
var replacement: ?*const RuntimeFeatures.ReplaceableExport = null;
const prev_macro_call_count = p.macro_call_count;
@@ -16788,15 +17674,13 @@ fn NewParser_(
var array = expr.data.e_array;
array.items.len = @min(array.items.len, @truncate(u32, bound_array.items.len));
- var slice = array.items.slice();
- for (bound_array.items[0..array.items.len], 0..) |item, item_i| {
- const child_expr = slice[item_i];
+ for (bound_array.items[0..array.items.len], array.items.slice()) |item, *child_expr| {
if (item.binding.data == .b_missing) {
- slice[item_i] = p.newExpr(E.Missing{}, expr.loc);
+ child_expr.* = p.newExpr(E.Missing{}, expr.loc);
continue;
}
- p.visitBindingAndExprForMacro(item.binding, child_expr);
+ p.visitBindingAndExprForMacro(item.binding, child_expr.*);
}
}
},
@@ -17133,7 +18017,7 @@ fn NewParser_(
}
}
- if (!prop.flags.contains(.is_method) and prop.key.?.data != .e_private_identifier and prop.ts_decorators.len > 0) {
+ if (prop.kind != .class_static_block and !prop.flags.contains(.is_method) and prop.key.?.data != .e_private_identifier and prop.ts_decorators.len > 0) {
// remove decorated fields without initializers to avoid assigning undefined.
const initializer = if (prop.initializer) |initializer_value| initializer_value else continue;
@@ -17160,9 +18044,9 @@ fn NewParser_(
// remove fields with decorators from class body. Move static members outside of class.
if (prop.flags.contains(.is_static)) {
- static_members.append(Expr.assignStmt(target, initializer, p.allocator)) catch unreachable;
+ static_members.append(Stmt.assign(target, initializer, p.allocator)) catch unreachable;
} else {
- instance_members.append(Expr.assignStmt(target, initializer, p.allocator)) catch unreachable;
+ instance_members.append(Stmt.assign(target, initializer, p.allocator)) catch unreachable;
}
continue;
}
@@ -17179,8 +18063,8 @@ fn NewParser_(
if (class.extends != null) {
const target = p.newExpr(E.Super{}, stmt.loc);
- const arguments_ref = p.newSymbol(.unbound, "arguments") catch unreachable;
- p.current_scope.generated.append(p.allocator, arguments_ref) catch unreachable;
+ const arguments_ref = p.newSymbol(.unbound, arguments_str) catch unreachable;
+ p.current_scope.generated.push(p.allocator, arguments_ref) catch unreachable;
const super = p.newExpr(E.Spread{ .value = p.newExpr(E.Identifier{ .ref = arguments_ref }, stmt.loc) }, stmt.loc);
const args = ExprNodeList.one(p.allocator, super) catch unreachable;
@@ -17232,7 +18116,7 @@ fn NewParser_(
args[0] = p.newExpr(E.Array{ .items = class.ts_decorators }, stmt.loc);
args[1] = p.newExpr(E.Identifier{ .ref = class.class_name.?.ref.? }, class.class_name.?.loc);
- stmts.appendAssumeCapacity(Expr.assignStmt(
+ stmts.appendAssumeCapacity(Stmt.assign(
p.newExpr(E.Identifier{ .ref = class.class_name.?.ref.? }, class.class_name.?.loc),
p.callRuntime(stmt.loc, "__decorateClass", args),
p.allocator,
@@ -17297,27 +18181,13 @@ fn NewParser_(
loc: logger.Loc,
ref: Ref,
) Expr {
- p.relocated_top_level_vars.append(p.allocator, LocRef{ .loc = loc, .ref = ref }) catch unreachable;
- var _ref = ref;
- p.recordUsage(_ref);
- return Expr.initIdentifier(_ref, loc);
- }
+ // There was a Zig stage1 bug here we had to copy `ref` into a local
+ // const variable or else the result would be wrong
+ // I remember that bug in particular took hours, possibly days to uncover.
- fn isAnonymousNamedExpr(_: *P, expr: ExprNodeIndex) bool {
- switch (expr.data) {
- .e_arrow => {
- return true;
- },
- .e_function => |func| {
- return func.func.name == null;
- },
- .e_class => |class| {
- return class.class_name == null;
- },
- else => {
- return false;
- },
- }
+ p.relocated_top_level_vars.append(p.allocator, LocRef{ .loc = loc, .ref = ref }) catch unreachable;
+ p.recordUsage(ref);
+ return Expr.initIdentifier(ref, loc);
}
fn valueForDefine(p: *P, loc: logger.Loc, assign_target: js_ast.AssignTarget, is_delete_target: bool, define_data: *const DefineData) Expr {
@@ -17346,8 +18216,6 @@ fn NewParser_(
};
}
- // This function is recursive
- // But it shouldn't be that long
fn isDotDefineMatch(p: *P, expr: Expr, parts: []const string) bool {
switch (expr.data) {
.e_dot => |ex| {
@@ -17363,7 +18231,7 @@ fn NewParser_(
}
},
.e_import_meta => {
- return parts.len == 2 and strings.eqlComptime(parts[0], "import") and strings.eqlComptime(parts[1], "meta");
+ return (parts.len == 2 and strings.eqlComptime(parts[0], "import") and strings.eqlComptime(parts[1], "meta"));
},
// Note: this behavior differs from esbuild
// esbuild does not try to match index accessors
@@ -17389,15 +18257,20 @@ fn NewParser_(
return false;
}
- const result = p.findSymbol(expr.loc, name) catch return false;
+ const result = p.findSymbolWithRecordUsage(expr.loc, name, false) catch return false;
// We must not be in a "with" statement scope
if (result.is_inside_with_scope) {
return false;
}
- // The last symbol must be unbound
- return p.symbols.items[result.ref.innerIndex()].kind == .unbound;
+ return
+ // TODO: figure out why this is needed when bundling
+ // The problem is all the top-level vars are getting removed when they're not actually side effect free
+ !p.source.index.isRuntime() and
+ // when there's actually no symbol by that name, we return Ref.None
+ // If a symbol had already existed by that name, we return .unbound
+ (result.ref.isNull() or p.symbols.items[result.ref.innerIndex()].kind == .unbound);
}
},
else => {},
@@ -17431,7 +18304,7 @@ fn NewParser_(
for (bind.items) |*item| {
p.visitBinding(item.binding, duplicate_arg_check);
if (item.default_value) |default_value| {
- const was_anonymous_named_expr = p.isAnonymousNamedExpr(default_value);
+ const was_anonymous_named_expr = default_value.isAnonymousNamed();
item.default_value = p.visitExpr(default_value);
switch (item.binding.data) {
@@ -17455,7 +18328,7 @@ fn NewParser_(
p.visitBinding(property.value, duplicate_arg_check);
if (property.default_value) |default_value| {
- const was_anonymous_named_expr = p.isAnonymousNamedExpr(default_value);
+ const was_anonymous_named_expr = default_value.isAnonymousNamed();
property.default_value = p.visitExpr(default_value);
switch (property.value.data) {
@@ -17552,7 +18425,7 @@ fn NewParser_(
return res;
}
- fn visitClass(p: *P, name_scope_loc: logger.Loc, class: *G.Class) Ref {
+ fn visitClass(p: *P, name_scope_loc: logger.Loc, class: *G.Class, default_name_ref: Ref) Ref {
if (only_scan_imports_and_do_not_visit) {
@compileError("only_scan_imports_and_do_not_visit must not run this.");
}
@@ -17567,26 +18440,24 @@ fn NewParser_(
const old_enclosing_class_keyword = p.enclosing_class_keyword;
p.enclosing_class_keyword = class.class_keyword;
p.current_scope.recursiveSetStrictMode(.implicit_strict_mode_class);
- var class_name_ref: Ref = if (class.class_name != null)
- class.class_name.?.ref.?
- else
- p.newSymbol(.other, "this") catch unreachable;
-
var shadow_ref = Ref.None;
- if (!class_name_ref.eql(Ref.None)) {
- // are not allowed to assign to this symbol (it throws a TypeError).
- const name = p.symbols.items[class_name_ref.innerIndex()].original_name;
- var identifier = p.allocator.alloc(u8, name.len + 1) catch unreachable;
- bun.copy(u8, identifier[1..identifier.len], name);
- identifier[0] = '_';
- shadow_ref = p.newSymbol(Symbol.Kind.cconst, identifier) catch unreachable;
- p.recordDeclaredSymbol(shadow_ref) catch unreachable;
- if (class.class_name) |class_name| {
- p.current_scope.members.put(p.allocator, identifier, Scope.Member{ .loc = class_name.loc, .ref = shadow_ref }) catch unreachable;
- }
+ // Insert a shadowing name that spans the whole class, which matches
+ // JavaScript's semantics. The class body (and extends clause) "captures" the
+ // original value of the name. This matters for class statements because the
+ // symbol can be re-assigned to something else later. The captured values
+ // must be the original value of the name, not the re-assigned value.
+ // Use "const" for this symbol to match JavaScript run-time semantics. You
+ // are not allowed to assign to this symbol (it throws a TypeError).
+ if (class.class_name) |name| {
+ shadow_ref = name.ref.?;
+ } else {
+ const name_str: []const u8 = if (default_name_ref.isNull()) "_this" else "_default";
+ shadow_ref = p.newSymbol(.cconst, name_str) catch unreachable;
}
+ p.recordDeclaredSymbol(shadow_ref) catch unreachable;
+
if (class.extends) |extends| {
class.extends = p.visitExpr(extends);
}
@@ -17607,8 +18478,14 @@ fn NewParser_(
var old_fn_or_arrow_data = p.fn_or_arrow_data_visit;
var old_fn_only_data = p.fn_only_data_visit;
p.fn_or_arrow_data_visit = .{};
- p.fn_only_data_visit = .{ .is_this_nested = true, .is_new_target_allowed = true };
+ p.fn_only_data_visit = .{
+ .is_this_nested = true,
+ .is_new_target_allowed = true,
+ .class_name_ref = &shadow_ref,
+ // TODO: down transpilation
+ .should_replace_this_with_class_name_ref = false,
+ };
p.pushScopeForVisitPass(.class_static_init, property.class_static_block.?.loc) catch unreachable;
// Make it an error to use "arguments" in a static class block
@@ -17641,12 +18518,12 @@ fn NewParser_(
// The value of "this" is shadowed inside property values
const old_is_this_captured = p.fn_only_data_visit.is_this_nested;
- const old_this = p.fn_only_data_visit.this_class_static_ref;
+ const old_class_name_ref = p.fn_only_data_visit.class_name_ref;
p.fn_only_data_visit.is_this_nested = true;
p.fn_only_data_visit.is_new_target_allowed = true;
- p.fn_only_data_visit.this_class_static_ref = null;
+ p.fn_only_data_visit.class_name_ref = &shadow_ref;
defer p.fn_only_data_visit.is_this_nested = old_is_this_captured;
- defer p.fn_only_data_visit.this_class_static_ref = old_this;
+ defer p.fn_only_data_visit.class_name_ref = old_class_name_ref;
// We need to explicitly assign the name to the property initializer if it
// will be transformed such that it is no longer an inline initializer.
@@ -17673,7 +18550,7 @@ fn NewParser_(
if (property.value) |val| {
if (name_to_keep) |name| {
- const was_anon = p.isAnonymousNamedExpr(val);
+ const was_anon = val.isAnonymousNamed();
property.value = p.maybeKeepExprSymbolName(p.visitExpr(val), name, was_anon);
} else {
property.value = p.visitExpr(val);
@@ -17689,7 +18566,7 @@ fn NewParser_(
if (property.initializer) |val| {
// if (property.flags.is_static and )
if (name_to_keep) |name| {
- const was_anon = p.isAnonymousNamedExpr(val);
+ const was_anon = val.isAnonymousNamed();
property.initializer = p.maybeKeepExprSymbolName(p.visitExpr(val), name, was_anon);
} else {
property.initializer = p.visitExpr(val);
@@ -17730,7 +18607,7 @@ fn NewParser_(
const name = p.symbols.items[id.ref.innerIndex()].original_name;
const ident = p.newExpr(E.Identifier{ .ref = id.ref }, arg.binding.loc);
- stmts.insert(if (super_index) |k| j + k + 1 else j, Expr.assignStmt(
+ stmts.insert(if (super_index) |k| j + k + 1 else j, Stmt.assign(
p.newExpr(E.Dot{
.target = p.newExpr(E.This{}, arg.binding.loc),
.name = name,
@@ -17757,18 +18634,17 @@ fn NewParser_(
}
}
- if (!shadow_ref.eql(Ref.None)) {
- if (p.symbols.items[shadow_ref.innerIndex()].use_count_estimate == 0) {
- // Don't generate a shadowing name if one isn't needed
- shadow_ref = Ref.None;
- } else if (class.class_name) |_| {
- // If there was originally no class name but something inside needed one
- // (e.g. there was a static property initializer that referenced "this"),
- // store our generated name so the class expression ends up with a name.
- class.class_name = LocRef{ .loc = name_scope_loc, .ref = class_name_ref };
- p.current_scope.generated.append(p.allocator, class_name_ref) catch unreachable;
- p.recordDeclaredSymbol(class_name_ref) catch unreachable;
- }
+ if (p.symbols.items[shadow_ref.innerIndex()].use_count_estimate == 0) {
+ // If there was originally no class name but something inside needed one
+ // (e.g. there was a static property initializer that referenced "this"),
+ // store our generated name so the class expression ends up with a name.
+ shadow_ref = Ref.None;
+ } else if (class.class_name == null) {
+ class.class_name = LocRef{
+ .ref = shadow_ref,
+ .loc = name_scope_loc,
+ };
+ p.recordDeclaredSymbol(shadow_ref) catch unreachable;
}
// class name scope
@@ -17793,33 +18669,56 @@ fn NewParser_(
}, loc);
}
- pub fn callRuntime(p: *P, loc: logger.Loc, comptime name: string, args: []Expr) Expr {
+ fn runtimeIdentifier(p: *P, loc: logger.Loc, comptime name: string) Expr {
var ref: Ref = undefined;
p.has_called_runtime = true;
if (!p.runtime_imports.contains(name)) {
ref = brk: {
- if (comptime strings.eqlComptime(name, "__require")) {
- p.ensureRequireSymbol();
- break :brk p.runtime_imports.__require.?.ref;
+ if (!p.options.bundle) {
+ if (comptime strings.eqlComptime(name, "__require")) {
+ p.ensureRequireSymbol();
+ break :brk p.runtime_imports.__require.?.ref;
+ }
+ const generated_symbol = p.declareGeneratedSymbol(.other, name) catch unreachable;
+ p.runtime_imports.put(name, generated_symbol);
+ break :brk generated_symbol.ref;
+ } else {
+ const loc_ref = js_ast.LocRef{
+ .loc = loc,
+ .ref = p.newSymbol(.other, name) catch unreachable,
+ };
+ p.runtime_imports.put(name, .{
+ .primary = loc_ref.ref.?,
+ .backup = loc_ref.ref.?,
+ .ref = loc_ref.ref.?,
+ });
+ p.module_scope.generated.push(p.allocator, loc_ref.ref.?) catch unreachable;
+ break :brk loc_ref.ref.?;
}
- const generated_symbol = p.declareGeneratedSymbol(.other, name) catch unreachable;
- p.runtime_imports.put(name, generated_symbol);
- break :brk generated_symbol.ref;
};
-
- p.module_scope.generated.append(p.allocator, ref) catch unreachable;
} else {
ref = p.runtime_imports.at(name).?;
}
p.recordUsage(ref);
- return p.newExpr(E.Call{
- .target = p.newExpr(E.Identifier{
+ return p.newExpr(
+ E.ImportIdentifier{
.ref = ref,
- }, loc),
- .args = ExprNodeList.init(args),
- }, loc);
+ .was_originally_identifier = false,
+ },
+ loc,
+ );
+ }
+
+ fn callRuntime(p: *P, loc: logger.Loc, comptime name: string, args: []Expr) Expr {
+ return p.newExpr(
+ E.Call{
+ .target = p.runtimeIdentifier(loc, name),
+ .args = ExprNodeList.init(args),
+ },
+ loc,
+ );
}
// Try separating the list for appending, so that it's not a pointer.
@@ -17876,6 +18775,118 @@ fn NewParser_(
try p.visitAndAppendStmt(list, stmt);
}
+ // Transform block-level function declarations into variable declarations
+ if (before.items.len > 0) {
+ var let_decls = ListManaged(G.Decl).init(p.allocator);
+ var var_decls = ListManaged(G.Decl).init(p.allocator);
+ var non_fn_stmts = ListManaged(Stmt).init(p.allocator);
+ var fn_stmts = std.AutoHashMap(Ref, u32).init(p.allocator);
+
+ defer {
+ non_fn_stmts.deinit();
+ fn_stmts.deinit();
+ }
+
+ for (before.items) |stmt| {
+ switch (stmt.data) {
+ .s_function => |data| {
+ // This transformation of function declarations in nested scopes is
+ // intended to preserve the hoisting semantics of the original code. In
+ // JavaScript, function hoisting works differently in strict mode vs.
+ // sloppy mode code. We want the code we generate to use the semantics of
+ // the original environment, not the generated environment. However, if
+ // direct "eval" is present then it's not possible to preserve the
+ // semantics because we need two identifiers to do that and direct "eval"
+ // means neither identifier can be renamed to something else. So in that
+ // case we give up and do not preserve the semantics of the original code.
+ const name_ref = data.func.name.?.ref.?;
+ if (p.current_scope.contains_direct_eval) {
+ if (p.hoisted_ref_for_sloppy_mode_block_fn.get(name_ref)) |hoisted_ref| {
+ // Merge the two identifiers back into a single one
+ p.symbols.items[hoisted_ref.innerIndex()].link = name_ref;
+ }
+ non_fn_stmts.append(stmt) catch unreachable;
+ continue;
+ }
+
+ var gpe = fn_stmts.getOrPut(name_ref) catch unreachable;
+ var index = gpe.value_ptr.*;
+ if (!gpe.found_existing) {
+ index = @intCast(u32, let_decls.items.len);
+ gpe.value_ptr.* = index;
+ let_decls.append(.{
+ .binding = p.b(B.Identifier{
+ .ref = name_ref,
+ }, data.func.name.?.loc),
+ }) catch unreachable;
+
+ // Also write the function to the hoisted sibling symbol if applicable
+ if (p.hoisted_ref_for_sloppy_mode_block_fn.get(name_ref)) |hoisted_ref| {
+ p.recordUsage(name_ref);
+ var_decls.append(.{
+ .binding = p.b(
+ B.Identifier{ .ref = hoisted_ref },
+ data.func.name.?.loc,
+ ),
+ .value = p.newExpr(
+ E.Identifier{
+ .ref = name_ref,
+ },
+ data.func.name.?.loc,
+ ),
+ }) catch unreachable;
+ }
+ }
+
+ // The last function statement for a given symbol wins
+ data.func.name = null;
+ let_decls.items[index].value = p.newExpr(
+ E.Function{
+ .func = data.func,
+ },
+ stmt.loc,
+ );
+ },
+ else => {
+ non_fn_stmts.append(stmt) catch unreachable;
+ continue;
+ },
+ }
+ }
+ before.items.len = 0;
+
+ before.ensureUnusedCapacity(@as(usize, @boolToInt(let_decls.items.len > 0)) + @as(usize, @boolToInt(var_decls.items.len > 0)) + non_fn_stmts.items.len) catch unreachable;
+
+ if (let_decls.items.len > 0) {
+ before.appendAssumeCapacity(p.s(
+ S.Local{
+ .kind = .k_let,
+ .decls = let_decls.items,
+ },
+ let_decls.items[0].value.?.loc,
+ ));
+ }
+
+ if (var_decls.items.len > 0) {
+ const relocated = p.maybeRelocateVarsToTopLevel(var_decls.items, .normal);
+ if (relocated.ok) {
+ if (relocated.stmt) |new| {
+ before.appendAssumeCapacity(new);
+ }
+ } else {
+ before.appendAssumeCapacity(p.s(
+ S.Local{
+ .kind = .k_var,
+ .decls = var_decls.items,
+ },
+ var_decls.items[0].value.?.loc,
+ ));
+ }
+ }
+
+ before.appendSliceAssumeCapacity(non_fn_stmts.items);
+ }
+
var visited_count = visited.items.len;
if (p.is_control_flow_dead) {
var end: usize = 0;
@@ -18298,13 +19309,13 @@ fn NewParser_(
// by the time we get here.
p.scopes_in_order.items[scope_index] = null;
// Remove the last child from the parent scope
- const last = parent.children.items.len - 1;
- if (comptime Environment.allow_assert) assert(parent.children.items[last] == to_flatten);
+ const last = parent.children.len - 1;
+ if (comptime Environment.allow_assert) assert(parent.children.ptr[last] == to_flatten);
_ = parent.children.popOrNull();
- for (to_flatten.children.items) |item| {
+ for (to_flatten.children.slice()) |item| {
item.parent = parent;
- parent.children.append(p.allocator, item) catch unreachable;
+ parent.children.push(p.allocator, item) catch unreachable;
}
}
@@ -18318,13 +19329,13 @@ fn NewParser_(
pub fn toAST(p: *P, _parts: []js_ast.Part, exports_kind: js_ast.ExportsKind, commonjs_wrapper_expr: ?Expr) !js_ast.Ast {
const allocator = p.allocator;
var parts = _parts;
- // Insert an import statement for any runtime imports we generated
- if (p.options.tree_shaking and p.options.features.trim_unused_imports) {
- p.treeShake(&parts, false);
- }
+ // if (p.options.tree_shaking and p.options.features.trim_unused_imports) {
+ // p.treeShake(&parts, false);
+ // }
- var parts_end: usize = 0;
+ const bundling = p.options.bundle;
+ var parts_end: usize = @as(usize, @boolToInt(bundling));
// Handle import paths after the whole file has been visited because we need
// symbol usage counts to be able to remove unused type-only imports in
// TypeScript code.
@@ -18332,27 +19343,40 @@ fn NewParser_(
var kept_import_equals = false;
var removed_import_equals = false;
- var i: usize = 0;
+ const begin = parts_end;
// Potentially remove some statements, then filter out parts to remove any
// with no statements
- while (i < parts.len) : (i += 1) {
- var part = parts[i];
- p.import_records_for_current_part.shrinkRetainingCapacity(0);
- p.declared_symbols.shrinkRetainingCapacity(0);
+ for (parts[begin..]) |part_| {
+ var part = part_;
+ p.import_records_for_current_part.clearRetainingCapacity();
+ p.declared_symbols.clearRetainingCapacity();
var result = try ImportScanner.scan(P, p, part.stmts, commonjs_wrapper_expr != null);
kept_import_equals = kept_import_equals or result.kept_import_equals;
removed_import_equals = removed_import_equals or result.removed_import_equals;
- part.import_record_indices = part.import_record_indices;
- part.declared_symbols = try p.declared_symbols.toOwnedSlice(allocator);
+
part.stmts = result.stmts;
if (part.stmts.len > 0) {
- if (p.module_scope.contains_direct_eval and part.declared_symbols.len > 0) {
+ if (p.module_scope.contains_direct_eval and part.declared_symbols.len() > 0) {
// If this file contains a direct call to "eval()", all parts that
// declare top-level symbols must be kept since the eval'd code may
// reference those symbols.
part.can_be_removed_if_unused = false;
}
+ if (part.declared_symbols.len() == 0) {
+ part.declared_symbols = p.declared_symbols.clone(p.allocator) catch unreachable;
+ } else {
+ part.declared_symbols.appendList(p.allocator, p.declared_symbols) catch unreachable;
+ }
+
+ if (part.import_record_indices.len == 0) {
+ part.import_record_indices = @TypeOf(part.import_record_indices).init(
+ (p.import_records_for_current_part.clone(p.allocator) catch unreachable).items,
+ );
+ } else {
+ part.import_record_indices.append(p.allocator, p.import_records_for_current_part.items) catch unreachable;
+ }
+
parts[parts_end] = part;
parts_end += 1;
}
@@ -18365,6 +19389,7 @@ fn NewParser_(
}
}
+ // leave the first part in there for namespace export when bundling
parts = parts[0..parts_end];
// Do a second pass for exported items now that imported items are filled out
@@ -18383,33 +19408,41 @@ fn NewParser_(
}
}
- if (p.options.tree_shaking) {
- p.treeShake(&parts, commonjs_wrapper_expr != null or p.options.features.hot_module_reloading or p.options.enable_bundling);
- }
+ // if (p.options.tree_shaking) {
+ // p.treeShake(&parts, commonjs_wrapper_expr != null or p.options.features.hot_module_reloading or p.options.enable_legacy_bundling);
+ // }
if (commonjs_wrapper_expr) |commonjs_wrapper| {
- var part = &parts[parts.len - 1];
-
var require_function_args = allocator.alloc(Arg, 2) catch unreachable;
+ var final_part_stmts_count: usize = 0;
var imports_count: u32 = 0;
// We have to also move export from, since we will preserve those
var exports_from_count: u32 = 0;
// Two passes. First pass just counts.
- for (parts[parts.len - 1].stmts) |stmt| {
- imports_count += switch (stmt.data) {
- .s_import => @as(u32, 1),
- else => @as(u32, 0),
- };
+ for (parts) |part| {
+ for (part.stmts) |stmt| {
+ imports_count += switch (stmt.data) {
+ .s_import => @as(u32, 1),
+ else => @as(u32, 0),
+ };
- exports_from_count += switch (stmt.data) {
- .s_export_star, .s_export_from => @as(u32, 1),
- else => @as(u32, 0),
- };
+ exports_from_count += switch (stmt.data) {
+ .s_export_star, .s_export_from => @as(u32, 1),
+ else => @as(u32, 0),
+ };
+
+ final_part_stmts_count += switch (stmt.data) {
+ .s_import, .s_export_star, .s_export_from => @as(usize, 0),
+ else => @as(usize, 1),
+ };
+ }
}
var new_stmts_list = allocator.alloc(Stmt, exports_from_count + imports_count + 1) catch unreachable;
+ var final_stmts_list = allocator.alloc(Stmt, final_part_stmts_count) catch unreachable;
+ var remaining_final_stmts = final_stmts_list;
var imports_list = new_stmts_list[0..imports_count];
var exports_list: []Stmt = if (exports_from_count > 0) new_stmts_list[imports_list.len + 1 ..] else &[_]Stmt{};
@@ -18420,22 +19453,26 @@ fn NewParser_(
var imports_list_i: u32 = 0;
var exports_list_i: u32 = 0;
- for (part.stmts, 0..) |_, i| {
- switch (part.stmts[i].data) {
- .s_import => {
- imports_list[imports_list_i] = part.stmts[i];
- part.stmts[i] = Stmt.empty();
- part.stmts[i].loc = imports_list[imports_list_i].loc;
- imports_list_i += 1;
- },
+ for (parts) |part| {
+ for (part.stmts) |*stmt| {
+ switch (stmt.data) {
+ .s_import => {
+ imports_list[imports_list_i] = stmt.*;
+ stmt.loc = imports_list[imports_list_i].loc;
+ imports_list_i += 1;
+ },
- .s_export_star, .s_export_from => {
- exports_list[exports_list_i] = part.stmts[i];
- part.stmts[i] = Stmt.empty();
- part.stmts[i].loc = exports_list[exports_list_i].loc;
- exports_list_i += 1;
- },
- else => {},
+ .s_export_star, .s_export_from => {
+ exports_list[exports_list_i] = stmt.*;
+ stmt.loc = exports_list[exports_list_i].loc;
+ exports_list_i += 1;
+ },
+ else => {
+ remaining_final_stmts[0] = stmt.*;
+ remaining_final_stmts = remaining_final_stmts[1..];
+ },
+ }
+ stmt.* = Stmt.empty();
}
}
@@ -18444,7 +19481,7 @@ fn NewParser_(
.name = null,
.open_parens_loc = logger.Loc.Empty,
.args = require_function_args,
- .body = .{ .loc = logger.Loc.Empty, .stmts = parts[parts.len - 1].stmts },
+ .body = .{ .loc = logger.Loc.Empty, .stmts = final_stmts_list },
.flags = Flags.Function.init(.{ .is_export = true }),
} },
logger.Loc.Empty,
@@ -18469,7 +19506,7 @@ fn NewParser_(
},
logger.Loc.Empty,
);
- part.stmts = new_stmts_list;
+ parts[parts.len - 1].stmts = new_stmts_list;
} else if (p.options.features.hot_module_reloading and p.options.features.allow_runtime) {
var named_exports_count: usize = p.named_exports.count();
const named_imports: js_ast.Ast.NamedImports = p.named_imports;
@@ -18698,7 +19735,7 @@ fn NewParser_(
.value = decl_value,
};
- update_function_stmts[named_export_i] = Expr.assignStmt(
+ update_function_stmts[named_export_i] = Stmt.assign(
p.newExpr(
E.Identifier{ .ref = name_ref },
logger.Loc.Empty,
@@ -18873,64 +19910,96 @@ fn NewParser_(
part.stmts = _stmts[0 .. imports_list.len + toplevel_stmts.len + exports_from.len];
} else if (p.options.features.hot_module_reloading) {}
+ var top_level_symbols_to_parts = js_ast.Ast.TopLevelSymbolToParts{};
+ var top_level = &top_level_symbols_to_parts;
- {
+ if (p.options.bundle) {
+ const Ctx = struct {
+ allocator: std.mem.Allocator,
+ top_level_symbols_to_parts: *js_ast.Ast.TopLevelSymbolToParts,
+ symbols: []const js_ast.Symbol,
+ part_index: u32,
+
+ pub fn next(ctx: @This(), input: Ref) void {
+ // If this symbol was merged, use the symbol at the end of the
+ // linked list in the map. This is the case for multiple "var"
+ // declarations with the same name, for example.
+ var ref = input;
+ var symbol_ref = &ctx.symbols[ref.innerIndex()];
+ while (symbol_ref.hasLink()) : (symbol_ref = &ctx.symbols[ref.innerIndex()]) {
+ ref = symbol_ref.link;
+ }
+
+ var entry = ctx.top_level_symbols_to_parts.getOrPut(ctx.allocator, ref) catch unreachable;
+ if (!entry.found_existing) {
+ entry.value_ptr.* = .{};
+ }
+
+ entry.value_ptr.push(ctx.allocator, @truncate(u32, ctx.part_index)) catch unreachable;
+ }
+ };
// Each part tracks the other parts it depends on within this file
- // var local_dependencies = AutoHashMap(u32, u32).init(p.allocator);
-
- // while (i < parts.len) : (i += 1) {
- // const part = parts[i];
- // if (part.symbol_uses.count() > 0) {
- // var iter = part.symbol_uses.iterator();
- // var dependencies = List(js_ast.Dependency).init(p.allocator);
- // while (iter.next()) |entry| {
- // const ref = entry.key;
-
- // if (p.top_level_symbol_to_parts.get(ref)) |tlstp| {
- // for (tlstp.items) |other_part_index| {
- // if (!local_dependencies.contains(other_part_index) or other_part_index != i) {
- // try local_dependencies.put(other_part_index, @intCast(u32, i));
- // try dependencies.append(js_ast.Dependency{
- // .source_index = p.source.index,
- // .part_index = other_part_index,
- // });
- // }
- // }
- // }
-
- // // Also map from imports to parts that use them
- // // TODO: will appending to this list like this be a perf issue?
- // if (p.named_imports.getEntry(ref)) |named_import_entry| {
- // const named_import = named_import_entry.value;
- // var buf = try p.allocator.alloc(u32, named_import.local_parts_with_uses.len + 1);
- // if (named_import.local_parts_with_uses.len > 0) {
- // bun.copy(u32, buf, named_import.local_parts_with_uses);
- // }
- // buf[buf.len - 1] = @intCast(u32, i);
- // named_import_entry.value.local_parts_with_uses = buf;
- // }
- // }
- // }
- // }
+ for (parts, 0..) |*part, part_index| {
+ var decls = &part.declared_symbols;
+ const ctx = Ctx{
+ .allocator = p.allocator,
+ .top_level_symbols_to_parts = top_level,
+ .symbols = p.symbols.items,
+ .part_index = @truncate(u32, part_index),
+ };
+
+ DeclaredSymbol.forEachTopLevelSymbol(decls, ctx, Ctx.next);
+ }
+
+ // Pulling in the exports of this module always pulls in the export part
+
+ {
+ var entry = top_level.getOrPut(p.allocator, p.exports_ref) catch unreachable;
+
+ if (!entry.found_existing) {
+ entry.value_ptr.* = .{};
+ }
+
+ entry.value_ptr.push(p.allocator, js_ast.namespace_export_part_index) catch unreachable;
+ }
}
+ const wrapper_ref: ?Ref = brk: {
+ if (p.options.bundle) {
+ break :brk p.newSymbol(
+ .other,
+ std.fmt.allocPrint(
+ p.allocator,
+ "require_{any}",
+ .{
+ p.source.fmtIdentifier(),
+ },
+ ) catch unreachable,
+ ) catch unreachable;
+ }
+
+ break :brk @as(?Ref, null);
+ };
+
return .{
+ .allocator = p.allocator,
.runtime_imports = p.runtime_imports,
- .parts = parts,
+ .parts = bun.BabyList(js_ast.Part).init(parts),
.module_scope = p.module_scope.*,
- .symbols = p.symbols.items,
+ .symbols = js_ast.Symbol.List.init(p.symbols.items),
.exports_ref = p.exports_ref,
- .wrapper_ref = null,
+ .wrapper_ref = wrapper_ref,
.module_ref = p.module_ref,
- .import_records = p.import_records.items,
+ .import_records = ImportRecord.List.init(p.import_records.items),
.export_star_import_records = p.export_star_import_records.items,
.approximate_newline_count = p.lexer.approximate_newline_count,
.exports_kind = exports_kind,
.named_imports = p.named_imports,
.named_exports = p.named_exports,
- .import_keyword = p.es6_import_keyword,
- .export_keyword = p.es6_export_keyword,
+ .import_keyword = p.esm_import_keyword,
+ .export_keyword = p.esm_export_keyword,
+ .top_level_symbols_to_parts = top_level_symbols_to_parts,
.require_ref = if (p.runtime_imports.__require != null)
p.runtime_imports.__require.?.ref
else
@@ -18944,6 +20013,7 @@ fn NewParser_(
false,
// .top_Level_await_keyword = p.top_level_await_keyword,
.bun_plugin = p.bun_plugin,
+ .commonjs_named_exports = p.commonjs_named_exports,
};
}
@@ -18999,6 +20069,9 @@ fn NewParser_(
.scopes_in_order = scope_order,
.needs_jsx_import = if (comptime only_scan_imports_and_do_not_visit) false else NeedsJSXType{},
.lexer = lexer,
+
+ // Only enable during bundling
+ .commonjs_named_exports_deoptimized = !opts.bundle,
};
this.symbols = std.ArrayList(Symbol).init(allocator);
@@ -19033,22 +20106,30 @@ fn NewParser_(
// Range (min … max): 24.1 ms … 39.7 ms 500 runs
// '../../build/macos-x86_64/bun node_modules/react-dom/cjs/react-dom.development.js --resolve=disable' ran
// 1.02 ± 0.07 times faster than '../../bun.before-comptime-js-parser node_modules/react-dom/cjs/react-dom.development.js --resolve=disable'
-const JavaScriptParser = NewParser(.{});
-const JSXParser = NewParser(.{ .jsx = .react });
+const JavaScriptParser = if (bun.fast_debug_build_mode)
+ TSXParser
+else
+ NewParser(.{});
+const JSXParser = if (bun.fast_debug_build_mode)
+ TSXParser
+else
+ NewParser(.{ .jsx = .react });
const TSXParser = NewParser(.{ .jsx = .react, .typescript = true });
const TypeScriptParser = NewParser(.{ .typescript = true });
-const JSParserMacro = NewParser(.{
- .jsx = .macro,
-});
+const JSParserMacro = if (bun.fast_debug_build_mode)
+ TSParserMacro
+else
+ NewParser(.{
+ .jsx = .macro,
+ });
const TSParserMacro = NewParser(.{
.jsx = .macro,
.typescript = true,
});
-
-const JavaScriptImportScanner = NewParser(.{ .scan_only = true });
-const JSXImportScanner = NewParser(.{ .jsx = .react, .scan_only = true });
+const JavaScriptImportScanner = if (bun.fast_debug_build_mode) TSXImportScanner else NewParser(.{ .scan_only = true });
+const JSXImportScanner = if (bun.fast_debug_build_mode) TSXImportScanner else NewParser(.{ .jsx = .react, .scan_only = true });
const TSXImportScanner = NewParser(.{ .jsx = .react, .typescript = true, .scan_only = true });
-const TypeScriptImportScanner = NewParser(.{ .typescript = true, .scan_only = true });
+const TypeScriptImportScanner = if (bun.fast_debug_build_mode) TSXImportScanner else NewParser(.{ .typescript = true, .scan_only = true });
// The "await" and "yield" expressions are never allowed in argument lists but
// may or may not be allowed otherwise depending on the details of the enclosing
diff --git a/src/js_printer.zig b/src/js_printer.zig
index bacf0d448..29cd66873 100644
--- a/src/js_printer.zig
+++ b/src/js_printer.zig
@@ -56,7 +56,7 @@ const assert = std.debug.assert;
threadlocal var imported_module_ids_list: std.ArrayList(u32) = undefined;
threadlocal var imported_module_ids_list_unset: bool = true;
-const ImportRecord = importRecord.ImportRecord;
+const ImportRecord = bun.ImportRecord;
const SourceMap = @import("./sourcemap/sourcemap.zig");
/// For support JavaScriptCore
@@ -475,7 +475,8 @@ pub const SourceMapHandler = struct {
pub const Options = struct {
transform_imports: bool = true,
- to_module_ref: Ref = Ref.None,
+ to_commonjs_ref: Ref = Ref.None,
+ to_esm_ref: Ref = Ref.None,
require_ref: ?Ref = null,
indent: usize = 0,
externals: []u32 = &[_]u32{},
@@ -488,8 +489,15 @@ pub const Options = struct {
source_map_handler: ?SourceMapHandler = null,
css_import_behavior: Api.CssInJsBehavior = Api.CssInJsBehavior.facade,
+ commonjs_named_exports: js_ast.Ast.CommonJSNamedExports = .{},
+ commonjs_named_exports_ref: Ref = Ref.None,
+
minify_whitespace: bool = false,
+ require_or_import_meta_for_source_callback: RequireOrImportMeta.Callback = .{},
+
+ module_type: options.OutputFormat = .preserve,
+
// TODO: remove this
// The reason for this is:
// 1. You're bundling a React component
@@ -513,11 +521,69 @@ pub const Options = struct {
pub inline fn unindent(self: *Options) void {
self.indent -|= 1;
}
+
+ pub fn requireOrImportMetaForSource(self: *const Options, id: u32) RequireOrImportMeta {
+ if (self.require_or_import_meta_for_source_callback.ctx == null)
+ return .{};
+
+ return self.require_or_import_meta_for_source_callback.call(id);
+ }
};
-pub const PrintResult = struct {
- js: string,
- source_map: ?SourceMap.Chunk = null,
+pub const RequireOrImportMeta = struct {
+ // CommonJS files will return the "require_*" wrapper function and an invalid
+ // exports object reference. Lazily-initialized ESM files will return the
+ // "init_*" wrapper function and the exports object for that file.
+ wrapper_ref: Ref = Ref.None,
+ exports_ref: Ref = Ref.None,
+ is_wrapper_async: bool = false,
+
+ pub const Callback = struct {
+ const Fn = fn (*anyopaque, u32) RequireOrImportMeta;
+
+ ctx: ?*anyopaque = null,
+ callback: *const Fn = undefined,
+
+ pub fn call(self: Callback, id: u32) RequireOrImportMeta {
+ return self.callback(self.ctx.?, id);
+ }
+
+ pub fn init(
+ comptime Type: type,
+ comptime callback: (fn (t: *Type, id: u32) RequireOrImportMeta),
+ ctx: *Type,
+ ) Callback {
+ return Callback{
+ .ctx = bun.cast(*anyopaque, ctx),
+ .callback = @ptrCast(*const Fn, &callback),
+ };
+ }
+ };
+};
+
+pub const PrintResult = union(enum) {
+ result: struct {
+ code: []u8,
+ source_map: ?SourceMap.Chunk = null,
+ },
+ err: anyerror,
+
+ pub fn clone(
+ this: PrintResult,
+ allocator: std.mem.Allocator,
+ ) !PrintResult {
+ return switch (this) {
+ .result => PrintResult{
+ .result = .{
+ .code = try allocator.dupe(u8, this.result.code),
+ .source_map = this.result.source_map,
+ },
+ },
+ .err => PrintResult{
+ .err = this.err,
+ },
+ };
+ }
};
// do not make this a packed struct
@@ -588,7 +654,7 @@ const ImportVariant = enum {
};
}
- pub fn determine(record: *const importRecord.ImportRecord, s_import: *const S.Import) ImportVariant {
+ pub fn determine(record: *const ImportRecord, s_import: *const S.Import) ImportVariant {
var variant = ImportVariant.path_only;
if (record.contains_import_star) {
@@ -615,10 +681,9 @@ const ImportVariant = enum {
}
};
-pub fn NewPrinter(
+fn NewPrinter(
comptime ascii_only: bool,
comptime Writer: type,
- comptime Linker: type,
comptime rewrite_esm_to_cjs: bool,
comptime is_bun_platform: bool,
comptime is_inside_bundle: bool,
@@ -626,9 +691,7 @@ pub fn NewPrinter(
comptime generate_source_map: bool,
) type {
return struct {
- symbols: Symbol.Map,
- import_records: []importRecord.ImportRecord,
- linker: ?*Linker,
+ import_records: []const ImportRecord,
needs_semicolon: bool = false,
stmt_start: i32 = -1,
@@ -652,6 +715,8 @@ pub fn NewPrinter(
symbol_counter: u32 = 0,
+ temporary_bindings: std.ArrayListUnmanaged(B.Property) = .{},
+
const Printer = @This();
pub fn writeAll(p: *Printer, bytes: anytype) anyerror!void {
@@ -941,9 +1006,10 @@ pub fn NewPrinter(
p.print("}");
}
- pub fn printDecls(p: *Printer, comptime keyword: string, decls: []G.Decl, flags: ExprFlag.Set) void {
+ pub fn printDecls(p: *Printer, comptime keyword: string, decls_: []G.Decl, flags: ExprFlag.Set) void {
p.print(keyword);
p.printSpace();
+ var decls = decls_;
if (decls.len == 0) {
// "var ;" is invalid syntax
@@ -951,6 +1017,118 @@ pub fn NewPrinter(
unreachable;
}
+ if (comptime FeatureFlags.same_target_becomes_destructuring) {
+ // Minify
+ //
+ // var a = obj.foo, b = obj.bar, c = obj.baz;
+ //
+ // to
+ //
+ // var {a, b, c} = obj;
+ //
+ // Caveats:
+ // - Same consecutive target
+ // - No optional chaining
+ // - No computed property access
+ // - Identifier bindings only
+ if (decls.len > 1) brk: {
+ const first_decl = &decls[0];
+ const second_decl = &decls[1];
+
+ if (first_decl.binding.data != .b_identifier) break :brk;
+ if (second_decl.value == null or
+ second_decl.value.?.data != .e_dot or
+ second_decl.binding.data != .b_identifier)
+ {
+ break :brk;
+ }
+
+ const target_value = first_decl.value orelse break :brk;
+ const target_e_dot: *E.Dot = if (target_value.data == .e_dot)
+ target_value.data.e_dot
+ else
+ break :brk;
+ const target_ref = if (target_e_dot.target.data == .e_identifier and target_e_dot.optional_chain == null)
+ target_e_dot.target.data.e_identifier.ref
+ else
+ break :brk;
+
+ const second_e_dot = second_decl.value.?.data.e_dot;
+ if (second_e_dot.target.data != .e_identifier or second_e_dot.optional_chain != null) {
+ break :brk;
+ }
+
+ const second_ref = second_e_dot.target.data.e_identifier.ref;
+ if (!second_ref.eql(target_ref)) {
+ break :brk;
+ }
+
+ {
+ // Reset the temporary bindings array early on
+ var temp_bindings = p.temporary_bindings;
+ p.temporary_bindings = .{};
+ defer {
+ if (p.temporary_bindings.capacity > 0) {
+ temp_bindings.deinit(bun.default_allocator);
+ } else {
+ temp_bindings.clearRetainingCapacity();
+ p.temporary_bindings = temp_bindings;
+ }
+ }
+ temp_bindings.ensureUnusedCapacity(bun.default_allocator, 2) catch unreachable;
+ temp_bindings.appendAssumeCapacity(.{
+ .key = Expr.init(E.String, E.String.init(target_e_dot.name), target_e_dot.name_loc),
+ .value = decls[0].binding,
+ });
+ temp_bindings.appendAssumeCapacity(.{
+ .key = Expr.init(E.String, E.String.init(second_e_dot.name), second_e_dot.name_loc),
+ .value = decls[1].binding,
+ });
+
+ decls = decls[2..];
+ while (decls.len > 0) {
+ const decl = &decls[0];
+
+ if (decl.value == null or decl.value.?.data != .e_dot or decl.binding.data != .b_identifier) {
+ break;
+ }
+
+ const e_dot = decl.value.?.data.e_dot;
+ if (e_dot.target.data != .e_identifier or e_dot.optional_chain != null) {
+ break;
+ }
+
+ const ref = e_dot.target.data.e_identifier.ref;
+ if (!ref.eql(target_ref)) {
+ break;
+ }
+
+ temp_bindings.append(bun.default_allocator, .{
+ .key = Expr.init(E.String, E.String.init(e_dot.name), e_dot.name_loc),
+ .value = decl.binding,
+ }) catch unreachable;
+ decls = decls[1..];
+ }
+ var b_object = B.Object{
+ .properties = temp_bindings.items,
+ .is_single_line = true,
+ };
+ const binding = Binding.init(&b_object, target_e_dot.target.loc);
+ p.printBinding(binding);
+ }
+
+ p.printWhitespacer(ws(" = "));
+ p.printExpr(second_e_dot.target, .comma, flags);
+
+ if (decls.len == 0) {
+ return;
+ }
+
+ p.print(",");
+ p.printSpace();
+ }
+ }
+
{
p.printBinding(decls[0].binding);
@@ -973,7 +1151,6 @@ pub fn NewPrinter(
}
}
- // noop for now
pub inline fn addSourceMapping(printer: *Printer, location: logger.Loc) void {
if (comptime !generate_source_map) {
return;
@@ -983,6 +1160,7 @@ pub fn NewPrinter(
}
pub fn printSymbol(p: *Printer, ref: Ref) void {
+ std.debug.assert(!ref.isNull());
const name = p.renamer.nameForSymbol(ref);
p.printIdentifier(name);
@@ -1442,7 +1620,7 @@ pub fn NewPrinter(
.e_identifier => |ident| {
if (ident.ref.isSourceContentsSlice()) return false;
- const symbol = p.symbols.get(p.symbols.follow(ident.ref)) orelse return false;
+ const symbol = p.symbols().get(p.symbols().follow(ident.ref)) orelse return false;
return symbol.kind == .unbound and strings.eqlComptime(symbol.original_name, "eval");
},
else => {
@@ -1451,25 +1629,37 @@ pub fn NewPrinter(
}
}
+ inline fn symbols(p: *Printer) js_ast.Symbol.Map {
+ return p.renamer.symbols();
+ }
+
pub fn printRequireError(p: *Printer, text: string) void {
p.print("(() => { throw (new Error(`Cannot require module ");
p.printQuotedUTF8(text, false);
p.print("`)); } )()");
}
+ pub inline fn importRecord(
+ p: *const Printer,
+ import_record_index: usize,
+ ) *const ImportRecord {
+ return &p.import_records[import_record_index];
+ }
+
pub fn printRequireOrImportExpr(
p: *Printer,
import_record_index: u32,
leading_interior_comments: []G.Comment,
- level: Level,
+ level_: Level,
flags: ExprFlag.Set,
) void {
+ var level = level_;
const wrap = level.gte(.new) or flags.contains(.forbid_call);
if (wrap) p.print("(");
defer if (wrap) p.print(")");
assert(p.import_records.len > import_record_index);
- const record = &p.import_records[import_record_index];
+ const record = p.importRecord(import_record_index);
if (comptime is_bun_platform) {
// "bun" is not a real module. It's just globalThis.Bun.
@@ -1492,6 +1682,86 @@ pub fn NewPrinter(
}
}
+ if (record.source_index.isValid()) {
+ var meta = p.options.requireOrImportMetaForSource(record.source_index.get());
+
+ // Don't need the namespace object if the result is unused anyway
+ if (flags.contains(.expr_result_is_unused)) {
+ meta.exports_ref = Ref.None;
+ }
+
+ // Internal "import()" of async ESM
+ if (record.kind == .dynamic and meta.is_wrapper_async) {
+ p.printSpaceBeforeIdentifier();
+ p.printSymbol(meta.wrapper_ref);
+ p.print("()");
+ if (meta.exports_ref.isValid()) {
+ _ = p.printDotThenPrefix();
+ p.printSpaceBeforeIdentifier();
+ p.printSymbol(meta.exports_ref);
+ p.printDotThenSuffix();
+ }
+ return;
+ }
+
+ // Internal "require()" or "import()"
+ if (record.kind == .dynamic) {
+ p.printSpaceBeforeIdentifier();
+ p.print("Promise.resolve()");
+
+ level = p.printDotThenPrefix();
+ }
+ defer if (record.kind == .dynamic) p.printDotThenSuffix();
+
+ // Make sure the comma operator is propertly wrapped
+
+ if (meta.exports_ref.isValid() and level.gte(.comma)) {
+ p.print("(");
+ }
+ defer if (meta.exports_ref.isValid() and level.gte(.comma)) p.print(")");
+
+ // Wrap this with a call to "__toESM()" if this is a CommonJS file
+ const wrap_with_to_esm = record.wrap_with_to_esm;
+ if (wrap_with_to_esm) {
+ p.printSpaceBeforeIdentifier();
+ p.printSymbol(p.options.to_esm_ref);
+ p.print("(");
+ }
+
+ // Call the wrapper
+ p.printSpaceBeforeIdentifier();
+ p.printSymbol(meta.wrapper_ref);
+ p.print("()");
+
+ // Return the namespace object if this is an ESM file
+ if (meta.exports_ref.isValid()) {
+ p.print(",");
+ p.printSpace();
+
+ // Wrap this with a call to "__toCommonJS()" if this is an ESM file
+ const wrap_with_to_cjs = record.wrap_with_to_commonjs;
+ if (wrap_with_to_cjs) {
+ p.printSymbol(p.options.to_commonjs_ref);
+ p.print("(");
+ }
+ p.printSymbol(meta.exports_ref);
+ if (wrap_with_to_cjs) {
+ p.print(")");
+ }
+ }
+
+ if (wrap_with_to_esm) {
+ if (p.options.module_type.isESM()) {
+ p.print(",");
+ p.printSpace();
+ p.print("1");
+ }
+ p.print(")");
+ }
+
+ return;
+ }
+
const is_external = std.mem.indexOfScalar(
u32,
p.options.externals,
@@ -1531,6 +1801,7 @@ pub fn NewPrinter(
p.addSourceMapping(record.range.loc);
p.printSpaceBeforeIdentifier();
+
// Allow it to fail at runtime, if it should
p.print("import(");
p.printImportRecordPath(record);
@@ -1657,6 +1928,23 @@ pub fn NewPrinter(
p.addSourceMapping(expr.loc);
p.print("import.meta");
},
+ .e_commonjs_export_identifier => |id| {
+ p.printSpaceBeforeIdentifier();
+ p.addSourceMapping(expr.loc);
+
+ for (p.options.commonjs_named_exports.keys(), p.options.commonjs_named_exports.values()) |key, value| {
+ if (value.loc_ref.ref.?.eql(id.ref)) {
+ if (value.needs_decl) {
+ p.printSymbol(p.options.commonjs_named_exports_ref);
+ p.print(".");
+ p.print(key);
+ } else {
+ p.printSymbol(value.loc_ref.ref.?);
+ }
+ break;
+ }
+ }
+ },
.e_new => |e| {
const has_pure_comment = e.can_be_unwrapped_if_unused;
const wrap = level.gte(.call) or (has_pure_comment and level.gte(.postfix));
@@ -1779,14 +2067,14 @@ pub fn NewPrinter(
}
},
.e_require => |e| {
- if (rewrite_esm_to_cjs and p.import_records[e.import_record_index].is_bundled) {
+ if (rewrite_esm_to_cjs and p.importRecord(e.import_record_index).is_bundled) {
p.printIndent();
p.printBundledRequire(e);
p.printSemicolonIfNeeded();
return;
}
- if (!rewrite_esm_to_cjs or !p.import_records[e.import_record_index].is_bundled) {
+ if (!rewrite_esm_to_cjs or !p.importRecord(e.import_record_index).is_bundled) {
p.printRequireOrImportExpr(e.import_record_index, &([_]G.Comment{}), level, flags);
}
},
@@ -1794,7 +2082,7 @@ pub fn NewPrinter(
if (p.options.rewrite_require_resolve) {
// require.resolve("../src.js") => "../src.js"
p.printSpaceBeforeIdentifier();
- p.printQuotedUTF8(p.import_records[e.import_record_index].path.text, true);
+ p.printQuotedUTF8(p.importRecord(e.import_record_index).path.text, true);
} else {
const wrap = level.gte(.new) or flags.contains(.forbid_call);
if (wrap) {
@@ -1803,7 +2091,7 @@ pub fn NewPrinter(
p.printSpaceBeforeIdentifier();
p.print("require.resolve(");
- p.printQuotedUTF8(p.import_records[e.import_record_index].path.text, true);
+ p.printQuotedUTF8(p.importRecord(e.import_record_index).path.text, true);
p.print(")");
if (wrap) {
@@ -1814,7 +2102,7 @@ pub fn NewPrinter(
.e_import => |e| {
// Handle non-string expressions
- if (Ref.isSourceIndexNull(e.import_record_index)) {
+ if (e.isImportRecordNull()) {
const wrap = level.gte(.new) or flags.contains(.forbid_call);
if (wrap) {
p.print("(");
@@ -2285,40 +2573,76 @@ pub fn NewPrinter(
// Potentially use a property access instead of an identifier
var didPrint = false;
- if (p.symbols.getWithLink(e.ref)) |symbol| {
+ if (p.symbols().getWithLink(e.ref)) |symbol| {
if (symbol.import_item_status == .missing) {
p.addSourceMapping(expr.loc);
p.printUndefined(level);
didPrint = true;
} else if (symbol.namespace_alias) |namespace| {
- const import_record = p.import_records[namespace.import_record_index];
- if ((comptime is_inside_bundle) or import_record.is_bundled or namespace.was_originally_property_access) {
- var wrap = false;
- didPrint = true;
+ if (namespace.import_record_index < p.import_records.len) {
+ const import_record = p.importRecord(namespace.import_record_index);
+ if ((comptime is_inside_bundle) or import_record.is_bundled or namespace.was_originally_property_access) {
+ var wrap = false;
+ didPrint = true;
+
+ if (p.call_target) |target| {
+ wrap = e.was_originally_identifier and (target == .e_identifier and
+ target.e_identifier.ref.eql(expr.data.e_import_identifier.ref));
+ }
+
+ if (wrap) {
+ p.printWhitespacer(ws("(0, "));
+ }
+ p.addSourceMapping(expr.loc);
+ p.printNamespaceAlias(import_record.*, namespace);
- if (p.call_target) |target| {
- wrap = e.was_originally_identifier and (target == .e_identifier and
- target.e_identifier.ref.eql(expr.data.e_import_identifier.ref));
+ if (wrap) {
+ p.print(")");
+ }
+ } else if (import_record.was_originally_require and import_record.path.is_disabled) {
+ p.addSourceMapping(expr.loc);
+
+ if (import_record.handles_import_errors) {
+ p.printRequireError(import_record.path.text);
+ } else {
+ p.printDisabledImport();
+ }
+ didPrint = true;
}
+ }
+
+ if (!didPrint) {
+ didPrint = true;
+
+ const wrap = if (p.call_target) |target|
+ e.was_originally_identifier and (target == .e_identifier and
+ target.e_identifier.ref.eql(expr.data.e_import_identifier.ref))
+ else
+ false;
if (wrap) {
p.printWhitespacer(ws("(0, "));
}
+
+ p.printSpaceBeforeIdentifier();
p.addSourceMapping(expr.loc);
- p.printNamespaceAlias(import_record, namespace);
+ p.printSymbol(namespace.namespace_ref);
+ const alias = namespace.alias;
+ if (p.canPrintIdentifier(alias)) {
+ p.print(".");
+ // TODO: addSourceMappingForName
+ p.printIdentifier(alias);
+ } else {
+ p.print("[");
+ // TODO: addSourceMappingForName
+ // p.addSourceMappingForName(alias);
+ p.printQuotedUTF8(alias, true);
+ p.print("]");
+ }
if (wrap) {
p.print(")");
}
- } else if (import_record.was_originally_require and import_record.path.is_disabled) {
- p.addSourceMapping(expr.loc);
-
- if (import_record.handles_import_errors) {
- p.printRequireError(import_record.path.text);
- } else {
- p.printDisabledImport();
- }
- didPrint = true;
}
}
}
@@ -2500,6 +2824,12 @@ pub fn NewPrinter(
p.printSpace();
flags.insert(.forbid_in);
+
+ // this feels like a hack? I think something is wrong here.
+ if (e.op == .bin_assign) {
+ flags.remove(.expr_result_is_unused);
+ }
+
p.printExpr(e.right, right_level, flags);
if (wrap) {
@@ -2840,8 +3170,8 @@ pub fn NewPrinter(
}
},
.e_import_identifier => |e| {
- const ref = p.symbols.follow(e.ref);
- if (p.symbols.get(ref)) |symbol| {
+ const ref = p.symbols().follow(e.ref);
+ if (p.symbols().get(ref)) |symbol| {
if (symbol.namespace_alias == null and strings.eql(key.data, p.renamer.nameForSymbol(e.ref))) {
if (item.initializer) |initial| {
p.printInitializer(initial);
@@ -2877,8 +3207,8 @@ pub fn NewPrinter(
// if (strings) {}
},
.e_import_identifier => |e| {
- const ref = p.symbols.follow(e.ref);
- if (p.symbols.get(ref)) |symbol| {
+ const ref = p.symbols().follow(e.ref);
+ if (p.symbols().get(ref)) |symbol| {
if (symbol.namespace_alias == null and strings.utf16EqlString(key.slice16(), p.renamer.nameForSymbol(e.ref))) {
if (item.initializer) |initial| {
p.printInitializer(initial);
@@ -3363,7 +3693,7 @@ pub fn NewPrinter(
}
p.printWhitespacer(ws("from "));
- p.printImportRecordPath(&p.import_records[s.import_record_index]);
+ p.printImportRecordPath(p.importRecord(s.import_record_index));
p.printSemicolonAfterStatement();
},
.s_export_clause => |s| {
@@ -3393,16 +3723,16 @@ pub fn NewPrinter(
p.printSpace();
const last = s.items.len - 1;
for (s.items, 0..) |item, i| {
- const symbol = p.symbols.getWithLink(item.name.ref.?).?;
+ const symbol = p.symbols().getWithLink(item.name.ref.?).?;
const name = symbol.original_name;
var did_print = false;
if (symbol.namespace_alias) |namespace| {
- const import_record = p.import_records[namespace.import_record_index];
+ const import_record = p.importRecord(namespace.import_record_index);
if (import_record.is_bundled or (comptime is_inside_bundle) or namespace.was_originally_property_access) {
p.printIdentifier(name);
p.print(": () => ");
- p.printNamespaceAlias(import_record, namespace);
+ p.printNamespaceAlias(import_record.*, namespace);
did_print = true;
}
}
@@ -3467,14 +3797,14 @@ pub fn NewPrinter(
const item: js_ast.ClauseItem = array.items[i];
if (item.original_name.len > 0) {
- if (p.symbols.get(item.name.ref.?)) |symbol| {
+ if (p.symbols().get(item.name.ref.?)) |symbol| {
if (symbol.namespace_alias) |namespace| {
- const import_record = p.import_records[namespace.import_record_index];
+ const import_record = p.importRecord(namespace.import_record_index);
if (import_record.is_bundled or (comptime is_inside_bundle) or namespace.was_originally_property_access) {
p.print("var ");
p.printSymbol(item.name.ref.?);
p.@"print = "();
- p.printNamespaceAlias(import_record, namespace);
+ p.printNamespaceAlias(import_record.*, namespace);
p.printSemicolonAfterStatement();
_ = array.swapRemove(i);
@@ -3583,7 +3913,7 @@ pub fn NewPrinter(
p.printIndent();
p.printSpaceBeforeIdentifier();
- const import_record = p.import_records[s.import_record_index];
+ const import_record = p.importRecord(s.import_record_index);
if (comptime is_bun_platform) {
if (import_record.do_commonjs_transform_in_printer) {
@@ -3610,7 +3940,7 @@ pub fn NewPrinter(
}
p.print("}=import.meta.require(");
- p.printImportRecordPath(&import_record);
+ p.printImportRecordPath(import_record);
p.print(")");
p.printSemicolonAfterStatement();
p.printWhitespacer(ws("export {"));
@@ -3673,7 +4003,7 @@ pub fn NewPrinter(
}
p.printWhitespacer(ws("} from "));
- p.printImportRecordPath(&import_record);
+ p.printImportRecordPath(import_record);
p.printSemicolonAfterStatement();
},
.s_local => |s| {
@@ -3895,7 +4225,7 @@ pub fn NewPrinter(
.s_import => |s| {
std.debug.assert(s.import_record_index < p.import_records.len);
- const record: *const ImportRecord = &p.import_records[s.import_record_index];
+ const record: *const ImportRecord = p.importRecord(s.import_record_index);
switch (record.print_mode) {
.css => {
@@ -4004,6 +4334,71 @@ pub fn NewPrinter(
const module_id = record.module_id;
+ if (comptime is_bun_platform) {
+ if (!record.path.is_disabled) {
+ if (record.contains_import_star) {
+ p.print("var ");
+ p.printSymbol(s.namespace_ref);
+ p.@"print = "();
+ p.print("import.meta.require(");
+ p.printImportRecordPath(record);
+ p.print(")");
+ p.printSemicolonAfterStatement();
+ }
+
+ if (s.items.len > 0 or s.default_name != null) {
+ p.printIndent();
+ p.printSpaceBeforeIdentifier();
+ p.printWhitespacer(ws("var {"));
+
+ if (s.default_name) |default_name| {
+ p.printSpace();
+ p.print("default:");
+ p.printSpace();
+ p.printSymbol(default_name.ref.?);
+
+ if (s.items.len > 0) {
+ p.printSpace();
+ p.print(",");
+ p.printSpace();
+ for (s.items, 0..) |item, i| {
+ p.printClauseItemAs(item, .@"var");
+
+ if (i < s.items.len - 1) {
+ p.print(",");
+ p.printSpace();
+ }
+ }
+ }
+ } else {
+ for (s.items, 0..) |item, i| {
+ p.printClauseItemAs(item, .@"var");
+
+ if (i < s.items.len - 1) {
+ p.print(",");
+ p.printSpace();
+ }
+ }
+ }
+
+ p.print("}");
+ p.@"print = "();
+
+ if (record.contains_import_star) {
+ p.printSymbol(s.namespace_ref);
+ p.printSemicolonAfterStatement();
+ } else {
+ p.print("import.meta.require(");
+ p.printImportRecordPath(record);
+ p.print(")");
+ p.printSemicolonAfterStatement();
+ }
+ }
+
+ return;
+ }
+ }
+
if (!record.path.is_disabled and std.mem.indexOfScalar(u32, p.imported_module_ids.items, module_id) == null) {
p.printWhitespacer(ws("import * as "));
p.printModuleId(module_id);
@@ -4293,7 +4688,13 @@ pub fn NewPrinter(
unreachable;
const quote = bestQuoteCharForString(u8, import_record.path.text, false);
- if (import_record.print_namespace_in_path and import_record.path.namespace.len > 0 and !strings.eqlComptime(import_record.path.namespace, "file")) {
+ if (import_record.print_namespace_in_path and import_record.module_id != 0) {
+ p.print(quote);
+ p.print(import_record.path.namespace);
+ p.print(":");
+ p.printModuleIdAssumeEnabled(import_record.module_id);
+ p.print(quote);
+ } else if (import_record.print_namespace_in_path and import_record.path.namespace.len > 0 and !strings.eqlComptime(import_record.path.namespace, "file")) {
p.print(quote);
p.print(import_record.path.namespace);
p.print(":");
@@ -4306,12 +4707,12 @@ pub fn NewPrinter(
}
}
- pub fn printBundledImport(p: *Printer, record: importRecord.ImportRecord, s: *S.Import) void {
+ pub fn printBundledImport(p: *Printer, record: ImportRecord, s: *S.Import) void {
if (record.is_internal) {
return;
}
- const import_record = p.import_records[s.import_record_index];
+ const import_record = p.importRecord(s.import_record_index);
const is_disabled = import_record.path.is_disabled;
const module_id = import_record.module_id;
@@ -4319,7 +4720,7 @@ pub fn NewPrinter(
// we can skip it
if (record.path.is_disabled) {
- if (p.symbols.get(s.namespace_ref) == null)
+ if (p.symbols().get(s.namespace_ref) == null)
return;
}
@@ -4417,13 +4818,13 @@ pub fn NewPrinter(
}
pub fn printLoadFromBundleWithoutCall(p: *Printer, import_record_index: u32) void {
- const record = p.import_records[import_record_index];
+ const record = p.importRecord(import_record_index);
if (record.path.is_disabled) {
p.printDisabledImport();
return;
}
- @call(.always_inline, printModuleId, .{ p, p.import_records[import_record_index].module_id });
+ @call(.always_inline, printModuleId, .{ p, p.importRecord(import_record_index).module_id });
}
pub fn printCallModuleID(p: *Printer, module_id: u32) void {
@@ -4442,7 +4843,7 @@ pub fn NewPrinter(
}
pub fn printBundledRequire(p: *Printer, require: E.Require) void {
- if (p.import_records[require.import_record_index].is_internal) {
+ if (p.importRecord(require.import_record_index).is_internal) {
return;
}
@@ -4821,13 +5222,11 @@ pub fn NewPrinter(
pub fn init(
writer: Writer,
- tree: *const Ast,
- source: *const logger.Source,
- symbols: Symbol.Map,
+ import_records: []const ImportRecord,
opts: Options,
- linker: ?*Linker,
- allocator: std.mem.Allocator,
- ) !Printer {
+ renamer: bun.renamer.Renamer,
+ source_map_builder: SourceMap.Chunk.Builder,
+ ) Printer {
if (imported_module_ids_list_unset) {
imported_module_ids_list = std.ArrayList(u32).init(default_allocator);
imported_module_ids_list_unset = false;
@@ -4835,31 +5234,24 @@ pub fn NewPrinter(
imported_module_ids_list.clearRetainingCapacity();
- var source_map_builder: SourceMap.Chunk.Builder = undefined;
-
- if (comptime generate_source_map) {
- source_map_builder = SourceMap.Chunk.Builder{
- .source_map = SourceMap.Chunk.Builder.SourceMapper.init(allocator, is_bun_platform),
- .cover_lines_without_mappings = true,
- .prepend_count = is_bun_platform,
- };
- source_map_builder.line_offset_tables = SourceMap.LineOffsetTable.generate(allocator, source.contents, @intCast(i32, tree.approximate_newline_count));
- }
-
return Printer{
- .import_records = tree.import_records,
+ .import_records = import_records,
.options = opts,
- .symbols = symbols,
.writer = writer,
- .linker = linker,
.imported_module_ids = imported_module_ids_list,
- .renamer = rename.Renamer.init(symbols, source),
+ .renamer = renamer,
.source_map_builder = source_map_builder,
};
}
};
}
+pub const WriteResult = struct {
+ off: u32,
+ len: usize,
+ end_off: u32,
+};
+
pub fn NewWriter(
comptime ContextType: type,
comptime writeByte: fn (ctx: *ContextType, char: u8) anyerror!usize,
@@ -5252,6 +5644,34 @@ pub const Format = enum {
cjs_ascii,
};
+fn getSourceMapBuilder(
+ comptime generate_source_map: bool,
+ comptime is_bun_platform: bool,
+ opts: Options,
+ source: *const logger.Source,
+ tree: *const Ast,
+) SourceMap.Chunk.Builder {
+ if (comptime !generate_source_map)
+ return undefined;
+
+ return .{
+ .source_map = SourceMap.Chunk.Builder.SourceMapper.init(
+ opts.allocator,
+ is_bun_platform,
+ ),
+ .cover_lines_without_mappings = true,
+ .prepend_count = is_bun_platform,
+ .line_offset_tables = SourceMap.LineOffsetTable.generate(
+ opts.allocator,
+ source.contents,
+ @intCast(
+ i32,
+ tree.approximate_newline_count,
+ ),
+ ),
+ };
+}
+
pub fn printAst(
comptime Writer: type,
_writer: Writer,
@@ -5260,14 +5680,13 @@ pub fn printAst(
source: *const logger.Source,
comptime ascii_only: bool,
opts: Options,
- comptime LinkerType: type,
- linker: ?*LinkerType,
comptime generate_source_map: bool,
) !usize {
+ var renamer = rename.NoOpRenamer.init(symbols, source);
+
const PrinterType = NewPrinter(
ascii_only,
Writer,
- LinkerType,
false,
// if it's ascii_only, it is also bun
ascii_only,
@@ -5277,14 +5696,12 @@ pub fn printAst(
);
var writer = _writer;
- var printer = try PrinterType.init(
+ var printer = PrinterType.init(
writer,
- &tree,
- source,
- symbols,
+ tree.import_records.slice(),
opts,
- linker,
- opts.allocator,
+ renamer.toRenamer(),
+ getSourceMapBuilder(generate_source_map, ascii_only, opts, source, &tree),
);
defer {
imported_module_ids_list = printer.imported_module_ids;
@@ -5299,7 +5716,7 @@ pub fn printAst(
}
}
- for (tree.parts) |part| {
+ for (tree.parts.slice()) |part| {
for (part.stmts) |stmt| {
printer.printSemicolonIfNeeded();
try printer.printStmt(stmt);
@@ -5326,7 +5743,7 @@ pub fn printJSON(
expr: Expr,
source: *const logger.Source,
) !usize {
- const PrinterType = NewPrinter(false, Writer, void, false, false, false, true, false);
+ const PrinterType = NewPrinter(false, Writer, false, false, false, true, false);
var writer = _writer;
var s_expr = S.SExpr{ .value = expr };
var stmt = Stmt{ .loc = logger.Loc.Empty, .data = .{
@@ -5335,17 +5752,16 @@ pub fn printJSON(
var stmts = &[_]js_ast.Stmt{stmt};
var parts = &[_]js_ast.Part{.{ .stmts = stmts }};
const ast = Ast.initTest(parts);
- var arena = std.heap.ArenaAllocator.init(bun.default_allocator);
- defer arena.deinit();
- var allocator = arena.allocator();
- var printer = try PrinterType.init(
+ var list = js_ast.Symbol.List.init(ast.symbols.slice());
+ var nested_list = js_ast.Symbol.NestedList.init(&[_]js_ast.Symbol.List{list});
+ var renamer = rename.NoOpRenamer.init(js_ast.Symbol.Map.initList(nested_list), source);
+
+ var printer = PrinterType.init(
writer,
- &ast,
- source,
- std.mem.zeroes(Symbol.Map),
+ ast.import_records.slice(),
.{},
- null,
- allocator,
+ renamer.toRenamer(),
+ undefined,
);
printer.printExpr(expr, Level.lowest, ExprFlag.Set{});
@@ -5357,6 +5773,105 @@ pub fn printJSON(
return @intCast(usize, @max(printer.writer.written, 0));
}
+pub fn print(
+ allocator: std.mem.Allocator,
+ platform: options.Platform,
+ opts: Options,
+ import_records: []const ImportRecord,
+ parts: []const js_ast.Part,
+ renamer: bun.renamer.Renamer,
+) PrintResult {
+ var buffer_writer = BufferWriter.init(allocator) catch |err| return .{ .err = err };
+ var buffer_printer = BufferPrinter.init(buffer_writer);
+
+ return printWithWriter(
+ *BufferPrinter,
+ &buffer_printer,
+ platform,
+ opts,
+ import_records,
+ parts,
+ renamer,
+ );
+}
+
+pub fn printWithWriter(
+ comptime Writer: type,
+ _writer: Writer,
+ platform: options.Platform,
+ opts: Options,
+ import_records: []const ImportRecord,
+ parts: []const js_ast.Part,
+ renamer: bun.renamer.Renamer,
+) PrintResult {
+ return switch (platform.isBun()) {
+ inline else => |is_bun_platform| printWithWriterAndPlatform(
+ Writer,
+ _writer,
+ is_bun_platform,
+ opts,
+ import_records,
+ parts,
+ renamer,
+ ),
+ };
+}
+
+/// The real one
+pub fn printWithWriterAndPlatform(
+ comptime Writer: type,
+ _writer: Writer,
+ comptime is_bun_platform: bool,
+ opts: Options,
+ import_records: []const ImportRecord,
+ parts: []const js_ast.Part,
+ renamer: bun.renamer.Renamer,
+) PrintResult {
+ const PrinterType = NewPrinter(
+ false,
+ Writer,
+ false,
+ is_bun_platform,
+ false,
+ false,
+ false,
+ );
+ var writer = _writer;
+ var printer = PrinterType.init(
+ writer,
+ import_records,
+ opts,
+ renamer,
+ undefined,
+ );
+ defer printer.temporary_bindings.deinit(bun.default_allocator);
+ defer _writer.* = printer.writer.*;
+ defer {
+ imported_module_ids_list = printer.imported_module_ids;
+ }
+
+ for (parts) |part| {
+ for (part.stmts) |stmt| {
+ printer.printSemicolonIfNeeded();
+ printer.printStmt(stmt) catch |err| {
+ return .{ .err = err };
+ };
+ if (printer.writer.getError()) {} else |err| {
+ return .{ .err = err };
+ }
+ }
+ }
+
+ printer.writer.done() catch |err|
+ return .{ .err = err };
+
+ return .{
+ .result = .{
+ .code = writer.ctx.getWritten(),
+ },
+ };
+}
+
pub fn printCommonJS(
comptime Writer: type,
_writer: Writer,
@@ -5365,20 +5880,17 @@ pub fn printCommonJS(
source: *const logger.Source,
comptime ascii_only: bool,
opts: Options,
- comptime LinkerType: type,
- linker: ?*LinkerType,
comptime generate_source_map: bool,
) !usize {
- const PrinterType = NewPrinter(ascii_only, Writer, LinkerType, true, false, false, false, generate_source_map);
+ const PrinterType = NewPrinter(ascii_only, Writer, true, false, false, false, generate_source_map);
var writer = _writer;
- var printer = try PrinterType.init(
+ var renamer = rename.NoOpRenamer.init(symbols, source);
+ var printer = PrinterType.init(
writer,
- &tree,
- source,
- symbols,
+ tree.import_records.slice(),
opts,
- linker,
- opts.allocator,
+ renamer.toRenamer(),
+ getSourceMapBuilder(generate_source_map, false, opts, source, &tree),
);
defer {
imported_module_ids_list = printer.imported_module_ids;
@@ -5393,7 +5905,7 @@ pub fn printCommonJS(
}
}
}
- for (tree.parts) |part| {
+ for (tree.parts.slice()) |part| {
for (part.stmts) |stmt| {
printer.printSemicolonIfNeeded();
try printer.printStmt(stmt);
@@ -5417,11 +5929,23 @@ pub fn printCommonJS(
return @intCast(usize, @max(printer.writer.written, 0));
}
-pub const WriteResult = struct {
- off: u32,
- len: usize,
- end_off: u32,
-};
+// pub fn printChunk(
+// comptime Writer: type,
+// _writer: Writer,
+// tree: Ast,
+// symbols: js_ast.Symbol.Map,
+// opts: Options,
+// ) PrintResult {
+// var writer = _writer;
+// var printer = PrinterType.init(
+// writer,
+// &tree,
+// source,
+// symbols,
+// opts,
+// undefined,
+// );
+// }
pub fn printCommonJSThreaded(
comptime Writer: type,
@@ -5431,23 +5955,20 @@ pub fn printCommonJSThreaded(
source: *const logger.Source,
comptime ascii_only: bool,
opts: Options,
- comptime LinkerType: type,
- linker: ?*LinkerType,
lock: *Lock,
comptime GetPosType: type,
getter: GetPosType,
comptime getPos: fn (ctx: GetPosType) anyerror!u64,
end_off_ptr: *u32,
) !WriteResult {
- const PrinterType = NewPrinter(ascii_only, Writer, LinkerType, true, ascii_only, true, false, false);
+ const PrinterType = NewPrinter(ascii_only, Writer, true, ascii_only, true, false, false);
var writer = _writer;
- var printer = try PrinterType.init(
+ var renamer = rename.NoOpRenamer.init(symbols, source);
+ var printer = PrinterType.init(
writer,
- &tree,
- source,
- symbols,
+ tree.import_records.slice(),
opts,
- linker,
+ renamer.toRenamer(),
undefined,
);
@@ -5464,7 +5985,7 @@ pub fn printCommonJSThreaded(
}
}
- for (tree.parts) |part| {
+ for (tree.parts.slice()) |part| {
for (part.stmts) |stmt| {
printer.printSemicolonIfNeeded();
try printer.printStmt(stmt);
diff --git a/src/jsc.zig b/src/jsc.zig
index 2ac14cde0..483d4015e 100644
--- a/src/jsc.zig
+++ b/src/jsc.zig
@@ -25,7 +25,8 @@ pub const Cloudflare = struct {
};
pub const Jest = @import("./bun.js/test/jest.zig");
pub const API = struct {
- pub const Transpiler = @import("./bun.js/api/transpiler.zig");
+ pub const JSBundler = @import("./bun.js/api/JSBundler.zig").JSBundler;
+ pub const JSTranspiler = @import("./bun.js/api/JSTranspiler.zig");
pub const Server = @import("./bun.js/api/server.zig").Server;
pub const ServerConfig = @import("./bun.js/api/server.zig").ServerConfig;
pub const ServerWebSocket = @import("./bun.js/api/server.zig").ServerWebSocket;
diff --git a/src/json_parser.zig b/src/json_parser.zig
index 956d23262..5eaf4d4d7 100644
--- a/src/json_parser.zig
+++ b/src/json_parser.zig
@@ -4,7 +4,7 @@ const js_lexer = bun.js_lexer;
const importRecord = @import("import_record.zig");
const js_ast = bun.JSAst;
const options = @import("options.zig");
-
+const BabyList = @import("./baby_list.zig").BabyList;
const fs = @import("fs.zig");
const bun = @import("bun");
const string = bun.string;
@@ -605,7 +605,7 @@ pub fn toAST(
return Expr.init(
js_ast.E.Object,
js_ast.E.Object{
- .properties = js_ast.BabyList(G.Property).init(properties[0..property_i]),
+ .properties = BabyList(G.Property).init(properties[0..property_i]),
.is_single_line = property_i <= 1,
},
logger.Loc.Empty,
@@ -671,8 +671,8 @@ pub fn toAST(
}
}
-const JSONParser = JSONLikeParser(js_lexer.JSONOptions{ .is_json = true });
-const RemoteJSONParser = JSONLikeParser(js_lexer.JSONOptions{ .is_json = true, .json_warn_duplicate_keys = false });
+const JSONParser = if (bun.fast_debug_build_mode) TSConfigParser else JSONLikeParser(js_lexer.JSONOptions{ .is_json = true });
+const RemoteJSONParser = if (bun.fast_debug_build_mode) TSConfigParser else JSONLikeParser(js_lexer.JSONOptions{ .is_json = true, .json_warn_duplicate_keys = false });
const DotEnvJSONParser = JSONLikeParser(js_lexer.JSONOptions{
.ignore_leading_escape_sequences = true,
.ignore_trailing_escape_sequences = true,
diff --git a/src/linker.zig b/src/linker.zig
index b8f1da526..a62f59b8c 100644
--- a/src/linker.zig
+++ b/src/linker.zig
@@ -219,22 +219,23 @@ pub const Linker = struct {
var needs_bundle = false;
var had_resolve_errors = false;
var needs_require = false;
+ _ = needs_require;
var node_module_bundle_import_path: ?string = null;
const is_deferred = result.pending_imports.len > 0;
- var import_records = result.ast.import_records;
+ var import_records = result.ast.import_records.listManaged(linker.allocator);
defer {
- result.ast.import_records = import_records;
+ result.ast.import_records = ImportRecord.List.fromList(import_records);
}
// Step 1. Resolve imports & requires
switch (result.loader) {
.jsx, .js, .ts, .tsx => {
var record_i: u32 = 0;
- const record_count = @truncate(u32, import_records.len);
+ const record_count = @truncate(u32, import_records.items.len);
outer: while (record_i < record_count) : (record_i += 1) {
- var import_record = &import_records[record_i];
+ var import_record = &import_records.items[record_i];
if (import_record.is_unused or
(is_bun and is_deferred and !result.isPendingImport(record_i))) continue;
@@ -373,7 +374,6 @@ pub const Linker = struct {
if (node_modules_bundle.getPackage(package_name)) |pkg| {
const import_path = text[@min(text.len, package_name.len + 1)..];
if (node_modules_bundle.findModuleIDInPackageIgnoringExtension(pkg, import_path)) |found_module| {
- import_record.is_bundled = true;
node_module_bundle_import_path = node_module_bundle_import_path orelse
linker.nodeModuleBundleImportPath(origin);
@@ -401,7 +401,6 @@ pub const Linker = struct {
if (node_modules_bundle.getPackage(package_name)) |pkg| {
const import_path = runtime[@min(runtime.len, package_name.len + 1)..];
if (node_modules_bundle.findModuleInPackage(pkg, import_path)) |found_module| {
- import_record.is_bundled = true;
node_module_bundle_import_path = node_module_bundle_import_path orelse
linker.nodeModuleBundleImportPath(origin);
@@ -531,7 +530,6 @@ pub const Linker = struct {
);
}
- import_record.is_bundled = true;
node_module_bundle_import_path = node_module_bundle_import_path orelse
linker.nodeModuleBundleImportPath(origin);
import_record.path.text = node_module_bundle_import_path.?;
@@ -569,8 +567,6 @@ pub const Linker = struct {
if (loader != .napi and resolved_import.shouldAssumeCommonJS(import_record.kind)) {
import_record.do_commonjs_transform_in_printer = true;
import_record.module_id = @truncate(u32, std.hash.Wyhash.hash(0, path.pretty));
- result.ast.needs_runtime = true;
- needs_require = true;
}
} else |err| {
switch (err) {
@@ -800,66 +796,67 @@ pub const Linker = struct {
if (had_resolve_errors) return error.ResolveError;
result.ast.externals = try externals.toOwnedSlice();
- if (result.ast.needs_runtime and (result.ast.runtime_import_record_id == null or import_records.len == 0)) {
- var new_import_records = try linker.allocator.alloc(ImportRecord, import_records.len + 1);
- bun.copy(ImportRecord, new_import_records, import_records);
-
- new_import_records[new_import_records.len - 1] = ImportRecord{
- .kind = .stmt,
- .path = if (linker.options.node_modules_bundle != null)
- Fs.Path.init(node_module_bundle_import_path orelse linker.nodeModuleBundleImportPath(origin))
- else if (import_path_format == .absolute_url)
- Fs.Path.initWithNamespace(try origin.joinAlloc(linker.allocator, "", "", "bun:wrap", "", ""), "bun")
- else
- try linker.generateImportPath(source_dir, Linker.runtime_source_path, false, "bun", origin, import_path_format),
-
- .range = logger.Range{ .loc = logger.Loc{ .start = 0 }, .len = 0 },
- };
- result.ast.runtime_import_record_id = @truncate(u32, new_import_records.len - 1);
- import_records = new_import_records;
- }
-
- // We _assume_ you're importing ESM.
- // But, that assumption can be wrong without parsing code of the imports.
- // That's where in here, we inject
- // > import {require} from 'bun:wrap';
- // Since they definitely aren't using require, we don't have to worry about the symbol being renamed.
- if (needs_require and !result.ast.uses_require_ref) {
- result.ast.uses_require_ref = true;
- const PrependPart = struct {
- stmts: [1]js_ast.Stmt,
- import_statement: js_ast.S.Import,
- clause_items: [1]js_ast.ClauseItem,
- };
- var prepend = linker.allocator.create(PrependPart) catch unreachable;
-
- prepend.* = .{
- .clause_items = .{
- .{
- .alias = require_alias,
- .original_name = "",
- .alias_loc = logger.Loc.Empty,
- .name = js_ast.LocRef{
- .loc = logger.Loc.Empty,
- .ref = result.ast.require_ref,
- },
- },
- },
- .import_statement = .{
- .namespace_ref = Ref.None,
- .items = &prepend.clause_items,
- .import_record_index = result.ast.runtime_import_record_id.?,
- },
- .stmts = undefined,
- };
-
- prepend.stmts[0] = .{
- .data = .{ .s_import = &prepend.import_statement },
- .loc = logger.Loc.Empty,
- };
-
- result.ast.prepend_part = js_ast.Part{ .stmts = &prepend.stmts };
- }
+ // if (result.ast.needs_runtime and (result.ast.runtime_import_record_id == null or import_records.items.len == 0)) {
+ // var new_import_records = try linker.allocator.alloc(ImportRecord, import_records.items.len + 1);
+ // bun.copy(ImportRecord, new_import_records, import_records.items);
+
+ // new_import_records[new_import_records.len - 1] = ImportRecord{
+ // .kind = .stmt,
+ // .path = if (linker.options.node_modules_bundle != null)
+ // Fs.Path.init(node_module_bundle_import_path orelse linker.nodeModuleBundleImportPath(origin))
+ // else if (import_path_format == .absolute_url)
+ // Fs.Path.initWithNamespace(try origin.joinAlloc(linker.allocator, "", "", "bun:wrap", "", ""), "bun")
+ // else
+ // try linker.generateImportPath(source_dir, Linker.runtime_source_path, false, "bun", origin, import_path_format),
+
+ // .range = logger.Range{ .loc = logger.Loc{ .start = 0 }, .len = 0 },
+ // };
+ // result.ast.runtime_import_record_id = @truncate(u32, import_records.items.len - 1);
+ // import_records.items = new_import_records;
+ // import_records.capacity = new_import_records.len;
+ // }
+
+ // // We _assume_ you're importing ESM.
+ // // But, that assumption can be wrong without parsing code of the imports.
+ // // That's where in here, we inject
+ // // > import {require} from 'bun:wrap';
+ // // Since they definitely aren't using require, we don't have to worry about the symbol being renamed.
+ // if (needs_require and !result.ast.uses_require_ref) {
+ // result.ast.uses_require_ref = true;
+ // const PrependPart = struct {
+ // stmts: [1]js_ast.Stmt,
+ // import_statement: js_ast.S.Import,
+ // clause_items: [1]js_ast.ClauseItem,
+ // };
+ // var prepend = linker.allocator.create(PrependPart) catch unreachable;
+
+ // prepend.* = .{
+ // .clause_items = .{
+ // .{
+ // .alias = require_alias,
+ // .original_name = "",
+ // .alias_loc = logger.Loc.Empty,
+ // .name = js_ast.LocRef{
+ // .loc = logger.Loc.Empty,
+ // .ref = result.ast.require_ref,
+ // },
+ // },
+ // },
+ // .import_statement = .{
+ // .namespace_ref = Ref.None,
+ // .items = &prepend.clause_items,
+ // .import_record_index = result.ast.runtime_import_record_id.?,
+ // },
+ // .stmts = undefined,
+ // };
+
+ // prepend.stmts[0] = .{
+ // .data = .{ .s_import = &prepend.import_statement },
+ // .loc = logger.Loc.Empty,
+ // };
+
+ // result.ast.prepend_part = js_ast.Part{ .stmts = &prepend.stmts };
+ // }
}
const ImportPathsList = allocators.BSSStringList(512, 128);
diff --git a/src/logger.zig b/src/logger.zig
index 0da7789b4..5bc8fc7eb 100644
--- a/src/logger.zig
+++ b/src/logger.zig
@@ -15,12 +15,12 @@ const C = bun.C;
const JSC = @import("bun").JSC;
const fs = @import("fs.zig");
const unicode = std.unicode;
-
+const Ref = @import("./ast/base.zig").Ref;
const expect = std.testing.expect;
const assert = std.debug.assert;
const ArrayList = std.ArrayList;
const StringBuilder = @import("./string_builder.zig");
-
+const Index = @import("./ast/base.zig").Index;
pub const Kind = enum(i8) {
err,
warn,
@@ -582,6 +582,10 @@ pub const Log = struct {
msgs: ArrayList(Msg),
level: Level = if (Environment.isDebug) Level.info else Level.warn,
+ pub inline fn hasErrors(this: *const Log) bool {
+ return this.errors > 0;
+ }
+
pub fn reset(this: *Log) void {
this.msgs.clearRetainingCapacity();
this.warnings = 0;
@@ -1147,10 +1151,36 @@ pub inline fn usize2Loc(loc: usize) Loc {
pub const Source = struct {
path: fs.Path,
key_path: fs.Path,
- index: u32 = 0,
+
contents: string,
contents_is_recycled: bool = false,
+ /// Lazily-generated human-readable identifier name that is non-unique
+ /// Avoid accessing this directly most of the time
+ identifier_name: string = "",
+
+ index: Index = Index.source(0),
+
+ pub fn fmtIdentifier(this: *const Source) strings.FormatValidIdentifier {
+ return this.path.name.fmtIdentifier();
+ }
+
+ pub fn identifierName(this: *Source, allocator: std.mem.Allocator) !string {
+ if (this.identifier_name.len > 0) {
+ return this.identifier_name;
+ }
+
+ std.debug.assert(this.path.text.len > 0);
+ const name = try this.path.name.nonUniqueNameString(allocator);
+ this.identifier_name = name;
+ return name;
+ }
+
+ pub fn rangeOfIdentifier(this: *const Source, loc: Loc) Range {
+ const js_lexer = @import("./js_lexer.zig");
+ return js_lexer.rangeOfIdentifier(this, loc);
+ }
+
pub fn isWebAssembly(this: *const Source) bool {
if (this.contents.len < 4) return false;
@@ -1167,7 +1197,7 @@ pub const Source = struct {
pub fn initEmptyFile(filepath: string) Source {
const path = fs.Path.init(filepath);
- return Source{ .path = path, .key_path = path, .index = 0, .contents = "" };
+ return Source{ .path = path, .key_path = path, .contents = "" };
}
pub fn initFile(file: fs.File, _: std.mem.Allocator) !Source {
diff --git a/src/main.zig b/src/main.zig
index ba3fd97d9..0c7cf9584 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -12,6 +12,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, addr
const CrashReporter = @import("./crash_reporter.zig");
pub fn main() void {
+ const bun = @import("root").bun;
const Output = bun.Output;
const Environment = bun.Environment;
@@ -42,4 +43,3 @@ test "panic" {
}
pub const build_options = @import("build_options");
-pub const bun = @import("./bun.zig");
diff --git a/src/meta.zig b/src/meta.zig
index cd171cc29..5bf99bbaa 100644
--- a/src/meta.zig
+++ b/src/meta.zig
@@ -7,7 +7,7 @@ pub fn ReturnOf(comptime function: anytype) type {
}
pub fn ReturnOfType(comptime Type: type) type {
- const typeinfo: std.builtin.Type.Fn = @typeInfo(Type);
+ const typeinfo: std.builtin.Type.Fn = @typeInfo(Type).Fn;
return typeinfo.return_type orelse void;
}
diff --git a/src/mimalloc_arena.zig b/src/mimalloc_arena.zig
index 2de5ce018..37ea2ecc3 100644
--- a/src/mimalloc_arena.zig
+++ b/src/mimalloc_arena.zig
@@ -73,6 +73,60 @@ pub const GlobalArena = struct {
}
};
+const ArenaRegistry = struct {
+ arenas: std.AutoArrayHashMap(?*mimalloc.Heap, std.Thread.Id) = std.AutoArrayHashMap(?*mimalloc.Heap, std.Thread.Id).init(bun.default_allocator),
+ mutex: std.Thread.Mutex = .{},
+
+ var registry = ArenaRegistry{};
+
+ pub fn register(arena: Arena) void {
+ if (comptime Environment.allow_assert) {
+ registry.mutex.lock();
+ defer registry.mutex.unlock();
+ var entry = registry.arenas.getOrPut(arena.heap.?) catch unreachable;
+ const received = std.Thread.getCurrentId();
+
+ if (entry.found_existing) {
+ const expected = entry.value_ptr.*;
+ if (expected != received) {
+ bun.unreachablePanic("Arena created on wrong thread! Expected: {d} received: {d}", .{
+ expected,
+ received,
+ });
+ }
+ }
+ entry.value_ptr.* = received;
+ }
+ }
+
+ pub fn assert(arena: Arena) void {
+ if (comptime Environment.allow_assert) {
+ registry.mutex.lock();
+ defer registry.mutex.unlock();
+ const expected = registry.arenas.get(arena.heap.?) orelse {
+ bun.unreachablePanic("Arena not registered!", .{});
+ };
+ const received = std.Thread.getCurrentId();
+ if (expected != received) {
+ bun.unreachablePanic("Arena accessed on wrong thread! Expected: {d} received: {d}", .{
+ expected,
+ received,
+ });
+ }
+ }
+ }
+
+ pub fn unregister(arena: Arena) void {
+ if (comptime Environment.allow_assert) {
+ registry.mutex.lock();
+ defer registry.mutex.unlock();
+ if (!registry.arenas.swapRemove(arena.heap.?)) {
+ bun.unreachablePanic("Arena not registered!", .{});
+ }
+ }
+ }
+};
+
pub const Arena = struct {
heap: ?*mimalloc.Heap = null,
@@ -95,6 +149,9 @@ pub const Arena = struct {
}
pub fn deinit(this: *Arena) void {
+ if (comptime Environment.allow_assert) {
+ ArenaRegistry.unregister(this.*);
+ }
mimalloc.mi_heap_destroy(this.heap.?);
this.heap = null;
@@ -128,7 +185,11 @@ pub const Arena = struct {
}
pub fn init() !Arena {
- return Arena{ .heap = mimalloc.mi_heap_new() orelse return error.OutOfMemory };
+ const arena = Arena{ .heap = mimalloc.mi_heap_new() orelse return error.OutOfMemory };
+ if (comptime Environment.allow_assert) {
+ ArenaRegistry.register(arena);
+ }
+ return arena;
}
pub fn gc(this: Arena, force: bool) void {
@@ -167,6 +228,8 @@ pub const Arena = struct {
fn alloc(arena: *anyopaque, len: usize, ptr_align: u8, _: usize) ?[*]u8 {
var this = bun.cast(*mimalloc.Heap, arena);
+ // if (comptime Environment.allow_assert)
+ // ArenaRegistry.assert(.{ .heap = this });
return alignedAlloc(this, len, ptr_align);
}
diff --git a/src/multi_array_list.zig b/src/multi_array_list.zig
new file mode 100644
index 000000000..e4249ae4b
--- /dev/null
+++ b/src/multi_array_list.zig
@@ -0,0 +1,724 @@
+// This fork adds a zero() function
+
+const std = @import("std");
+const builtin = @import("builtin");
+const assert = std.debug.assert;
+const meta = std.meta;
+const mem = std.mem;
+const Allocator = mem.Allocator;
+const testing = std.testing;
+
+/// A MultiArrayList stores a list of a struct type.
+/// Instead of storing a single list of items, MultiArrayList
+/// stores separate lists for each field of the struct.
+/// This allows for memory savings if the struct has padding,
+/// and also improves cache usage if only some fields are needed
+/// for a computation. The primary API for accessing fields is
+/// the `slice()` function, which computes the start pointers
+/// for the array of each field. From the slice you can call
+/// `.items(.<field_name>)` to obtain a slice of field values.
+pub fn MultiArrayList(comptime S: type) type {
+ return struct {
+ bytes: [*]align(@alignOf(S)) u8 = undefined,
+ len: usize = 0,
+ capacity: usize = 0,
+
+ pub const Elem = S;
+
+ pub const Field = meta.FieldEnum(S);
+
+ /// A MultiArrayList.Slice contains cached start pointers for each field in the list.
+ /// These pointers are not normally stored to reduce the size of the list in memory.
+ /// If you are accessing multiple fields, call slice() first to compute the pointers,
+ /// and then get the field arrays from the slice.
+ pub const Slice = struct {
+ /// This array is indexed by the field index which can be obtained
+ /// by using @enumToInt() on the Field enum
+ ptrs: [fields.len][*]u8,
+ len: usize,
+ capacity: usize,
+
+ pub fn items(self: Slice, comptime field: Field) []FieldType(field) {
+ const F = FieldType(field);
+ if (self.capacity == 0) {
+ return &[_]F{};
+ }
+ const byte_ptr = self.ptrs[@enumToInt(field)];
+ const casted_ptr: [*]F = if (@sizeOf(F) == 0)
+ undefined
+ else
+ @ptrCast([*]F, @alignCast(@alignOf(F), byte_ptr));
+ return casted_ptr[0..self.len];
+ }
+
+ pub fn toMultiArrayList(self: Slice) Self {
+ if (self.ptrs.len == 0) {
+ return .{};
+ }
+ const unaligned_ptr = self.ptrs[sizes.fields[0]];
+ const aligned_ptr = @alignCast(@alignOf(S), unaligned_ptr);
+ const casted_ptr = @ptrCast([*]align(@alignOf(S)) u8, aligned_ptr);
+ return .{
+ .bytes = casted_ptr,
+ .len = self.len,
+ .capacity = self.capacity,
+ };
+ }
+
+ pub fn deinit(self: *Slice, gpa: Allocator) void {
+ var other = self.toMultiArrayList();
+ other.deinit(gpa);
+ self.* = undefined;
+ }
+ };
+
+ const Self = @This();
+
+ const fields = meta.fields(S);
+ /// `sizes.bytes` is an array of @sizeOf each S field. Sorted by alignment, descending.
+ /// `sizes.fields` is an array mapping from `sizes.bytes` array index to field index.
+ const sizes = blk: {
+ const Data = struct {
+ size: usize,
+ size_index: usize,
+ alignment: usize,
+ };
+ var data: [fields.len]Data = undefined;
+ for (fields, 0..) |field_info, i| {
+ data[i] = .{
+ .size = @sizeOf(field_info.type),
+ .size_index = i,
+ .alignment = if (@sizeOf(field_info.type) == 0) 1 else field_info.alignment,
+ };
+ }
+ const Sort = struct {
+ fn lessThan(context: void, lhs: Data, rhs: Data) bool {
+ _ = context;
+ return lhs.alignment > rhs.alignment;
+ }
+ };
+ std.sort.sort(Data, &data, {}, Sort.lessThan);
+ var sizes_bytes: [fields.len]usize = undefined;
+ var field_indexes: [fields.len]usize = undefined;
+ for (data, 0..) |elem, i| {
+ sizes_bytes[i] = elem.size;
+ field_indexes[i] = elem.size_index;
+ }
+ break :blk .{
+ .bytes = sizes_bytes,
+ .fields = field_indexes,
+ };
+ };
+
+ /// Release all allocated memory.
+ pub fn deinit(self: *Self, gpa: Allocator) void {
+ gpa.free(self.allocatedBytes());
+ self.* = undefined;
+ }
+
+ /// The caller owns the returned memory. Empties this MultiArrayList.
+ pub fn toOwnedSlice(self: *Self) Slice {
+ const result = self.slice();
+ self.* = .{};
+ return result;
+ }
+
+ /// Compute pointers to the start of each field of the array.
+ /// If you need to access multiple fields, calling this may
+ /// be more efficient than calling `items()` multiple times.
+ pub fn slice(self: Self) Slice {
+ var result: Slice = .{
+ .ptrs = undefined,
+ .len = self.len,
+ .capacity = self.capacity,
+ };
+ var ptr: [*]u8 = self.bytes;
+ for (sizes.bytes, 0..) |field_size, i| {
+ result.ptrs[sizes.fields[i]] = ptr;
+ ptr += field_size * self.capacity;
+ }
+ return result;
+ }
+
+ /// Get the slice of values for a specified field.
+ /// If you need multiple fields, consider calling slice()
+ /// instead.
+ pub fn items(self: Self, comptime field: Field) []FieldType(field) {
+ return self.slice().items(field);
+ }
+
+ /// Overwrite one array element with new data.
+ pub fn set(self: *Self, index: usize, elem: S) void {
+ const slices = self.slice();
+ inline for (fields, 0..) |field_info, i| {
+ slices.items(@intToEnum(Field, i))[index] = @field(elem, field_info.name);
+ }
+ }
+
+ /// Obtain all the data for one array element.
+ pub fn get(self: Self, index: usize) S {
+ const slices = self.slice();
+ var result: S = undefined;
+ inline for (fields, 0..) |field_info, i| {
+ @field(result, field_info.name) = slices.items(@intToEnum(Field, i))[index];
+ }
+ return result;
+ }
+
+ /// Extend the list by 1 element. Allocates more memory as necessary.
+ pub fn append(self: *Self, gpa: Allocator, elem: S) !void {
+ try self.ensureUnusedCapacity(gpa, 1);
+ self.appendAssumeCapacity(elem);
+ }
+
+ /// Extend the list by 1 element, but asserting `self.capacity`
+ /// is sufficient to hold an additional item.
+ pub fn appendAssumeCapacity(self: *Self, elem: S) void {
+ assert(self.len < self.capacity);
+ self.len += 1;
+ self.set(self.len - 1, elem);
+ }
+
+ /// Extend the list by 1 element, returning the newly reserved
+ /// index with uninitialized data.
+ /// Allocates more memory as necesasry.
+ pub fn addOne(self: *Self, allocator: Allocator) Allocator.Error!usize {
+ try self.ensureUnusedCapacity(allocator, 1);
+ return self.addOneAssumeCapacity();
+ }
+
+ /// Extend the list by 1 element, asserting `self.capacity`
+ /// is sufficient to hold an additional item. Returns the
+ /// newly reserved index with uninitialized data.
+ pub fn addOneAssumeCapacity(self: *Self) usize {
+ assert(self.len < self.capacity);
+ const index = self.len;
+ self.len += 1;
+ return index;
+ }
+
+ /// Remove and return the last element from the list.
+ /// Asserts the list has at least one item.
+ /// Invalidates pointers to fields of the removed element.
+ pub fn pop(self: *Self) S {
+ const val = self.get(self.len - 1);
+ self.len -= 1;
+ return val;
+ }
+
+ /// Remove and return the last element from the list, or
+ /// return `null` if list is empty.
+ /// Invalidates pointers to fields of the removed element, if any.
+ pub fn popOrNull(self: *Self) ?S {
+ if (self.len == 0) return null;
+ return self.pop();
+ }
+
+ /// Inserts an item into an ordered list. Shifts all elements
+ /// after and including the specified index back by one and
+ /// sets the given index to the specified element. May reallocate
+ /// and invalidate iterators.
+ pub fn insert(self: *Self, gpa: Allocator, index: usize, elem: S) !void {
+ try self.ensureUnusedCapacity(gpa, 1);
+ self.insertAssumeCapacity(index, elem);
+ }
+
+ /// Inserts an item into an ordered list which has room for it.
+ /// Shifts all elements after and including the specified index
+ /// back by one and sets the given index to the specified element.
+ /// Will not reallocate the array, does not invalidate iterators.
+ pub fn insertAssumeCapacity(self: *Self, index: usize, elem: S) void {
+ assert(self.len < self.capacity);
+ assert(index <= self.len);
+ self.len += 1;
+ const slices = self.slice();
+ inline for (fields, 0..) |field_info, field_index| {
+ const field_slice = slices.items(@intToEnum(Field, field_index));
+ var i: usize = self.len - 1;
+ while (i > index) : (i -= 1) {
+ field_slice[i] = field_slice[i - 1];
+ }
+ field_slice[index] = @field(elem, field_info.name);
+ }
+ }
+
+ /// Remove the specified item from the list, swapping the last
+ /// item in the list into its position. Fast, but does not
+ /// retain list ordering.
+ pub fn swapRemove(self: *Self, index: usize) void {
+ const slices = self.slice();
+ inline for (fields, 0..) |_, i| {
+ const field_slice = slices.items(@intToEnum(Field, i));
+ field_slice[index] = field_slice[self.len - 1];
+ field_slice[self.len - 1] = undefined;
+ }
+ self.len -= 1;
+ }
+
+ /// Remove the specified item from the list, shifting items
+ /// after it to preserve order.
+ pub fn orderedRemove(self: *Self, index: usize) void {
+ const slices = self.slice();
+ inline for (fields, 0..) |_, field_index| {
+ const field_slice = slices.items(@intToEnum(Field, field_index));
+ var i = index;
+ while (i < self.len - 1) : (i += 1) {
+ field_slice[i] = field_slice[i + 1];
+ }
+ field_slice[i] = undefined;
+ }
+ self.len -= 1;
+ }
+
+ /// Adjust the list's length to `new_len`.
+ /// Does not initialize added items, if any.
+ pub fn resize(self: *Self, gpa: Allocator, new_len: usize) !void {
+ try self.ensureTotalCapacity(gpa, new_len);
+ self.len = new_len;
+ }
+
+ /// Attempt to reduce allocated capacity to `new_len`.
+ /// If `new_len` is greater than zero, this may fail to reduce the capacity,
+ /// but the data remains intact and the length is updated to new_len.
+ pub fn shrinkAndFree(self: *Self, gpa: Allocator, new_len: usize) void {
+ if (new_len == 0) {
+ gpa.free(self.allocatedBytes());
+ self.* = .{};
+ return;
+ }
+ assert(new_len <= self.capacity);
+ assert(new_len <= self.len);
+
+ const other_bytes = gpa.alignedAlloc(
+ u8,
+ @alignOf(S),
+ capacityInBytes(new_len),
+ ) catch {
+ const self_slice = self.slice();
+ inline for (fields, 0..) |field_info, i| {
+ if (@sizeOf(field_info.type) != 0) {
+ const field = @intToEnum(Field, i);
+ const dest_slice = self_slice.items(field)[new_len..];
+ const byte_count = dest_slice.len * @sizeOf(field_info.type);
+ // We use memset here for more efficient codegen in safety-checked,
+ // valgrind-enabled builds. Otherwise the valgrind client request
+ // will be repeated for every element.
+ @memset(@ptrCast([*]u8, dest_slice.ptr), undefined, byte_count);
+ }
+ }
+ self.len = new_len;
+ return;
+ };
+ var other = Self{
+ .bytes = other_bytes.ptr,
+ .capacity = new_len,
+ .len = new_len,
+ };
+ self.len = new_len;
+ const self_slice = self.slice();
+ const other_slice = other.slice();
+ inline for (fields, 0..) |field_info, i| {
+ if (@sizeOf(field_info.type) != 0) {
+ const field = @intToEnum(Field, i);
+ mem.copy(field_info.type, other_slice.items(field), self_slice.items(field));
+ }
+ }
+ gpa.free(self.allocatedBytes());
+ self.* = other;
+ }
+
+ /// Reduce length to `new_len`.
+ /// Invalidates pointers to elements `items[new_len..]`.
+ /// Keeps capacity the same.
+ pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void {
+ self.len = new_len;
+ }
+
+ /// Modify the array so that it can hold at least `new_capacity` items.
+ /// Implements super-linear growth to achieve amortized O(1) append operations.
+ /// Invalidates pointers if additional memory is needed.
+ pub fn ensureTotalCapacity(self: *Self, gpa: Allocator, new_capacity: usize) !void {
+ var better_capacity = self.capacity;
+ if (better_capacity >= new_capacity) return;
+
+ while (true) {
+ better_capacity += better_capacity / 2 + 8;
+ if (better_capacity >= new_capacity) break;
+ }
+
+ return self.setCapacity(gpa, better_capacity);
+ }
+
+ /// Modify the array so that it can hold at least `additional_count` **more** items.
+ /// Invalidates pointers if additional memory is needed.
+ pub fn ensureUnusedCapacity(self: *Self, gpa: Allocator, additional_count: usize) !void {
+ return self.ensureTotalCapacity(gpa, self.len + additional_count);
+ }
+
+ /// Modify the array so that it can hold exactly `new_capacity` items.
+ /// Invalidates pointers if additional memory is needed.
+ /// `new_capacity` must be greater or equal to `len`.
+ pub fn setCapacity(self: *Self, gpa: Allocator, new_capacity: usize) !void {
+ assert(new_capacity >= self.len);
+ const new_bytes = try gpa.alignedAlloc(
+ u8,
+ @alignOf(S),
+ capacityInBytes(new_capacity),
+ );
+ if (self.len == 0) {
+ gpa.free(self.allocatedBytes());
+ self.bytes = new_bytes.ptr;
+ self.capacity = new_capacity;
+ return;
+ }
+ var other = Self{
+ .bytes = new_bytes.ptr,
+ .capacity = new_capacity,
+ .len = self.len,
+ };
+ const self_slice = self.slice();
+ const other_slice = other.slice();
+ inline for (fields, 0..) |field_info, i| {
+ if (@sizeOf(field_info.type) != 0) {
+ const field = @intToEnum(Field, i);
+ mem.copy(field_info.type, other_slice.items(field), self_slice.items(field));
+ }
+ }
+ gpa.free(self.allocatedBytes());
+ self.* = other;
+ }
+
+ /// Create a copy of this list with a new backing store,
+ /// using the specified allocator.
+ pub fn clone(self: Self, gpa: Allocator) !Self {
+ var result = Self{};
+ errdefer result.deinit(gpa);
+ try result.ensureTotalCapacity(gpa, self.len);
+ result.len = self.len;
+ const self_slice = self.slice();
+ const result_slice = result.slice();
+ inline for (fields, 0..) |field_info, i| {
+ if (@sizeOf(field_info.type) != 0) {
+ const field = @intToEnum(Field, i);
+ mem.copy(field_info.type, result_slice.items(field), self_slice.items(field));
+ }
+ }
+ return result;
+ }
+
+ pub fn clearRetainingCapacity(this: *Self) void {
+ this.len = 0;
+ }
+
+ /// `ctx` has the following method:
+ /// `fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool`
+ pub fn sort(self: Self, ctx: anytype) void {
+ const SortContext = struct {
+ sub_ctx: @TypeOf(ctx),
+ slice: Slice,
+
+ pub fn swap(sc: @This(), a_index: usize, b_index: usize) void {
+ inline for (fields, 0..) |field_info, i| {
+ if (@sizeOf(field_info.type) != 0) {
+ const field = @intToEnum(Field, i);
+ const ptr = sc.slice.items(field);
+ mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]);
+ }
+ }
+ }
+
+ pub fn lessThan(sc: @This(), a_index: usize, b_index: usize) bool {
+ return sc.sub_ctx.lessThan(a_index, b_index);
+ }
+ };
+
+ std.sort.sortContext(self.len, SortContext{
+ .sub_ctx = ctx,
+ .slice = self.slice(),
+ });
+ }
+
+ fn capacityInBytes(capacity: usize) usize {
+ if (builtin.zig_backend == .stage2_c) {
+ var bytes: usize = 0;
+ for (sizes.bytes) |size| bytes += size * capacity;
+ return bytes;
+ } else {
+ const sizes_vector: @Vector(sizes.bytes.len, usize) = sizes.bytes;
+ const capacity_vector = @splat(sizes.bytes.len, capacity);
+ return @reduce(.Add, capacity_vector * sizes_vector);
+ }
+ }
+
+ pub fn appendListAssumeCapacity(this: *Self, other: Self) void {
+ const offset = this.len;
+ this.len += other.len;
+ const other_slice = other.slice();
+ const this_slice = this.slice();
+ inline for (fields, 0..) |field_info, i| {
+ if (@sizeOf(field_info.type) != 0) {
+ const field = @intToEnum(Field, i);
+ mem.copy(field_info.type, this_slice.items(field)[offset..], other_slice.items(field));
+ }
+ }
+ }
+
+ pub fn appendList(this: *Self, allocator: std.mem.Allocator, other: Self) !void {
+ try this.ensureUnusedCapacity(allocator, other.len);
+ this.appendListAssumeCapacity(other);
+ }
+
+ fn allocatedBytes(self: Self) []align(@alignOf(S)) u8 {
+ return self.bytes[0..capacityInBytes(self.capacity)];
+ }
+
+ pub fn zero(this: *Self) void {
+ var allocated = this.allocatedBytes();
+ if (allocated.len > 0) {
+ @memset(allocated.ptr, 0, allocated.len);
+ }
+ }
+
+ fn FieldType(comptime field: Field) type {
+ return meta.fieldInfo(S, field).type;
+ }
+
+ /// This function is used in tools/zig-gdb.py to fetch the child type to facilitate
+ /// fancy debug printing for this type.
+ fn gdbHelper(self: *Self, child: *S) void {
+ _ = self;
+ _ = child;
+ }
+
+ comptime {
+ if (builtin.mode == .Debug) {
+ _ = gdbHelper;
+ }
+ }
+ };
+}
+
+test "basic usage" {
+ const ally = testing.allocator;
+
+ const Foo = struct {
+ a: u32,
+ b: []const u8,
+ c: u8,
+ };
+
+ var list = MultiArrayList(Foo){};
+ defer list.deinit(ally);
+
+ try testing.expectEqual(@as(usize, 0), list.items(.a).len);
+
+ try list.ensureTotalCapacity(ally, 2);
+
+ list.appendAssumeCapacity(.{
+ .a = 1,
+ .b = "foobar",
+ .c = 'a',
+ });
+
+ list.appendAssumeCapacity(.{
+ .a = 2,
+ .b = "zigzag",
+ .c = 'b',
+ });
+
+ try testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2 });
+ try testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b' });
+
+ try testing.expectEqual(@as(usize, 2), list.items(.b).len);
+ try testing.expectEqualStrings("foobar", list.items(.b)[0]);
+ try testing.expectEqualStrings("zigzag", list.items(.b)[1]);
+
+ try list.append(ally, .{
+ .a = 3,
+ .b = "fizzbuzz",
+ .c = 'c',
+ });
+
+ try testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2, 3 });
+ try testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b', 'c' });
+
+ try testing.expectEqual(@as(usize, 3), list.items(.b).len);
+ try testing.expectEqualStrings("foobar", list.items(.b)[0]);
+ try testing.expectEqualStrings("zigzag", list.items(.b)[1]);
+ try testing.expectEqualStrings("fizzbuzz", list.items(.b)[2]);
+
+ // Add 6 more things to force a capacity increase.
+ var i: usize = 0;
+ while (i < 6) : (i += 1) {
+ try list.append(ally, .{
+ .a = @intCast(u32, 4 + i),
+ .b = "whatever",
+ .c = @intCast(u8, 'd' + i),
+ });
+ }
+
+ try testing.expectEqualSlices(
+ u32,
+ &[_]u32{ 1, 2, 3, 4, 5, 6, 7, 8, 9 },
+ list.items(.a),
+ );
+ try testing.expectEqualSlices(
+ u8,
+ &[_]u8{ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' },
+ list.items(.c),
+ );
+
+ list.shrinkAndFree(ally, 3);
+
+ try testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2, 3 });
+ try testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b', 'c' });
+
+ try testing.expectEqual(@as(usize, 3), list.items(.b).len);
+ try testing.expectEqualStrings("foobar", list.items(.b)[0]);
+ try testing.expectEqualStrings("zigzag", list.items(.b)[1]);
+ try testing.expectEqualStrings("fizzbuzz", list.items(.b)[2]);
+
+ list.set(try list.addOne(ally), .{
+ .a = 4,
+ .b = "xnopyt",
+ .c = 'd',
+ });
+ try testing.expectEqualStrings("xnopyt", list.pop().b);
+ try testing.expectEqual(@as(?u8, 'c'), if (list.popOrNull()) |elem| elem.c else null);
+ try testing.expectEqual(@as(u32, 2), list.pop().a);
+ try testing.expectEqual(@as(u8, 'a'), list.pop().c);
+ try testing.expectEqual(@as(?Foo, null), list.popOrNull());
+}
+
+// This was observed to fail on aarch64 with LLVM 11, when the capacityInBytes
+// function used the @reduce code path.
+test "regression test for @reduce bug" {
+ const ally = testing.allocator;
+ var list = MultiArrayList(struct {
+ tag: std.zig.Token.Tag,
+ start: u32,
+ }){};
+ defer list.deinit(ally);
+
+ try list.ensureTotalCapacity(ally, 20);
+
+ try list.append(ally, .{ .tag = .keyword_const, .start = 0 });
+ try list.append(ally, .{ .tag = .identifier, .start = 6 });
+ try list.append(ally, .{ .tag = .equal, .start = 10 });
+ try list.append(ally, .{ .tag = .builtin, .start = 12 });
+ try list.append(ally, .{ .tag = .l_paren, .start = 19 });
+ try list.append(ally, .{ .tag = .string_literal, .start = 20 });
+ try list.append(ally, .{ .tag = .r_paren, .start = 25 });
+ try list.append(ally, .{ .tag = .semicolon, .start = 26 });
+ try list.append(ally, .{ .tag = .keyword_pub, .start = 29 });
+ try list.append(ally, .{ .tag = .keyword_fn, .start = 33 });
+ try list.append(ally, .{ .tag = .identifier, .start = 36 });
+ try list.append(ally, .{ .tag = .l_paren, .start = 40 });
+ try list.append(ally, .{ .tag = .r_paren, .start = 41 });
+ try list.append(ally, .{ .tag = .identifier, .start = 43 });
+ try list.append(ally, .{ .tag = .bang, .start = 51 });
+ try list.append(ally, .{ .tag = .identifier, .start = 52 });
+ try list.append(ally, .{ .tag = .l_brace, .start = 57 });
+ try list.append(ally, .{ .tag = .identifier, .start = 63 });
+ try list.append(ally, .{ .tag = .period, .start = 66 });
+ try list.append(ally, .{ .tag = .identifier, .start = 67 });
+ try list.append(ally, .{ .tag = .period, .start = 70 });
+ try list.append(ally, .{ .tag = .identifier, .start = 71 });
+ try list.append(ally, .{ .tag = .l_paren, .start = 75 });
+ try list.append(ally, .{ .tag = .string_literal, .start = 76 });
+ try list.append(ally, .{ .tag = .comma, .start = 113 });
+ try list.append(ally, .{ .tag = .period, .start = 115 });
+ try list.append(ally, .{ .tag = .l_brace, .start = 116 });
+ try list.append(ally, .{ .tag = .r_brace, .start = 117 });
+ try list.append(ally, .{ .tag = .r_paren, .start = 118 });
+ try list.append(ally, .{ .tag = .semicolon, .start = 119 });
+ try list.append(ally, .{ .tag = .r_brace, .start = 121 });
+ try list.append(ally, .{ .tag = .eof, .start = 123 });
+
+ const tags = list.items(.tag);
+ try testing.expectEqual(tags[1], .identifier);
+ try testing.expectEqual(tags[2], .equal);
+ try testing.expectEqual(tags[3], .builtin);
+ try testing.expectEqual(tags[4], .l_paren);
+ try testing.expectEqual(tags[5], .string_literal);
+ try testing.expectEqual(tags[6], .r_paren);
+ try testing.expectEqual(tags[7], .semicolon);
+ try testing.expectEqual(tags[8], .keyword_pub);
+ try testing.expectEqual(tags[9], .keyword_fn);
+ try testing.expectEqual(tags[10], .identifier);
+ try testing.expectEqual(tags[11], .l_paren);
+ try testing.expectEqual(tags[12], .r_paren);
+ try testing.expectEqual(tags[13], .identifier);
+ try testing.expectEqual(tags[14], .bang);
+ try testing.expectEqual(tags[15], .identifier);
+ try testing.expectEqual(tags[16], .l_brace);
+ try testing.expectEqual(tags[17], .identifier);
+ try testing.expectEqual(tags[18], .period);
+ try testing.expectEqual(tags[19], .identifier);
+ try testing.expectEqual(tags[20], .period);
+ try testing.expectEqual(tags[21], .identifier);
+ try testing.expectEqual(tags[22], .l_paren);
+ try testing.expectEqual(tags[23], .string_literal);
+ try testing.expectEqual(tags[24], .comma);
+ try testing.expectEqual(tags[25], .period);
+ try testing.expectEqual(tags[26], .l_brace);
+ try testing.expectEqual(tags[27], .r_brace);
+ try testing.expectEqual(tags[28], .r_paren);
+ try testing.expectEqual(tags[29], .semicolon);
+ try testing.expectEqual(tags[30], .r_brace);
+ try testing.expectEqual(tags[31], .eof);
+}
+
+test "ensure capacity on empty list" {
+ const ally = testing.allocator;
+
+ const Foo = struct {
+ a: u32,
+ b: u8,
+ };
+
+ var list = MultiArrayList(Foo){};
+ defer list.deinit(ally);
+
+ try list.ensureTotalCapacity(ally, 2);
+ list.appendAssumeCapacity(.{ .a = 1, .b = 2 });
+ list.appendAssumeCapacity(.{ .a = 3, .b = 4 });
+
+ try testing.expectEqualSlices(u32, &[_]u32{ 1, 3 }, list.items(.a));
+ try testing.expectEqualSlices(u8, &[_]u8{ 2, 4 }, list.items(.b));
+
+ list.len = 0;
+ list.appendAssumeCapacity(.{ .a = 5, .b = 6 });
+ list.appendAssumeCapacity(.{ .a = 7, .b = 8 });
+
+ try testing.expectEqualSlices(u32, &[_]u32{ 5, 7 }, list.items(.a));
+ try testing.expectEqualSlices(u8, &[_]u8{ 6, 8 }, list.items(.b));
+
+ list.len = 0;
+ try list.ensureTotalCapacity(ally, 16);
+
+ list.appendAssumeCapacity(.{ .a = 9, .b = 10 });
+ list.appendAssumeCapacity(.{ .a = 11, .b = 12 });
+
+ try testing.expectEqualSlices(u32, &[_]u32{ 9, 11 }, list.items(.a));
+ try testing.expectEqualSlices(u8, &[_]u8{ 10, 12 }, list.items(.b));
+}
+
+test "insert elements" {
+ const ally = testing.allocator;
+
+ const Foo = struct {
+ a: u8,
+ b: u32,
+ };
+
+ var list = MultiArrayList(Foo){};
+ defer list.deinit(ally);
+
+ try list.insert(ally, 0, .{ .a = 1, .b = 2 });
+ try list.ensureUnusedCapacity(ally, 1);
+ list.insertAssumeCapacity(1, .{ .a = 2, .b = 3 });
+
+ try testing.expectEqualSlices(u8, &[_]u8{ 1, 2 }, list.items(.a));
+ try testing.expectEqualSlices(u32, &[_]u32{ 2, 3 }, list.items(.b));
+}
diff --git a/src/options.zig b/src/options.zig
index addc67a8c..e3e4c5115 100644
--- a/src/options.zig
+++ b/src/options.zig
@@ -376,6 +376,32 @@ pub const Platform = enum {
bun_macro,
node,
+ pub const Map = ComptimeStringMap(
+ Platform,
+ .{
+ .{
+ "neutral",
+ Platform.neutral,
+ },
+ .{
+ "browser",
+ Platform.browser,
+ },
+ .{
+ "bun",
+ Platform.bun,
+ },
+ .{
+ "bun_macro",
+ Platform.bun_macro,
+ },
+ .{
+ "node",
+ Platform.node,
+ },
+ },
+ );
+
pub fn fromJS(global: *JSC.JSGlobalObject, value: JSC.JSValue, exception: JSC.C.ExceptionRef) ?Platform {
if (!value.jsType().isStringLike()) {
JSC.throwInvalidArguments("platform must be a string", .{}, global, exception);
@@ -636,6 +662,13 @@ pub const Loader = enum(u4) {
wasm,
napi,
+ pub fn canHaveSourceMap(this: Loader) bool {
+ return switch (this) {
+ .jsx, .js, .ts, .tsx => true,
+ else => false,
+ };
+ }
+
pub fn canBeRunByBun(this: Loader) bool {
return switch (this) {
.jsx, .js, .ts, .tsx, .json, .wasm => true,
@@ -1181,6 +1214,29 @@ pub const SourceMapOption = enum {
});
};
+pub const OutputFormat = enum {
+ preserve,
+
+ /// ES module format
+ /// This is the default format
+ esm,
+ /// Immediately-invoked function expression
+ /// (
+ /// function(){}
+ /// )();
+ iife,
+ /// CommonJS
+ cjs,
+
+ pub fn keepES6ImportExportSyntax(this: OutputFormat) bool {
+ return this == .esm;
+ }
+
+ pub inline fn isESM(this: OutputFormat) bool {
+ return this == .esm;
+ }
+};
+
/// BundleOptions is used when ResolveMode is not set to "disable".
/// BundleOptions is effectively webpack + babel
pub const BundleOptions = struct {
@@ -1194,7 +1250,9 @@ pub const BundleOptions = struct {
allow_runtime: bool = true,
trim_unused_imports: ?bool = null,
-
+ mark_bun_builtins_as_external: bool = false,
+ react_server_components: bool = false,
+ react_server_components_boundary: string = "",
hot_module_reloading: bool = false,
inject: ?[]string = null,
origin: URL = URL{},
@@ -1212,6 +1270,9 @@ pub const BundleOptions = struct {
production: bool = false,
serve: bool = false,
+ // only used by bundle_v2
+ output_format: OutputFormat = .esm,
+
append_package_version_in_query_string: bool = false,
jsx_optimization_inline: ?bool = null,
@@ -1224,6 +1285,7 @@ pub const BundleOptions = struct {
log: *logger.Log,
external: ExternalModules = ExternalModules{},
entry_points: []const string,
+ entry_names: []const u8 = "",
extension_order: []const string = &Defaults.ExtensionOrder,
esm_extension_order: []const string = &Defaults.ModuleExtensionOrder,
out_extensions: bun.StringHashMap(string),
@@ -1241,6 +1303,7 @@ pub const BundleOptions = struct {
conditions: ESMConditions = undefined,
tree_shaking: bool = false,
+ code_splitting: bool = false,
sourcemap: SourceMapOption = SourceMapOption.none,
disable_transpilation: bool = false,
@@ -2324,3 +2387,90 @@ pub const RouteConfig = struct {
};
pub const GlobalCache = @import("./resolver/resolver.zig").GlobalCache;
+
+pub const PathTemplate = struct {
+ data: string = "",
+ placeholder: Placeholder = .{},
+
+ pub fn format(self: PathTemplate, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
+ var remain = self.data;
+ while (strings.indexOfChar(remain, '[')) |j| {
+ try writer.writeAll(remain[0..j]);
+ remain = remain[j + 1 ..];
+ if (remain.len == 0) {
+ // TODO: throw error
+ try writer.writeAll("[");
+ break;
+ }
+
+ var count: isize = 1;
+ var end_len: usize = remain.len;
+ for (remain) |*c| {
+ count += switch (c.*) {
+ '[' => 1,
+ ']' => -1,
+ else => 0,
+ };
+
+ if (count == 0) {
+ end_len = @ptrToInt(c) - @ptrToInt(remain.ptr);
+ std.debug.assert(end_len <= remain.len);
+ break;
+ }
+ }
+
+ const placeholder = remain[0..end_len];
+
+ const field = PathTemplate.Placeholder.map.get(placeholder) orelse {
+ try writer.writeAll(placeholder);
+ remain = remain[end_len..];
+ continue;
+ };
+
+ switch (field) {
+ .dir => try writer.writeAll(self.placeholder.dir),
+ .name => try writer.writeAll(self.placeholder.name),
+ .ext => try writer.writeAll(self.placeholder.ext),
+ .hash => {
+ if (self.placeholder.hash) |hash| {
+ try writer.print("{any}", .{bun.fmt.hexIntLower(hash)});
+ }
+ },
+ }
+ remain = remain[end_len + 1 ..];
+ }
+
+ try writer.writeAll(remain);
+ }
+
+ pub const Placeholder = struct {
+ dir: []const u8 = "",
+ name: []const u8 = "",
+ ext: []const u8 = "",
+ hash: ?u64 = null,
+
+ pub const map = bun.ComptimeStringMap(
+ std.meta.FieldEnum(Placeholder),
+ .{
+ .{ "dir", .dir },
+ .{ "name", .name },
+ .{ "ext", .ext },
+ .{ "hash", .hash },
+ },
+ );
+ };
+
+ pub const chunk = PathTemplate{
+ .data = "./chunk-[hash].[ext]",
+ .placeholder = .{
+ .name = "chunk",
+ .ext = "js",
+ .dir = "",
+ },
+ };
+
+ pub const file = PathTemplate{
+ .data = "./[name]-[hash].[ext]",
+ .placeholder = .{},
+ };
+};
diff --git a/src/output.zig b/src/output.zig
index 96bf1b8a7..1fed2d684 100644
--- a/src/output.zig
+++ b/src/output.zig
@@ -275,7 +275,7 @@ inline fn printElapsedToWithCtx(elapsed: f64, comptime printerFn: anytype, compt
}
}
-pub fn printElapsedTo(elapsed: f64, comptime printerFn: anytype, ctx: anytype) void {
+pub noinline fn printElapsedTo(elapsed: f64, comptime printerFn: anytype, ctx: anytype) void {
printElapsedToWithCtx(elapsed, printerFn, true, ctx);
}
@@ -303,7 +303,7 @@ pub fn printTimer(timer: *SystemTimer) void {
printElapsed(@intToFloat(f64, elapsed));
}
-pub fn printErrorable(comptime fmt: string, args: anytype) !void {
+pub noinline fn printErrorable(comptime fmt: string, args: anytype) !void {
if (comptime Environment.isWasm) {
try source.stream.seekTo(0);
try source.stream.writer().print(fmt, args);
@@ -316,7 +316,7 @@ pub fn printErrorable(comptime fmt: string, args: anytype) !void {
/// Print to stdout
/// This will appear in the terminal, including in production.
/// Text automatically buffers
-pub fn println(comptime fmt: string, args: anytype) void {
+pub noinline fn println(comptime fmt: string, args: anytype) void {
if (fmt.len == 0 or fmt[fmt.len - 1] != '\n') {
return print(fmt ++ "\n", args);
}
@@ -332,18 +332,19 @@ pub inline fn debug(comptime fmt: string, args: anytype) void {
flush();
}
-pub fn _debug(comptime fmt: string, args: anytype) void {
+pub inline fn _debug(comptime fmt: string, args: anytype) void {
std.debug.assert(source_set);
println(fmt, args);
}
-pub fn print(comptime fmt: string, args: anytype) void {
+pub noinline fn print(comptime fmt: string, args: anytype) void {
if (comptime Environment.isWasm) {
source.stream.pos = 0;
std.fmt.format(source.stream.writer(), fmt, args) catch unreachable;
root.console_log(root.Uint8Array.fromSlice(source.stream.buffer[0..source.stream.pos]));
} else {
- std.debug.assert(source_set);
+ if (comptime Environment.allow_assert)
+ std.debug.assert(source_set);
if (enable_buffering) {
std.fmt.format(source.buffered_stream.writer(), fmt, args) catch unreachable;
@@ -375,6 +376,7 @@ pub fn scoped(comptime tag: @Type(.EnumLiteral), comptime disabled: bool) _log_f
var out_set = false;
var really_disable = disabled;
var evaluated_disable = false;
+ var lock = std.Thread.Mutex{};
/// Debug-only logs which should not appear in release mode
/// To enable a specific log at runtime, set the environment variable
@@ -410,6 +412,9 @@ pub fn scoped(comptime tag: @Type(.EnumLiteral), comptime disabled: bool) _log_f
out_set = true;
}
+ lock.lock();
+ defer lock.unlock();
+
if (Output.enable_ansi_colors_stderr) {
out.print(comptime prettyFmt("<r><d>[" ++ @tagName(tag) ++ "]<r> " ++ fmt, true), args) catch unreachable;
buffered_writer.flush() catch unreachable;
@@ -450,6 +455,9 @@ pub const color_map = ComptimeStringMap(string, .{
});
const RESET: string = "\x1b[0m";
pub fn prettyFmt(comptime fmt: string, comptime is_enabled: bool) string {
+ if (comptime @import("bun").fast_debug_build_mode)
+ return fmt;
+
comptime var new_fmt: [fmt.len * 4]u8 = undefined;
comptime var new_fmt_i: usize = 0;
@@ -527,7 +535,7 @@ pub fn prettyFmt(comptime fmt: string, comptime is_enabled: bool) string {
return comptime new_fmt[0..new_fmt_i];
}
-pub fn prettyWithPrinter(comptime fmt: string, args: anytype, comptime printer: anytype, comptime l: Level) void {
+pub noinline fn prettyWithPrinter(comptime fmt: string, args: anytype, comptime printer: anytype, comptime l: Level) void {
if (comptime l == .Warn) {
if (level == .Error) return;
}
@@ -539,7 +547,10 @@ pub fn prettyWithPrinter(comptime fmt: string, args: anytype, comptime printer:
}
}
-pub fn prettyWithPrinterFn(comptime fmt: string, args: anytype, comptime printFn: anytype, ctx: anytype) void {
+pub noinline fn prettyWithPrinterFn(comptime fmt: string, args: anytype, comptime printFn: anytype, ctx: anytype) void {
+ if (comptime @import("bun").fast_debug_build_mode)
+ return printFn(ctx, comptime prettyFmt(fmt, false), args);
+
if (enable_ansi_colors) {
printFn(ctx, comptime prettyFmt(fmt, true), args);
} else {
@@ -547,7 +558,7 @@ pub fn prettyWithPrinterFn(comptime fmt: string, args: anytype, comptime printFn
}
}
-pub fn pretty(comptime fmt: string, args: anytype) void {
+pub noinline fn pretty(comptime fmt: string, args: anytype) void {
prettyWithPrinter(fmt, args, print, .stdout);
}
@@ -557,7 +568,7 @@ pub fn prettyln(comptime fmt: string, args: anytype) void {
prettyWithPrinter(fmt, args, println, .stdout);
}
-pub fn printErrorln(comptime fmt: string, args: anytype) void {
+pub noinline fn printErrorln(comptime fmt: string, args: anytype) void {
if (fmt.len == 0 or fmt[fmt.len - 1] != '\n') {
return printError(fmt ++ "\n", args);
}
@@ -565,7 +576,7 @@ pub fn printErrorln(comptime fmt: string, args: anytype) void {
return printError(fmt, args);
}
-pub fn prettyError(comptime fmt: string, args: anytype) void {
+pub noinline fn prettyError(comptime fmt: string, args: anytype) void {
prettyWithPrinter(fmt, args, printError, .Error);
}
@@ -583,7 +594,7 @@ pub const Level = enum(u8) {
pub var level = if (Environment.isDebug) Level.Warn else Level.Error;
-pub fn prettyWarn(comptime fmt: string, args: anytype) void {
+pub noinline fn prettyWarn(comptime fmt: string, args: anytype) void {
prettyWithPrinter(fmt, args, printError, .Warn);
}
@@ -591,7 +602,7 @@ pub fn prettyWarnln(comptime fmt: string, args: anytype) void {
prettyWithPrinter(fmt, args, printErrorln, .Warn);
}
-pub fn printError(comptime fmt: string, args: anytype) void {
+pub noinline fn printError(comptime fmt: string, args: anytype) void {
if (comptime Environment.isWasm) {
source.error_stream.seekTo(0) catch return;
source.error_stream.writer().print(fmt, args) catch unreachable;
diff --git a/src/renamer.zig b/src/renamer.zig
index bce2d3030..88dcb769c 100644
--- a/src/renamer.zig
+++ b/src/renamer.zig
@@ -12,19 +12,19 @@ const C = bun.C;
const std = @import("std");
const Ref = @import("./ast/base.zig").Ref;
const logger = @import("bun").logger;
+const JSLexer = @import("./js_lexer.zig");
-// This is...poorly named
-// It does not rename
-// It merely names
-pub const Renamer = struct {
+pub const NoOpRenamer = struct {
symbols: js_ast.Symbol.Map,
source: *const logger.Source,
- pub fn init(symbols: js_ast.Symbol.Map, source: *const logger.Source) Renamer {
- return Renamer{ .symbols = symbols, .source = source };
+ pub fn init(symbols: js_ast.Symbol.Map, source: *const logger.Source) NoOpRenamer {
+ return NoOpRenamer{ .symbols = symbols, .source = source };
}
- pub fn nameForSymbol(renamer: *Renamer, ref: Ref) string {
+ pub const originalName = nameForSymbol;
+
+ pub fn nameForSymbol(renamer: *NoOpRenamer, ref: Ref) string {
if (ref.isSourceContentsSlice()) {
return renamer.source.contents[ref.sourceIndex() .. ref.sourceIndex() + ref.innerIndex()];
}
@@ -37,11 +37,509 @@ pub const Renamer = struct {
Global.panic("Invalid symbol {s} in {s}", .{ ref, renamer.source.path.text });
}
}
+
+ pub fn toRenamer(this: *NoOpRenamer) Renamer {
+ return .{
+ .NoOpRenamer = this,
+ };
+ }
+};
+
+pub const Renamer = union(enum) {
+ NumberRenamer: *NumberRenamer,
+ NoOpRenamer: *NoOpRenamer,
+
+ pub fn symbols(this: Renamer) js_ast.Symbol.Map {
+ return switch (this) {
+ inline else => |r| r.symbols,
+ };
+ }
+
+ pub fn nameForSymbol(renamer: Renamer, ref: Ref) string {
+ return switch (renamer) {
+ inline else => |r| r.nameForSymbol(ref),
+ };
+ }
+
+ pub fn originalName(renamer: Renamer, ref: Ref) ?string {
+ return switch (renamer) {
+ inline else => |r| r.originalName(ref),
+ };
+ }
+
+ pub fn deinit(renamer: Renamer) void {
+ switch (renamer) {
+ .NumberRenamer => |r| r.deinit(),
+ else => {},
+ }
+ }
+};
+
+pub const NumberRenamer = struct {
+ symbols: js_ast.Symbol.Map,
+ names: []bun.BabyList(string) = &.{},
+ allocator: std.mem.Allocator,
+ temp_allocator: std.mem.Allocator,
+ number_scope_pool: bun.HiveArray(NumberScope, 128).Fallback,
+ arena: std.heap.ArenaAllocator,
+ root: NumberScope = .{},
+ name_stack_fallback: std.heap.StackFallbackAllocator(512) = undefined,
+ name_temp_allocator: std.mem.Allocator = undefined,
+
+ pub fn deinit(self: *NumberRenamer) void {
+ self.allocator.free(self.names);
+ self.root.deinit(self.temp_allocator);
+ self.arena.deinit();
+ }
+
+ pub fn toRenamer(this: *NumberRenamer) Renamer {
+ return .{
+ .NumberRenamer = this,
+ };
+ }
+
+ pub fn originalName(r: *NumberRenamer, ref: Ref) string {
+ if (ref.isSourceContentsSlice()) {
+ unreachable;
+ }
+
+ const resolved = r.symbols.follow(ref);
+ return r.symbols.getConst(resolved).?.original_name;
+ }
+
+ pub fn assignName(r: *NumberRenamer, scope: *NumberScope, input_ref: Ref) void {
+ const ref = r.symbols.follow(input_ref);
+
+ // Don't rename the same symbol more than once
+ var inner: *bun.BabyList(string) = &r.names[ref.sourceIndex()];
+ if (inner.len > ref.innerIndex() and inner.at(ref.innerIndex()).len > 0) return;
+
+ // Don't rename unbound symbols, symbols marked as reserved names, labels, or private names
+ const symbol = r.symbols.get(ref).?;
+ if (symbol.slotNamespace() != .default) {
+ return;
+ }
+
+ r.name_stack_fallback.fixed_buffer_allocator.end_index = 0;
+ switch (scope.findUnusedName(r.allocator, r.name_temp_allocator, symbol.original_name)) {
+ .renamed => |name| {
+ const new_len = @max(inner.len, ref.innerIndex() + 1);
+ if (inner.cap <= new_len) {
+ const prev_cap = inner.len;
+ inner.ensureUnusedCapacity(r.allocator, new_len - prev_cap) catch unreachable;
+ const to_write = inner.ptr[prev_cap..inner.cap];
+ @memset(std.mem.sliceAsBytes(to_write).ptr, 0, std.mem.sliceAsBytes(to_write).len);
+ }
+ inner.len = new_len;
+ inner.mut(ref.innerIndex()).* = name;
+ },
+ .no_collision => {},
+ }
+ }
+
+ pub fn init(
+ allocator: std.mem.Allocator,
+ temp_allocator: std.mem.Allocator,
+ symbols: js_ast.Symbol.Map,
+ root_names: bun.StringHashMapUnmanaged(u32),
+ ) !*NumberRenamer {
+ var renamer = try allocator.create(NumberRenamer);
+ renamer.* = NumberRenamer{
+ .symbols = symbols,
+ .allocator = allocator,
+ .temp_allocator = temp_allocator,
+ .names = try allocator.alloc(bun.BabyList(string), symbols.symbols_for_source.len),
+ .number_scope_pool = undefined,
+ .arena = std.heap.ArenaAllocator.init(temp_allocator),
+ };
+ renamer.name_stack_fallback = .{
+ .buffer = undefined,
+ .fallback_allocator = renamer.arena.allocator(),
+ .fixed_buffer_allocator = undefined,
+ };
+ renamer.name_temp_allocator = renamer.name_stack_fallback.get();
+ renamer.number_scope_pool = bun.HiveArray(NumberScope, 128).Fallback.init(renamer.arena.allocator());
+ renamer.root.name_counts = root_names;
+ if (comptime Environment.allow_assert) {
+ if (std.os.getenv("BUN_DUMP_SYMBOLS") != null)
+ symbols.dump();
+ }
+
+ @memset(std.mem.sliceAsBytes(renamer.names).ptr, 0, std.mem.sliceAsBytes(renamer.names).len);
+
+ return renamer;
+ }
+
+ pub fn assignNamesRecursive(r: *NumberRenamer, scope: *js_ast.Scope, source_index: u32, parent: ?*NumberScope, sorted: *std.ArrayList(u32)) void {
+ var s = r.number_scope_pool.get();
+ s.* = NumberScope{
+ .parent = parent,
+ .name_counts = .{},
+ };
+ defer {
+ s.deinit(r.temp_allocator);
+ r.number_scope_pool.put(s);
+ }
+
+ assignNamesRecursiveWithNumberScope(r, s, scope, source_index, sorted);
+ }
+
+ fn assignNamesInScope(
+ r: *NumberRenamer,
+ s: *NumberScope,
+ scope: *js_ast.Scope,
+ source_index: u32,
+ sorted: *std.ArrayList(u32),
+ ) void {
+ {
+ sorted.clearRetainingCapacity();
+ sorted.ensureUnusedCapacity(scope.members.count()) catch unreachable;
+ sorted.items.len = scope.members.count();
+ var remaining = sorted.items;
+ var value_iter = scope.members.valueIterator();
+ while (value_iter.next()) |value_ref| {
+ if (comptime Environment.allow_assert)
+ std.debug.assert(!value_ref.ref.isSourceContentsSlice());
+
+ remaining[0] = value_ref.ref.innerIndex();
+ remaining = remaining[1..];
+ }
+ std.debug.assert(remaining.len == 0);
+ std.sort.sort(u32, sorted.items, void{}, std.sort.asc(u32));
+
+ for (sorted.items) |inner_index| {
+ r.assignName(s, Ref.init(@intCast(Ref.Int, inner_index), source_index, false));
+ }
+ }
+
+ for (scope.generated.slice()) |ref| {
+ r.assignName(s, ref);
+ }
+ }
+
+ pub fn assignNamesRecursiveWithNumberScope(r: *NumberRenamer, initial_scope: *NumberScope, scope_: *js_ast.Scope, source_index: u32, sorted: *std.ArrayList(u32)) void {
+ var s = initial_scope;
+ var scope = scope_;
+ defer if (s != initial_scope) {
+ s.deinit(r.temp_allocator);
+ r.number_scope_pool.put(s);
+ };
+
+ // Ignore function argument scopes
+ if (scope.kind == .function_args and scope.children.len == 1) {
+ scope = scope.children.ptr[0];
+ std.debug.assert(scope.kind == .function_body);
+ }
+
+ while (true) {
+ if (scope.members.count() > 0 or scope.generated.len > 0) {
+ var new_child_scope = r.number_scope_pool.get();
+ new_child_scope.* = .{
+ .parent = s,
+ .name_counts = .{},
+ };
+ s = new_child_scope;
+
+ r.assignNamesInScope(s, scope, source_index, sorted);
+ }
+
+ if (scope.children.len == 1) {
+ scope = scope.children.ptr[0];
+ if (scope.kind == .function_args and scope.children.len == 1) {
+ scope = scope.children.ptr[0];
+ std.debug.assert(scope.kind == .function_body);
+ }
+ } else {
+ break;
+ }
+ }
+
+ // Symbols in child scopes may also have to be renamed to avoid conflicts
+ for (scope.children.slice()) |child| {
+ r.assignNamesRecursiveWithNumberScope(s, child, source_index, sorted);
+ }
+ }
+
+ pub fn addTopLevelSymbol(r: *NumberRenamer, ref: Ref) void {
+ r.assignName(&r.root, ref);
+ }
+
+ pub fn addTopLevelDeclaredSymbols(r: *NumberRenamer, declared_symbols: js_ast.DeclaredSymbol.List) void {
+ var decls = declared_symbols;
+ js_ast.DeclaredSymbol.forEachTopLevelSymbol(&decls, r, addTopLevelSymbol);
+ }
+
+ pub fn nameForSymbol(renamer: *NumberRenamer, ref: Ref) string {
+ if (ref.isSourceContentsSlice()) {
+ bun.unreachablePanic("Unexpected unbound symbol!\n{any}", .{ref});
+ }
+
+ const resolved = renamer.symbols.follow(ref);
+
+ const source_index = resolved.sourceIndex();
+ const inner_index = resolved.innerIndex();
+
+ const renamed_list = renamer.names[source_index];
+
+ if (renamed_list.len > inner_index) {
+ const renamed = renamed_list.at(inner_index).*;
+ if (renamed.len > 0) {
+ return renamed;
+ }
+ }
+
+ return renamer.symbols.symbols_for_source.at(source_index).at(inner_index).original_name;
+ }
+
+ pub const NumberScope = struct {
+ parent: ?*NumberScope = null,
+ name_counts: bun.StringHashMapUnmanaged(u32) = .{},
+
+ pub fn deinit(this: *NumberScope, allocator: std.mem.Allocator) void {
+ this.name_counts.deinit(allocator);
+ this.* = undefined;
+ }
+
+ pub const NameUse = union(enum) {
+ unused: void,
+ same_scope: u32,
+ used: void,
+
+ pub fn find(this: *NumberScope, name: []const u8) NameUse {
+ // This version doesn't allocate
+ if (comptime Environment.allow_assert)
+ std.debug.assert(JSLexer.isIdentifier(name));
+
+ // avoid rehashing the same string over for each scope
+ const ctx = bun.StringHashMapContext.pre(name);
+
+ if (this.name_counts.getAdapted(name, ctx)) |count| {
+ return .{ .same_scope = count };
+ }
+
+ var s: ?*NumberScope = this.parent;
+
+ while (s) |scope| : (s = scope.parent) {
+ if (scope.name_counts.containsAdapted(name, ctx)) {
+ return .{ .used = void{} };
+ }
+ }
+
+ return .{ .unused = void{} };
+ }
+ };
+
+ const UnusedName = union(enum) {
+ no_collision: void,
+ renamed: string,
+ };
+
+ /// Caller must use an arena allocator
+ pub fn findUnusedName(this: *NumberScope, allocator: std.mem.Allocator, temp_allocator: std.mem.Allocator, input_name: []const u8) UnusedName {
+ var name = bun.MutableString.ensureValidIdentifier(input_name, temp_allocator) catch unreachable;
+
+ switch (NameUse.find(this, name)) {
+ .unused => {},
+ else => |use| {
+ var tries: u32 = if (use == .used)
+ 1
+ else
+ // To avoid O(n^2) behavior, the number must start off being the number
+ // that we used last time there was a collision with this name. Otherwise
+ // if there are many collisions with the same name, each name collision
+ // would have to increment the counter past all previous name collisions
+ // which is a O(n^2) time algorithm. Only do this if this symbol comes
+ // from the same scope as the previous one since sibling scopes can reuse
+ // the same name without problems.
+ use.same_scope;
+
+ const prefix = name;
+
+ tries += 1;
+
+ var mutable_name = MutableString.initEmpty(temp_allocator);
+ mutable_name.growIfNeeded(prefix.len + 4) catch unreachable;
+ mutable_name.appendSlice(prefix) catch unreachable;
+ mutable_name.appendInt(tries) catch unreachable;
+
+ switch (NameUse.find(this, mutable_name.toOwnedSliceLeaky())) {
+ .unused => {
+ name = mutable_name.toOwnedSliceLeaky();
+
+ if (use == .same_scope) {
+ var existing = this.name_counts.getOrPut(allocator, prefix) catch unreachable;
+ if (!existing.found_existing) {
+ if (strings.eqlLong(input_name, prefix, true)) {
+ existing.key_ptr.* = input_name;
+ } else {
+ existing.key_ptr.* = allocator.dupe(u8, prefix) catch unreachable;
+ }
+ }
+
+ existing.value_ptr.* = tries;
+ }
+ },
+ else => |cur_use| {
+ while (true) {
+ mutable_name.resetTo(prefix.len);
+ mutable_name.appendInt(tries) catch unreachable;
+
+ tries += 1;
+
+ switch (NameUse.find(this, mutable_name.toOwnedSliceLeaky())) {
+ .unused => {
+ if (cur_use == .same_scope) {
+ var existing = this.name_counts.getOrPut(allocator, prefix) catch unreachable;
+ if (!existing.found_existing) {
+ if (strings.eqlLong(input_name, prefix, true)) {
+ existing.key_ptr.* = input_name;
+ } else {
+ existing.key_ptr.* = allocator.dupe(u8, prefix) catch unreachable;
+ }
+ }
+
+ existing.value_ptr.* = tries;
+ }
+
+ name = mutable_name.toOwnedSliceLeaky();
+ break;
+ },
+ else => {},
+ }
+ }
+ },
+ }
+ },
+ }
+
+ // Each name starts off with a count of 1 so that the first collision with
+ // "name" is called "name2"
+ if (strings.eqlLong(name, input_name, true)) {
+ this.name_counts.putNoClobber(allocator, input_name, 1) catch unreachable;
+ return .{ .no_collision = {} };
+ }
+
+ name = allocator.dupe(u8, name) catch unreachable;
+
+ this.name_counts.putNoClobber(allocator, name, 1) catch unreachable;
+ return .{ .renamed = name };
+ }
+ };
};
-pub const DisabledRenamer = struct {
- pub fn init(_: js_ast.Symbol.Map) DisabledRenamer {}
- pub inline fn nameForSymbol(_: *Renamer, _: js_ast.Ref) string {
- @compileError("DisabledRunner called");
+pub const ExportRenamer = struct {
+ string_buffer: bun.MutableString,
+ used: bun.StringHashMap(u32),
+
+ pub fn init(allocator: std.mem.Allocator) ExportRenamer {
+ return ExportRenamer{
+ .string_buffer = MutableString.initEmpty(allocator),
+ .used = bun.StringHashMap(u32).init(allocator),
+ };
+ }
+
+ pub fn clearRetainingCapacity(this: *ExportRenamer) void {
+ this.used.clearRetainingCapacity();
+ this.string_buffer.reset();
+ }
+
+ pub fn deinit(this: *ExportRenamer) void {
+ this.used.deinit();
+ this.string_buffer.deinit();
+ }
+
+ pub fn nextRenamedName(this: *ExportRenamer, input: []const u8) string {
+ var entry = this.used.getOrPut(input) catch unreachable;
+ var tries: u32 = 1;
+ if (entry.found_existing) {
+ while (true) {
+ this.string_buffer.reset();
+ var writer = this.string_buffer.writer();
+ writer.print("{s}{d}", .{ input, tries }) catch unreachable;
+ tries += 1;
+ var attempt = this.string_buffer.toOwnedSliceLeaky();
+ entry = this.used.getOrPut(attempt) catch unreachable;
+ if (!entry.found_existing) {
+ const to_use = this.string_buffer.allocator.dupe(u8, attempt) catch unreachable;
+ entry.key_ptr.* = to_use;
+ entry.value_ptr.* = tries;
+
+ entry = this.used.getOrPut(input) catch unreachable;
+ entry.value_ptr.* = tries;
+ return to_use;
+ }
+ }
+ } else {
+ entry.value_ptr.* = tries;
+ }
+
+ return entry.key_ptr.*;
}
};
+
+pub fn computeInitialReservedNames(
+ allocator: std.mem.Allocator,
+) !bun.StringHashMapUnmanaged(u32) {
+ var names = bun.StringHashMapUnmanaged(u32){};
+
+ const extras = .{
+ "Promise",
+ "Require",
+ };
+
+ try names.ensureTotalCapacityContext(
+ allocator,
+ @truncate(u32, JSLexer.Keywords.keys().len + JSLexer.StrictModeReservedWords.keys().len + 1 + extras.len),
+ bun.StringHashMapContext{},
+ );
+
+ for (JSLexer.Keywords.keys()) |keyword| {
+ names.putAssumeCapacity(keyword, 1);
+ }
+
+ for (JSLexer.StrictModeReservedWords.keys()) |keyword| {
+ names.putAssumeCapacity(keyword, 1);
+ }
+
+ inline for (comptime extras) |extra| {
+ names.putAssumeCapacity(extra, 1);
+ }
+
+ return names;
+}
+
+pub fn computeReservedNamesForScope(
+ scope: *js_ast.Scope,
+ symbols: *const js_ast.Symbol.Map,
+ names_: *bun.StringHashMapUnmanaged(u32),
+ allocator: std.mem.Allocator,
+) void {
+ var names = names_.*;
+ defer names_.* = names;
+
+ var member_iter = scope.members.valueIterator();
+ while (member_iter.next()) |member| {
+ const symbol = symbols.get(member.ref).?;
+ if (symbol.kind == .unbound or symbol.must_not_be_renamed) {
+ names.put(allocator, symbol.original_name, 1) catch unreachable;
+ }
+ }
+
+ for (scope.generated.slice()) |ref| {
+ const symbol = symbols.get(ref).?;
+ if (symbol.kind == .unbound or symbol.must_not_be_renamed) {
+ names.put(allocator, symbol.original_name, 1) catch unreachable;
+ }
+ }
+
+ // If there's a direct "eval" somewhere inside the current scope, continue
+ // traversing down the scope tree until we find it to get all reserved names
+ if (scope.contains_direct_eval) {
+ for (scope.children.slice()) |child| {
+ if (child.contains_direct_eval) {
+ names_.* = names;
+ computeReservedNamesForScope(child, symbols, &names, allocator);
+ }
+ }
+ }
+}
diff --git a/src/resolver/package_json.zig b/src/resolver/package_json.zig
index 0785e0493..f7ff5f3e4 100644
--- a/src/resolver/package_json.zig
+++ b/src/resolver/package_json.zig
@@ -37,6 +37,7 @@ const FolderResolver = @import("../install/resolvers/folder_resolver.zig");
const Architecture = @import("../install/npm.zig").Architecture;
const OperatingSystem = @import("../install/npm.zig").OperatingSystem;
+pub const SideEffectsMap = std.HashMapUnmanaged(bun.StringHashMapUnowned.Key, void, bun.StringHashMapUnowned.Adapter, 80);
pub const DependencyMap = struct {
map: HashMap = .{},
source_buf: []const u8 = "",
@@ -72,6 +73,7 @@ pub const PackageJSON = struct {
}
const node_modules_path = std.fs.path.sep_str ++ "node_modules" ++ std.fs.path.sep_str;
+
pub fn nameForImport(this: *const PackageJSON, allocator: std.mem.Allocator) !string {
if (strings.indexOf(this.source.path.text, node_modules_path)) |_| {
return this.name;
@@ -110,6 +112,12 @@ pub const PackageJSON = struct {
package_manager_package_id: Install.PackageID = Install.invalid_package_id,
dependencies: DependencyMap = .{},
+ side_effects: union(enum) {
+ unspecified: void,
+ false: void,
+ map: SideEffectsMap,
+ } = .{ .unspecified = {} },
+
// Present if the "browser" field is present. This field is intended to be
// used by bundlers and lets you redirect the paths of certain 3rd-party
// modules that don't work in the browser to other modules that shim that
@@ -641,107 +649,155 @@ pub const PackageJSON = struct {
}
}
- if (json.asProperty("type")) |type_json| {
- if (type_json.expr.asString(r.allocator)) |type_str| {
- switch (options.ModuleType.List.get(type_str) orelse options.ModuleType.unknown) {
- .cjs => {
- package_json.module_type = .cjs;
- },
- .esm => {
- package_json.module_type = .esm;
- },
- .unknown => {
- r.log.addRangeWarningFmt(
- &json_source,
- json_source.rangeOfString(type_json.loc),
- r.allocator,
- "\"{s}\" is not a valid value for \"type\" field (must be either \"commonjs\" or \"module\")",
- .{type_str},
- ) catch unreachable;
- },
+ // If we're coming from `bun run`
+ // We do not need to parse all this stuff.
+ if (comptime !include_scripts) {
+ if (json.asProperty("type")) |type_json| {
+ if (type_json.expr.asString(r.allocator)) |type_str| {
+ switch (options.ModuleType.List.get(type_str) orelse options.ModuleType.unknown) {
+ .cjs => {
+ package_json.module_type = .cjs;
+ },
+ .esm => {
+ package_json.module_type = .esm;
+ },
+ .unknown => {
+ r.log.addRangeWarningFmt(
+ &json_source,
+ json_source.rangeOfString(type_json.loc),
+ r.allocator,
+ "\"{s}\" is not a valid value for \"type\" field (must be either \"commonjs\" or \"module\")",
+ .{type_str},
+ ) catch unreachable;
+ },
+ }
+ } else {
+ r.log.addWarning(&json_source, type_json.loc, "The value for \"type\" must be a string") catch unreachable;
}
- } else {
- r.log.addWarning(&json_source, type_json.loc, "The value for \"type\" must be a string") catch unreachable;
}
- }
- // Read the "main" fields
- for (r.opts.main_fields) |main| {
- if (json.asProperty(main)) |main_json| {
- const expr: js_ast.Expr = main_json.expr;
+ // Read the "main" fields
+ for (r.opts.main_fields) |main| {
+ if (json.asProperty(main)) |main_json| {
+ const expr: js_ast.Expr = main_json.expr;
- if ((expr.asString(r.allocator))) |str| {
- if (str.len > 0) {
- package_json.main_fields.put(main, r.allocator.dupe(u8, str) catch unreachable) catch unreachable;
+ if ((expr.asString(r.allocator))) |str| {
+ if (str.len > 0) {
+ package_json.main_fields.put(main, r.allocator.dupe(u8, str) catch unreachable) catch unreachable;
+ }
}
}
}
- }
- // Read the "browser" property, but only when targeting the browser
- if (r.opts.platform.supportsBrowserField()) {
- // We both want the ability to have the option of CJS vs. ESM and the
- // option of having node vs. browser. The way to do this is to use the
- // object literal form of the "browser" field like this:
- //
- // "main": "dist/index.node.cjs.js",
- // "module": "dist/index.node.esm.js",
- // "browser": {
- // "./dist/index.node.cjs.js": "./dist/index.browser.cjs.js",
- // "./dist/index.node.esm.js": "./dist/index.browser.esm.js"
- // },
- //
- if (json.asProperty("browser")) |browser_prop| {
- switch (browser_prop.expr.data) {
- .e_object => |obj| {
- // The value is an object
-
- // Remap all files in the browser field
- for (obj.properties.slice()) |*prop| {
- var _key_str = (prop.key orelse continue).asString(r.allocator) orelse continue;
- const value: js_ast.Expr = prop.value orelse continue;
-
- // Normalize the path so we can compare against it without getting
- // confused by "./". There is no distinction between package paths and
- // relative paths for these values because some tools (i.e. Browserify)
- // don't make such a distinction.
- //
- // This leads to weird things like a mapping for "./foo" matching an
- // import of "foo", but that's actually not a bug. Or arguably it's a
- // bug in Browserify but we have to replicate this bug because packages
- // do this in the wild.
- const key = r.allocator.dupe(u8, r.fs.normalize(_key_str)) catch unreachable;
-
- switch (value.data) {
- .e_string => |str| {
- // If this is a string, it's a replacement package
- package_json.browser_map.put(key, str.string(r.allocator) catch unreachable) catch unreachable;
- },
- .e_boolean => |boolean| {
- if (!boolean.value) {
- package_json.browser_map.put(key, "") catch unreachable;
- }
- },
- else => {
- r.log.addWarning(&json_source, value.loc, "Each \"browser\" mapping must be a string or boolean") catch unreachable;
- },
+ // Read the "browser" property, but only when targeting the browser
+ if (r.opts.platform.supportsBrowserField()) {
+ // We both want the ability to have the option of CJS vs. ESM and the
+ // option of having node vs. browser. The way to do this is to use the
+ // object literal form of the "browser" field like this:
+ //
+ // "main": "dist/index.node.cjs.js",
+ // "module": "dist/index.node.esm.js",
+ // "browser": {
+ // "./dist/index.node.cjs.js": "./dist/index.browser.cjs.js",
+ // "./dist/index.node.esm.js": "./dist/index.browser.esm.js"
+ // },
+ //
+ if (json.asProperty("browser")) |browser_prop| {
+ switch (browser_prop.expr.data) {
+ .e_object => |obj| {
+ // The value is an object
+
+ // Remap all files in the browser field
+ for (obj.properties.slice()) |*prop| {
+ var _key_str = (prop.key orelse continue).asString(r.allocator) orelse continue;
+ const value: js_ast.Expr = prop.value orelse continue;
+
+ // Normalize the path so we can compare against it without getting
+ // confused by "./". There is no distinction between package paths and
+ // relative paths for these values because some tools (i.e. Browserify)
+ // don't make such a distinction.
+ //
+ // This leads to weird things like a mapping for "./foo" matching an
+ // import of "foo", but that's actually not a bug. Or arguably it's a
+ // bug in Browserify but we have to replicate this bug because packages
+ // do this in the wild.
+ const key = r.allocator.dupe(u8, r.fs.normalize(_key_str)) catch unreachable;
+
+ switch (value.data) {
+ .e_string => |str| {
+ // If this is a string, it's a replacement package
+ package_json.browser_map.put(key, str.string(r.allocator) catch unreachable) catch unreachable;
+ },
+ .e_boolean => |boolean| {
+ if (!boolean.value) {
+ package_json.browser_map.put(key, "") catch unreachable;
+ }
+ },
+ else => {
+ r.log.addWarning(&json_source, value.loc, "Each \"browser\" mapping must be a string or boolean") catch unreachable;
+ },
+ }
}
- }
- },
- else => {},
+ },
+ else => {},
+ }
}
}
- }
- if (json.asProperty("exports")) |exports_prop| {
- if (ExportsMap.parse(r.allocator, &json_source, r.log, exports_prop.expr, exports_prop.loc)) |exports_map| {
- package_json.exports = exports_map;
+ if (json.asProperty("exports")) |exports_prop| {
+ if (ExportsMap.parse(r.allocator, &json_source, r.log, exports_prop.expr, exports_prop.loc)) |exports_map| {
+ package_json.exports = exports_map;
+ }
}
- }
- if (json.asProperty("imports")) |imports_prop| {
- if (ExportsMap.parse(r.allocator, &json_source, r.log, imports_prop.expr, imports_prop.loc)) |imports_map| {
- package_json.imports = imports_map;
+ if (json.asProperty("imports")) |imports_prop| {
+ if (ExportsMap.parse(r.allocator, &json_source, r.log, imports_prop.expr, imports_prop.loc)) |imports_map| {
+ package_json.imports = imports_map;
+ }
+ }
+
+ if (json.get("sideEffects")) |side_effects_field| outer: {
+ if (side_effects_field.asBool()) |boolean| {
+ if (!boolean)
+ package_json.side_effects = .{ .false = {} };
+ } else if (side_effects_field.asArray()) |array_| {
+ var array = array_;
+ // TODO: switch to only storing hashes
+ var map = SideEffectsMap{};
+ map.ensureTotalCapacity(r.allocator, array.array.items.len) catch unreachable;
+ while (array.next()) |item| {
+ if (item.asString(r.allocator)) |name| {
+ // TODO: support RegExp using JavaScriptCore <> C++ bindings
+ if (strings.containsChar(name, '*')) {
+ // https://sourcegraph.com/search?q=context:global+file:package.json+sideEffects%22:+%5B&patternType=standard&sm=1&groupBy=repo
+ // a lot of these seem to be css files which we don't care about for now anyway
+ // so we can just skip them in here
+ if (strings.eqlComptime(std.fs.path.extension(name), ".css"))
+ continue;
+
+ r.log.addWarning(
+ &json_source,
+ item.loc,
+ "wildcard sideEffects are not supported yet, which means this package will be deoptimized",
+ ) catch unreachable;
+ map.deinit(r.allocator);
+
+ package_json.side_effects = .{ .unspecified = {} };
+ break :outer;
+ }
+
+ var joined = [_]string{
+ json_source.path.name.dirWithTrailingSlash(),
+ name,
+ };
+
+ _ = map.getOrPutAssumeCapacity(
+ bun.StringHashMapUnowned.Key.init(r.fs.join(&joined)),
+ );
+ }
+ }
+ package_json.side_effects = .{ .map = map };
+ }
}
}
@@ -938,8 +994,6 @@ pub const PackageJSON = struct {
}
}
- // TODO: side effects
-
if (generate_hash) {
if (package_json.name.len > 0 and package_json.version.len > 0) {
package_json.generateHash();
diff --git a/src/resolver/resolve_path.zig b/src/resolver/resolve_path.zig
index b1cd6e0bf..50d41eab0 100644
--- a/src/resolver/resolve_path.zig
+++ b/src/resolver/resolve_path.zig
@@ -130,7 +130,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u
var string_index: usize = 1;
while (index < min_length) : (index += 1) {
while (string_index < input.len) : (string_index += 1) {
- if (input[0][index] != input[index][string_index]) {
+ if (input[0][string_index] != input[index][string_index]) {
break;
}
}
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig
index 493685ca7..da2753772 100644
--- a/src/resolver/resolver.zig
+++ b/src/resolver/resolver.zig
@@ -102,6 +102,29 @@ pub const PathPair = struct {
}
};
+// this is ripped from esbuild, comments included
+pub const SideEffects = enum {
+ /// The default value conservatively considers all files to have side effects.
+ has_side_effects,
+
+ /// This file was listed as not having side effects by a "package.json"
+ /// file in one of our containing directories with a "sideEffects" field.
+ no_side_effects__package_json,
+
+ /// This file is considered to have no side effects because the AST was empty
+ /// after parsing finished. This should be the case for ".d.ts" files.
+ no_side_effects__empty_ast,
+
+ /// This file was loaded using a data-oriented loader (e.g. "text") that is
+ /// known to not have side effects.
+ no_side_effects__pure_data,
+
+ // / Same as above but it came from a plugin. We don't want to warn about
+ // / unused imports to these files since running the plugin is a side effect.
+ // / Removing the import would not call the plugin which is observable.
+ // no_side_effects__pure_data_from_plugin,
+};
+
pub const Result = struct {
path_pair: PathPair,
@@ -118,7 +141,7 @@ pub const Result = struct {
// If present, any ES6 imports to this file can be considered to have no side
// effects. This means they should be removed if unused.
- primary_side_effects_data: ?SideEffectsData = null,
+ primary_side_effects_data: SideEffects = SideEffects.has_side_effects,
// If true, unused imports are retained in TypeScript code. This matches the
// behavior of the "importsNotUsedAsValues" field in "tsconfig.json" when the
@@ -538,6 +561,12 @@ pub const Resolver = struct {
}
pub fn isExternalPattern(r: *ThisResolver, import_path: string) bool {
+ if (r.opts.mark_bun_builtins_as_external) {
+ if (bun.JSC.HardcodedModule.Aliases.has(import_path)) {
+ return true;
+ }
+ }
+
for (r.opts.external.patterns) |pattern| {
if (import_path.len >= pattern.prefix.len + pattern.suffix.len and (strings.startsWith(
import_path,
@@ -857,12 +886,34 @@ pub const Resolver = struct {
var module_type = result.module_type;
while (iter.next()) |path| {
var dir: *DirInfo = (r.readDirInfo(path.name.dir) catch continue) orelse continue;
+ var needs_side_effects = true;
if (result.package_json) |existing| {
+ // if we don't have it here, they might put it in a sideEfffects
+ // map of the parent package.json
+ // TODO: check if webpack also does this parent lookup
+ needs_side_effects = existing.side_effects == .unspecified;
+
+ result.primary_side_effects_data = switch (existing.side_effects) {
+ .unspecified => .has_side_effects,
+ .false => .no_side_effects__package_json,
+ .map => |map| if (map.contains(bun.StringHashMapUnowned.Key.init(path.text))) .has_side_effects else .no_side_effects__package_json,
+ };
+
if (existing.name.len == 0 or r.care_about_bin_folder) result.package_json = null;
}
result.package_json = result.package_json orelse dir.enclosing_package_json;
+ if (needs_side_effects) {
+ if (result.package_json) |package_json| {
+ result.primary_side_effects_data = switch (package_json.side_effects) {
+ .unspecified => .has_side_effects,
+ .false => .no_side_effects__package_json,
+ .map => |map| if (map.contains(bun.StringHashMapUnowned.Key.init(path.text))) .has_side_effects else .no_side_effects__package_json,
+ };
+ }
+ }
+
if (dir.enclosing_tsconfig_json) |tsconfig| {
result.jsx = tsconfig.mergeJSX(result.jsx);
}
@@ -1548,6 +1599,7 @@ pub const Resolver = struct {
// this is the magic!
if (global_cache.canUse(any_node_modules_folder) and r.usePackageManager() and esm_ != null) {
+ if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .RunCommand) unreachable;
const esm = esm_.?.withAutoVersion();
load_module_from_cache: {
diff --git a/src/runtime.js b/src/runtime.js
index 537ea9eed..b4631ea1e 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -1,4 +1,5 @@
-var $$mod$ = Symbol.for;
+var tagSymbol;
+var cjsRequireSymbol;
var __create = Object.create;
var __descs = Object.getOwnPropertyDescriptors;
var __defProp = Object.defineProperty;
@@ -7,28 +8,83 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
-// We're disabling Object.freeze because it breaks CJS => ESM and can cause
-// issues with Suspense and other things that expect the CJS module namespace
-// to be mutable when the ESM module namespace is NOT mutable
-// var __objectFreezePolyfill = new WeakSet();
+export var __markAsModule = target => __defProp(target, "__esModule", { value: true, configurable: true });
-// globalThis.Object.freeze = function freeze(obj) {
-// __objectFreezePolyfill.add(obj);
-// return obj;
-// };
+// This is used to implement "export * from" statements. It copies properties
+// from the imported module to the current module's ESM export object. If the
+// current module is an entry point and the target format is CommonJS, we
+// also copy the properties to "module.exports" in addition to our module's
+// internal ESM export object.
+export var __reExport = (target, mod, secondTarget) => {
+ for (let key of __getOwnPropNames(mod))
+ if (!__hasOwnProp.call(target, key) && key !== "default")
+ __defProp(target, key, {
+ get: () => mod[key],
+ enumerable: true,
+ });
-// globalThis.Object.isFrozen = function isFrozen(obj) {
-// return __objectFreezePolyfill.has(obj);
-// };
+ if (secondTarget) {
+ for (let key of __getOwnPropNames(mod))
+ if (!__hasOwnProp.call(secondTarget, key) && key !== "default")
+ __defProp(secondTarget, key, {
+ get: () => mod[key],
+ enumerable: true,
+ });
-export var __markAsModule = target => __defProp(target, "__esModule", { value: true, configurable: true });
+ return secondTarget;
+ }
+};
+
+// Converts the module from CommonJS to ESM. When in node mode (i.e. in an
+// ".mjs" file, package.json has "type: module", or the "__esModule" export
+// in the CommonJS file is falsy or missing), the "default" property is
+// overridden to point to the original CommonJS exports object instead.
+export var __toESM = (mod, isNodeMode, target) => {
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
+ const to =
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
+
+ // If the importer is in node compatibility mode or this is not an ESM
+ // file that has been converted to a CommonJS file using a Babel-
+ // compatible transform (i.e. "__esModule" has not been set), then set
+ // "default" to the CommonJS "module.exports" for node compatibility.
+ for (let key of __getOwnPropNames(mod))
+ if (!__hasOwnProp.call(to, key))
+ __defProp(to, key, {
+ get: () => mod[key],
+ enumerable: true,
+ });
+
+ return to;
+};
+
+// Converts the module from ESM to CommonJS. This clones the input module
+// object with the addition of a non-enumerable "__esModule" property set
+// to "true", which overwrites any existing export named "__esModule".
+export var __toCommonJS = /* @__PURE__ */ from => {
+ const moduleCache = (__toCommonJS.moduleCache ??= new WeakMap());
+ var cached = moduleCache.get(from);
+ if (cached) return cached;
+ var to = __defProp({}, "__esModule", { value: true });
+ var desc = { enumerable: false };
+ if ((from && typeof from === "object") || typeof from === "function")
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key))
+ __defProp(to, key, {
+ get: () => from[key],
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
+ });
+
+ moduleCache.set(from, to);
+ return to;
+};
// lazy require to prevent loading one icon from a design system
-export var $$lzy = (target, module, props) => {
+export var $$lzy = (target, mod, props) => {
for (let key in props) {
if (!__hasOwnProp.call(target, key))
__defProp(target, key, {
- get: () => module()[props[key]],
+ get: () => mod()[props[key]],
enumerable: true,
configurable: true,
});
@@ -36,27 +92,16 @@ export var $$lzy = (target, module, props) => {
return target;
};
-export var __toModule = module => {
- return __reExport(
- __markAsModule(
- __defProp(
- module != null ? __create(__getProtoOf(module)) : {},
- "default",
- module && module.__esModule && "default" in module
- ? { get: () => module.default, enumerable: true, configurable: true }
- : { value: module, enumerable: true, configurable: true },
- ),
- ),
- module,
- );
-};
+// When you do know the module is CJS
+export var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
-var tagSymbol = Symbol.for("CommonJSTransformed");
-var cjsRequireSymbol = Symbol.for("CommonJS");
-export var __commonJS = (cb, name) => {
+// When you don't know if the module is going to be ESM or CJS
+export var __cJS2eSM = (cb, name) => {
var mod;
var origExports;
var has_run = false;
+ tagSymbol ??= Symbol.for("CommonJSTransformed");
+ cjsRequireSymbol ??= Symbol.for("CommonJS");
const requireFunction = function load() {
if (has_run) {
@@ -125,15 +170,13 @@ export var __commonJS = (cb, name) => {
return requireFunction;
};
-export var __cJS2eSM = __commonJS;
-
-export var __internalIsCommonJSNamespace = namespace =>
+export var __internalIsCommonJSNamespace = /* @__PURE__ */ namespace =>
namespace != null &&
typeof namespace === "object" &&
((namespace.default && namespace.default[cjsRequireSymbol]) || namespace[cjsRequireSymbol]);
// require()
-export var __require = namespace => {
+export var __require = /* @__PURE__ */ namespace => {
if (__internalIsCommonJSNamespace(namespace)) {
return namespace.default();
}
@@ -141,13 +184,6 @@ export var __require = namespace => {
return namespace;
};
-// require().default
-// this currently does nothing
-// get rid of this wrapper once we're more confident we do not need special handling for default
-__require.d = namespace => {
- return namespace;
-};
-
export var $$m = __commonJS;
export var __name = (target, name) => {
@@ -162,7 +198,8 @@ export var __name = (target, name) => {
// ESM export -> CJS export
// except, writable incase something re-exports
-export var __export = (target, all) => {
+
+export var __export = /* @__PURE__ */ (target, all) => {
for (var name in all)
__defProp(target, name, {
get: all[name],
@@ -192,18 +229,6 @@ export var __exportDefault = (target, value) => {
});
};
-export var __reExport = (target, module, desc) => {
- if ((module && typeof module === "object") || typeof module === "function")
- for (let key of __getOwnPropNames(module))
- if (!__hasOwnProp.call(target, key) && key !== "default")
- __defProp(target, key, {
- get: () => module[key],
- configurable: true,
- enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable,
- });
- return target;
-};
-
function hasAnyProps(obj) {
for (let key in obj) return true;
return false;
@@ -236,3 +261,8 @@ export var __decorateClass = (decorators, target, key, kind) => {
};
export var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
+
+export var __esm = (fn, res) => () => (fn && (res = fn((fn = 0))), res);
+
+// This is used for JSX inlining with React.
+export var $$typeof = /* @__PURE__ */ Symbol.for("react.element");
diff --git a/src/runtime.zig b/src/runtime.zig
index cfc9574ed..379078448 100644
--- a/src/runtime.zig
+++ b/src/runtime.zig
@@ -294,6 +294,8 @@ pub const Runtime = struct {
inject_jest_globals: bool = false,
+ commonjs_named_exports: bool = true,
+
/// Instead of jsx("div", {}, void 0)
/// ->
/// {
@@ -362,6 +364,7 @@ pub const Runtime = struct {
__merge: ?GeneratedSymbol = null,
__decorateClass: ?GeneratedSymbol = null,
__decorateParam: ?GeneratedSymbol = null,
+ @"$$typeof": ?GeneratedSymbol = null,
pub const all = [_][]const u8{
// __HMRClient goes first
@@ -384,7 +387,35 @@ pub const Runtime = struct {
"__merge",
"__decorateClass",
"__decorateParam",
+ "$$typeof",
+ };
+ const all_sorted: [all.len]string = brk: {
+ var list = all;
+ const Sorter = struct {
+ fn compare(_: void, a: []const u8, b: []const u8) bool {
+ return std.mem.order(u8, a, b) == .lt;
+ }
+ };
+ std.sort.sort(string, &list, void{}, Sorter.compare);
+ break :brk list;
};
+
+ /// When generating the list of runtime imports, we sort it for determinism.
+ /// This is a lookup table so we don't need to resort the strings each time
+ pub const all_sorted_index = brk: {
+ var out: [all.len]usize = undefined;
+ inline for (all, 0..) |name, i| {
+ for (all_sorted, 0..) |cmp, j| {
+ if (strings.eqlComptime(name, cmp)) {
+ out[i] = j;
+ break;
+ }
+ }
+ }
+
+ break :brk out;
+ };
+
pub const Name = "bun:wrap";
pub const alt_name = "bun:wrap";
@@ -493,6 +524,11 @@ pub const Runtime = struct {
return Entry{ .key = 17, .value = val.ref };
}
},
+ 18 => {
+ if (@field(this.runtime_imports, all[18])) |val| {
+ return Entry{ .key = 18, .value = val.ref };
+ }
+ },
else => {
return null;
},
@@ -555,6 +591,7 @@ pub const Runtime = struct {
15 => (@field(imports, all[15]) orelse return null).ref,
16 => (@field(imports, all[16]) orelse return null).ref,
17 => (@field(imports, all[17]) orelse return null).ref,
+ 18 => (@field(imports, all[18]) orelse return null).ref,
else => null,
};
}
diff --git a/src/sourcemap/sourcemap.zig b/src/sourcemap/sourcemap.zig
index 3fa063e74..721c8caf6 100644
--- a/src/sourcemap/sourcemap.zig
+++ b/src/sourcemap/sourcemap.zig
@@ -315,10 +315,61 @@ pub const Mapping = struct {
};
};
-pub const LineColumnOffset = struct {
+pub const LineColumnOffset = packed struct {
lines: i32 = 0,
columns: i32 = 0,
+ pub const Optional = union(enum) {
+ null: void,
+ value: LineColumnOffset,
+
+ pub fn advance(this: *Optional, input: []const u8) void {
+ switch (this.*) {
+ .null => {},
+ .value => this.value.advance(input),
+ }
+ }
+ };
+
+ pub fn advance(this: *LineColumnOffset, input: []const u8) void {
+ var columns = this.columns;
+ defer this.columns = columns;
+ var offset: u32 = 0;
+ while (strings.indexOfNewlineOrNonASCII(input, offset)) |i| {
+ std.debug.assert(i >= offset);
+ std.debug.assert(i < input.len);
+
+ columns += @intCast(i32, i - offset);
+ offset = i;
+
+ var cp = strings.CodepointIterator.initOffset(input, offset);
+ var cursor = strings.CodepointIterator.Cursor{};
+ _ = cp.next(&cursor);
+ switch (cursor.c) {
+ '\r', '\n', 0x2028, 0x2029 => {
+ // Handle Windows-specific "\r\n" newlines
+ if (cp.c == '\r' and input.len > offset + 1 and input[offset + 1] == '\n') {
+ columns += 1;
+ offset += 1;
+ continue;
+ }
+
+ this.lines += 1;
+ columns = 0;
+ },
+ else => |c| {
+ // Mozilla's "source-map" library counts columns using UTF-16 code units
+ columns += switch (c) {
+ 0...0xFFFF => 1,
+ else => 2,
+ };
+ },
+ }
+ }
+
+ columns += @intCast(i32, input.len - offset);
+ }
+
pub fn cmp(_: void, a: LineColumnOffset, b: LineColumnOffset) std.math.Order {
if (a.lines != b.lines) {
return std.math.order(a.lines, b.lines);
diff --git a/src/string_builder.zig b/src/string_builder.zig
index e3921568b..1dcf7b494 100644
--- a/src/string_builder.zig
+++ b/src/string_builder.zig
@@ -4,6 +4,7 @@ const bun = @import("bun");
const Environment = bun.Environment;
const string = @import("string_types.zig").string;
const StringBuilder = @This();
+const assert = std.debug.assert;
const DebugHashTable = if (Environment.allow_assert) std.AutoHashMapUnmanaged(u64, void) else void;
@@ -11,13 +12,19 @@ len: usize = 0,
cap: usize = 0,
ptr: ?[*]u8 = null,
-debug_only_checker: DebugHashTable = DebugHashTable{},
+pub fn initCapacity(
+ allocator: std.mem.Allocator,
+ cap: usize,
+) !StringBuilder {
+ return StringBuilder{
+ .cap = cap,
+ .len = 0,
+ .ptr = (try allocator.alloc(u8, cap)).ptr,
+ };
+}
pub fn count(this: *StringBuilder, slice: string) void {
this.cap += slice.len;
- if (comptime Environment.allow_assert) {
- _ = this.debug_only_checker.getOrPut(bun.default_allocator, bun.hash(slice)) catch unreachable;
- }
}
pub fn allocate(this: *StringBuilder, allocator: Allocator) !void {
@@ -29,39 +36,34 @@ pub fn allocate(this: *StringBuilder, allocator: Allocator) !void {
pub fn deinit(this: *StringBuilder, allocator: Allocator) void {
if (this.ptr == null or this.cap == 0) return;
allocator.free(this.ptr.?[0..this.cap]);
- if (comptime Environment.allow_assert) {
- this.debug_only_checker.deinit(bun.default_allocator);
- this.debug_only_checker = .{};
- }
}
pub fn append(this: *StringBuilder, slice: string) string {
if (comptime Environment.allow_assert) {
- std.debug.assert(this.len <= this.cap); // didn't count everything
- std.debug.assert(this.ptr != null); // must call allocate first
- std.debug.assert(this.debug_only_checker.contains(bun.hash(slice)));
+ assert(this.len <= this.cap); // didn't count everything
+ assert(this.ptr != null); // must call allocate first
}
bun.copy(u8, this.ptr.?[this.len..this.cap], slice);
const result = this.ptr.?[this.len..this.cap][0..slice.len];
this.len += slice.len;
- if (comptime Environment.allow_assert) std.debug.assert(this.len <= this.cap);
+ if (comptime Environment.allow_assert) assert(this.len <= this.cap);
return result;
}
pub fn fmt(this: *StringBuilder, comptime str: string, args: anytype) string {
if (comptime Environment.allow_assert) {
- std.debug.assert(this.len <= this.cap); // didn't count everything
- std.debug.assert(this.ptr != null); // must call allocate first
+ assert(this.len <= this.cap); // didn't count everything
+ assert(this.ptr != null); // must call allocate first
}
var buf = this.ptr.?[this.len..this.cap];
const out = std.fmt.bufPrint(buf, str, args) catch unreachable;
this.len += out.len;
- if (comptime Environment.allow_assert) std.debug.assert(this.len <= this.cap);
+ if (comptime Environment.allow_assert) assert(this.len <= this.cap);
return out;
}
@@ -73,8 +75,7 @@ pub fn fmtCount(this: *StringBuilder, comptime str: string, args: anytype) void
pub fn allocatedSlice(this: *StringBuilder) []u8 {
var ptr = this.ptr orelse return &[_]u8{};
if (comptime Environment.allow_assert) {
- std.debug.assert(this.cap > 0);
- std.debug.assert(this.len > 0);
+ assert(this.cap > 0);
}
return ptr[0..this.cap];
}
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index f4c6fae07..889add550 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -20,7 +20,7 @@ pub inline fn containsChar(self: string, char: u8) bool {
}
pub inline fn contains(self: string, str: string) bool {
- return std.mem.indexOf(u8, self, str) != null;
+ return indexOf(self, str) != null;
}
pub fn toUTF16Literal(comptime str: []const u8) []const u16 {
@@ -41,11 +41,9 @@ pub fn toUTF16Literal(comptime str: []const u8) []const u16 {
const OptionalUsize = std.meta.Int(.unsigned, @bitSizeOf(usize) - 1);
pub fn indexOfAny(self: string, comptime str: anytype) ?OptionalUsize {
- for (self, 0..) |c, i| {
- inline for (str) |a| {
- if (c == a) {
- return @intCast(OptionalUsize, i);
- }
+ inline for (str) |a| {
+ if (indexOfChar(self, a)) |i| {
+ return @intCast(OptionalUsize, i);
}
}
@@ -148,6 +146,79 @@ pub fn indexOfCharNeg(self: string, char: u8) i32 {
return -1;
}
+/// Format a string to an ECMAScript identifier.
+/// Unlike the string_mutable.zig version, this always allocate/copy
+pub fn fmtIdentifier(name: string) FormatValidIdentifier {
+ return FormatValidIdentifier{ .name = name };
+}
+
+/// Format a string to an ECMAScript identifier.
+/// Different implementation than string_mutable because string_mutable may avoid allocating
+/// This will always allocate
+pub const FormatValidIdentifier = struct {
+ name: string,
+ const js_lexer = @import("./js_lexer.zig");
+ pub fn format(self: FormatValidIdentifier, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
+ var iterator = strings.CodepointIterator.init(self.name);
+ var cursor = strings.CodepointIterator.Cursor{};
+
+ var has_needed_gap = false;
+ var needs_gap = false;
+ var start_i: usize = 0;
+
+ if (!iterator.next(&cursor)) {
+ try writer.writeAll("_");
+ return;
+ }
+
+ // Common case: no gap necessary. No allocation necessary.
+ needs_gap = !js_lexer.isIdentifierStart(cursor.c);
+ if (!needs_gap) {
+ // Are there any non-alphanumeric chars at all?
+ while (iterator.next(&cursor)) {
+ if (!js_lexer.isIdentifierContinue(cursor.c) or cursor.width > 1) {
+ needs_gap = true;
+ start_i = cursor.i;
+ break;
+ }
+ }
+ }
+
+ if (needs_gap) {
+ needs_gap = false;
+ if (start_i > 0) try writer.writeAll(self.name[0..start_i]);
+ var slice = self.name[start_i..];
+ iterator = strings.CodepointIterator.init(slice);
+ cursor = strings.CodepointIterator.Cursor{};
+
+ while (iterator.next(&cursor)) {
+ if (js_lexer.isIdentifierContinue(cursor.c) and cursor.width == 1) {
+ if (needs_gap) {
+ try writer.writeAll("_");
+ needs_gap = false;
+ has_needed_gap = true;
+ }
+ try writer.writeAll(slice[cursor.i .. cursor.i + @as(u32, cursor.width)]);
+ } else if (!needs_gap) {
+ needs_gap = true;
+ // skip the code point, replace it with a single _
+ }
+ }
+
+ // If it ends with an emoji
+ if (needs_gap) {
+ try writer.writeAll("_");
+ needs_gap = false;
+ has_needed_gap = true;
+ }
+
+ return;
+ }
+
+ try writer.writeAll(self.name);
+ }
+};
+
pub fn indexOfSigned(self: string, str: string) i32 {
const i = std.mem.indexOf(u8, self, str) orelse return -1;
return @intCast(i32, i);
@@ -177,7 +248,9 @@ pub inline fn indexOf(self: string, str: string) ?usize {
const start = bun.C.memmem(self_ptr, self_len, str_ptr, str_len) orelse return null;
- return @ptrToInt(start) - @ptrToInt(self_ptr);
+ const i = @ptrToInt(start) - @ptrToInt(self_ptr);
+ std.debug.assert(i < self_len);
+ return @intCast(usize, i);
}
pub fn split(self: string, delimiter: string) SplitIterator {
@@ -2899,12 +2972,12 @@ pub const max_16_ascii = @splat(ascii_vector_size, @as(u8, 127));
pub const min_16_ascii = @splat(ascii_vector_size, @as(u8, 0x20));
pub const max_u16_ascii = @splat(ascii_u16_vector_size, @as(u16, 127));
pub const min_u16_ascii = @splat(ascii_u16_vector_size, @as(u16, 0x20));
-pub const AsciiVector = std.meta.Vector(ascii_vector_size, u8);
-pub const AsciiVectorSmall = std.meta.Vector(8, u8);
-pub const AsciiVectorU1 = std.meta.Vector(ascii_vector_size, u1);
-pub const AsciiVectorU1Small = std.meta.Vector(8, u1);
-pub const AsciiVectorU16U1 = std.meta.Vector(ascii_u16_vector_size, u1);
-pub const AsciiU16Vector = std.meta.Vector(ascii_u16_vector_size, u16);
+pub const AsciiVector = @Vector(ascii_vector_size, u8);
+pub const AsciiVectorSmall = @Vector(8, u8);
+pub const AsciiVectorU1 = @Vector(ascii_vector_size, u1);
+pub const AsciiVectorU1Small = @Vector(8, u1);
+pub const AsciiVectorU16U1 = @Vector(ascii_u16_vector_size, u1);
+pub const AsciiU16Vector = @Vector(ascii_u16_vector_size, u16);
pub const max_4_ascii = @splat(4, @as(u8, 127));
pub fn isAllASCII(slice: []const u8) bool {
if (bun.FeatureFlags.use_simdutf)
@@ -3200,34 +3273,15 @@ pub fn indexOfCharZ(sliceZ: [:0]const u8, char: u8) ?u63 {
}
pub fn indexOfChar(slice: []const u8, char: u8) ?u32 {
- var remaining = slice;
- if (remaining.len == 0)
+ if (slice.len == 0)
return null;
- if (remaining[0] == char)
- return 0;
-
- if (comptime Environment.enableSIMD) {
- while (remaining.len >= ascii_vector_size) {
- const vec: AsciiVector = remaining[0..ascii_vector_size].*;
- const cmp = vec == @splat(ascii_vector_size, char);
-
- if (@reduce(.Max, @bitCast(AsciiVectorU1, cmp)) > 0) {
- const bitmask = @bitCast(AsciiVectorInt, cmp);
- const first = @ctz(bitmask);
- return @intCast(u32, @as(u32, first) + @intCast(u32, slice.len - remaining.len));
- }
- remaining = remaining[ascii_vector_size..];
- }
- }
-
- for (remaining, 0..) |c, i| {
- if (c == char) {
- return @truncate(u32, i + (slice.len - remaining.len));
- }
- }
+ const ptr = bun.C.memchr(slice.ptr, char, slice.len) orelse return null;
+ const i = @ptrToInt(ptr) - @ptrToInt(slice.ptr);
+ std.debug.assert(i < slice.len);
+ std.debug.assert(slice[i] == char);
- return null;
+ return @truncate(u32, i);
}
test "indexOfChar" {
@@ -3829,25 +3883,51 @@ pub fn join(slices: []const string, delimiter: string, allocator: std.mem.Alloca
return try std.mem.join(allocator, delimiter, slices);
}
+pub fn order(a: []const u8, b: []const u8) std.math.Order {
+ const len = @min(a.len, b.len);
+ const cmp = bun.C.memcmp(a.ptr, b.ptr, len);
+ return switch (std.math.sign(cmp)) {
+ 0 => std.math.order(a.len, b.len),
+ 1 => .gt,
+ -1 => .lt,
+ else => unreachable,
+ };
+}
+
pub fn cmpStringsAsc(_: void, a: string, b: string) bool {
- return std.mem.order(u8, a, b) == .lt;
+ return order(a, b) == .lt;
}
pub fn cmpStringsDesc(_: void, a: string, b: string) bool {
- return std.mem.order(u8, a, b) == .gt;
+ return order(a, b) == .gt;
}
const sort_asc = std.sort.asc(u8);
const sort_desc = std.sort.desc(u8);
pub fn sortAsc(in: []string) void {
+ // TODO: experiment with simd to see if it's faster
std.sort.sort([]const u8, in, {}, cmpStringsAsc);
}
pub fn sortDesc(in: []string) void {
+ // TODO: experiment with simd to see if it's faster
std.sort.sort([]const u8, in, {}, cmpStringsDesc);
}
+pub const StringArrayByIndexSorter = struct {
+ keys: []const []const u8,
+ pub fn lessThan(sorter: *const @This(), a: usize, b: usize) bool {
+ return strings.order(sorter.keys[a], sorter.keys[b]) == .lt;
+ }
+
+ pub fn init(keys: []const []const u8) @This() {
+ return .{
+ .keys = keys,
+ };
+ }
+};
+
pub fn isASCIIHexDigit(c: u8) bool {
return std.ascii.isHex(c);
}
diff --git a/src/string_joiner.zig b/src/string_joiner.zig
index 490989c9a..373d24633 100644
--- a/src/string_joiner.zig
+++ b/src/string_joiner.zig
@@ -1,7 +1,8 @@
/// Rope-like data structure for joining many small strings into one big string.
const std = @import("std");
-const default_allocator = @import("bun").default_allocator;
-const string = @import("string_types.zig").string;
+const default_allocator = bun.default_allocator;
+const bun = @import("bun");
+const string = bun.string;
const Allocator = std.mem.Allocator;
const ObjectPool = @import("./pool.zig").ObjectPool;
const Joiner = @This();
@@ -15,7 +16,6 @@ const Joinable = struct {
pub const Pool = ObjectPool(Joinable, null, true, 4);
};
-last_byte: u8 = 0,
len: usize = 0,
use_pool: bool = true,
node_allocator: Allocator = undefined,
@@ -23,6 +23,15 @@ node_allocator: Allocator = undefined,
head: ?*Joinable.Pool.Node = null,
tail: ?*Joinable.Pool.Node = null,
+/// Avoid an extra pass over the list when joining
+watcher: Watcher = .{},
+
+pub const Watcher = struct {
+ input: []const u8 = "",
+ estimated_count: u32 = 0,
+ needs_newline: bool = false,
+};
+
pub fn done(this: *Joiner, allocator: Allocator) ![]u8 {
if (this.head == null) {
var out: []u8 = &[_]u8{};
@@ -60,6 +69,17 @@ pub fn lastByte(this: *const Joiner) u8 {
return 0;
}
+pub fn push(this: *Joiner, slice: string) void {
+ this.append(slice, 0, null);
+}
+
+pub fn ensureNewlineAtEnd(this: *Joiner) void {
+ if (this.watcher.needs_newline) {
+ this.watcher.needs_newline = false;
+ this.push("\n");
+ }
+}
+
pub fn append(this: *Joiner, slice: string, offset: u32, allocator: ?Allocator) void {
const data = slice[offset..];
this.len += @truncate(u32, data.len);
@@ -69,6 +89,14 @@ pub fn append(this: *Joiner, slice: string, offset: u32, allocator: ?Allocator)
else
(this.node_allocator.create(Joinable.Pool.Node) catch unreachable);
+ this.watcher.estimated_count += @boolToInt(
+ this.watcher.input.len > 0 and
+ bun.strings.contains(data, this.watcher.input),
+ );
+
+ this.watcher.needs_newline = this.watcher.input.len > 0 and data.len > 0 and
+ data[data.len - 1] != '\n';
+
new_tail.* = .{
.allocator = default_allocator,
.data = Joinable{
diff --git a/src/string_mutable.zig b/src/string_mutable.zig
index 129ea1481..3a6918b5c 100644
--- a/src/string_mutable.zig
+++ b/src/string_mutable.zig
@@ -68,10 +68,9 @@ pub const MutableString = struct {
return mutable;
}
- // Convert it to an ASCII identifier. Note: If you change this to a non-ASCII
- // identifier, you're going to potentially cause trouble with non-BMP code
- // points in target environments that don't support bracketed Unicode escapes.
-
+ /// Convert it to an ASCII identifier. Note: If you change this to a non-ASCII
+ /// identifier, you're going to potentially cause trouble with non-BMP code
+ /// points in target environments that don't support bracketed Unicode escapes.
pub fn ensureValidIdentifier(str: string, allocator: std.mem.Allocator) !string {
if (str.len == 0) {
return "_";
@@ -101,7 +100,7 @@ pub const MutableString = struct {
}
}
- if (!needs_gap and str.len >= 3 and str.len <= 10) {
+ if (!needs_gap) {
return JSLexerTables.StrictModeReservedWordsRemap.get(str) orelse str;
}
@@ -174,7 +173,15 @@ pub const MutableString = struct {
pub inline fn reset(
self: *MutableString,
) void {
- self.list.shrinkRetainingCapacity(0);
+ self.list.clearRetainingCapacity();
+ }
+
+ pub inline fn resetTo(
+ self: *MutableString,
+ index: usize,
+ ) void {
+ std.debug.assert(index <= self.list.capacity);
+ self.list.items.len = index;
}
pub fn inflate(self: *MutableString, amount: usize) !void {
@@ -190,6 +197,14 @@ pub const MutableString = struct {
pub inline fn append(self: *MutableString, char: []const u8) !void {
try self.list.appendSlice(self.allocator, char);
}
+ pub inline fn appendInt(self: *MutableString, int: u64) !void {
+ const count = bun.fmt.fastDigitCount(int);
+ try self.list.ensureUnusedCapacity(self.allocator, count);
+ const old = self.list.items.len;
+ self.list.items.len += count;
+ std.debug.assert(count == bun.fmt.formatIntBuf(self.list.items.ptr[old .. old + count], int, 10, .lower, .{}));
+ }
+
pub inline fn appendAssumeCapacity(self: *MutableString, char: []const u8) void {
self.list.appendSliceAssumeCapacity(
char,
diff --git a/src/sync.zig b/src/sync.zig
index ec3d57c5d..b51b1116f 100644
--- a/src/sync.zig
+++ b/src/sync.zig
@@ -771,11 +771,15 @@ pub const WaitGroup = struct {
self.* = undefined;
}
- pub fn add(self: *WaitGroup) void {
+ pub fn addN(self: *WaitGroup, n: usize) void {
self.mutex.lock();
defer self.mutex.unlock();
- self.active += 1;
+ self.active += n;
+ }
+
+ pub fn add(self: *WaitGroup) void {
+ return self.addN(1);
}
pub fn done(self: *WaitGroup) void {
diff --git a/src/thread_pool.zig b/src/thread_pool.zig
index 47feae0df..da402407e 100644
--- a/src/thread_pool.zig
+++ b/src/thread_pool.zig
@@ -125,6 +125,269 @@ pub const Batch = struct {
}
};
+pub const WaitGroup = struct {
+ mutex: std.Thread.Mutex = .{},
+ counter: u32 = 0,
+ event: std.Thread.ResetEvent,
+
+ pub fn init(self: *WaitGroup) void {
+ self.* = .{
+ .mutex = .{},
+ .counter = 0,
+ .event = undefined,
+ };
+ }
+
+ pub fn deinit(self: *WaitGroup) void {
+ self.event.reset();
+ self.* = undefined;
+ }
+
+ pub fn start(self: *WaitGroup) void {
+ self.mutex.lock();
+ defer self.mutex.unlock();
+
+ self.counter += 1;
+ }
+
+ pub fn finish(self: *WaitGroup) void {
+ self.mutex.lock();
+ defer self.mutex.unlock();
+
+ self.counter -= 1;
+
+ if (self.counter == 0) {
+ self.event.set();
+ }
+ }
+
+ pub fn wait(self: *WaitGroup) void {
+ while (true) {
+ self.mutex.lock();
+
+ if (self.counter == 0) {
+ self.mutex.unlock();
+ return;
+ }
+
+ self.mutex.unlock();
+ self.event.wait();
+ }
+ }
+
+ pub fn reset(self: *WaitGroup) void {
+ self.event.reset();
+ }
+};
+
+pub fn ConcurrentFunction(
+ comptime Function: anytype,
+) type {
+ return struct {
+ const Fn = Function;
+ const Args = std.meta.ArgsTuple(@TypeOf(Fn));
+ const Runner = @This();
+ thread_pool: *ThreadPool,
+ states: []Routine = undefined,
+ batch: Batch = .{},
+ allocator: std.mem.Allocator,
+
+ pub fn init(allocator: std.mem.Allocator, thread_pool: *ThreadPool, count: usize) !Runner {
+ return Runner{
+ .allocator = allocator,
+ .thread_pool = thread_pool,
+ .states = try allocator.alloc(Routine, count),
+ .batch = .{},
+ };
+ }
+
+ pub fn call(this: *@This(), args: Args) void {
+ this.states[this.batch.len] = .{
+ .args = args,
+ };
+ this.batch.push(Batch.from(&this.states[this.batch.len].task));
+ }
+
+ pub fn run(this: *@This()) void {
+ this.thread_pool.schedule(this.batch);
+ }
+
+ pub const Routine = struct {
+ args: Args,
+ task: Task = .{ .callback = callback },
+
+ pub fn callback(task: *Task) void {
+ var routine = @fieldParentPtr(@This(), "task", task);
+ @call(.always_inline, Fn, routine.args);
+ }
+ };
+
+ pub fn deinit(this: *@This()) void {
+ this.allocator.free(this.states);
+ }
+ };
+}
+
+pub fn runner(
+ this: *ThreadPool,
+ allocator: std.mem.Allocator,
+ comptime Function: anytype,
+ count: usize,
+) !ConcurrentFunction(Function) {
+ return try ConcurrentFunction(Function).init(allocator, this, count);
+}
+
+/// Loop over an array of tasks and invoke `Run` on each one in a different thread
+/// **Blocks the calling thread** until all tasks are completed.
+pub fn do(
+ this: *ThreadPool,
+ allocator: std.mem.Allocator,
+ wg: ?*WaitGroup,
+ ctx: anytype,
+ comptime Run: anytype,
+ values: anytype,
+) !void {
+ return try Do(this, allocator, wg, @TypeOf(ctx), ctx, Run, @TypeOf(values), values, false);
+}
+
+pub fn doPtr(
+ this: *ThreadPool,
+ allocator: std.mem.Allocator,
+ wg: ?*WaitGroup,
+ ctx: anytype,
+ comptime Run: anytype,
+ values: anytype,
+) !void {
+ return try Do(this, allocator, wg, @TypeOf(ctx), ctx, Run, @TypeOf(values), values, true);
+}
+
+pub fn Do(
+ this: *ThreadPool,
+ allocator: std.mem.Allocator,
+ wg: ?*WaitGroup,
+ comptime Context: type,
+ ctx: Context,
+ comptime Function: anytype,
+ comptime ValuesType: type,
+ values: ValuesType,
+ comptime as_ptr: bool,
+) !void {
+ if (values.len == 0)
+ return;
+ var allocated_wait_group: ?*WaitGroup = null;
+ defer {
+ if (allocated_wait_group) |group| {
+ group.deinit();
+ allocator.destroy(group);
+ }
+ }
+
+ var wait_group = wg orelse brk: {
+ allocated_wait_group = try allocator.create(WaitGroup);
+ allocated_wait_group.?.init();
+ break :brk allocated_wait_group.?;
+ };
+ const WaitContext = struct {
+ wait_group: *WaitGroup = undefined,
+ ctx: Context,
+ values: ValuesType,
+ };
+
+ const RunnerTask = struct {
+ task: Task,
+ ctx: *WaitContext,
+ i: usize = 0,
+
+ pub fn call(task: *Task) void {
+ var runner_task = @fieldParentPtr(@This(), "task", task);
+ const i = runner_task.i;
+ if (comptime as_ptr) {
+ Function(runner_task.ctx.ctx, &runner_task.ctx.values[i], i);
+ } else {
+ Function(runner_task.ctx.ctx, runner_task.ctx.values[i], i);
+ }
+
+ runner_task.ctx.wait_group.finish();
+ }
+ };
+ var wait_context = allocator.create(WaitContext) catch unreachable;
+ wait_context.* = .{
+ .ctx = ctx,
+ .wait_group = wait_group,
+ .values = values,
+ };
+ defer allocator.destroy(wait_context);
+ var tasks = allocator.alloc(RunnerTask, values.len) catch unreachable;
+ defer allocator.free(tasks);
+ var batch: Batch = undefined;
+ var offset = tasks.len - 1;
+
+ {
+ tasks[0] = .{
+ .i = offset,
+ .task = .{ .callback = RunnerTask.call },
+ .ctx = wait_context,
+ };
+ batch = Batch.from(&tasks[0].task);
+ }
+ if (tasks.len > 1) {
+ for (tasks[1..]) |*runner_task| {
+ offset -= 1;
+ runner_task.* = .{
+ .i = offset,
+ .task = .{ .callback = RunnerTask.call },
+ .ctx = wait_context,
+ };
+ batch.push(Batch.from(&runner_task.task));
+ }
+ }
+
+ wait_group.counter += @intCast(u32, values.len);
+ this.schedule(batch);
+ wait_group.wait();
+}
+
+test "parallel for loop" {
+ Output.initTest();
+ var thread_pool = ThreadPool.init(.{ .max_threads = 12 });
+ var sleepy_time: u32 = 100;
+ var huge_array = &[_]u32{
+ sleepy_time + std.rand.DefaultPrng.init(1).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(2).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(3).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(4).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(5).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(6).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(7).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(8).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(9).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(10).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(11).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(12).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(13).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(14).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(15).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(16).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(17).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(18).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(19).random().uintAtMost(u32, 20),
+ sleepy_time + std.rand.DefaultPrng.init(20).random().uintAtMost(u32, 20),
+ };
+ const Runner = struct {
+ completed: usize = 0,
+ total: usize = 0,
+ pub fn run(ctx: *@This(), value: u32, _: usize) void {
+ std.time.sleep(value);
+ ctx.completed += 1;
+ std.debug.assert(ctx.completed <= ctx.total);
+ }
+ };
+ var runny = try std.heap.page_allocator.create(Runner);
+ runny.* = .{ .total = huge_array.len };
+ try thread_pool.doAndWait(std.heap.page_allocator, null, runny, Runner.run, std.mem.span(huge_array));
+ try std.testing.expectEqual(huge_array.len, runny.completed);
+}
+
/// Schedule a batch of tasks to be executed by some thread on the thread pool.
pub fn schedule(self: *ThreadPool, batch: Batch) void {
// Sanity check
diff --git a/src/util.zig b/src/util.zig
new file mode 100644
index 000000000..8e06df9a1
--- /dev/null
+++ b/src/util.zig
@@ -0,0 +1,341 @@
+// Things that maybe should go in Zig standard library at some point
+const std = @import("std");
+const bun = @import("bun");
+
+pub fn Key(comptime Map: type) type {
+ return FieldType(Map.KV, "key").?;
+}
+
+pub fn Value(comptime Map: type) type {
+ return FieldType(Map.KV, "value").?;
+}
+
+pub fn fromEntries(
+ comptime Map: type,
+ allocator: std.mem.Allocator,
+ comptime EntryType: type,
+ entries: EntryType,
+) !Map {
+ var map: Map = undefined;
+ if (@hasField(Map, "allocator")) {
+ map = Map.init(allocator);
+ } else {
+ map = Map{};
+ }
+
+ if (comptime std.meta.trait.isIndexable(EntryType)) {
+ if (comptime !needsAllocator(Map.ensureUnusedCapacity)) {
+ try map.ensureUnusedCapacity(entries.len);
+ } else {
+ try map.ensureUnusedCapacity(allocator, entries.len);
+ }
+
+ comptime var i: usize = 0;
+
+ inline while (i < std.meta.fields(EntryType).len) : (i += 1) {
+ map.putAssumeCapacity(entries[i].@"0", entries[i].@"1");
+ }
+
+ return map;
+ } else if (comptime std.meta.trait.isContainer(EntryType) and @hasDecl(EntryType, "count")) {
+ if (comptime !needsAllocator(Map.ensureUnusedCapacity)) {
+ try map.ensureUnusedCapacity(entries.count());
+ } else {
+ try map.ensureUnusedCapacity(allocator, entries.count());
+ }
+
+ if (comptime @hasDecl(EntryType, "iterator")) {
+ var iter = entries.iterator();
+ while (iter.next()) |entry| {
+ map.putAssumeCapacity(entry.@"0", entry.@"1");
+ }
+
+ return map;
+ }
+ } else if (comptime std.meta.trait.isContainer(EntryType) and std.meta.fields(EntryType).len > 0) {
+ if (comptime !needsAllocator(Map.ensureUnusedCapacity)) {
+ try map.ensureUnusedCapacity(std.meta.fields(EntryType).len);
+ } else {
+ try map.ensureUnusedCapacity(allocator, std.meta.fields(EntryType).len);
+ }
+
+ inline for (comptime std.meta.fieldNames(@TypeOf(EntryType))) |entry| {
+ map.putAssumeCapacity(entry.@"0", entry.@"1");
+ }
+
+ return map;
+ } else if (comptime std.meta.trait.isConstPtr(EntryType) and std.meta.fields(std.meta.Child(EntryType)).len > 0) {
+ if (comptime !needsAllocator(Map.ensureUnusedCapacity)) {
+ try map.ensureUnusedCapacity(std.meta.fields(std.meta.Child(EntryType)).len);
+ } else {
+ try map.ensureUnusedCapacity(allocator, std.meta.fields(std.meta.Child(EntryType)).len);
+ }
+
+ comptime var i: usize = 0;
+
+ inline while (i < std.meta.fields(std.meta.Child(EntryType)).len) : (i += 1) {
+ map.putAssumeCapacity(entries.*[i].@"0", entries.*[i].@"1");
+ }
+
+ return map;
+ }
+
+ @compileError("Cannot construct Map from entries of type " ++ @typeName(EntryType));
+}
+
+pub fn fromMapLike(
+ comptime Map: type,
+ allocator: std.mem.Allocator,
+ entries: anytype,
+) !Map {
+ var map: Map = undefined;
+ if (comptime @hasField(Map, "allocator")) {
+ map = Map.init(allocator);
+ } else {
+ map = Map{};
+ }
+
+ try map.ensureUnusedCapacity(entries.count());
+
+ var iter = entries.iterator();
+ while (iter.next()) |entry| {
+ map.putAssumeCapacityNoClobber(entry.key_ptr.*, entry.value_ptr.*);
+ }
+
+ return map;
+}
+
+pub fn FieldType(comptime Map: type, comptime name: []const u8) ?type {
+ const i = std.meta.fieldIndex(Map, name) orelse return null;
+ const field = std.meta.fields(Map)[i];
+ return field.field_type;
+}
+
+pub fn Of(comptime ArrayLike: type) type {
+ if (std.meta.trait.isSlice(ArrayLike)) {
+ return std.meta.Child(ArrayLike);
+ }
+
+ if (comptime @hasDecl(ArrayLike, "Elem")) {
+ return ArrayLike.Elem;
+ }
+
+ if (comptime @hasField(ArrayLike, "items")) {
+ return std.meta.Child(FieldType(ArrayLike, "items").?);
+ }
+
+ if (comptime @hasField(ArrayLike, "ptr")) {
+ return std.meta.Child(FieldType(ArrayLike, "ptr").?);
+ }
+
+ @compileError("Cannot infer type within " ++ @typeName(ArrayLike));
+}
+
+pub inline fn from(
+ comptime Array: type,
+ allocator: std.mem.Allocator,
+ default: anytype,
+) !Array {
+ const DefaultType = @TypeOf(default);
+ if (comptime std.meta.trait.isSlice(DefaultType)) {
+ return fromSlice(Array, allocator, DefaultType, default);
+ }
+
+ if (comptime std.meta.trait.isContainer(DefaultType)) {
+ if (comptime std.meta.trait.isContainer(Array) and @hasDecl(DefaultType, "put")) {
+ return fromMapLike(Array, allocator, default);
+ }
+
+ if (comptime @hasField(DefaultType, "items")) {
+ if (Of(FieldType(DefaultType, "items").?) == Of(Array)) {
+ return fromSlice(Array, allocator, @TypeOf(default.items), default.items);
+ }
+ }
+ }
+
+ if (comptime std.meta.trait.isContainer(Array) and @hasDecl(Array, "put")) {
+ if (comptime std.meta.trait.isConstPtr(DefaultType) and std.meta.fields(std.meta.Child(DefaultType)).len > 0) {
+ return fromEntries(Array, allocator, @TypeOf(default.*), default.*);
+ }
+ return fromEntries(Array, allocator, DefaultType, default);
+ }
+
+ if (comptime @typeInfo(DefaultType) == .Struct) {
+ return fromSlice(Array, allocator, DefaultType, default);
+ }
+
+ if (comptime @typeInfo(DefaultType) == .Array) {
+ return fromSlice(Array, allocator, []const Of(Array), @as([]const Of(Array), &default));
+ }
+
+ return fromSlice(Array, allocator, []const Of(Array), @as([]const Of(Array), default));
+}
+
+pub fn concat(
+ comptime T: type,
+ dest: []T,
+ src: []const []const T,
+) void {
+ var remain = dest;
+ for (src) |group| {
+ bun.copy(T, remain[0..group.len], group);
+ remain = remain[group.len..];
+ }
+}
+
+pub fn fromSlice(
+ comptime Array: type,
+ allocator: std.mem.Allocator,
+ comptime DefaultType: type,
+ default: DefaultType,
+) !Array {
+ var map: Array = undefined;
+ if (comptime std.meta.trait.isSlice(Array)) {} else if (comptime @hasField(Array, "allocator")) {
+ map = Array.init(allocator);
+ } else {
+ map = Array{};
+ }
+
+ // is it a MultiArrayList?
+ if (comptime !std.meta.trait.isSlice(Array) and @hasField(Array, "bytes")) {
+ try map.ensureUnusedCapacity(allocator, default.len);
+ for (default) |elem| {
+ map.appendAssumeCapacity(elem);
+ }
+
+ return map;
+ } else {
+ var slice: []Of(Array) = undefined;
+ if (comptime !std.meta.trait.isSlice(Array)) {
+ // is it an ArrayList with an allocator?
+ if (comptime !needsAllocator(Array.ensureUnusedCapacity)) {
+ try map.ensureUnusedCapacity(default.len);
+ // is it an ArrayList without an allocator?
+ } else {
+ try map.ensureUnusedCapacity(allocator, default.len);
+ }
+ if (comptime @hasField(Array, "items")) {
+ map.items.len = default.len;
+ slice = map.items;
+ } else if (comptime @hasField(Array, "len")) {
+ map.len = @intCast(u32, default.len);
+ slice = map.slice();
+ } else {
+ @compileError("Cannot set length of " ++ @typeName(Array));
+ }
+ } else if (comptime std.meta.trait.isSlice(Array)) {
+ slice = try allocator.alloc(Of(Array), default.len);
+ } else if (comptime @hasField(map, "ptr")) {
+ slice = try allocator.alloc(Of(Array), default.len);
+ map = .{
+ .ptr = slice.ptr,
+ .len = @truncate(u32, default.len),
+ .cap = @truncate(u32, default.len),
+ };
+ }
+
+ if (comptime std.meta.trait.isIndexable(DefaultType) and (std.meta.trait.isSlice(DefaultType) or std.meta.trait.is(.Array)(DefaultType))) {
+ var in = std.mem.sliceAsBytes(default);
+ var out = std.mem.sliceAsBytes(slice);
+ @memcpy(out.ptr, in.ptr, in.len);
+ } else {
+ @compileError("Needs a more specific type to copy from");
+ }
+
+ if (comptime std.meta.trait.isSlice(Array)) {
+ return @as(Array, slice);
+ }
+
+ return map;
+ }
+}
+
+/// Say you need to allocate a bunch of tiny arrays
+/// You could just do separate allocations for each, but that is slow
+/// With std.ArrayList, pointers invalidate on resize and that means it will crash.
+/// So a better idea is to batch up your allocations into one larger allocation
+/// and then just make all the arrays point to different parts of the larger allocation
+pub fn Batcher(comptime Type: type) type {
+ return struct {
+ head: []Type,
+
+ pub fn init(allocator: std.mem.Allocator, count: usize) !@This() {
+ var all = try allocator.alloc(Type, count);
+ return @This(){ .head = all };
+ }
+
+ pub inline fn done(this: *@This()) void {
+ std.debug.assert(this.head.len == 0);
+ }
+
+ pub inline fn eat(this: *@This(), value: Type) *Type {
+ return @ptrCast(*Type, &this.head.eat1(value).ptr);
+ }
+
+ pub inline fn eat1(this: *@This(), value: Type) []Type {
+ var prev = this.head[0..1];
+ prev[0] = value;
+ this.head = this.head[1..];
+ return prev;
+ }
+
+ pub inline fn next(this: *@This(), values: anytype) []Type {
+ this.head[0..values.len].* = values;
+ var prev = this.head[0..values.len];
+ this.head = this.head[values.len..];
+ return prev;
+ }
+ };
+}
+
+test "fromEntries" {
+ const values = try from(std.AutoHashMap(u32, u32), std.heap.page_allocator, .{
+ .{ 123, 456 },
+ .{ 789, 101112 },
+ });
+ const mapToMap = try from(std.AutoHashMap(u32, u32), std.heap.page_allocator, values);
+ try std.testing.expectEqual(values.get(123).?, 456);
+ try std.testing.expectEqual(values.get(789).?, 101112);
+ try std.testing.expectEqual(mapToMap.get(123).?, 456);
+ try std.testing.expectEqual(mapToMap.get(789).?, 101112);
+}
+
+test "from" {
+ const values = try from(
+ []const u32,
+ std.heap.page_allocator,
+ &.{ 1, 2, 3, 4, 5, 6 },
+ );
+ try std.testing.expectEqualSlices(u32, &.{ 1, 2, 3, 4, 5, 6 }, values);
+}
+
+test "from arraylist" {
+ const values = try from(
+ std.ArrayList(u32),
+ std.heap.page_allocator,
+ &.{ 1, 2, 3, 4, 5, 6 },
+ );
+ try std.testing.expectEqualSlices(u32, &.{ 1, 2, 3, 4, 5, 6 }, values.items);
+
+ const cloned = try from(
+ std.ArrayListUnmanaged(u32),
+ std.heap.page_allocator,
+ values,
+ );
+
+ try std.testing.expectEqualSlices(u32, &.{ 1, 2, 3, 4, 5, 6 }, cloned.items);
+}
+
+test "from arraylist with struct" {
+ const Entry = std.meta.Tuple(&.{ u32, u32 });
+ const values = try from(
+ std.ArrayList(Entry),
+ std.heap.page_allocator,
+ &.{ Entry{ 123, 456 }, Entry{ 123, 456 }, Entry{ 123, 456 }, Entry{ 123, 456 } },
+ );
+ try std.testing.expectEqualSlices(Entry, &[_]Entry{ .{ 123, 456 }, .{ 123, 456 }, .{ 123, 456 }, .{ 123, 456 } }, values.items);
+}
+
+fn needsAllocator(comptime Fn: anytype) bool {
+ return std.meta.fields(std.meta.ArgsTuple(@TypeOf(Fn))).len > 2;
+}