diff options
-rw-r--r-- | src/bun.js/bindings/bindings.zig | 19 | ||||
-rw-r--r-- | src/bun.js/bindings/headers.h | 3 | ||||
-rw-r--r-- | src/bun.js/bindings/headers.zig | 1 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index a22271593..c4318f991 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -1769,6 +1769,24 @@ pub const JSGlobalObject = extern struct { this.vm().throwError(this, err); } + pub fn createSyntheticModule_(this: *JSGlobalObject, export_names: [*]const ZigString, export_len: usize, value_ptrs: [*]const JSValue, values_len: usize) void { + shim.cppFn("createSyntheticModule_", .{ this, export_names, export_len, value_ptrs, values_len }); + } + + pub fn createSyntheticModule(this: *JSGlobalObject, comptime module: anytype) void { + const names = comptime std.meta.fieldNames(@TypeOf(module)); + var export_names: [names.len]ZigString = undefined; + var export_values: [names.len]JSValue = undefined; + inline for (comptime names) |export_name, i| { + export_names[i] = ZigString.init(export_name); + const function = @field(module, export_name).@"0"; + const len = @field(module, export_name).@"1"; + export_values[i] = JSC.NewFunction(this, &export_names[i], len, function); + } + + createSyntheticModule_(this, &export_names, names.len, &export_values, names.len); + } + pub fn throw( this: *JSGlobalObject, comptime fmt: string, @@ -1991,6 +2009,7 @@ pub const JSGlobalObject = extern struct { "generateHeapSnapshot", "startRemoteInspector", "handleRejectedPromises", + "createSyntheticModule_", // "createError", // "throwError", }; diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h index e7f4880bd..7501e3342 100644 --- a/src/bun.js/bindings/headers.h +++ b/src/bun.js/bindings/headers.h @@ -1,5 +1,5 @@ // clang-format off -//-- AUTOGENERATED FILE -- 1660803660 +//-- AUTOGENERATED FILE -- 1661011208 #pragma once #include <stddef.h> @@ -390,6 +390,7 @@ CPP_DECL JSC__BigIntPrototype* JSC__JSGlobalObject__bigIntPrototype(JSC__JSGloba CPP_DECL JSC__JSObject* JSC__JSGlobalObject__booleanPrototype(JSC__JSGlobalObject* arg0); CPP_DECL VirtualMachine* JSC__JSGlobalObject__bunVM(JSC__JSGlobalObject* arg0); CPP_DECL JSC__JSValue JSC__JSGlobalObject__createAggregateError(JSC__JSGlobalObject* arg0, void** arg1, uint16_t arg2, const ZigString* arg3); +CPP_DECL void JSC__JSGlobalObject__createSyntheticModule_(JSC__JSGlobalObject* arg0, ZigString* arg1, size_t arg2, JSC__JSValue* arg3, size_t arg4); CPP_DECL JSC__JSObject* JSC__JSGlobalObject__datePrototype(JSC__JSGlobalObject* arg0); CPP_DECL void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC__JSGlobalObject* arg0, ZigString* arg1); CPP_DECL JSC__JSObject* JSC__JSGlobalObject__errorPrototype(JSC__JSGlobalObject* arg0); diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig index 6e197b8a0..b24757b5d 100644 --- a/src/bun.js/bindings/headers.zig +++ b/src/bun.js/bindings/headers.zig @@ -193,6 +193,7 @@ pub extern fn JSC__JSGlobalObject__bigIntPrototype(arg0: ?*JSC__JSGlobalObject) pub extern fn JSC__JSGlobalObject__booleanPrototype(arg0: ?*JSC__JSGlobalObject) [*c]JSC__JSObject; pub extern fn JSC__JSGlobalObject__bunVM(arg0: ?*JSC__JSGlobalObject) ?*bindings.VirtualMachine; pub extern fn JSC__JSGlobalObject__createAggregateError(arg0: ?*JSC__JSGlobalObject, arg1: [*c]*anyopaque, arg2: u16, arg3: [*c]const ZigString) JSC__JSValue; +pub extern fn JSC__JSGlobalObject__createSyntheticModule_(arg0: ?*JSC__JSGlobalObject, arg1: [*c]ZigString, arg2: usize, arg3: [*c]JSC__JSValue, arg4: usize) void; pub extern fn JSC__JSGlobalObject__datePrototype(arg0: ?*JSC__JSGlobalObject) [*c]JSC__JSObject; pub extern fn JSC__JSGlobalObject__deleteModuleRegistryEntry(arg0: ?*JSC__JSGlobalObject, arg1: [*c]ZigString) void; pub extern fn JSC__JSGlobalObject__errorPrototype(arg0: ?*JSC__JSGlobalObject) [*c]JSC__JSObject; |