add basics of printing under new command structure
This commit is contained in:
parent
128f58c502
commit
f973d6807d
1 changed files with 64 additions and 2 deletions
|
@ -1,12 +1,74 @@
|
|||
const langs = @import("lang.zig");
|
||||
|
||||
pub fn printCommand(cmd: langs.Command, comptime tag: langs.Command.Tag) !void {
|
||||
const CommandStruct = langs.Command.tagToType(tag);
|
||||
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 = typ.command_type;
|
||||
switch (ctype) {
|
||||
.lv2_command => try printLV2Command(casted),
|
||||
.custom_command => try printCustomCommand(casted),
|
||||
else => @panic("TODO support command type"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn printList(list: langs.CommandList, stream: var) !void {
|
||||
for (list.items) |cmd| {
|
||||
const command = @tagName(cmd.tag);
|
||||
try stream.print("{}", .{command});
|
||||
|
||||
for (cmd.args.items) |arg| {
|
||||
try stream.print(" {}", .{arg});
|
||||
switch (cmd.tag) {
|
||||
.load => {
|
||||
const load = command.cast(langs.Command.Load).?;
|
||||
try stream.print("{}", .{load.path});
|
||||
},
|
||||
.quicksave => {},
|
||||
.rotate => {
|
||||
const rotate = command.cast(langs.Command.Rotate).?;
|
||||
try stream.print("{} {}", .{ rotate.deg, rotate.bgfill });
|
||||
},
|
||||
|
||||
.amp => try printCommand(cmd, .amp),
|
||||
.rflanger => try printCommand(cmd, .rflanger),
|
||||
.eq => try printCommand(cmd, .eq),
|
||||
.phaser => try printCommand(cmd, .phaser),
|
||||
.mbeq => try printCommand(cmd, .mbeq),
|
||||
.chorus => try printCommand(cmd, .chorus),
|
||||
.pitchscaler => try printCommand(cmd, .pitchscaler),
|
||||
.reverb => try printCommand(cmd, .reverb),
|
||||
.highpass => try printCommand(cmd, .highpass),
|
||||
.delay => try printCommand(cmd, .delay),
|
||||
.vinyl => try printCommand(cmd, .vinyl),
|
||||
.revdelay => try printCommand(cmd, .revdelay),
|
||||
.gate => try printCommand(cmd, .gate),
|
||||
.detune => try printCommand(cmd, .detune),
|
||||
.overdrive => try printCommand(cmd, .overdrive),
|
||||
.degrade => try printCommand(cmd, .degrade),
|
||||
.repsycho => try printCommand(cmd, .repsycho),
|
||||
.talkbox => try printCommand(cmd, .talkbox),
|
||||
.dyncomp => try printCommand(cmd, .dyncomp),
|
||||
.thruzero => try printCommand(cmd, .thruzero),
|
||||
.foverdrive => try printCommand(cmd, .foverdrive),
|
||||
.gverb => try printCommand(cmd, .gverb),
|
||||
.invert => try printCommand(cmd, .invert),
|
||||
.tapedelay => try printCommand(cmd, .tapedelay),
|
||||
.moddelay => try printCommand(cmd, .moddelay),
|
||||
.multichorus => try printCommand(cmd, .multichorus),
|
||||
.saturator => try printCommand(cmd, .saturator),
|
||||
.vintagedelay => try printCommand(cmd, .vintagedelay),
|
||||
|
||||
.noise => try printCommand(cmd, .noise),
|
||||
.wildnoise => try printCommand(cmd, .wildnoise),
|
||||
.write => try printCommand(cmd, .write),
|
||||
.embed => try printCommand(cmd, .embed),
|
||||
|
||||
else => @compileError("unhandled command"),
|
||||
}
|
||||
|
||||
_ = try stream.write(";\n");
|
||||
|
|
Loading…
Reference in a new issue