diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-28 21:07:13 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-12 13:22:02 -0300 |
| commit | 590ba7b9b579b97e34b51ab7e3460ebc85713343 (patch) | |
| tree | 6a73a7570ff4f79f41deff078455877b9bc6571b /src/host/library.zig | |
| parent | bc8e6eb1bfef0c5e9b3c40fc1e4fd5a1659e2b03 (diff) | |
| download | sketchbook-590ba7b9b579b97e34b51ab7e3460ebc85713343.tar.gz sketchbook-590ba7b9b579b97e34b51ab7e3460ebc85713343.zip | |
sketchbook: Zig 0.17, a Store on disk, requests, a scope (waveform, spectrum, spectrogram), audio codecs and fonts, web host
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) }; } |
