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
Showing only changes of commit 82dc99d7d5 - Show all commits

View file

@ -500,13 +500,10 @@ pub const Lang = struct {
} }
const arg = maybe_arg.?; const arg = maybe_arg.?;
if (cmd_field.field_type != f32)
@compileError("LV2 parameter struct can only have f32 fields");
const argument_value = switch (cmd_field.field_type) { @field(cmd.parameters, cmd_field.name) = try std.fmt.parseFloat(f32, arg);
f32 => try std.fmt.parseFloat(f32, arg),
else => @compileError("LV2 parameter struct can only have f32 fields"),
};
@field(cmd.parameters, cmd_field.name) = argument_value;
} }
} else { } else {
inline for (@typeInfo(command_struct).Struct.fields) |cmd_field| { inline for (@typeInfo(command_struct).Struct.fields) |cmd_field| {