Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Struct

Value

Public Struct
std.Build.Configuration.Step.ConfigHeader.Value
pub const Value = struct

Fields

flags: @This().Flags
i64: Storage.EnumOptional(.flags, .tag, .i64, i64)
u64: Storage.EnumOptional(.flags, .tag, .u64, u64)
ident: Storage.EnumOptional(.flags, .tag, .ident, String)
string: Storage.EnumOptional(.flags, .tag, .string, String)

Structs

Types

Functions

pub fn initSigned(x: i64) @This()

File

Build/Configuration.zig:1106
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
        pub const Value = struct {
            flags: @This().Flags,
            i64: Storage.EnumOptional(.flags, .tag, .i64, i64),
            u64: Storage.EnumOptional(.flags, .tag, .u64, u64),
            ident: Storage.EnumOptional(.flags, .tag, .ident, String),
            string: Storage.EnumOptional(.flags, .tag, .string, String),

            pub const Flags = packed struct(u32) {
                tag: Value.Tag,
                small: u29,
            };

            pub const Tag = enum(u3) {
                ident,
                string,
                small_unsigned,
                small_signed,
                i64,
                u64,
            };

            pub const Pair = extern struct {
                key: String,
                index: Value.Index,
            };

            pub const Index = enum(u32) {
                int_0 = max_u32 - 5,
                int_1 = max_u32 - 4,
                bool_false = max_u32 - 3,
                bool_true = max_u32 - 2,
                undef = max_u32 - 1,
                defined = max_u32,
                _,

                pub fn unpack(this: @This(), c: *const Configuration) Unpacked {
                    return switch (this) {
                        .int_0 => .{ .u64 = 0 },
                        .int_1 => .{ .u64 = 1 },
                        .bool_false => .{ .bool = false },
                        .bool_true => .{ .bool = true },
                        .undef => .undef,
                        .defined => .defined,
                        _ => {
                            const value = extraData(c, Value, @backingInt(this));
                            return switch (value.flags.tag) {
                                .ident => .{ .ident = value.ident.value.?.slice(c) },
                                .string => .{ .string = value.string.value.?.slice(c) },
                                .small_unsigned => .{ .u64 = value.flags.small },
                                .small_signed => .{ .i64 = @as(i29, @bitCast(value.flags.small)) },
                                .i64 => .{ .i64 = value.i64.value.? },
                                .u64 => .{ .u64 = value.u64.value.? },
                            };
                        },
                    };
                }
            };

            pub const Unpacked = union(enum) {
                bool: bool,
                undef,
                defined,
                i64: i64,
                u64: u64,
                ident: []const u8,
                string: []const u8,
            };

            pub fn initSigned(x: i64) @This() {
                return switch (x) {
                    0 => unreachable, // should have been an Index
                    1 => unreachable, // should have been an Index
                    2...std.math.maxInt(u29) => .{
                        .flags = .{
                            .tag = .small_unsigned,
                            .small = @intCast(x),
                        },
                        .i64 = .{ .value = null },
                        .u64 = .{ .value = null },
                        .ident = .{ .value = null },
                        .string = .{ .value = null },
                    },
                    std.math.minInt(i29)...-1 => .{
                        .flags = .{
                            .tag = .small_signed,
                            .small = @bitCast(@as(i29, @intCast(x))),
                        },
                        .i64 = .{ .value = null },
                        .u64 = .{ .value = null },
                        .ident = .{ .value = null },
                        .string = .{ .value = null },
                    },
                    else => .{
                        .flags = .{
                            .tag = .i64,
                            .small = 0,
                        },
                        .i64 = .{ .value = x },
                        .u64 = .{ .value = null },
                        .ident = .{ .value = null },
                        .string = .{ .value = null },
                    },
                };
            }
        }