From 956ecb061b1862a4b632c8d5d6b6fa4318e1f640 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Fri, 22 Aug 2025 20:12:56 +0200 Subject: object refactor and add wl output Now the Object is held by the registry instead of the struct its referencing and the struct only has a `handle` which is a usize. --- src/object.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/object.zig') diff --git a/src/object.zig b/src/object.zig index 0751859..14089c1 100644 --- a/src/object.zig +++ b/src/object.zig @@ -3,11 +3,12 @@ const wayland = @import("root.zig"); const Self = @This(); +pub const Ref = usize; + const VTable = struct { on_event: *const fn (ptr: *anyopaque, ctx: *wayland.Context, opcode: u16, args: []const u8) void, }; -id: ?u32 = null, ptr: ?*anyopaque, vtable: VTable, @@ -28,6 +29,10 @@ pub inline fn from_self(ptr: anytype) Self { }; } +pub fn disable(self: *Self) void { + self.ptr = null; +} + pub fn format( self: *const Self, comptime fmt: []const u8, @@ -37,5 +42,5 @@ pub fn format( _ = fmt; _ = options; - try writer.print("Object {{ {?} }}", .{self.id}); + try writer.print("Object {{ {?} }}", .{self.ptr}); } -- cgit v1.2.3-70-g09d2