Zig 0.14: builtin.Type variant renames

This commit is contained in:
LN Liberda
2025-03-10 02:02:35 +01:00
parent ecf75c146a
commit 0b201fc868
6 changed files with 44 additions and 44 deletions

View File

@ -88,7 +88,7 @@ fn writeBashCompletions(writer: anytype) !void {
\\
);
for (@typeInfo(Config).Struct.fields) |field| {
for (@typeInfo(Config).@"struct".fields) |field| {
if (field.name[0] == '_') continue;
switch (field.type) {
bool, ?bool => try writer.writeAll(pad2 ++ "config+=\" '--" ++ field.name ++ " '\"\n"),
@ -102,7 +102,7 @@ fn writeBashCompletions(writer: anytype) !void {
\\
);
for (@typeInfo(Config).Struct.fields) |field| {
for (@typeInfo(Config).@"struct".fields) |field| {
if (field.name[0] == '_') continue;
try writer.writeAll(pad3 ++ "--" ++ field.name ++ ") ");
@ -118,8 +118,8 @@ fn writeBashCompletions(writer: anytype) !void {
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
const compgenSuffix = "\" -- \"$cur\" ); _add_spaces ;;";
switch (@typeInfo(field.type)) {
.Bool => try writer.writeAll("return ;;"),
.Enum => |info| {
.bool => try writer.writeAll("return ;;"),
.@"enum" => |info| {
try writer.writeAll(compgenPrefix);
for (info.fields, 0..) |f, i| {
if (i > 0) try writer.writeAll(" ");
@ -127,7 +127,7 @@ fn writeBashCompletions(writer: anytype) !void {
}
try writer.writeAll(compgenSuffix);
},
.Struct => |info| {
.@"struct" => |info| {
if (!@hasDecl(field.type, "parseCLI") and info.layout == .@"packed") {
try writer.writeAll(compgenPrefix);
for (info.fields, 0..) |f, i| {
@ -157,13 +157,13 @@ fn writeBashCompletions(writer: anytype) !void {
\\
);
for (@typeInfo(Action).Enum.fields) |field| {
for (@typeInfo(Action).@"enum".fields) |field| {
if (std.mem.eql(u8, "help", field.name)) continue;
if (std.mem.eql(u8, "version", field.name)) continue;
const options = @field(Action, field.name).options();
// assumes options will never be created with only <_name> members
if (@typeInfo(options).Struct.fields.len == 0) continue;
if (@typeInfo(options).@"struct".fields.len == 0) continue;
var buffer: [field.name.len]u8 = undefined;
const bashName: []u8 = buffer[0..field.name.len];
@ -174,7 +174,7 @@ fn writeBashCompletions(writer: anytype) !void {
{
var count = 0;
for (@typeInfo(options).Struct.fields) |opt| {
for (@typeInfo(options).@"struct".fields) |opt| {
if (opt.name[0] == '_') continue;
if (count > 0) try writer.writeAll(" ");
switch (opt.type) {
@ -193,12 +193,12 @@ fn writeBashCompletions(writer: anytype) !void {
\\
);
for (@typeInfo(Action).Enum.fields) |field| {
for (@typeInfo(Action).@"enum".fields) |field| {
if (std.mem.eql(u8, "help", field.name)) continue;
if (std.mem.eql(u8, "version", field.name)) continue;
const options = @field(Action, field.name).options();
if (@typeInfo(options).Struct.fields.len == 0) continue;
if (@typeInfo(options).@"struct".fields.len == 0) continue;
// bash doesn't allow variable names containing '-' so replace them
var buffer: [field.name.len]u8 = undefined;
@ -207,7 +207,7 @@ fn writeBashCompletions(writer: anytype) !void {
try writer.writeAll(pad3 ++ "+" ++ field.name ++ ")\n");
try writer.writeAll(pad4 ++ "case $prev in\n");
for (@typeInfo(options).Struct.fields) |opt| {
for (@typeInfo(options).@"struct".fields) |opt| {
if (opt.name[0] == '_') continue;
try writer.writeAll(pad5 ++ "--" ++ opt.name ++ ") ");
@ -215,8 +215,8 @@ fn writeBashCompletions(writer: anytype) !void {
const compgenPrefix = "mapfile -t COMPREPLY < <( compgen -W \"";
const compgenSuffix = "\" -- \"$cur\" ); _add_spaces ;;";
switch (@typeInfo(opt.type)) {
.Bool => try writer.writeAll("return ;;"),
.Enum => |info| {
.bool => try writer.writeAll("return ;;"),
.@"enum" => |info| {
try writer.writeAll(compgenPrefix);
for (info.fields, 0..) |f, i| {
if (i > 0) try writer.writeAll(" ");
@ -224,9 +224,9 @@ fn writeBashCompletions(writer: anytype) !void {
}
try writer.writeAll(compgenSuffix);
},
.Optional => |optional| {
.optional => |optional| {
switch (@typeInfo(optional.child)) {
.Enum => |info| {
.@"enum" => |info| {
try writer.writeAll(compgenPrefix);
for (info.fields, 0..) |f, i| {
if (i > 0) try writer.writeAll(" ");
@ -271,7 +271,7 @@ fn writeBashCompletions(writer: anytype) !void {
\\
);
for (@typeInfo(Action).Enum.fields) |field| {
for (@typeInfo(Action).@"enum".fields) |field| {
if (std.mem.eql(u8, "help", field.name)) continue;
if (std.mem.eql(u8, "version", field.name)) continue;

View File

@ -25,7 +25,7 @@ fn writeFishCompletions(writer: anytype) !void {
{
try writer.writeAll("set -l commands \"");
var count: usize = 0;
for (@typeInfo(Action).Enum.fields) |field| {
for (@typeInfo(Action).@"enum".fields) |field| {
if (std.mem.eql(u8, "help", field.name)) continue;
if (std.mem.eql(u8, "version", field.name)) continue;
if (count > 0) try writer.writeAll(" ");
@ -41,7 +41,7 @@ fn writeFishCompletions(writer: anytype) !void {
try writer.writeAll("complete -c ghostty -s e -l help -f\n");
try writer.writeAll("complete -c ghostty -n \"not __fish_seen_subcommand_from $commands\" -l version -f\n");
for (@typeInfo(Config).Struct.fields) |field| {
for (@typeInfo(Config).@"struct".fields) |field| {
if (field.name[0] == '_') continue;
try writer.writeAll("complete -c ghostty -n \"not __fish_seen_subcommand_from $commands\" -l ");
@ -56,8 +56,8 @@ fn writeFishCompletions(writer: anytype) !void {
else {
try writer.writeAll(if (field.type != Config.RepeatablePath) " -f" else " -F");
switch (@typeInfo(field.type)) {
.Bool => {},
.Enum => |info| {
.bool => {},
.@"enum" => |info| {
try writer.writeAll(" -a \"");
for (info.fields, 0..) |f, i| {
if (i > 0) try writer.writeAll(" ");
@ -65,7 +65,7 @@ fn writeFishCompletions(writer: anytype) !void {
}
try writer.writeAll("\"");
},
.Struct => |info| {
.@"struct" => |info| {
if (!@hasDecl(field.type, "parseCLI") and info.layout == .@"packed") {
try writer.writeAll(" -a \"");
for (info.fields, 0..) |f, i| {
@ -86,7 +86,7 @@ fn writeFishCompletions(writer: anytype) !void {
{
try writer.writeAll("complete -c ghostty -n \"string match -q -- '+*' (commandline -pt)\" -f -a \"");
var count: usize = 0;
for (@typeInfo(Action).Enum.fields) |field| {
for (@typeInfo(Action).@"enum".fields) |field| {
if (std.mem.eql(u8, "help", field.name)) continue;
if (std.mem.eql(u8, "version", field.name)) continue;
if (count > 0) try writer.writeAll(" ");
@ -97,12 +97,12 @@ fn writeFishCompletions(writer: anytype) !void {
try writer.writeAll("\"\n");
}
for (@typeInfo(Action).Enum.fields) |field| {
for (@typeInfo(Action).@"enum".fields) |field| {
if (std.mem.eql(u8, "help", field.name)) continue;
if (std.mem.eql(u8, "version", field.name)) continue;
const options = @field(Action, field.name).options();
for (@typeInfo(options).Struct.fields) |opt| {
for (@typeInfo(options).@"struct".fields) |opt| {
if (opt.name[0] == '_') continue;
try writer.writeAll("complete -c ghostty -n \"__fish_seen_subcommand_from +" ++ field.name ++ "\" -l ");
try writer.writeAll(opt.name);
@ -114,8 +114,8 @@ fn writeFishCompletions(writer: anytype) !void {
} else try writer.writeAll(" -f");
switch (@typeInfo(opt.type)) {
.Bool => {},
.Enum => |info| {
.bool => {},
.@"enum" => |info| {
try writer.writeAll(" -a \"");
for (info.fields, 0..) |f, i| {
if (i > 0) try writer.writeAll(" ");
@ -123,9 +123,9 @@ fn writeFishCompletions(writer: anytype) !void {
}
try writer.writeAll("\"");
},
.Optional => |optional| {
.optional => |optional| {
switch (@typeInfo(optional.child)) {
.Enum => |info| {
.@"enum" => |info| {
try writer.writeAll(" -a \"");
for (info.fields, 0..) |f, i| {
if (i > 0) try writer.writeAll(" ");

View File

@ -45,7 +45,7 @@ fn writeZshCompletions(writer: anytype) !void {
try writer.writeAll(" _arguments \\\n");
try writer.writeAll(" \"--help\" \\\n");
try writer.writeAll(" \"--version\" \\\n");
for (@typeInfo(Config).Struct.fields) |field| {
for (@typeInfo(Config).@"struct".fields) |field| {
if (field.name[0] == '_') continue;
try writer.writeAll(" \"--");
try writer.writeAll(field.name);
@ -64,8 +64,8 @@ fn writeZshCompletions(writer: anytype) !void {
try writer.writeAll("_files"); // todo check if this is needed
} else {
switch (@typeInfo(field.type)) {
.Bool => {},
.Enum => |info| {
.bool => {},
.@"enum" => |info| {
try writer.writeAll(equals_required);
try writer.writeAll("(");
for (info.fields, 0..) |f, i| {
@ -74,7 +74,7 @@ fn writeZshCompletions(writer: anytype) !void {
}
try writer.writeAll(")");
},
.Struct => |info| {
.@"struct" => |info| {
try writer.writeAll(equals_required);
if (!@hasDecl(field.type, "parseCLI") and info.layout == .@"packed") {
try writer.writeAll("(");
@ -138,7 +138,7 @@ fn writeZshCompletions(writer: anytype) !void {
// how to get 'commands'
var count: usize = 0;
const padding = " ";
for (@typeInfo(Action).Enum.fields) |field| {
for (@typeInfo(Action).@"enum".fields) |field| {
if (std.mem.eql(u8, "help", field.name)) continue;
if (std.mem.eql(u8, "version", field.name)) continue;
@ -167,25 +167,25 @@ fn writeZshCompletions(writer: anytype) !void {
);
{
const padding = " ";
for (@typeInfo(Action).Enum.fields) |field| {
for (@typeInfo(Action).@"enum".fields) |field| {
if (std.mem.eql(u8, "help", field.name)) continue;
if (std.mem.eql(u8, "version", field.name)) continue;
const options = @field(Action, field.name).options();
// assumes options will never be created with only <_name> members
if (@typeInfo(options).Struct.fields.len == 0) continue;
if (@typeInfo(options).@"struct".fields.len == 0) continue;
try writer.writeAll(padding ++ "(+" ++ field.name ++ ")\n");
try writer.writeAll(padding ++ " _arguments \\\n");
for (@typeInfo(options).Struct.fields) |opt| {
for (@typeInfo(options).@"struct".fields) |opt| {
if (opt.name[0] == '_') continue;
try writer.writeAll(padding ++ " '--");
try writer.writeAll(opt.name);
switch (@typeInfo(opt.type)) {
.Bool => {},
.Enum => |info| {
.bool => {},
.@"enum" => |info| {
try writer.writeAll(equals_required);
try writer.writeAll("(");
for (info.fields, 0..) |f, i| {
@ -194,10 +194,10 @@ fn writeZshCompletions(writer: anytype) !void {
}
try writer.writeAll(")");
},
.Optional => |optional| {
.optional => |optional| {
try writer.writeAll(equals_required);
switch (@typeInfo(optional.child)) {
.Enum => |info| {
.@"enum" => |info| {
try writer.writeAll("(");
for (info.fields, 0..) |f, i| {
if (i > 0) try writer.writeAll(" ");

View File

@ -39,14 +39,14 @@ pub const State = struct {
/// An enum of the available conditional configuration keys.
pub const Key = key: {
const stateInfo = @typeInfo(State).Struct;
const stateInfo = @typeInfo(State).@"struct";
var fields: [stateInfo.fields.len]std.builtin.Type.EnumField = undefined;
for (stateInfo.fields, 0..) |field, i| fields[i] = .{
.name = field.name,
.value = i,
};
break :key @Type(.{ .Enum = .{
break :key @Type(.{ .@"enum" = .{
.tag_type = std.math.IntFittingRange(0, fields.len - 1),
.fields = &fields,
.decls = &.{},

View File

@ -36,7 +36,7 @@ fn isInternal(name: []const u8) bool {
fn generateKeywords() []const u8 {
@setEvalBranchQuota(5000);
var keywords: []const u8 = "";
const config_fields = @typeInfo(Config).Struct.fields;
const config_fields = @typeInfo(Config).@"struct".fields;
for (config_fields) |field| {
if (isInternal(field.name)) continue;

View File

@ -91,7 +91,7 @@ fn writeSyntax(writer: anytype) !void {
\\syn keyword ghosttyConfigKeyword
);
const config_fields = @typeInfo(Config).Struct.fields;
const config_fields = @typeInfo(Config).@"struct".fields;
inline for (config_fields) |field| {
if (field.name[0] == '_') continue;
try writer.print("\n\t\\ {s}", .{field.name});