add Blob ancestor initializer to Factory

This commit is contained in:
Halil Durak
2025-11-21 14:50:23 +03:00
parent 9a7bafb02c
commit b4f9f968f6

View File

@@ -31,6 +31,7 @@ const Element = @import("webapi/Element.zig");
const Document = @import("webapi/Document.zig");
const EventTarget = @import("webapi/EventTarget.zig");
const XMLHttpRequestEventTarget = @import("webapi/net/XMLHttpRequestEventTarget.zig");
const Blob = @import("webapi/Blob.zig");
const MemoryPoolAligned = std.heap.MemoryPoolAligned;
@@ -224,6 +225,20 @@ pub fn xhrEventTarget(self: *Factory, child: anytype) !*@TypeOf(child) {
return child_ptr;
}
pub fn blob(self: *Factory, child: anytype) !*@TypeOf(child) {
const child_ptr = try self.createT(@TypeOf(child));
child_ptr.* = child;
const b = try self.createT(Blob);
child_ptr._proto = b;
b.* = .{
._type = unionInit(Blob.Type, child_ptr),
.slice = "",
.mime = "",
};
return child_ptr;
}
pub fn create(self: *Factory, value: anytype) !*@TypeOf(value) {
const ptr = try self.createT(@TypeOf(value));
ptr.* = value;