Fix `@call` usage errors and duplicate test names

master
Aron Gabriel 1 year ago
parent 5045a4fa33
commit 13ea2be1c1

@ -59,7 +59,7 @@ pub fn Cache(comptime T: type) type {
pub fn remove(self: *@This(), id: u32) void {
if (self.resources.fetchRemove(id)) |kv| {
if (@hasDecl(T, "deinit")) {
@call(.always_inline, @field(kv.value, "deinit"), .{});
@call(.always_inline, T.deinit, .{kv.value});
}
}
}
@ -69,7 +69,7 @@ pub fn Cache(comptime T: type) type {
if (@hasDecl(T, "deinit")) {
var iter = self.resources.iterator();
while (iter.next()) |kv| {
@call(.always_inline, @field(kv.value_ptr.*, "deinit"), .{});
@call(.always_inline, T.deinit, .{kv.value_ptr.*});
}
}
self.resources.clearAndFree();

@ -17,12 +17,13 @@ pub fn Delegate(comptime Event: type) type {
std.debug.assert(@intFromPtr(ctx) != 0);
const T = @TypeOf(ctx);
const BaseT = @typeInfo(T).Pointer.child;
return Self{
.ctx_ptr_address = @intFromPtr(ctx),
.callback = .{
.bound = struct {
fn cb(self: usize, param: Event) void {
@call(.always_inline, @field(@ptrFromInt(T, self), fn_name), .{param});
@call(.always_inline, @field(BaseT, fn_name), .{ @ptrFromInt(T, self), param });
}
}.cb,
},

@ -58,7 +58,7 @@ test "context not pointer" {
// reg.setContext(pos);
}
test "context get/set/unset" {
test "context get/set/unset typed" {
const SomeType = struct { dummy: u1 };
var reg = Registry.init(std.testing.allocator);

Loading…
Cancel
Save