mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
update ref counting for new ReadableStream usages
This commit is contained in:
@@ -72,6 +72,14 @@ pub fn init(label_: ?[]const u8, opts_: ?InitOpts, page: *Page) !TextDecoderStre
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn acquireRef(self: *TextDecoderStream) void {
|
||||||
|
self._transform.acquireRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit(self: *TextDecoderStream, shutdown: bool, page: *Page) void {
|
||||||
|
self._transform.deinit(shutdown, page);
|
||||||
|
}
|
||||||
|
|
||||||
fn decodeTransform(controller: *TransformStream.DefaultController, chunk: js.Value, ignoreBOM: bool) !void {
|
fn decodeTransform(controller: *TransformStream.DefaultController, chunk: js.Value, ignoreBOM: bool) !void {
|
||||||
// chunk should be a Uint8Array; decode it as UTF-8 string
|
// chunk should be a Uint8Array; decode it as UTF-8 string
|
||||||
const typed_array = try chunk.toZig(js.TypedArray(u8));
|
const typed_array = try chunk.toZig(js.TypedArray(u8));
|
||||||
@@ -111,6 +119,8 @@ pub const JsApi = struct {
|
|||||||
pub const name = "TextDecoderStream";
|
pub const name = "TextDecoderStream";
|
||||||
pub const prototype_chain = bridge.prototypeChain();
|
pub const prototype_chain = bridge.prototypeChain();
|
||||||
pub var class_id: bridge.ClassId = undefined;
|
pub var class_id: bridge.ClassId = undefined;
|
||||||
|
pub const weak = true;
|
||||||
|
pub const finalizer = bridge.finalizer(TextDecoderStream.deinit);
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const constructor = bridge.constructor(TextDecoderStream.init, .{});
|
pub const constructor = bridge.constructor(TextDecoderStream.init, .{});
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ pub fn init(page: *Page) !TextEncoderStream {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn acquireRef(self: *TextEncoderStream) void {
|
||||||
|
self._transform.acquireRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit(self: *TextEncoderStream, shutdown: bool, page: *Page) void {
|
||||||
|
self._transform.deinit(shutdown, page);
|
||||||
|
}
|
||||||
|
|
||||||
fn encodeTransform(controller: *TransformStream.DefaultController, chunk: js.Value) !void {
|
fn encodeTransform(controller: *TransformStream.DefaultController, chunk: js.Value) !void {
|
||||||
// chunk should be a JS string; encode it as UTF-8 bytes (Uint8Array)
|
// chunk should be a JS string; encode it as UTF-8 bytes (Uint8Array)
|
||||||
const str = chunk.isString() orelse return error.InvalidChunk;
|
const str = chunk.isString() orelse return error.InvalidChunk;
|
||||||
@@ -56,6 +64,8 @@ pub const JsApi = struct {
|
|||||||
pub const name = "TextEncoderStream";
|
pub const name = "TextEncoderStream";
|
||||||
pub const prototype_chain = bridge.prototypeChain();
|
pub const prototype_chain = bridge.prototypeChain();
|
||||||
pub var class_id: bridge.ClassId = undefined;
|
pub var class_id: bridge.ClassId = undefined;
|
||||||
|
pub const weak = true;
|
||||||
|
pub const finalizer = bridge.finalizer(TextEncoderStream.deinit);
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const constructor = bridge.constructor(TextEncoderStream.init, .{});
|
pub const constructor = bridge.constructor(TextEncoderStream.init, .{});
|
||||||
|
|||||||
@@ -85,6 +85,14 @@ pub fn initWithZigTransform(zig_transform: ZigTransformFn, page: *Page) !*Transf
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn acquireRef(self: *TransformStream) void {
|
||||||
|
self._readable.acquireRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit(self: *TransformStream, shutdown: bool, page: *Page) void {
|
||||||
|
self._readable.deinit(shutdown, page);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn transformWrite(self: *TransformStream, chunk: js.Value, page: *Page) !void {
|
pub fn transformWrite(self: *TransformStream, chunk: js.Value, page: *Page) !void {
|
||||||
if (self._controller._zig_transform_fn) |zig_fn| {
|
if (self._controller._zig_transform_fn) |zig_fn| {
|
||||||
// Zig-level transform (used by TextEncoderStream etc.)
|
// Zig-level transform (used by TextEncoderStream etc.)
|
||||||
@@ -130,6 +138,8 @@ pub const JsApi = struct {
|
|||||||
pub const name = "TransformStream";
|
pub const name = "TransformStream";
|
||||||
pub const prototype_chain = bridge.prototypeChain();
|
pub const prototype_chain = bridge.prototypeChain();
|
||||||
pub var class_id: bridge.ClassId = undefined;
|
pub var class_id: bridge.ClassId = undefined;
|
||||||
|
pub const weak = true;
|
||||||
|
pub const finalizer = bridge.finalizer(TransformStream.deinit);
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const constructor = bridge.constructor(TransformStream.init, .{});
|
pub const constructor = bridge.constructor(TransformStream.init, .{});
|
||||||
@@ -165,6 +175,14 @@ pub const TransformStreamDefaultController = struct {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn acquireRef(self: *TransformStreamDefaultController) void {
|
||||||
|
self._stream.acquireRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deinit(self: *TransformStreamDefaultController, shutdown: bool, page: *Page) void {
|
||||||
|
self._stream.deinit(shutdown, page);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn enqueue(self: *TransformStreamDefaultController, chunk: ReadableStreamDefaultController.Chunk) !void {
|
pub fn enqueue(self: *TransformStreamDefaultController, chunk: ReadableStreamDefaultController.Chunk) !void {
|
||||||
try self._stream._readable._controller.enqueue(chunk);
|
try self._stream._readable._controller.enqueue(chunk);
|
||||||
}
|
}
|
||||||
@@ -189,6 +207,8 @@ pub const TransformStreamDefaultController = struct {
|
|||||||
pub const name = "TransformStreamDefaultController";
|
pub const name = "TransformStreamDefaultController";
|
||||||
pub const prototype_chain = bridge.prototypeChain();
|
pub const prototype_chain = bridge.prototypeChain();
|
||||||
pub var class_id: bridge.ClassId = undefined;
|
pub var class_id: bridge.ClassId = undefined;
|
||||||
|
pub const weak = true;
|
||||||
|
pub const finalizer = bridge.finalizer(TransformStreamDefaultController.deinit);
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const enqueue = bridge.function(TransformStreamDefaultController.enqueueValue, .{});
|
pub const enqueue = bridge.function(TransformStreamDefaultController.enqueueValue, .{});
|
||||||
|
|||||||
Reference in New Issue
Block a user