Use comptime for fully declarative LV2 and Custom commands #14
1 changed files with 7 additions and 2 deletions
|
@ -1,10 +1,15 @@
|
||||||
|
const std = @import("std");
|
||||||
const langs = @import("lang.zig");
|
const langs = @import("lang.zig");
|
||||||
|
|
||||||
fn printCommandWithParams(stream: var, command: var) !void {
|
fn printCommandWithParams(stream: var, command: var) !void {
|
||||||
const Parameters = @TypeOf(command.parameters);
|
const Parameters = @TypeOf(command.parameters);
|
||||||
inline for (@typeInfo(Parameters).Struct.fields) |field| {
|
inline for (@typeInfo(Parameters).Struct.fields) |field| {
|
||||||
|
if (field.field_type == f32 or field.field_type == f64) {
|
||||||
|
try stream.print(" {d}", .{@field(command.parameters, field.name)});
|
||||||
|
} else {
|
||||||
try stream.print(" {}", .{@field(command.parameters, field.name)});
|
try stream.print(" {}", .{@field(command.parameters, field.name)});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn printCommand(stream: var, cmd: *langs.Command, comptime tag: langs.Command.Tag) !void {
|
fn printCommand(stream: var, cmd: *langs.Command, comptime tag: langs.Command.Tag) !void {
|
||||||
|
@ -42,7 +47,7 @@ pub fn printList(list: langs.CommandList, stream: var) !void {
|
||||||
.noop, .quicksave => {},
|
.noop, .quicksave => {},
|
||||||
.rotate => {
|
.rotate => {
|
||||||
const rotate = cmd.cast(langs.Command.Rotate).?;
|
const rotate = cmd.cast(langs.Command.Rotate).?;
|
||||||
try stream.print(" {} {}", .{ rotate.deg, rotate.bgfill });
|
try stream.print(" {d} {}", .{ rotate.deg, rotate.bgfill });
|
||||||
},
|
},
|
||||||
|
|
||||||
.amp => try printCommand(stream, cmd, .amp),
|
.amp => try printCommand(stream, cmd, .amp),
|
||||||
|
|
Loading…
Reference in a new issue