Use comptime for fully declarative LV2 and Custom commands #14
2 changed files with 18 additions and 1 deletions
17
src/lang.zig
17
src/lang.zig
|
@ -103,6 +103,19 @@ pub const NewCommand = struct {
|
||||||
rotate,
|
rotate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub fn tagToType(tag: Tag) type {
|
||||||
|
return switch (tag) {
|
||||||
|
.noop => Noop,
|
||||||
|
.load => Load,
|
||||||
|
.quicksave => Quicksave,
|
||||||
|
.runqs => RunQS,
|
||||||
|
|
||||||
|
.amp => Amp,
|
||||||
|
.rflanger => RFlanger,
|
||||||
|
else => @panic("TODO"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn cast(base: *@This(), comptime T: type) ?*T {
|
pub fn cast(base: *@This(), comptime T: type) ?*T {
|
||||||
if (base.tag != T.base_tag)
|
if (base.tag != T.base_tag)
|
||||||
return null;
|
return null;
|
||||||
|
@ -110,6 +123,10 @@ pub const NewCommand = struct {
|
||||||
return @fieldParentPtr(T, "base", base);
|
return @fieldParentPtr(T, "base", base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn print(base: *const @This()) void {
|
||||||
|
std.debug.warn("{}\n", .{base.tag});
|
||||||
|
}
|
||||||
|
|
||||||
pub const Noop = struct {
|
pub const Noop = struct {
|
||||||
pub const base_tag = Tag.noop;
|
pub const base_tag = Tag.noop;
|
||||||
base: NewCommand,
|
base: NewCommand,
|
||||||
|
|
|
@ -778,7 +778,7 @@ pub const Runner = struct {
|
||||||
debug_flag: bool,
|
debug_flag: bool,
|
||||||
) !void {
|
) !void {
|
||||||
for (cmds.items) |cmd| {
|
for (cmds.items) |cmd| {
|
||||||
// if (debug_flag) const_cmd.print();
|
cmd.print();
|
||||||
try self.newRunCommand(cmd);
|
try self.newRunCommand(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue