diff options
| author | s-ol <s+removethis@s-ol.nu> | 2021-11-11 11:30:28 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2021-11-11 11:31:34 +0000 |
| commit | d05c479194bedd52500c5e4be5bdef2266f73061 (patch) | |
| tree | 5dabb0e90f1b3d17fd7b0eb97f34004a0d9447cf /src | |
| parent | remove/ignore unused variables (diff) | |
| download | glsl-view-d05c479194bedd52500c5e4be5bdef2266f73061.tar.gz glsl-view-d05c479194bedd52500c5e4be5bdef2266f73061.zip | |
update for zig 0.8.0
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.zig | 8 | ||||
| -rw-r--r-- | src/control.zig | 4 | ||||
| -rw-r--r-- | src/debug_gl.zig | 2 | ||||
| -rw-r--r-- | src/gl.zig | 14 | ||||
| -rw-r--r-- | src/main.zig | 17 |
5 files changed, 23 insertions, 22 deletions
diff --git a/src/config.zig b/src/config.zig index 9655a85..b5c29df 100644 --- a/src/config.zig +++ b/src/config.zig @@ -100,7 +100,7 @@ pub const Config = struct { } else if (std.mem.eql(u8, key, "osc")) { config.osc = try parseOSC(&parser, allocator); } else { - debug.warn("unknown key: '{}'\n", .{key}); + debug.warn("unknown key: '{s}'\n", .{key}); try skipAny(&parser); } }, @@ -241,7 +241,7 @@ fn parseOutputs(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]Outp } else if (std.mem.eql(u8, key, "fullscreen")) { output.*.fullscreen = try parseBool(parser); } else { - debug.warn("unknown key: '{}'\n", .{key}); + debug.warn("unknown key: '{s}'\n", .{key}); try skipAny(parser); } }, @@ -303,7 +303,7 @@ fn parseParameters(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) ![]P param.*.type = try parseString(parser, allocator); have_type = true; } else { - debug.warn("unknown key: '{}'\n", .{key}); + debug.warn("unknown key: '{s}'\n", .{key}); try skipAny(parser); } }, @@ -364,7 +364,7 @@ fn parseOSC(parser: *c.yaml_parser_t, allocator: *std.mem.Allocator) !OSCConfig } else if (std.mem.eql(u8, key, "port")) { config.Manual.port = try parseInt(parser, u16); } else { - debug.warn("unknown key: '{}'\n", .{key}); + debug.warn("unknown key: '{s}'\n", .{key}); try skipAny(parser); } }, diff --git a/src/control.zig b/src/control.zig index c282e7a..e490c7c 100644 --- a/src/control.zig +++ b/src/control.zig @@ -6,7 +6,7 @@ const cfg = @import("config.zig"); fn verify_args(expected: u8, got: []const u8) !void { for (got) |typ| { if (typ != expected) { - std.debug.warn("expected '{c}' but got '{c}' element (expected {})\n", .{expected, typ, got}); + std.debug.warn("expected '{c}' but got '{c}' element (expected {s})\n", .{ expected, typ, got }); return error.typeMismatch; } } @@ -185,7 +185,7 @@ pub const ControlServer = struct { } self.set_uniform(path[1..], argv, argc, types) catch |err| { - std.debug.warn("{} while processing {}\n", .{err, path}); + std.debug.warn("{} while processing {s}\n", .{ err, path }); }; return 0; } diff --git a/src/debug_gl.zig b/src/debug_gl.zig index eb6276a..dc92e85 100644 --- a/src/debug_gl.zig +++ b/src/debug_gl.zig @@ -4,7 +4,7 @@ const os = std.os; const panic = std.debug.panic; const builtin = @import("builtin"); -pub const is_on = if (builtin.mode == builtin.Mode.ReleaseFast) c.GL_FALSE else c.GL_TRUE; +pub const is_on = if (builtin.mode == .ReleaseFast) c.GL_FALSE else c.GL_TRUE; fn glDebugMessage( source: c.GLenum, @@ -359,7 +359,7 @@ pub const UniformCache = struct { pub fn deinit(self: *UniformCache) void { var it = self.uniforms.iterator(); while (it.next()) |entry| { - self.allocator.free(entry.key); + self.allocator.free(entry.key_ptr.*); } self.uniforms.deinit(); @@ -381,8 +381,8 @@ pub const UniformCache = struct { var it = self.uniforms.iterator(); var i: usize = 0; while (it.next()) |entry| { - existing_names[i] = entry.key; - existing_names_c[i] = entry.key.ptr; + existing_names[i] = entry.key_ptr.*; + existing_names_c[i] = entry.key_ptr.*.ptr; i += 1; } } @@ -397,8 +397,8 @@ pub const UniformCache = struct { for (existing_indices) |index, i| { const name = existing_names[i]; if (index == c.GL_INVALID_INDEX) { - if (self.uniforms.remove(name)) |removed| { - self.allocator.free(removed.key); + if (self.uniforms.remove(name)) { + self.allocator.free(name); } } else { var uniform = self.uniforms.get(name).?; @@ -415,14 +415,14 @@ pub const UniformCache = struct { var result = try self.uniforms.getOrPut(cloned_name); if (!result.found_existing) { - result.entry.value = CachedUniform.init(self.shader.*, name.ptr) catch { + result.value_ptr.* = CachedUniform.init(self.shader.*, name.ptr) catch { _ = self.uniforms.remove(cloned_name); self.allocator.free(cloned_name); return null; }; } - return &result.entry.value; + return result.value_ptr; } }; diff --git a/src/main.zig b/src/main.zig index 460b6a8..bfb42b0 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,6 +1,7 @@ const std = @import("std"); const fs = @import("std").fs; -const panic = std.debug.panic; +const debug = std.debug; +const panic = debug.panic; const c = @import("c.zig"); const debug_gl = @import("debug_gl.zig"); const cfg = @import("config.zig"); @@ -12,7 +13,7 @@ const c_allocator = @import("std").heap.c_allocator; var window: *c.GLFWwindow = undefined; fn errorCallback(err: c_int, description: [*c]const u8) callconv(.C) void { - panic("Error {}: {}\n", .{err, description}); + panic("Error {}: {s}\n", .{ err, description }); } pub fn main() !void { @@ -31,7 +32,7 @@ pub fn main() !void { var monitor_count: c_int = 0; const monitors = c.glfwGetMonitors(&monitor_count); for (monitors[0..@intCast(usize, monitor_count)]) |monitor, i| { - std.debug.warn( + debug.warn( "monitor {}: '{s}'\n", .{ i, @ptrCast([*:0]const u8, c.glfwGetMonitorName(monitor)) }, ); @@ -179,8 +180,8 @@ fn loadFile(writer: anytype, dir: []const u8, filename: []const u8) !void { if (std.mem.eql(u8, pragma, "include")) { var include_path = parts.next().?; if (include_path[0] != '"' or include_path[include_path.len - 1] != '"') { - std.debug.warn("{}:{}: Invalid #pragma include\n", .{file_path, line_number}); - std.debug.warn("{}:{}: {}\n", .{file_path, line_number, line}); + debug.warn("{s}:{}: Invalid #pragma include\n", .{ file_path, line_number }); + debug.warn("{s}:{}: {s}\n", .{ file_path, line_number, line }); continue; } include_path = include_path[1 .. include_path.len - 1]; @@ -189,8 +190,8 @@ fn loadFile(writer: anytype, dir: []const u8, filename: []const u8) !void { continue; } else { - std.debug.warn("{}:{}: Unknown #pragma directive '{}'\n", .{file_path, line_number, pragma}); - std.debug.warn("{}:{}: {}\n", .{file_path, line_number, line}); + debug.warn("{s}:{}: Unknown #pragma directive '{s}'\n", .{ file_path, line_number, pragma }); + debug.warn("{s}:{}: {s}\n", .{ file_path, line_number, line }); } } @@ -224,6 +225,6 @@ fn reloadShader(current: *gl.ShaderProgram, frag_filename: []const u8, size: u64 current.destroy(); current.* = new_program; } else |err| { - std.debug.warn("Error while reloading shader:{}\n", .{err}); + debug.warn("Error while reloading shader: {}\n", .{err}); } } |
