From ed23befd26750a6148dc3d1c954b4a5b1d8cac92 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 31 May 2020 22:10:21 -0700 Subject: [PATCH] formatting --- zig-ecs/build.zig | 5 ++--- zig-ecs/examples/simple.zig | 8 ++++---- zig-ecs/src/ecs/registry.zig | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/zig-ecs/build.zig b/zig-ecs/build.zig index 679ac1c..f3d58d0 100644 --- a/zig-ecs/build.zig +++ b/zig-ecs/build.zig @@ -10,7 +10,7 @@ pub fn build(b: *Builder) void { }; for (examples) |example, i| { - const name = example[0]; + const name = if (i == 0) "ecs" else example[0]; const source = example[1]; var exe = b.addExecutable(name, source); @@ -23,7 +23,6 @@ pub fn build(b: *Builder) void { // first element in the list is added as "run" so "zig build run" works if (i == 0) { - exe.name = "ecs"; exe.setOutputDir("zig-cache/bin"); const run_exe_step = b.step("run", b.fmt("run {}.zig", .{name})); run_exe_step.dependOn(&run_cmd.step); @@ -71,4 +70,4 @@ pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, target: std } artifact.addPackagePath("ecs", std.fs.path.join(b.allocator, &[_][]const u8{ rel_path, "ecs.zig" }) catch unreachable); -} \ No newline at end of file +} diff --git a/zig-ecs/examples/simple.zig b/zig-ecs/examples/simple.zig index 07b488e..a67c325 100644 --- a/zig-ecs/examples/simple.zig +++ b/zig-ecs/examples/simple.zig @@ -19,13 +19,13 @@ pub fn main() !void { reg.add(e2, Position{ .x = 10, .y = 10 }); reg.add(e2, Velocity{ .x = 15, .y = 17 }); - var view = reg.view(.{Velocity, Position}); + var view = reg.view(.{ Velocity, Position }); var iter = view.iterator(); while (iter.next()) |entity| { var pos = view.get(Position, entity); const vel = view.getConst(Velocity, entity); - std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{entity, pos.*, vel}); + std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{ entity, pos.*, vel }); pos.*.x += vel.x; pos.*.y += vel.y; } @@ -36,6 +36,6 @@ pub fn main() !void { while (iter.next()) |entity| { const pos = view.getConst(Position, entity); const vel = view.getConst(Velocity, entity); - std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{entity, pos, vel}); + std.debug.warn("entity: {}, pos: {d}, vel: {d}\n", .{ entity, pos, vel }); } -} \ No newline at end of file +} diff --git a/zig-ecs/src/ecs/registry.zig b/zig-ecs/src/ecs/registry.zig index 0201e13..716d05d 100644 --- a/zig-ecs/src/ecs/registry.zig +++ b/zig-ecs/src/ecs/registry.zig @@ -227,7 +227,7 @@ pub const Registry = struct { _ = self.component_contexts.put(type_id, 0) catch unreachable; } - /// Returns a pointer to an object in the context of the Component type + /// Returns a pointer to an object in the context of the Component type pub fn getComponentContext(self: *Registry, comptime Component: type, comptime T: type) ?*T { var type_id: u8 = undefined; _ = self.typemap.getOrPut(Component, &type_id); @@ -287,7 +287,7 @@ test "context not pointer" { } test "component context get/set/unset" { - const SomeType = struct { dummy: u1}; + const SomeType = struct { dummy: u1 }; var reg = Registry.init(std.testing.allocator); defer reg.deinit(); @@ -303,4 +303,4 @@ test "component context get/set/unset" { reg.unsetComponentContext(Position); ctx = reg.getComponentContext(Position, SomeType); std.testing.expectEqual(ctx, null); -} \ No newline at end of file +}