mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 19:38:58 +00:00
refactor: move HTMLRewriter to c++ bindings (#4193)
This commit is contained in:
@@ -88,10 +88,6 @@ const PackageManager = @import("../install/install.zig").PackageManager;
|
||||
const ModuleLoader = JSC.ModuleLoader;
|
||||
const FetchFlags = JSC.FetchFlags;
|
||||
|
||||
pub const GlobalConstructors = [_]type{
|
||||
JSC.Cloudflare.HTMLRewriter.Constructor,
|
||||
};
|
||||
|
||||
pub const GlobalClasses = [_]type{
|
||||
Bun.Class,
|
||||
WebCore.Crypto.Class,
|
||||
@@ -459,8 +455,6 @@ pub const VirtualMachine = struct {
|
||||
/// []
|
||||
argv: []const []const u8 = &[_][]const u8{"bun"},
|
||||
|
||||
global_api_constructors: [GlobalConstructors.len]JSC.JSValue = undefined,
|
||||
|
||||
origin_timer: std.time.Timer = undefined,
|
||||
origin_timestamp: u64 = 0,
|
||||
macro_event_loop: EventLoop = EventLoop{},
|
||||
@@ -885,31 +879,6 @@ pub const VirtualMachine = struct {
|
||||
return classes;
|
||||
}
|
||||
|
||||
pub fn getAPIConstructors(globalObject: *JSGlobalObject) []const JSC.JSValue {
|
||||
if (is_bindgen)
|
||||
return &[_]JSC.JSValue{};
|
||||
const is_first = !VirtualMachine.get().has_loaded_constructors;
|
||||
if (is_first) {
|
||||
VirtualMachine.get().global = globalObject;
|
||||
VirtualMachine.get().has_loaded_constructors = true;
|
||||
}
|
||||
|
||||
var slice = if (is_first)
|
||||
@as([]JSC.JSValue, &JSC.VirtualMachine.get().global_api_constructors)
|
||||
else
|
||||
VirtualMachine.get().allocator.alloc(JSC.JSValue, GlobalConstructors.len) catch unreachable;
|
||||
|
||||
inline for (GlobalConstructors, 0..) |Class, i| {
|
||||
var ref = Class.constructor(globalObject.ref()).?;
|
||||
JSC.C.JSValueProtect(globalObject.ref(), ref);
|
||||
slice[i] = JSC.JSValue.fromRef(
|
||||
ref,
|
||||
);
|
||||
}
|
||||
|
||||
return slice;
|
||||
}
|
||||
|
||||
pub fn isWatcherEnabled(this: *VirtualMachine) bool {
|
||||
return this.bun_dev_watcher != null or this.bun_watcher != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user