Use comptime for fully declarative LV2 and Custom commands #14
1 changed files with 7 additions and 4 deletions
11
src/lang.zig
11
src/lang.zig
|
@ -268,7 +268,7 @@ pub const Command = struct {
|
|||
}
|
||||
};
|
||||
|
||||
pub const CommandList = std.ArrayList(NewCommand);
|
||||
pub const CommandList = std.ArrayList(*NewCommand);
|
||||
pub const ArgList = std.ArrayList([]const u8);
|
||||
|
||||
pub const KeywordMap = std.StringHashMap(CommandType);
|
||||
|
@ -413,21 +413,24 @@ pub const Lang = struct {
|
|||
usize => try std.fmt.parseInt(usize, arg, 10),
|
||||
i32 => try std.fmt.parseInt(i32, arg, 10),
|
||||
f32 => try std.fmt.parseFloat(f32, arg),
|
||||
[]const u8 => arg,
|
||||
[]const u8 => try self.allocator.dupe(u8, arg),
|
||||
else => @panic("Invalid parameter type (" ++ @typeName(cmd_field.field_type) ++ ") left on command struct " ++ @typeName(command_struct) ++ "."),
|
||||
};
|
||||
|
||||
std.debug.warn("parsing {}, arg of type {} => {}\n", .{ @typeName(command_struct), @typeName(@TypeOf(argument_value)), argument_value });
|
||||
|
||||
@field(cmd, cmd_field.name) = argument_value;
|
||||
}
|
||||
|
||||
cmd.base.tag = command_struct.base_tag;
|
||||
const command = cmd.base.cast(command_struct).?;
|
||||
std.debug.warn("cmd: {}\n", .{command});
|
||||
|
||||
try commands.append(cmd.base);
|
||||
try commands.append(&cmd.base);
|
||||
}
|
||||
|
||||
pub fn parse(self: *Lang, data: []const u8) !CommandList {
|
||||
var splitted_it = std.mem.split(data, ";");
|
||||
// try self.fillKeywords();
|
||||
var cmds = CommandList.init(self.allocator);
|
||||
|
||||
while (splitted_it.next()) |stmt_orig| {
|
||||
|
|
Loading…
Reference in a new issue