This data structure is used by the Zig language code generation and therefore must be kept in sync with the compiler implementation.
name: [:0]const u8type: typedefault_value_ptr: ?*const anyopaqueThe type of the default value is the type of this struct field, which
is the value of the type field in this struct. However there is no
way to refer to that type here, so we use *const anyopaque.
See also: defaultValue.
is_comptime: boolalignment: comptime_intpub inline fn defaultValue(comptime sf: StructField) ?sf.typeLoads the field's default value from default_value_ptr.
Returns null if the field has no default value.
sf: StructFieldpub inline fn defaultValue(comptime sf: StructField) ?sf.type {
const dp: *const sf.type = @ptrCast(@alignCast(sf.default_value_ptr orelse return null));
return dp.*;
}pub const StructField = struct {
name: [:0]const u8,
type: type,
/// The type of the default value is the type of this struct field, which
/// is the value of the `type` field in this struct. However there is no
/// way to refer to that type here, so we use `*const anyopaque`.
/// See also: `defaultValue`.
default_value_ptr: ?*const anyopaque,
is_comptime: bool,
alignment: comptime_int,
/// Loads the field's default value from `default_value_ptr`.
/// Returns `null` if the field has no default value.
pub inline fn defaultValue(comptime sf: StructField) ?sf.type {
const dp: *const sf.type = @ptrCast(@alignCast(sf.default_value_ptr orelse return null));
return dp.*;
}
}