Compare commits

...

3 Commits

Author SHA1 Message Date
Luna 9937365433 update to latest zig 2021-04-03 22:16:04 -03:00
Luna 667e6cbdac zig fmt pass 2021-04-03 21:09:44 -03:00
Luna 2acb45fdca build.zig: fix for latest zig 2021-04-03 21:09:30 -03:00
11 changed files with 53 additions and 68 deletions

View File

@ -24,14 +24,14 @@ fn setupLinks(step: *builds.LibExeObjStep) void {
for (possible_lilv_include_dirs) |possible_lilv_dir| { for (possible_lilv_include_dirs) |possible_lilv_dir| {
var possible_dir = std.fs.cwd().openDir(possible_lilv_dir, .{}) catch |err| { var possible_dir = std.fs.cwd().openDir(possible_lilv_dir, .{}) catch |err| {
std.debug.warn("possible lilv {} fail: {}\n", .{ possible_lilv_dir, err }); std.debug.warn("possible lilv {s} fail: {s}\n", .{ possible_lilv_dir, err });
continue; continue;
}; };
possible_dir.close(); possible_dir.close();
found_any_lilv = true; found_any_lilv = true;
std.debug.warn("found lilv at '{}'\n", .{possible_lilv_dir}); std.debug.warn("found lilv at '{s}'\n", .{possible_lilv_dir});
step.addIncludeDir(possible_lilv_dir); step.addIncludeDir(possible_lilv_dir);
} }

View File

@ -20,7 +20,7 @@ pub fn magicValid(magic: []const u8) !void {
} }
if (!valid) { if (!valid) {
std.debug.warn("\tINVALID HEADER: '{}'\n", .{magic}); std.debug.warn("\tINVALID HEADER: '{s}'\n", .{magic});
return BMPValidError.InvalidMagic; return BMPValidError.InvalidMagic;
} }
} }

View File

@ -174,7 +174,7 @@ pub const Embed = struct {
if (read_bytes < 0) { if (read_bytes < 0) {
const st: i32 = c.sf_error(self.sndfile); const st: i32 = c.sf_error(self.sndfile);
std.debug.warn("Failed to read {} ({})\n", .{ std.debug.warn("Failed to read {s} ({s})\n", .{
self.filepath, self.filepath,
c.sf_error_number(st), c.sf_error_number(st),
}); });

View File

@ -32,7 +32,7 @@ pub fn sopen(
const st: i32 = c.sf_error(file); const st: i32 = c.sf_error(file);
if (st != 0) { if (st != 0) {
std.debug.warn("Failed to open {} ({})\n", .{ std.debug.warn("Failed to open {s} ({s})\n", .{
path, path,
c.sf_error_number(st), c.sf_error_number(st),
}); });
@ -181,7 +181,7 @@ pub const Image = struct {
pub fn close(self: *Image) void { pub fn close(self: *Image) void {
var st: i32 = c.sf_close(self.sndfile); var st: i32 = c.sf_close(self.sndfile);
if (st != 0) { if (st != 0) {
std.debug.warn("Failed to close {} ({})\n", .{ std.debug.warn("Failed to close {s} ({s})\n", .{
self.path, self.path,
c.sf_error_number(st), c.sf_error_number(st),
}); });
@ -228,7 +228,7 @@ pub const Image = struct {
sseek(out_file, start); sseek(out_file, start);
while (i <= end) : (i += buf.len) { while (i <= end) : (i += buf.len) {
std.debug.warn("\t\ti={}, buf.len={}, end={}\n", .{ i, buf.len, end }); std.debug.warn("\t\ti={d}, buf.len={d}, end={d}\n", .{ i, buf.len, end });
sseek(self.sndfile, i); sseek(self.sndfile, i);
sseek(out_file, i); sseek(out_file, i);
@ -254,7 +254,7 @@ pub const Image = struct {
fn getSeekPos(self: *Image, position: plugins.Position) plugins.SeekPos { fn getSeekPos(self: *Image, position: plugins.Position) plugins.SeekPos {
const file_end = self.frames; const file_end = self.frames;
var seek_pos = position.seekPos(file_end); var seek_pos = position.seekPos(file_end);
std.debug.warn("\tstart {} end {}\n", .{ seek_pos.start, seek_pos.end }); std.debug.warn("\tstart {d} end {d}\n", .{ seek_pos.start, seek_pos.end });
return seek_pos; return seek_pos;
} }
@ -267,7 +267,7 @@ pub const Image = struct {
self.curpath = path; self.curpath = path;
self.frames = @intCast(usize, in_fmt.frames); self.frames = @intCast(usize, in_fmt.frames);
std.debug.warn("\timage: reopened on '{}' (frames={}, fmt.frames={})\n", .{ std.debug.warn("\timage: reopened on '{s}' (frames={d}, fmt.frames={d})\n", .{
self.curpath, self.curpath,
self.frames, self.frames,
in_fmt.frames, in_fmt.frames,
@ -310,12 +310,12 @@ pub const Image = struct {
defer ctx.allocator.free(ports); defer ctx.allocator.free(ports);
if (ctx.n_audio_in > 2) { if (ctx.n_audio_in > 2) {
std.debug.warn("plugin <{}> has more than two inputs.\n", .{plugin_uri}); std.debug.warn("plugin <{s}> has more than two inputs.\n", .{plugin_uri});
return ImageError.InvalidPlugin; return ImageError.InvalidPlugin;
} }
if (ctx.n_audio_out > 2) { if (ctx.n_audio_out > 2) {
std.debug.warn("plugin <{}> has more than two outputs.\n", .{plugin_uri}); std.debug.warn("plugin <{s}> has more than two outputs.\n", .{plugin_uri});
return ImageError.InvalidPlugin; return ImageError.InvalidPlugin;
} }
@ -327,14 +327,14 @@ pub const Image = struct {
var sym = c.lilv_new_string(ctx.world, sym_cstr.ptr); var sym = c.lilv_new_string(ctx.world, sym_cstr.ptr);
const port = c.lilv_plugin_get_port_by_symbol(ctx.plugin, sym) orelse { const port = c.lilv_plugin_get_port_by_symbol(ctx.plugin, sym) orelse {
std.debug.warn("assert fail: symbol {} not found on port\n", .{param.sym}); std.debug.warn("assert fail: symbol {s} not found on port\n", .{param.sym});
return ImageError.InvalidSymbol; return ImageError.InvalidSymbol;
}; };
c.lilv_node_free(sym); c.lilv_node_free(sym);
var idx = c.lilv_port_get_index(ctx.plugin, port); var idx = c.lilv_port_get_index(ctx.plugin, port);
std.debug.warn("\tset sym={}, idx={} to val={}\n", .{ std.debug.warn("\tset sym={s}, idx={d} to val={}\n", .{
param.sym, param.sym,
idx, idx,
param.value, param.value,
@ -345,7 +345,7 @@ pub const Image = struct {
// now we need to generate a temporary file and put the output of // now we need to generate a temporary file and put the output of
// running the plugin on that file // running the plugin on that file
var tmpnam = try temporaryName(self.allocator); var tmpnam = try temporaryName(self.allocator);
std.debug.warn("\trunning plugin from '{}' to '{}'\n", .{ self.curpath, tmpnam }); std.debug.warn("\trunning plugin from '{s}' to '{s}'\n", .{ self.curpath, tmpnam });
var out_fmt = mkSfInfo(); var out_fmt = mkSfInfo();
var out_file = try sopen(self.allocator, tmpnam, c.SFM_WRITE, &out_fmt); var out_file = try sopen(self.allocator, tmpnam, c.SFM_WRITE, &out_fmt);
@ -378,7 +378,7 @@ pub const Image = struct {
sseek(self.sndfile, seek_pos.start); sseek(self.sndfile, seek_pos.start);
var i: usize = seek_pos.start; var i: usize = seek_pos.start;
std.debug.warn("\tseek pos start: {} end: {}\n", .{ seek_pos.start, seek_pos.end }); std.debug.warn("\tseek pos start: {d} end: {d}\n", .{ seek_pos.start, seek_pos.end });
var inbuf = &rctx.buffers.in; var inbuf = &rctx.buffers.in;
var outbuf = &rctx.buffers.out; var outbuf = &rctx.buffers.out;
@ -389,7 +389,7 @@ pub const Image = struct {
const read_bytes = c.sf_readf_float(self.sndfile, inbuf, 1); const read_bytes = c.sf_readf_float(self.sndfile, inbuf, 1);
if (read_bytes == 0) { if (read_bytes == 0) {
std.debug.warn("WARN! reached EOF at idx={}\n", .{i}); std.debug.warn("WARN! reached EOF at idx={d}\n", .{i});
break; break;
} }
@ -422,7 +422,7 @@ pub const Image = struct {
} }
pub fn saveTo(self: *Image, out_path: []const u8) !void { pub fn saveTo(self: *Image, out_path: []const u8) !void {
std.debug.warn("\timg: copy from '{}' to '{}'\n", .{ self.curpath, out_path }); std.debug.warn("\timg: copy from '{s}' to '{s}'\n", .{ self.curpath, out_path });
try std.fs.copyFileAbsolute(self.curpath, out_path, .{}); try std.fs.copyFileAbsolute(self.curpath, out_path, .{});
} }
@ -450,7 +450,7 @@ pub const Image = struct {
// the code here is a copypaste of runPlugin() without the specific // the code here is a copypaste of runPlugin() without the specific
// lilv things. // lilv things.
var tmpnam = try temporaryName(self.allocator); var tmpnam = try temporaryName(self.allocator);
std.debug.warn("\trunning CUSTOM plugin from '{}' to '{}'\n", .{ self.curpath, tmpnam }); std.debug.warn("\trunning CUSTOM plugin from '{s}' to '{s}'\n", .{ self.curpath, tmpnam });
var out_fmt = mkSfInfo(); var out_fmt = mkSfInfo();
var out_file = try sopen(self.allocator, tmpnam, c.SFM_WRITE, &out_fmt); var out_file = try sopen(self.allocator, tmpnam, c.SFM_WRITE, &out_fmt);
@ -477,7 +477,7 @@ pub const Image = struct {
sseek(self.sndfile, seek_pos.start); sseek(self.sndfile, seek_pos.start);
var i: usize = seek_pos.start; var i: usize = seek_pos.start;
std.debug.warn("\tseek pos start: {} end: {}\n", .{ seek_pos.start, seek_pos.end }); std.debug.warn("\tseek pos start: {d} end: {d}\n", .{ seek_pos.start, seek_pos.end });
var inbuf = &bufs.in; var inbuf = &bufs.in;
var outbuf = &bufs.out; var outbuf = &bufs.out;
@ -485,7 +485,7 @@ pub const Image = struct {
while (i <= seek_pos.end) : (i += 1) { while (i <= seek_pos.end) : (i += 1) {
const read_bytes = c.sf_readf_float(self.sndfile, inbuf, 1); const read_bytes = c.sf_readf_float(self.sndfile, inbuf, 1);
if (read_bytes == 0) { if (read_bytes == 0) {
std.debug.warn("WARN! reached EOF at idx={}\n", .{i}); std.debug.warn("WARN! reached EOF at idx={d}\n", .{i});
break; break;
} }

View File

@ -146,7 +146,7 @@ pub const Command = struct {
} }
pub fn print(base: *const @This()) void { pub fn print(base: *const @This()) void {
std.debug.warn("tag: {}\n", .{base.tag}); std.debug.warn("tag: {s}\n", .{base.tag});
} }
pub const Noop = struct { pub const Noop = struct {
@ -199,33 +199,25 @@ pub const Command = struct {
pub const Amp = LV2Command( pub const Amp = LV2Command(
.amp, .amp,
"http://lv2plug.in/plugins/eg-amp", "http://lv2plug.in/plugins/eg-amp",
struct { struct { gain: f32 },
gain: f32
},
); );
pub const RFlanger = LV2Command( pub const RFlanger = LV2Command(
.rflanger, .rflanger,
"http://plugin.org.uk/swh-plugins/retroFlange", "http://plugin.org.uk/swh-plugins/retroFlange",
struct { struct { delay_depth_avg: f32, law_freq: f32 },
delay_depth_avg: f32, law_freq: f32
},
); );
pub const Eq = LV2Command( pub const Eq = LV2Command(
.rflanger, .rflanger,
"http://plugin.org.uk/swh-plugins/dj_eq_mono", "http://plugin.org.uk/swh-plugins/dj_eq_mono",
struct { struct { lo: f32, mid: f32, hi: f32 },
lo: f32, mid: f32, hi: f32
},
); );
pub const Phaser = LV2Command( pub const Phaser = LV2Command(
.phaser, .phaser,
"http://plugin.org.uk/swh-plugins/lfoPhaser", "http://plugin.org.uk/swh-plugins/lfoPhaser",
struct { struct { lfo_rate: f32, lfo_depth: f32, fb: f32, spread: f32 },
lfo_rate: f32, lfo_depth: f32, fb: f32, spread: f32
},
); );
pub const Mbeq = LV2Command( pub const Mbeq = LV2Command(
@ -378,9 +370,7 @@ pub const Command = struct {
pub const Foverdrive = LV2Command(.foverdrive, "http://plugin.org.uk/swh-plugins/foverdrive", struct { pub const Foverdrive = LV2Command(.foverdrive, "http://plugin.org.uk/swh-plugins/foverdrive", struct {
drive: f32, drive: f32,
}); });
pub const Thruzero = LV2Command(.thruzero, "http://drobilla.net/plugins/mda/ThruZero", struct { pub const Thruzero = LV2Command(.thruzero, "http://drobilla.net/plugins/mda/ThruZero", struct { rate: f32, mix: f32, feedback: f32, depth_mod: f32 });
rate: f32, mix: f32, feedback: f32, depth_mod: f32
});
pub const Gverb = LV2Command(.gverb, "http://plugin.org.uk/swh-plugins/gverb", struct { pub const Gverb = LV2Command(.gverb, "http://plugin.org.uk/swh-plugins/gverb", struct {
roomsize: f32, roomsize: f32,
@ -559,7 +549,7 @@ pub const Lang = struct {
inline for (@typeInfo(@TypeOf(cmd.parameters)).Struct.fields) |cmd_field| { inline for (@typeInfo(@TypeOf(cmd.parameters)).Struct.fields) |cmd_field| {
const maybe_arg = tok_it.next(); const maybe_arg = tok_it.next();
if (maybe_arg == null) { if (maybe_arg == null) {
self.doError("Expected parameter for {}, got nothing", .{cmd_field.name}); self.doError("Expected parameter for {s}, got nothing", .{cmd_field.name});
return; return;
} }
@ -590,7 +580,7 @@ pub const Lang = struct {
else => @compileError("Invalid parameter type (" ++ @typeName(cmd_field.field_type) ++ ") left on command struct " ++ @typeName(command_struct) ++ "."), else => @compileError("Invalid parameter type (" ++ @typeName(cmd_field.field_type) ++ ") left on command struct " ++ @typeName(command_struct) ++ "."),
}; };
std.debug.warn("parsing {}, arg of type {} => {}\n", .{ std.debug.warn("parsing {s}, arg of type {s} => {any}\n", .{
@typeName(command_struct), @typeName(command_struct),
@typeName(@TypeOf(argument_value)), @typeName(@TypeOf(argument_value)),
argument_value, argument_value,
@ -602,7 +592,7 @@ pub const Lang = struct {
cmd.base.tag = command_struct.base_tag; cmd.base.tag = command_struct.base_tag;
const command = cmd.base.cast(command_struct).?; const command = cmd.base.cast(command_struct).?;
std.debug.warn("cmd: {}\n", .{command}); std.debug.warn("cmd: {s}\n", .{command});
try commands.append(&cmd.base); try commands.append(&cmd.base);
} }
@ -663,7 +653,7 @@ pub const Lang = struct {
} }
if (!found) { if (!found) {
self.doError("Unknown command '{}' ({})", .{ command_string, command_string.len }); self.doError("Unknown command '{s}' ({d} bytes)", .{ command_string, command_string.len });
continue; continue;
} }
} }

View File

@ -118,7 +118,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port {
if (c.lilv_port_is_a(ctx.plugin, lport, lv2_InputPort)) { if (c.lilv_port_is_a(ctx.plugin, lport, lv2_InputPort)) {
port.is_input = true; port.is_input = true;
} else if (!c.lilv_port_is_a(ctx.plugin, lport, lv2_OutputPort) and !port.optional) { } else if (!c.lilv_port_is_a(ctx.plugin, lport, lv2_OutputPort) and !port.optional) {
std.debug.warn("Port {} is neither input or output\n", .{i}); std.debug.warn("Port {d} is neither input or output\n", .{i});
return error.UnassignedIOPort; return error.UnassignedIOPort;
} }
@ -134,7 +134,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port {
ctx.n_audio_out += 1; ctx.n_audio_out += 1;
} }
} else if (!port.optional) { } else if (!port.optional) {
std.debug.warn("Port {} has unsupported type\n", .{i}); std.debug.warn("Port {d} has unsupported type\n", .{i});
return error.UnsupportedPortType; return error.UnsupportedPortType;
} }
} }

View File

@ -39,7 +39,7 @@ fn magickLoad(image: *Image) !MagickContext {
var curpath = try std.cstr.addNullByte(image.allocator, image.curpath); var curpath = try std.cstr.addNullByte(image.allocator, image.curpath);
defer image.allocator.free(curpath); defer image.allocator.free(curpath);
std.debug.warn("loading '{}'\n", .{curpath}); std.debug.warn("loading '{s}'\n", .{curpath});
if (mc.MagickReadImage(mctx.wand, curpath.ptr) != 1) if (mc.MagickReadImage(mctx.wand, curpath.ptr) != 1)
return error.MagickReadFail; return error.MagickReadFail;
@ -54,7 +54,7 @@ fn magickSave(image: *Image, wand: *mc.MagickWand) !void {
var c_tmpnam = try std.cstr.addNullByte(allocator, tmpnam); var c_tmpnam = try std.cstr.addNullByte(allocator, tmpnam);
defer allocator.free(c_tmpnam); defer allocator.free(c_tmpnam);
std.debug.warn("\tmagick: saving to '{}'..", .{c_tmpnam}); std.debug.warn("\tmagick: saving to '{s}'..", .{c_tmpnam});
if (mc.MagickWriteImage(wand, c_tmpnam.ptr) != 1) if (mc.MagickWriteImage(wand, c_tmpnam.ptr) != 1)
return error.MagickWriteFail; return error.MagickWriteFail;

View File

@ -38,7 +38,7 @@ fn copyCommandToHeap(allocator: *std.mem.Allocator, command: langs.Command, comp
pub fn doRepl(allocator: *std.mem.Allocator, args_it: anytype) !void { pub fn doRepl(allocator: *std.mem.Allocator, args_it: anytype) !void {
var stdout_file = std.io.getStdOut(); var stdout_file = std.io.getStdOut();
const stdout = &stdout_file.outStream(); const stdout = &stdout_file.writer();
const scri_path = try (args_it.next(allocator) orelse @panic("expected scri path")); const scri_path = try (args_it.next(allocator) orelse @panic("expected scri path"));
var file_read_opt: ?std.fs.File = std.fs.cwd().openFile(scri_path, .{}) catch |err| blk: { var file_read_opt: ?std.fs.File = std.fs.cwd().openFile(scri_path, .{}) catch |err| blk: {
@ -95,7 +95,7 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: anytype) !void {
}); });
defer file.close(); defer file.close();
var out = file.outStream(); var out = file.writer();
var stream = &out; var stream = &out;
// since we opened the file for writing, it becomes empty, so, to ensure // since we opened the file for writing, it becomes empty, so, to ensure

View File

@ -137,7 +137,7 @@ pub fn makeContext(allocator: *std.mem.Allocator, plugin_uri: []const u8) !Conte
c.lilv_world_load_all(world); c.lilv_world_load_all(world);
var uri: *c.LilvNode = c.lilv_new_uri(world, cstr_plugin_uri.ptr) orelse { var uri: *c.LilvNode = c.lilv_new_uri(world, cstr_plugin_uri.ptr) orelse {
std.debug.warn("Invalid plugin URI <{}>\n", .{plugin_uri}); std.debug.warn("Invalid plugin URI <{s}>\n", .{plugin_uri});
return ImageError.InvalidPlugin; return ImageError.InvalidPlugin;
}; };
defer c.lilv_node_free(uri); defer c.lilv_node_free(uri);
@ -145,7 +145,7 @@ pub fn makeContext(allocator: *std.mem.Allocator, plugin_uri: []const u8) !Conte
const plugins: *const c.LilvPlugins = c.lilv_world_get_all_plugins(world).?; const plugins: *const c.LilvPlugins = c.lilv_world_get_all_plugins(world).?;
var plugin: *const c.LilvPlugin = c.lilv_plugins_get_by_uri(plugins, uri) orelse { var plugin: *const c.LilvPlugin = c.lilv_plugins_get_by_uri(plugins, uri) orelse {
std.debug.warn("Plugin <{}> not found\n", .{plugin_uri}); std.debug.warn("Plugin <{s}> not found\n", .{plugin_uri});
return ImageError.UnknownPlugin; return ImageError.UnknownPlugin;
}; };

View File

@ -3,12 +3,14 @@ const langs = @import("lang.zig");
fn printCommandWithParams(stream: anytype, command: anytype) !void { fn printCommandWithParams(stream: anytype, command: anytype) !void {
const Parameters = @TypeOf(command.parameters); const Parameters = @TypeOf(command.parameters);
try stream.print(" {} {}", .{ command.split, command.index }); try stream.print(" {d} {d}", .{ command.split, command.index });
inline for (@typeInfo(Parameters).Struct.fields) |field| { inline for (@typeInfo(Parameters).Struct.fields) |field| {
if (field.field_type == f32 or field.field_type == f64) { if (field.field_type == f32 or field.field_type == f64) {
try stream.print(" {}", .{@field(command.parameters, field.name)});
} else if (field.field_type == usize or field.field_type == u64) {
try stream.print(" {d}", .{@field(command.parameters, field.name)}); try stream.print(" {d}", .{@field(command.parameters, field.name)});
} else { } else {
try stream.print(" {}", .{@field(command.parameters, field.name)}); try stream.print(" {s}", .{@field(command.parameters, field.name)});
} }
} }
} }
@ -17,12 +19,6 @@ fn printCommand(stream: anytype, cmd: *langs.Command, comptime tag: langs.Comman
const CommandStruct = langs.Command.tagToType(tag); const CommandStruct = langs.Command.tagToType(tag);
const casted = cmd.cast(CommandStruct).?; const casted = cmd.cast(CommandStruct).?;
// TODO move this to Tag method?
const is_typed = switch (tag) {
.noop, .load, .quicksave, .runqs, .rotate => false,
else => true,
};
const ctype = CommandStruct.command_type; const ctype = CommandStruct.command_type;
switch (ctype) { switch (ctype) {
.lv2_command => try printCommandWithParams(stream, casted), .lv2_command => try printCommandWithParams(stream, casted),
@ -33,21 +29,21 @@ fn printCommand(stream: anytype, cmd: *langs.Command, comptime tag: langs.Comman
pub fn printList(list: langs.CommandList, stream: anytype) !void { pub fn printList(list: langs.CommandList, stream: anytype) !void {
for (list.list.items) |cmd| { for (list.list.items) |cmd| {
const command = @tagName(cmd.tag); const command = @tagName(cmd.tag);
try stream.print("{}", .{command}); try stream.print("{s}", .{command});
switch (cmd.tag) { switch (cmd.tag) {
.load => { .load => {
const load = cmd.cast(langs.Command.Load).?; const load = cmd.cast(langs.Command.Load).?;
try stream.print(" {}", .{load.path}); try stream.print(" {s}", .{load.path});
}, },
.runqs => { .runqs => {
const runqs = cmd.cast(langs.Command.RunQS).?; const runqs = cmd.cast(langs.Command.RunQS).?;
try stream.print(" {}", .{runqs.program}); try stream.print(" {s}", .{runqs.program});
}, },
.noop, .quicksave => {}, .noop, .quicksave => {},
.rotate => { .rotate => {
const rotate = cmd.cast(langs.Command.Rotate).?; const rotate = cmd.cast(langs.Command.Rotate).?;
try stream.print(" {d} {}", .{ rotate.deg, rotate.bgfill }); try stream.print(" {d} {s}", .{ rotate.deg, rotate.bgfill });
}, },
.amp => try printCommand(stream, cmd, .amp), .amp => try printCommand(stream, cmd, .amp),

View File

@ -67,11 +67,10 @@ pub const Runner = struct {
// ':0' should ALWAYS point to the image. // ':0' should ALWAYS point to the image.
if (self.repl) index += 3 else index += 2; if (self.repl) index += 3 else index += 2;
std.debug.warn("ARGS!! {} \n", .{self.args.len});
for (self.args) |arg, idx| { for (self.args) |arg, idx| {
std.debug.warn("arg{} = {}\n", .{ idx, arg }); std.debug.warn("arg{d} = {s}\n", .{ idx, arg });
} }
std.debug.warn("fetch arg idx={}, val={}\n", .{ index, self.args[index] }); std.debug.warn("fetch arg idx={d}, val={s}\n", .{ index, self.args[index] });
return self.args[index]; return self.args[index];
} else { } else {
return load_path; return load_path;
@ -91,7 +90,7 @@ pub const Runner = struct {
fn loadCmd(self: *Runner, path_or_argidx: []const u8) !void { fn loadCmd(self: *Runner, path_or_argidx: []const u8) !void {
const load_path = try self.resolveArgPath(path_or_argidx); const load_path = try self.resolveArgPath(path_or_argidx);
std.debug.warn("\tload path: {}\n", .{load_path}); std.debug.warn("\tload path: {s}\n", .{load_path});
// we could use ImageMagick to convert from X to BMP // we could use ImageMagick to convert from X to BMP
// but i can't find an easy way to do things in memory. // but i can't find an easy way to do things in memory.
@ -101,7 +100,7 @@ pub const Runner = struct {
// krita/gimp and make it export a bmp and while in the program you can // krita/gimp and make it export a bmp and while in the program you can
// apply filters, etc. // apply filters, etc.
if (!std.mem.endsWith(u8, load_path, ".bmp") and !std.mem.endsWith(u8, load_path, ".ppm")) { if (!std.mem.endsWith(u8, load_path, ".bmp") and !std.mem.endsWith(u8, load_path, ".ppm")) {
std.debug.warn("Only BMP files are allowed to be loaded. Got path '{}'\n", .{load_path}); std.debug.warn("Only BMP files are allowed to be loaded. Got path '{s}'\n", .{load_path});
return RunError.NoBMP; return RunError.NoBMP;
} }
@ -138,7 +137,7 @@ pub const Runner = struct {
// starts_with would be "x_g", we want to find all files in the directory // starts_with would be "x_g", we want to find all files in the directory
// that start with that name. // that start with that name.
const starts_with = try std.fmt.allocPrint(self.allocator, "{}_g", .{ const starts_with = try std.fmt.allocPrint(self.allocator, "{s}_g", .{
basename[0..period_idx], basename[0..period_idx],
}); });
defer self.allocator.free(starts_with); defer self.allocator.free(starts_with);
@ -172,7 +171,7 @@ pub const Runner = struct {
} }
} }
const out_path = try std.fmt.allocPrint(self.allocator, "{}/{}{}{}", .{ const out_path = try std.fmt.allocPrint(self.allocator, "{s}/{s}{d}{s}", .{
dirname, dirname,
starts_with, starts_with,
max + 1, max + 1,
@ -202,7 +201,7 @@ pub const Runner = struct {
); );
defer proc.deinit(); defer proc.deinit();
std.debug.warn("running '{} {}'\n", .{ runqs.program, out_path }); std.debug.warn("running '{s} {s}'\n", .{ runqs.program, out_path });
_ = try proc.spawnAndWait(); _ = try proc.spawnAndWait();
} }