From 7d519b73b69de726fb8fbc67f9e07c2c261dd1c0 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 30 May 2020 22:56:45 -0300 Subject: [PATCH] add runner support on command cast --- src/lang.zig | 2 +- src/runner.zig | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lang.zig b/src/lang.zig index 1a747b9..07d3d50 100644 --- a/src/lang.zig +++ b/src/lang.zig @@ -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; diff --git a/src/runner.zig b/src/runner.zig index eacc3c7..024fa42 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -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);