diff options
Diffstat (limited to 'src/host/library.zig')
| -rw-r--r-- | src/host/library.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/host/library.zig b/src/host/library.zig index 6c9338f..6958eec 100644 --- a/src/host/library.zig +++ b/src/host/library.zig @@ -17,10 +17,10 @@ pub const Library = struct { const object = c.SDL_LoadObject(path.ptr) orelse return error.LoadLibrary; errdefer c.SDL_UnloadObject(object); var sketch: abi.Sketch = undefined; - inline for (@typeInfo(abi.Sketch).@"struct".fields) |field| { - const symbol = @field(abi.Sketch.symbols, field.name); + inline for (comptime std.meta.fieldNames(abi.Sketch)) |name| { + const symbol = @field(abi.Sketch.symbols, name); const address = c.SDL_LoadFunction(object, symbol) orelse return error.MissingEntryPoint; - @field(sketch, field.name) = @ptrCast(address); + @field(sketch, name) = @ptrCast(address); } if (sketch.info().abi != abi.hash) return error.AbiMismatch; return .{ .object = object, .sketch = sketch }; @@ -29,7 +29,7 @@ pub const Library = struct { /// Loads `source` through a uniquely named copy in `scratch_dir`. pub fn openCopy(io: std.Io, source: []const u8, scratch_dir: []const u8, serial: usize) !Library { var buf: [std.fs.max_path_bytes]u8 = undefined; - const copy = try std.fmt.bufPrintZ(&buf, "{s}/sketchbook-{d}-{d}.so", .{ scratch_dir, linux.getpid(), serial }); + const copy = try std.mem.printSentinel(&buf, "{s}/sketchbook-{d}-{d}.so", .{ scratch_dir, linux.getpid(), serial }, 0); const cwd = std.Io.Dir.cwd(); try cwd.copyFile(source, cwd, copy, io, .{}); defer cwd.deleteFile(io, copy) catch {}; @@ -53,7 +53,7 @@ pub const Watch = struct { errdefer _ = linux.close(fd); var buf: [std.fs.max_path_bytes]u8 = undefined; const dir = std.fs.path.dirname(path) orelse "."; - const dir_z = try std.fmt.bufPrintZ(&buf, "{s}", .{dir}); + const dir_z = try std.mem.printSentinel(&buf, "{s}", .{dir}, 0); if (@as(isize, @bitCast(linux.inotify_add_watch(fd, dir_z, linux.IN.MOVED_TO | linux.IN.CLOSE_WRITE))) < 0) return error.WatchFailed; return .{ .fd = fd, .name = std.fs.path.basename(path) }; } |
