Skip to content

Commit 73881af

Browse files
committed
implement clap features
1 parent 425b431 commit 73881af

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

examples/sine/src/Plugin.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ pub const meta: zigplug.Meta = .{
2727

2828
pub const clap_meta: @import("zigplug_clap").Meta = .{
2929
.id = "com.bandithedoge.zigplug_sine_example",
30-
// .features = &.{ .instrument, .synthesizer, .mono },
31-
.features = &.{},
30+
.features = &.{ .instrument, .synthesizer, .mono },
3231
};
3332

3433
gpa: std.heap.GeneralPurposeAllocator(.{}) = .init,

src/clap/root.zig

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,13 @@ fn makeClapDescriptor(comptime Plugin: type) std.mem.Allocator.Error!*const c.cl
302302
.support_url = meta.support_url orelse meta.url,
303303
.version = meta.version,
304304
.description = meta.description,
305-
.features = &[_][*c]const u8{null},
306-
// TODO: actually implement features
307-
// .features = blk: {
308-
// var features: [clap_meta.features.len + 1:null]?[*:0]const u8 = undefined;
309-
// inline for (clap_meta.features, 0..) |feature, i|
310-
// features[i] = feature.toString();
311-
// // features[clap_meta.features.len] = null;
312-
// break :blk &features;
313-
// },
305+
.features = blk: {
306+
const features = try std.heap.page_allocator.alloc([*c]const u8, clap_meta.features.len + 1);
307+
inline for (clap_meta.features, 0..) |feature, i|
308+
features[i] = feature.toString();
309+
features[clap_meta.features.len] = null;
310+
break :blk features.ptr;
311+
},
314312
};
315313

316314
return desc;

0 commit comments

Comments
 (0)