diff --git a/libs/basisu/src/transcoder.zig b/libs/basisu/src/transcoder.zig index 2869d775..dd44804b 100644 --- a/libs/basisu/src/transcoder.zig +++ b/libs/basisu/src/transcoder.zig @@ -21,7 +21,8 @@ pub const Transcoder = struct { const h = b.transcoder_init(src.ptr, @intCast(u32, src.len)); return if (!b.transcoder_start_transcoding(h)) error.Unknown - else .{ .handle = h }; + else + .{ .handle = h }; } pub fn deinit(self: Transcoder) void { diff --git a/libs/ecs/src/entities.zig b/libs/ecs/src/entities.zig index 7be3dadb..b53ecca9 100644 --- a/libs/ecs/src/entities.zig +++ b/libs/ecs/src/entities.zig @@ -67,7 +67,7 @@ pub const ArchetypeStorage = struct { } fn debugValidateRow(storage: *ArchetypeStorage, gpa: Allocator, row: anytype) void { - inline for (std.meta.fields(@TypeOf(row))) |field, index| { + inline for (std.meta.fields(@TypeOf(row)), 0..) |field, index| { const column = storage.columns[index]; if (typeId(field.type) != column.type_id) { const msg = std.mem.concat(gpa, u8, &.{ @@ -148,7 +148,7 @@ pub const ArchetypeStorage = struct { if (is_debug) storage.debugValidateRow(gpa, row); const fields = std.meta.fields(@TypeOf(row)); - inline for (fields) |field, index| { + inline for (fields, 0..) |field, index| { const ColumnType = field.type; if (@sizeOf(ColumnType) == 0) continue; @@ -335,7 +335,7 @@ pub fn Entities(comptime all_components: anytype) type { pub const Query = Query: { const namespaces = std.meta.fields(@TypeOf(all_components)); var fields: [namespaces.len]std.builtin.Type.UnionField = undefined; - inline for (namespaces) |namespace, i| { + inline for (namespaces, 0..) |namespace, i| { const component_enum = std.meta.FieldEnum(namespace.type); fields[i] = .{ .name = namespace.name, diff --git a/libs/ecs/src/systems.zig b/libs/ecs/src/systems.zig index 21de673d..2fcc5ab2 100644 --- a/libs/ecs/src/systems.zig +++ b/libs/ecs/src/systems.zig @@ -71,7 +71,7 @@ pub fn Messages(comptime messages: anytype) type { pub fn MessagesTag(comptime messages: anytype) type { var fields: []const EnumField = &[0]EnumField{}; const message_fields = std.meta.fields(@TypeOf(messages)); - inline for (message_fields) |message_field, index| { + inline for (message_fields, 0..) |message_field, index| { fields = fields ++ [_]std.builtin.Type.EnumField{.{ .name = message_field.name, .value = index, diff --git a/libs/glfw/src/vulkan.zig b/libs/glfw/src/vulkan.zig index 699a9a89..0700127b 100644 --- a/libs/glfw/src/vulkan.zig +++ b/libs/glfw/src/vulkan.zig @@ -235,12 +235,12 @@ pub inline fn createWindowSurface(vk_instance: anytype, window: Window, vk_alloc else => @ptrCast(c.VkInstance, vk_instance), }; - return @boolToInt(c.glfwCreateWindowSurface( + return c.glfwCreateWindowSurface( instance, window.handle, if (vk_allocation_callbacks == null) null else @ptrCast(*const c.VkAllocationCallbacks, @alignCast(@alignOf(c.VkAllocationCallbacks), vk_allocation_callbacks)), @ptrCast(*c.VkSurfaceKHR, @alignCast(@alignOf(c.VkSurfaceKHR), vk_surface_khr)), - ) == c.VK_SUCCESS); + ); } test "vulkanSupported" { diff --git a/libs/model3d/src/main.zig b/libs/model3d/src/main.zig index 7af57631..2b98a789 100644 --- a/libs/model3d/src/main.zig +++ b/libs/model3d/src/main.zig @@ -216,7 +216,7 @@ fn intToError(int: c_int) Error { test { testing.refAllDeclsRecursive(@This()); - var model_file = try std.fs.cwd().openFile( thisDir("/../assets/cube.m3d"), .{}); + var model_file = try std.fs.cwd().openFile(thisDir("/../assets/cube.m3d"), .{}); defer model_file.close(); var model_data = try model_file.readToEndAllocOptions(testing.allocator, 1024, 119, @alignOf(u8), 0); defer testing.allocator.free(model_data); diff --git a/libs/sysaudio/src/alsa.zig b/libs/sysaudio/src/alsa.zig index 2cd1ad3f..f4329eda 100644 --- a/libs/sysaudio/src/alsa.zig +++ b/libs/sysaudio/src/alsa.zig @@ -364,7 +364,7 @@ pub const Context = struct { if (chmap[0] == null) continue; var channels = try self.allocator.alloc(main.Channel, chmap.*.*.map.channels); - for (channels) |*ch, i| + for (channels, 0..) |*ch, i| ch.*.id = fromAlsaChannel(chmap[0][0].map.pos()[i]) catch return error.OpeningDevice; break :blk channels; } else { @@ -580,7 +580,7 @@ pub const Player = struct { } fn writeLoop(self: *Player) void { - for (self.channels) |*ch, i| { + for (self.channels, 0..) |*ch, i| { ch.*.ptr = self.sample_buffer.ptr + self.format.frameSize(i); } diff --git a/libs/sysaudio/src/jack.zig b/libs/sysaudio/src/jack.zig index 935eafc7..25427bd8 100644 --- a/libs/sysaudio/src/jack.zig +++ b/libs/sysaudio/src/jack.zig @@ -201,7 +201,7 @@ pub const Context = struct { var ports = try self.allocator.alloc(*c.jack_port_t, device.channels.len); var dest_ports = try self.allocator.alloc([:0]const u8, ports.len); var buf: [64]u8 = undefined; - for (device.channels) |_, i| { + for (device.channels, 0..) |_, i| { const port_name = std.fmt.bufPrintZ(&buf, "playback_{d}", .{i + 1}) catch unreachable; const dest_name = try std.fmt.allocPrintZ(self.allocator, "{s}:{s}", .{ device.id, port_name }); ports[i] = lib.jack_port_register(self.client, port_name.ptr, c.JACK_DEFAULT_AUDIO_TYPE, c.JackPortIsOutput, 0) orelse @@ -259,7 +259,7 @@ pub const Player = struct { if (lib.jack_activate(self.client) != 0) return error.CannotPlay; - for (self.ports) |port, i| { + for (self.ports, 0..) |port, i| { if (lib.jack_connect(self.client, lib.jack_port_name(port), self.dest_ports[i].ptr) != 0) return error.CannotPlay; } @@ -268,7 +268,7 @@ pub const Player = struct { fn processCallback(n_frames: c.jack_nframes_t, self_opaque: ?*anyopaque) callconv(.C) c_int { const self = @ptrCast(*Player, @alignCast(@alignOf(*Player), self_opaque.?)); - for (self.channels) |*ch, i| { + for (self.channels, 0..) |*ch, i| { ch.*.ptr = @ptrCast([*]u8, lib.jack_port_get_buffer(self.ports[i], n_frames)); } self.writeFn(self.user_data, n_frames); @@ -279,7 +279,7 @@ pub const Player = struct { pub fn play(self: *Player) !void { self.mutex.lock(); defer self.mutex.unlock(); - for (self.ports) |port, i| { + for (self.ports, 0..) |port, i| { if (lib.jack_connect(self.client, lib.jack_port_name(port), self.dest_ports[i].ptr) != 0) return error.CannotPlay; } @@ -288,7 +288,7 @@ pub const Player = struct { pub fn pause(self: *Player) !void { self.mutex.lock(); defer self.mutex.unlock(); - for (self.ports) |port, i| { + for (self.ports, 0..) |port, i| { if (lib.jack_disconnect(self.client, lib.jack_port_name(port), self.dest_ports[i].ptr) != 0) return error.CannotPause; } @@ -297,7 +297,7 @@ pub const Player = struct { pub fn paused(self: *Player) bool { self.mutex.lock(); defer self.mutex.unlock(); - for (self.ports) |port, i| { + for (self.ports, 0..) |port, i| { if (lib.jack_port_connected_to(port, self.dest_ports[i].ptr) == 1) return false; } diff --git a/libs/sysaudio/src/main.zig b/libs/sysaudio/src/main.zig index bfec2b9c..91532733 100644 --- a/libs/sysaudio/src/main.zig +++ b/libs/sysaudio/src/main.zig @@ -35,7 +35,7 @@ pub const Context = struct { std.meta.fieldInfo(backends.BackendContext, b).type, ).Pointer.child.init(allocator, options); } else { - inline for (std.meta.fields(Backend)) |b, i| { + inline for (std.meta.fields(Backend), 0..) |b, i| { if (@typeInfo( std.meta.fieldInfo(backends.BackendContext, @intToEnum(Backend, b.value)).type, ).Pointer.child.init(allocator, options)) |d| { diff --git a/libs/sysaudio/src/pipewire.zig b/libs/sysaudio/src/pipewire.zig index 3ad720ce..27734328 100644 --- a/libs/sysaudio/src/pipewire.zig +++ b/libs/sysaudio/src/pipewire.zig @@ -318,7 +318,7 @@ pub const Player = struct { buf.*.buffer.*.datas[0].chunk.*.stride = stride; buf.*.buffer.*.datas[0].chunk.*.size = n_frames * stride; - for (self.channels) |*ch, i| { + for (self.channels, 0..) |*ch, i| { ch.ptr = @ptrCast([*]u8, buf.*.buffer.*.datas[0].data.?) + self.format.frameSize(i); } self.writeFn(self.user_data, n_frames); diff --git a/libs/sysaudio/src/pulseaudio.zig b/libs/sysaudio/src/pulseaudio.zig index 4a8ab7ea..dd9575fb 100644 --- a/libs/sysaudio/src/pulseaudio.zig +++ b/libs/sysaudio/src/pulseaudio.zig @@ -239,7 +239,7 @@ pub const Context = struct { if (self.default_source) |d| self.allocator.free(d); } - for (self.devices_info.list.items) |device, i| { + for (self.devices_info.list.items, 0..) |device, i| { if ((device.mode == .playback and self.default_sink != null and std.mem.eql(u8, device.id, self.default_sink.?)) or @@ -295,7 +295,7 @@ pub const Context = struct { .mode = mode, .channels = blk: { var channels = try self.allocator.alloc(main.Channel, info.*.channel_map.channels); - for (channels) |*ch, i| + for (channels, 0..) |*ch, i| ch.*.id = fromPAChannelPos(info.*.channel_map.map[i]) catch unreachable; break :blk channels; }, @@ -473,7 +473,7 @@ pub const Player = struct { return; } - for (self.channels) |*ch, i| { + for (self.channels, 0..) |*ch, i| { ch.*.ptr = self.write_ptr + self.format.frameSize(i); } @@ -644,7 +644,7 @@ pub fn toPAFormat(format: main.Format) !c.pa_sample_format_t { pub fn toPAChannelMap(channels: []const main.Channel) !c.pa_channel_map { var channel_map: c.pa_channel_map = undefined; channel_map.channels = @intCast(u5, channels.len); - for (channels) |ch, i| + for (channels, 0..) |ch, i| channel_map.map[i] = try toPAChannelPos(ch.id); return channel_map; } diff --git a/libs/sysaudio/src/wasapi.zig b/libs/sysaudio/src/wasapi.zig index c3e05ef4..ef063764 100644 --- a/libs/sysaudio/src/wasapi.zig +++ b/libs/sysaudio/src/wasapi.zig @@ -742,7 +742,7 @@ pub const Player = struct { else => unreachable, } - for (self.channels) |*ch, i| { + for (self.channels, 0..) |*ch, i| { ch.*.ptr = data + self.format.frameSize(i); } diff --git a/libs/sysaudio/src/wasapi/win32.zig b/libs/sysaudio/src/wasapi/win32.zig index e9a821bc..6116dcb8 100644 --- a/libs/sysaudio/src/wasapi/win32.zig +++ b/libs/sysaudio/src/wasapi/win32.zig @@ -13,7 +13,7 @@ pub const Guid = extern union { }; pub fn initString(s: []const u8) Guid { var guid = Guid{ .Bytes = undefined }; - for (hex_offsets) |hex_offset, i| { + for (hex_offsets, 0..) |hex_offset, i| { guid.Bytes[i] = decodeHexByte([2]u8{ s[hex_offset], s[hex_offset + 1] }); } return guid; diff --git a/libs/sysaudio/src/webaudio.zig b/libs/sysaudio/src/webaudio.zig index 26390f02..e2d0614f 100644 --- a/libs/sysaudio/src/webaudio.zig +++ b/libs/sysaudio/src/webaudio.zig @@ -118,7 +118,7 @@ pub const Context = struct { .write_step = @sizeOf(f32), }; - for (player.channels) |*ch, i| { + for (player.channels, 0..) |*ch, i| { ch.*.ptr = player.buf.ptr + i * channel_size_bytes; } @@ -186,7 +186,7 @@ pub const Player = struct { self.writeFn(self.user_data, channel_size); - for (self.channels) |_, i| { + for (self.channels, 0..) |_, i| { self.buf_js.copyBytes(self.buf[i * channel_size_bytes .. (i + 1) * channel_size_bytes]); const buf_f32_js = js.constructType("Float32Array", &.{ self.buf_js.get("buffer"), self.buf_js.get("byteOffset"), js.createNumber(channel_size) }); defer buf_f32_js.deinit(); diff --git a/tools/wasmserve/wasmserve.zig b/tools/wasmserve/wasmserve.zig index f7f403da..f3bbc580 100644 --- a/tools/wasmserve/wasmserve.zig +++ b/tools/wasmserve/wasmserve.zig @@ -299,7 +299,7 @@ const Wasmserve = struct { }; fn dropFragment(input: []const u8) []const u8 { - for (input) |c, i| + for (input, 0..) |c, i| if (c == '?' or c == '#') return input[0..i];