summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index f73c5982..d9cef8c9 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -98,11 +98,11 @@ fn isEnabled(comptime T: type) bool {
/// 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);
+ inline for (@typeInfo(@This()).@"struct".decl_names) |d| {
+ if (comptime @TypeOf(@field(@This(), d)) == type) {
+ const T = @field(@This(), d);
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";
+ if (std.mem.eql(u8, d, name)) return if (@hasDecl(T, "gui_only")) "GUI-only" else "not in this build";
}
}
}
@@ -112,12 +112,12 @@ pub fn absentWhy(name: []const u8) ?[]const u8 {
fn manualBuiltinCount() comptime_int {
comptime {
var count = 0;
- for (@typeInfo(@This()).@"struct".decls) |d| {
- if (@TypeOf(@field(@This(), d.name)) != type) continue;
- const T = @field(@This(), d.name);
+ for (@typeInfo(@This()).@"struct".decl_names) |d| {
+ if (@TypeOf(@field(@This(), d)) != type) continue;
+ const T = @field(@This(), d);
if (@typeInfo(T) != .@"struct" or !@hasDecl(T, "run") or !isEnabled(T)) continue;
if (@TypeOf(T.run) != fn (Ctx) void)
- @compileError(d.name ++ ".run must have signature fn (Ctx) void");
+ @compileError(d ++ ".run must have signature fn (Ctx) void");
count += 1;
}
return count;
@@ -129,9 +129,9 @@ fn manualBuiltinList() [manualBuiltinCount()]type {
@setEvalBranchQuota(4000);
var list: [manualBuiltinCount()]type = undefined;
var count = 0;
- for (@typeInfo(@This()).@"struct".decls) |d| {
- if (@TypeOf(@field(@This(), d.name)) != type) continue;
- const T = @field(@This(), d.name);
+ for (@typeInfo(@This()).@"struct".decl_names) |d| {
+ if (@TypeOf(@field(@This(), d)) != type) continue;
+ const T = @field(@This(), d);
if (@typeInfo(T) != .@"struct" or !@hasDecl(T, "run") or !isEnabled(T)) continue;
list[count] = T;
count += 1;
@@ -317,7 +317,7 @@ test "Exit over a ctl write or a click names every pane it asks about, a second
first.file.?.saved_hash = 0; // edited: what it had is not what it has
p.newScratchBelow(p.active);
const second = p.panes[p.active].?;
- panes.File.setContent(p, &second.file.?, try std.testing.allocator.dupe(u8, "x" ** 120));
+ panes.File.setContent(p, &second.file.?, try std.testing.allocator.dupe(u8, &@as([120]u8, @splat('x'))));
try std.testing.expect(second.file.?.revision != second.file.?.saved_revision);
// A ctl write, or a click through exec (ctl.captured).
if (clicked) p.fs.capturing = true else p.fs.no_prompt = true;
@@ -341,7 +341,7 @@ test "Exit over a ctl write or a click names every pane it asks about, a second
try std.testing.expect(noticed);
// Edited since: only that one is named again (acme's rule).
p.fs.failure_len = 0;
- panes.File.setContent(p, &second.file.?, try std.testing.allocator.dupe(u8, "y" ** 120));
+ panes.File.setContent(p, &second.file.?, try std.testing.allocator.dupe(u8, &@as([120]u8, @splat('y'))));
try std.testing.expect(p.executeBuiltinLine(p.active, "Exit"));
try std.testing.expect(!p.quit);
const again = p.fs.failure[0..p.fs.failure_len];