mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-04-03 16:10:29 +00:00
Move V8 pipe callback helpers into js/ layer
ReadableStream.zig was the only webapi file importing v8 directly. Extract the repeated newFunctionWithData / callback boilerplate into js/Local (newFunctionWithData) and js/Caller (initFromHandle, FunctionCallbackInfo.getData), and update ReadableStream and Context to use them.
This commit is contained in:
@@ -82,6 +82,16 @@ pub fn createTypedArray(self: *const Local, comptime array_type: js.ArrayType, s
|
||||
return .init(self, size);
|
||||
}
|
||||
|
||||
pub fn newFunctionWithData(
|
||||
self: *const Local,
|
||||
comptime callback: *const fn (?*const v8.FunctionCallbackInfo) callconv(.c) void,
|
||||
data: *anyopaque,
|
||||
) js.Function {
|
||||
const external = self.isolate.createExternal(data);
|
||||
const handle = v8.v8__Function__New__DEFAULT2(self.handle, callback, @ptrCast(external)).?;
|
||||
return .{ .local = self, .handle = handle };
|
||||
}
|
||||
|
||||
pub fn runMacrotasks(self: *const Local) void {
|
||||
const env = self.ctx.env;
|
||||
env.pumpMessageLoop();
|
||||
|
||||
Reference in New Issue
Block a user