Use comptime for fully declarative LV2 and Custom commands #14

Merged
luna merged 69 commits from declarative-commands into master 2020-06-02 21:37:47 +00:00
2 changed files with 18 additions and 1 deletions
Showing only changes of commit 47a97636cd - Show all commits

View File

@ -103,6 +103,19 @@ pub const NewCommand = struct {
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 {
if (base.tag != T.base_tag)
return null;
@ -110,6 +123,10 @@ pub const NewCommand = struct {
return @fieldParentPtr(T, "base", base);
}
pub fn print(base: *const @This()) void {
std.debug.warn("{}\n", .{base.tag});
}
pub const Noop = struct {
pub const base_tag = Tag.noop;
base: NewCommand,

View File

@ -778,7 +778,7 @@ pub const Runner = struct {
debug_flag: bool,
) !void {
for (cmds.items) |cmd| {
// if (debug_flag) const_cmd.print();
cmd.print();
try self.newRunCommand(cmd);
}
}