This data structure is used by the Zig language code generation and therefore must be kept in sync with the compiler implementation.
size: Sizeis_const: boolis_volatile: boolalignment: comptime_intTODO make this u16 instead of comptime_int
address_space: AddressSpacechild: typeis_allowzero: boolsentinel_ptr: ?*const anyopaqueThe type of the sentinel is the element type of the pointer, which is
the value of the child field in this struct. However there is no way
to refer to that type here, so we use *const anyopaque.
See also: sentinel
pub inline fn sentinel(comptime ptr: Pointer) ?ptr.childLoads the pointer type's sentinel value from sentinel_ptr.
Returns null if the pointer type has no sentinel.
ptr: Pointerpub inline fn sentinel(comptime ptr: Pointer) ?ptr.child {
const sp: *const ptr.child = @ptrCast(@alignCast(ptr.sentinel_ptr orelse return null));
return sp.*;
}pub const Pointer = struct {
size: Size,
is_const: bool,
is_volatile: bool,
/// TODO make this u16 instead of comptime_int
alignment: comptime_int,
address_space: AddressSpace,
child: type,
is_allowzero: bool,
/// The type of the sentinel is the element type of the pointer, which is
/// the value of the `child` field in this struct. However there is no way
/// to refer to that type here, so we use `*const anyopaque`.
/// See also: `sentinel`
sentinel_ptr: ?*const anyopaque,
/// Loads the pointer type's sentinel value from `sentinel_ptr`.
/// Returns `null` if the pointer type has no sentinel.
pub inline fn sentinel(comptime ptr: Pointer) ?ptr.child {
const sp: *const ptr.child = @ptrCast(@alignCast(ptr.sentinel_ptr orelse return null));
return sp.*;
}
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Size = enum(u2) {
one,
many,
slice,
c,
};
}