Merge pull request #1 from joachimschmidt557/update-latest-zig

Update to latest zig
master
prime31 4 years ago committed by GitHub
commit 6a19b1cd93

@ -411,7 +411,7 @@ pub const Registry = struct {
std.debug.assert(@typeInfo(T) != .Pointer); std.debug.assert(@typeInfo(T) != .Pointer);
return if (self.contexts.get(utils.typeId(T))) |ptr| return if (self.contexts.get(utils.typeId(T))) |ptr|
return if (ptr.value > 0) @intToPtr(*T, ptr.value) else null return if (ptr > 0) @intToPtr(*T, ptr) else null
else else
null; null;
} }

@ -29,7 +29,7 @@ pub const TypeStore = struct {
} }
pub fn get(self: *TypeStore, comptime T: type) *T { pub fn get(self: *TypeStore, comptime T: type) *T {
if (self.map.getValue(utils.typeId(T))) |bytes| { if (self.map.get(utils.typeId(T))) |bytes| {
return @ptrCast(*T, @alignCast(@alignOf(T), bytes)); return @ptrCast(*T, @alignCast(@alignOf(T), bytes));
} }
unreachable; unreachable;
@ -48,7 +48,7 @@ pub const TypeStore = struct {
} }
pub fn remove(self: *TypeStore, comptime T: type) void { pub fn remove(self: *TypeStore, comptime T: type) void {
if (self.map.getValue(utils.typeId(T))) |bytes| { if (self.map.get(utils.typeId(T))) |bytes| {
self.allocator.free(bytes); self.allocator.free(bytes);
_ = self.map.remove(utils.typeId(T)); _ = self.map.remove(utils.typeId(T));
} }

@ -13,7 +13,7 @@ pub const Assets = struct {
}; };
} }
pub fn deinit(self: Assets) void { pub fn deinit(self: *Assets) void {
var it = self.caches.iterator(); var it = self.caches.iterator();
while (it.next()) |ptr| { while (it.next()) |ptr| {
// HACK: we dont know the Type here but we need to call deinit // HACK: we dont know the Type here but we need to call deinit
@ -24,7 +24,7 @@ pub const Assets = struct {
} }
pub fn get(self: *Assets, comptime AssetT: type) *Cache(AssetT) { pub fn get(self: *Assets, comptime AssetT: type) *Cache(AssetT) {
if (self.caches.getValue(utils.typeId(AssetT))) |tid| { if (self.caches.get(utils.typeId(AssetT))) |tid| {
return @intToPtr(*Cache(AssetT), tid); return @intToPtr(*Cache(AssetT), tid);
} }

@ -43,7 +43,7 @@ pub fn Cache(comptime T: type) type {
} }
pub fn load(self: *@This(), id: u32, comptime loader: anytype) @typeInfo(@TypeOf(@field(loader, "load"))).BoundFn.return_type.? { pub fn load(self: *@This(), id: u32, comptime loader: anytype) @typeInfo(@TypeOf(@field(loader, "load"))).BoundFn.return_type.? {
if (self.resources.getValue(id)) |resource| { if (self.resources.get(id)) |resource| {
return resource; return resource;
} }
@ -72,11 +72,11 @@ pub fn Cache(comptime T: type) type {
@call(.{ .modifier = .always_inline }, @field(kv.value, "deinit"), .{}); @call(.{ .modifier = .always_inline }, @field(kv.value, "deinit"), .{});
} }
} }
self.resources.clear(); self.resources.clearAndFree();
} }
pub fn size(self: @This()) usize { pub fn size(self: @This()) usize {
return self.resources.size; return self.resources.items().len;
} }
}; };
} }

@ -14,7 +14,7 @@ pub const Dispatcher = struct {
}; };
} }
pub fn deinit(self: Dispatcher) void { pub fn deinit(self: *Dispatcher) void {
var it = self.signals.iterator(); var it = self.signals.iterator();
while (it.next()) |ptr| { while (it.next()) |ptr| {
// HACK: we dont know the Type here but we need to call deinit // HACK: we dont know the Type here but we need to call deinit
@ -27,8 +27,8 @@ pub const Dispatcher = struct {
fn assure(self: *Dispatcher, comptime T: type) *Signal(T) { fn assure(self: *Dispatcher, comptime T: type) *Signal(T) {
var type_id = utils.typeId(T); var type_id = utils.typeId(T);
if (self.signals.get(type_id)) |kv| { if (self.signals.get(type_id)) |value| {
return @intToPtr(*Signal(T), kv.value); return @intToPtr(*Signal(T), value);
} }
var signal = Signal(T).create(self.allocator); var signal = Signal(T).create(self.allocator);

Loading…
Cancel
Save