diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-08-22 20:12:56 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-08-22 20:12:56 +0200 |
| commit | 956ecb061b1862a4b632c8d5d6b6fa4318e1f640 (patch) | |
| tree | f00adc9bfced275f280239b25a2b2ae15f57765b /src/object.zig | |
| parent | 33e1de2710fe44512440e0e6055578d67dab330c (diff) | |
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.
Diffstat (limited to 'src/object.zig')
| -rw-r--r-- | src/object.zig | 9 |
1 files changed, 7 insertions, 2 deletions
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}); } |