Basic module

get_field

procedureSource

Finds the member called name in a struct, looking through using members too. Returns the member and its byte offset from the start of the struct, or null and 0 when there is none.

get_field :: (
    info: *Type_Info_Struct,
    name: string
) -> (*Type_Info_Struct_Member, offset_in_bytes: s64)

Parameters

info: *Type_Info_Struct
name: string

Returns

*Type_Info_Struct_Member
offset_in_bytes: s64
Example↗
Point :: struct { x: int; y: int; }
info := cast(*Type_Info_Struct) type_info(Point);
member, offset := get_field(info, "y");
assert(member != null && offset == 8);

See also