add runner support on command cast

This commit is contained in:
Luna 2020-05-30 22:56:45 -03:00
parent 6497fc1dd8
commit 7d519b73b6
2 changed files with 18 additions and 2 deletions

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);