From 427620742afd4e6d8646148db249960e3332c061 Mon Sep 17 00:00:00 2001 From: Steven Kabbes Date: Sun, 18 Dec 2022 12:45:36 -0700 Subject: [PATCH] track builtin API changes from zig/master see: https://github.com/ziglang/zig/pull/13930 In this PR, std.builtin.Type.field_type is renamed to type And there is discussion that all Enum layouts are .Auto --- src/Server.zig | 10 +++++----- src/configuration.zig | 6 +++--- src/requests.zig | 9 +++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Server.zig b/src/Server.zig index c2b4a7d..874d23a 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -2752,18 +2752,18 @@ pub fn processJsonRpc(server: *Server, writer: anytype, json: []const u8) !void inline for (std.meta.fields(Config)) |field, index| { const value = result.items[index]; - const ft = if (@typeInfo(field.field_type) == .Optional) - @typeInfo(field.field_type).Optional.child + const ft = if (@typeInfo(field.type) == .Optional) + @typeInfo(field.type).Optional.child else - field.field_type; + field.type; const ti = @typeInfo(ft); if (value != .Null) { - const new_value: field.field_type = switch (ft) { + const new_value: field.type = switch (ft) { []const u8 => switch (value) { .String => |s| blk: { if (s.len == 0) { - if (field.field_type == ?[]const u8) { + if (field.type == ?[]const u8) { break :blk null; } else { break :blk s; diff --git a/src/configuration.zig b/src/configuration.zig index 9204e2b..8006941 100644 --- a/src/configuration.zig +++ b/src/configuration.zig @@ -198,9 +198,9 @@ fn getConfigurationType() type { var fields: [config_info.Struct.fields.len]std.builtin.Type.StructField = undefined; for (config_info.Struct.fields) |field, i| { fields[i] = field; - if (@typeInfo(field.field_type) != .Optional) { - fields[i].field_type = @Type(std.builtin.Type{ - .Optional = .{ .child = field.field_type }, + if (@typeInfo(field.type) != .Optional) { + fields[i].type = @Type(std.builtin.Type{ + .Optional = .{ .child = field.type }, }); } } diff --git a/src/requests.zig b/src/requests.zig index b728161..f0cdb2b 100644 --- a/src/requests.zig +++ b/src/requests.zig @@ -45,10 +45,10 @@ fn fromDynamicTreeInternal(arena: *std.heap.ArenaAllocator, value: std.json.Valu var err = false; inline for (std.meta.fields(T)) |field| { - const is_exists = field.field_type == Exists; + const is_exists = field.type == Exists; - const is_optional = comptime std.meta.trait.is(.Optional)(field.field_type); - const actual_type = if (is_optional) std.meta.Child(field.field_type) else field.field_type; + const is_optional = comptime std.meta.trait.is(.Optional)(field.type); + const actual_type = if (is_optional) std.meta.Child(field.type) else field.type; const is_struct = comptime std.meta.trait.is(.Struct)(actual_type); const is_default = comptime if (is_struct) std.meta.trait.hasDecls(actual_type, .{ "default", "value_type" }) else false; @@ -107,9 +107,6 @@ fn fromDynamicTreeInternal(arena: *std.heap.ArenaAllocator, value: std.json.Valu out.* = value; } else if (comptime std.meta.trait.is(.Enum)(T)) { const info = @typeInfo(T).Enum; - if (info.layout != .Auto) - @compileError("Only auto layout enums are allowed"); - const TagType = info.tag_type; if (value != .Integer) return error.MalformedJson; out.* = std.meta.intToEnum(