rename NewCommand to Command

This commit is contained in:
Luna 2020-05-31 17:18:36 -03:00
parent 8e0ebbe5e0
commit c6c31f5a60
2 changed files with 14 additions and 15 deletions

View File

@ -15,7 +15,7 @@ pub const CommandType = enum {
}; };
fn LV2Command( fn LV2Command(
comptime tag: NewCommand.Tag, comptime tag: Command.Tag,
comptime plugin_url: []const u8, comptime plugin_url: []const u8,
comptime LV2Parameters: type, comptime LV2Parameters: type,
) type { ) type {
@ -24,14 +24,14 @@ fn LV2Command(
pub const command_type = CommandType.lv2_command; pub const command_type = CommandType.lv2_command;
pub const lv2_url = plugin_url; pub const lv2_url = plugin_url;
base: NewCommand, base: Command,
split: usize, split: usize,
index: usize, index: usize,
parameters: LV2Parameters, parameters: LV2Parameters,
}; };
} }
pub const NewCommand = struct { pub const Command = struct {
tag: Tag, tag: Tag,
pub const Tag = enum { pub const Tag = enum {
@ -130,24 +130,24 @@ pub const NewCommand = struct {
pub const Noop = struct { pub const Noop = struct {
pub const base_tag = Tag.noop; pub const base_tag = Tag.noop;
base: NewCommand, base: Command,
}; };
pub const Load = struct { pub const Load = struct {
pub const base_tag = Tag.load; pub const base_tag = Tag.load;
base: NewCommand, base: Command,
path: []const u8, path: []const u8,
}; };
pub const Quicksave = struct { pub const Quicksave = struct {
pub const base_tag = Tag.quicksave; pub const base_tag = Tag.quicksave;
base: NewCommand, base: Command,
}; };
pub const RunQS = struct { pub const RunQS = struct {
pub const base_tag = Tag.runqs; pub const base_tag = Tag.runqs;
program: []const u8, program: []const u8,
base: NewCommand, base: Command,
}; };
pub const Amp = LV2Command( pub const Amp = LV2Command(
@ -183,7 +183,7 @@ pub const NewCommand = struct {
); );
}; };
pub const CommandList = std.ArrayList(*NewCommand); pub const CommandList = std.ArrayList(*Command);
pub const ArgList = std.ArrayList([]const u8); pub const ArgList = std.ArrayList([]const u8);
pub const KeywordMap = std.StringHashMap(CommandType); pub const KeywordMap = std.StringHashMap(CommandType);
@ -306,7 +306,7 @@ pub const Lang = struct {
var found: bool = false; var found: bool = false;
inline for (@typeInfo(NewCommand).Struct.decls) |cmd_struct_decl| { inline for (@typeInfo(Command).Struct.decls) |cmd_struct_decl| {
switch (cmd_struct_decl.data) { switch (cmd_struct_decl.data) {
.Type => |typ| switch (@typeInfo(typ)) { .Type => |typ| switch (@typeInfo(typ)) {
.Struct => {}, .Struct => {},

View File

@ -398,10 +398,10 @@ pub const Runner = struct {
fn newRunCommandSingle( fn newRunCommandSingle(
self: *@This(), self: *@This(),
cmd: lang.NewCommand, cmd: lang.Command,
comptime tag: lang.NewCommand.Tag, comptime tag: lang.Command.Tag,
) !void { ) !void {
comptime const typ = lang.NewCommand.tagToType(tag); comptime const typ = lang.Command.tagToType(tag);
const command = cmd.cast(typ).?; const command = cmd.cast(typ).?;
inline for (@typeInfo(typ).Struct.decls) |decl| { inline for (@typeInfo(typ).Struct.decls) |decl| {
comptime { comptime {
@ -418,11 +418,10 @@ pub const Runner = struct {
} }
} }
fn newRunCommand(self: *@This(), cmd: lang.NewCommand) !void { fn newRunCommand(self: *@This(), cmd: lang.Command) !void {
// .load => try self.newRunCommandSingle(cmd, .load),
switch (cmd.tag) { switch (cmd.tag) {
.load => { .load => {
const command = cmd.cast(lang.NewCommand.Load).?; const command = cmd.cast(lang.Command.Load).?;
try self.loadCmd(command.path); try self.loadCmd(command.path);
}, },
.quicksave => { .quicksave => {