diff options
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index 9025da6d..b0499dc0 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -56,6 +56,22 @@ fn isEnabled(comptime T: type) bool { return !@hasDecl(T, "enabled") or T.enabled; } +/// Why `word`, a builtin some build has, is none in this one: `GUI-only` +/// for the GUI's own (`gui_only`), else `not in this build`; null for a +/// word that is one here, or in no build. +pub fn absentWhy(name: []const u8) ?[]const u8 { + @setEvalBranchQuota(20000); + inline for (@typeInfo(@This()).@"struct".decls) |d| { + if (comptime @TypeOf(@field(@This(), d.name)) == type) { + const T = @field(@This(), d.name); + if (comptime @typeInfo(T) == .@"struct" and @hasDecl(T, "run") and !isEnabled(T)) { + if (std.mem.eql(u8, d.name, name)) return if (@hasDecl(T, "gui_only")) "GUI-only" else "not in this build"; + } + } + } + return null; +} + fn manualBuiltinCount() comptime_int { comptime { var count = 0; @@ -814,6 +830,7 @@ pub const Fonts = struct { pub const scope: Scope = .session; pub const output: OutputTraits = .{ .name = config.fonts_buffer, .steps = true, .commands = true }; pub const enabled = capabilities.font_picker; + pub const gui_only = true; pub fn run(c: Ctx) void { if (comptime enabled) apply(c) else unreachable; } @@ -1319,6 +1336,7 @@ pub const EffectCode = struct { pub const takes_arg = true; pub const requires_arg = true; pub const enabled = capabilities.panel_transitions or capabilities.scene_shaders; + pub const gui_only = true; pub const output: OutputTraits = .{ .name = config.effect_code_buffer }; pub fn run(c: Ctx) void { if (comptime enabled) @@ -1335,6 +1353,7 @@ pub const Pet = struct { pub const takes_arg = true; pub const requires_arg = true; pub const enabled = pardes.platform == .gui; + pub const gui_only = true; pub fn run(c: Ctx) void { const name = std.mem.trim(u8, c.arg orelse return, " \t\r\n"); c.p.settings.pet = std.meta.stringToEnum(@TypeOf(c.p.settings.pet), name) orelse return; |
