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 2 deletions
Showing only changes of commit 7d519b73b6 - Show all commits

View file

@ -116,7 +116,7 @@ pub const NewCommand = struct {
};
}
pub fn cast(base: *@This(), comptime T: type) ?*T {
pub fn cast(base: *const @This(), comptime T: type) ?*const T {
if (base.tag != T.base_tag)
return null;

View file

@ -374,7 +374,23 @@ pub const Runner = struct {
try image.runPlugin("http://calf.sourceforge.net/plugins/VintageDelay", pos, params);
}
fn newRunCommand(self: *@This(), cmd: lang.NewCommand) !void {}
fn newRunCommandSingle(
self: *@This(),
cmd: lang.NewCommand,
comptime tag: lang.NewCommand.Tag,
) !void {
comptime const typ = lang.NewCommand.tagToType(tag);
const command = cmd.cast(typ).?;
std.debug.warn("{}\n", .{command});
}
fn newRunCommand(self: *@This(), cmd: lang.NewCommand) !void {
switch (cmd.tag) {
.load => try self.newRunCommandSingle(cmd, .load),
else => @panic("TODO"),
}
}
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
var params = ParamList.init(self.allocator);