From a18a627f98b50980bbb188906fc6b95c6b8dcdbe Mon Sep 17 00:00:00 2001 From: Mike Desaro Date: Mon, 3 Aug 2020 10:13:33 -0700 Subject: [PATCH] bump for new zig version --- zig-ecs/build.zig | 2 +- zig-ecs/examples/group_sort.zig | 3 +-- zig-ecs/src/ecs/views.zig | 8 ++++---- zig-ecs/tests/dispatcher_test.zig | 3 +-- zig-ecs/tests/groups_test.zig | 8 ++++---- zig-ecs/tests/registry_test.zig | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/zig-ecs/build.zig b/zig-ecs/build.zig index 50d6f2a..8af56bf 100644 --- a/zig-ecs/build.zig +++ b/zig-ecs/build.zig @@ -5,8 +5,8 @@ pub fn build(b: *Builder) void { const buildMode = b.standardReleaseOptions(); const examples = [_][2][]const u8{ - [_][]const u8{ "group_sort", "examples/group_sort.zig" }, [_][]const u8{ "view_vs_group", "examples/view_vs_group.zig" }, + [_][]const u8{ "group_sort", "examples/group_sort.zig" }, [_][]const u8{ "simple", "examples/simple.zig" }, }; diff --git a/zig-ecs/examples/group_sort.zig b/zig-ecs/examples/group_sort.zig index eb3b939..a5c91f1 100644 --- a/zig-ecs/examples/group_sort.zig +++ b/zig-ecs/examples/group_sort.zig @@ -32,7 +32,7 @@ fn createEntities(reg: *ecs.Registry) void { } var end = timer.lap(); - std.debug.warn("create {d} entities: {d}\n", .{total_entities, @intToFloat(f64, end) / 1000000000}); + std.debug.warn("create {d} entities: {d}\n", .{ total_entities, @intToFloat(f64, end) / 1000000000 }); } fn owningGroup(reg: *ecs.Registry) void { @@ -59,7 +59,6 @@ fn owningGroup(reg: *ecs.Registry) void { end = timer.lap(); std.debug.warn("group (sort 2): {d}\n", .{@intToFloat(f64, end) / 1000000000}); - // var group_iter2 = group.iterator(struct { vel: *Velocity, pos: *Position }); // while (group_iter2.next()) |e| { // std.debug.warn("pos.y {d:.3}, ent: {}\n", .{e.pos.y, group_iter2.entity()}); diff --git a/zig-ecs/src/ecs/views.zig b/zig-ecs/src/ecs/views.zig index 44f12fa..685fcbe 100644 --- a/zig-ecs/src/ecs/views.zig +++ b/zig-ecs/src/ecs/views.zig @@ -67,7 +67,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type { entities: *const []Entity, pub fn init(view: *Self) Iterator { - const ptr = view.registry.components.getValue(view.type_ids[0]).?; + const ptr = view.registry.components.get(view.type_ids[0]).?; const entities = @intToPtr(*Storage(u8), ptr).dataPtr(); return .{ .view = view, @@ -85,7 +85,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type { // entity must be in all other Storages for (it.view.type_ids) |tid| { - const ptr = it.view.registry.components.getValue(tid).?; + const ptr = it.view.registry.components.get(tid).?; if (!@intToPtr(*Storage(u1), ptr).contains(entity)) { break :blk; } @@ -93,7 +93,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type { // entity must not be in all other excluded Storages for (it.view.exclude_type_ids) |tid| { - const ptr = it.view.registry.components.getValue(tid).?; + const ptr = it.view.registry.components.get(tid).?; if (@intToPtr(*Storage(u1), ptr).contains(entity)) { break :blk; } @@ -129,7 +129,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type { // get our component counts in an array so we can sort the type_ids based on how many entities are in each var sub_items: [n_includes]usize = undefined; for (self.type_ids) |tid, i| { - const ptr = self.registry.components.getValue(tid).?; + const ptr = self.registry.components.get(tid).?; const store = @intToPtr(*Storage(u8), ptr); sub_items[i] = store.len(); } diff --git a/zig-ecs/tests/dispatcher_test.zig b/zig-ecs/tests/dispatcher_test.zig index 63cc4a2..90c7eeb 100644 --- a/zig-ecs/tests/dispatcher_test.zig +++ b/zig-ecs/tests/dispatcher_test.zig @@ -21,7 +21,6 @@ const Thing = struct { } }; - test "Dispatcher" { var thing = Thing{}; @@ -37,4 +36,4 @@ test "Dispatcher" { sink2.connect(tester2); sink2.connectBound(&thing, "testI32"); d.trigger(i32, -543); -} \ No newline at end of file +} diff --git a/zig-ecs/tests/groups_test.zig b/zig-ecs/tests/groups_test.zig index 94c93f6..a58316d 100644 --- a/zig-ecs/tests/groups_test.zig +++ b/zig-ecs/tests/groups_test.zig @@ -13,7 +13,7 @@ const Transform = struct { x: f32 = 0 }; const Renderable = struct { x: f32 = 0 }; const Rotation = struct { x: f32 = 0 }; -fn printStore(store: var, name: []const u8) void { +fn printStore(store: anytype, name: []const u8) void { warn("--- {} ---\n", .{name}); for (store.set.dense.items) |e, i| { warn("e[{}] s[{}]{}", .{ e, store.set.page(store.set.dense.items[i]), store.set.sparse.items[store.set.page(store.set.dense.items[i])] }); @@ -106,11 +106,11 @@ test "sort OwningGroup by Entity" { return sprite_a.x > sprite_b.x; } }; - const context = SortContext{.group = group}; + const context = SortContext{ .group = group }; group.sort(ecs.Entity, context, SortContext.sort); var val: f32 = 0; - var iter = group.iterator(struct {s: *Sprite, r: *Renderable}); + var iter = group.iterator(struct { s: *Sprite, r: *Renderable }); while (iter.next()) |entity| { std.testing.expectEqual(val, entity.s.*.x); val += 1; @@ -138,7 +138,7 @@ test "sort OwningGroup by Component" { group.sort(Sprite, {}, SortContext.sort); var val: f32 = 0; - var iter = group.iterator(struct {s: *Sprite, r: *Renderable}); + var iter = group.iterator(struct { s: *Sprite, r: *Renderable }); while (iter.next()) |entity| { std.testing.expectEqual(val, entity.s.*.x); val += 1; diff --git a/zig-ecs/tests/registry_test.zig b/zig-ecs/tests/registry_test.zig index dd8144b..09eafa6 100644 --- a/zig-ecs/tests/registry_test.zig +++ b/zig-ecs/tests/registry_test.zig @@ -17,7 +17,7 @@ test "Registry" { var e1 = reg.create(); - reg.addTypes(e1, .{Empty, Position}); + reg.addTypes(e1, .{ Empty, Position }); reg.add(e1, BigOne{ .pos = Position{ .x = 5, .y = 5 }, .vel = Velocity{ .x = 5, .y = 5 }, .accel = Velocity{ .x = 5, .y = 5 } }); std.testing.expect(reg.has(Empty, e1));