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. Private Function

addValueInner

Private Function
std.Build.Step.ConfigHeader.addValueInner
fn addValueInner(config_header: *ConfigHeader, name: []const u8, comptime T: type, value: T) !void

Params

  • config_header: *ConfigHeader
  • name: []const u8
  • T: type
  • value: T

File

Build/Step/ConfigHeader.zig:122
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
fn addValueInner(config_header: *ConfigHeader, name: []const u8, comptime T: type, value: T) !void {
    const arena = config_header.step.owner.allocator;
    switch (@typeInfo(T)) {
        .null => {
            try config_header.values.put(arena, name, .undef);
        },
        .void => {
            try config_header.values.put(arena, name, .defined);
        },
        .bool => {
            try config_header.values.put(arena, name, .{ .boolean = value });
        },
        .int => {
            try config_header.values.put(arena, name, .{ .int = value });
        },
        .comptime_int => {
            try config_header.values.put(arena, name, .{ .int = value });
        },
        .@"enum", .enum_literal => {
            try config_header.values.put(arena, name, .{ .ident = @tagName(value) });
        },
        .optional => {
            if (value) |x| {
                return addValueInner(config_header, name, @TypeOf(x), x);
            } else {
                try config_header.values.put(arena, name, .undef);
            }
        },
        .pointer => |ptr| {
            switch (@typeInfo(ptr.child)) {
                .array => |array| {
                    if (ptr.size == .one and array.child == u8) {
                        try config_header.values.put(arena, name, .{ .string = value });
                        return;
                    }
                },
                .int => {
                    if (ptr.size == .slice and ptr.child == u8) {
                        try config_header.values.put(arena, name, .{ .string = value });
                        return;
                    }
                },
                else => {},
            }

            @compileError("unsupported ConfigHeader value type: " ++ @typeName(T));
        },
        else => @compileError("unsupported ConfigHeader value type: " ++ @typeName(T)),
    }
}