core/reflect

reflect

Types

6

Struct_Tag

Struct_Tag :: stringSource

Struct_Tag represents the type of the string of a struct field

Through convention, tags are the concatenation of optionally space-separated key:"value" pairs. Each key is a non-empty string which contains no control characters other than space, quotes, and colon.

Type_Kind

Type_Kind :: enum int { Invalid = 0, Named = 1, Integer = 2, Rune = 3, Float = 4, Complex = 5, Quaternion = 6, String = 7, Boolean = 8, Any = 9, Type_Id = 10, Pointer = 11, Multi_Pointer = 12, Procedure = 13, Array = 14, Enumerated_Array = 15, Dynamic_Array = 16, Slice = 17, Parameters = 18, Struct = 19, Union = 20, Enum = 21, Map = 22, Bit_Set = 23, Simd_Vector = 24, Matrix = 25, Soa_Pointer = 26, Bit_Field = 27, Fixed_Capacity_Dynamic_Array = 28, }Source

Constants

34

Procedures

112

bit_fields_zipped

bit_fields_zipped :: proc(T: typeid) -> (fields)Source

Returns the fields of a bit_field type T as an #soa slice. This is useful to iterate over.

Example:

for field, i in reflect.bit_fields_zipped(Foo_Bit_Field) { ... }

capacity

capacity :: proc(val: any) -> (int)Source

Returns the capacity of the type that represents the any value, or returns 0 if not possible cap(^T) -> cap(T) cap([N]T) -> N cap(#simd[N]T) -> N cap([dynamic]T) cap(map[K]V)

enum_fields_zipped

enum_fields_zipped :: proc(Enum_Type: typeid) -> (fields)Source

Returns a #soa slice of the enum field information of type Enum_Type This is useful to iterate over.

Example:

for field, i in reflect.enum_fields_zipped(Foo) { ... }

eq

eq :: proc(a: any, b: any, including_indirect_array_recursion: untyped boolean = false, recursion_level: untyped integer = 0) -> (bool)Source

equal

equal :: proc(a: any, b: any, including_indirect_array_recursion: untyped boolean = false, recursion_level: untyped integer = 0) -> (bool)Source

Checks to see if two any values are semantically equivalent

index

index :: proc(val: any, i: int, loc = #caller_location) -> (any)Source

Dynamically indexes any as an indexable-type if possible. Returns nil if not possible

is_endian_big

is_endian_big :: proc(info: ^Type_Info) -> (bool)Source

Returns true when the core-type is represented with a platform-native endian type or the same endianness as the system. This will also return false when the type is not an integer, pointer, or bit_set. If the type is the same as the platform-native endian type (e.g. u32be on a big-endian system), this will return true.

is_endian_little

is_endian_little :: proc(info: ^Type_Info) -> (bool)Source

Returns true when the core-type is represented with a platform-native endian type or the same endianness as the system. This will also return false when the type is not an integer, pointer, or bit_set. If the type is the same as the platform-native endian type (e.g. u32le on a little-endian system), this will return true.

is_endian_platform

is_endian_platform :: proc(info: ^Type_Info) -> (bool)Source

Returns true when the core-type is represented with a platform-native endian type, and returns false otherwise. This will also return false when the type is not an integer, pointer, or bit_set. If the type is the same as the platform-native endian type (e.g. u32le on a little-endian system), this will return false.

is_raw_union

is_raw_union :: proc(info: ^Type_Info) -> (bool)Source

Returns true when the type is a struct type with #raw_union applied, when #raw_union is not applied, the value will be false. All other types will be false otherwise.

length

length :: proc(val: any) -> (int)Source

Returns the length of the type that represents the any value, or returns 0 if not possible len(^T) -> len(T) len([N]T) -> N len(#simd[N]T) -> N len([]T) len([dynamic]T) len(map[K]V) len(string) or len(cstring) len(string16) or len(cstring16)

ne

ne :: proc(a: any, b: any, including_indirect_array_recursion: untyped boolean = false, recursion_level: untyped integer = 0) -> (bool)Source

not_equal

not_equal :: proc(a: any, b: any, including_indirect_array_recursion: untyped boolean = false, recursion_level: untyped integer = 0) -> (bool)Source

Checks to see if two any values are not semantically equivalent

struct_field_count

struct_field_count :: proc(T: typeid, method = Struct_Field_Count_Method.Top_Level) -> (count: int)Source

Counts the number of fields in a struct

This procedure returns the number of fields in a struct, counting in one of three ways:

  • .Top_Level: Only counts the top-level fields
  • .Using: Same count as .Top_Level, and adds the field count of any using s: Struct it encounters (in addition to itself)
  • .Recursive: The count of all top-level fields, plus the count of any child struct's fields, recursively
  • T: The struct type
  • method: The counting method
  • The count, enumerated using the method, which will be 0 if the type is not a struct

Example:

symbols_loaded, ok := dynlib.initialize_symbols(&game_api, "game.dll")
symbols_expected   := reflect.struct_field_count(Game_Api) - API_PRIVATE_COUNT

if symbols_loaded != symbols_expected {
	fmt.eprintf("Expected %v symbols, got %v", symbols_expected, symbols_loaded)
	return
}

struct_tag_get

struct_tag_get :: proc(tag: Struct_Tag, key: string) -> (value: string)Source

struct_tag_get returns the value associated with a key in the tag string. If the key is present in the tag, the value (which might be empty) is returned. Otherwise an empty string is returned. This is just a wrapper around struct_tag_lookup with the ok value being ignored.

The convention for struct tags is usually of the form:

`key:"value" another:"set" and:"whatever"`

struct_tag_lookup

struct_tag_lookup :: proc(tag: Struct_Tag, key: string) -> (value: string, ok: bool)Source

struct_tag_lookup returns the value associated with a key in the tag string. If the key is present in the tag, the value (which might be empty) is return. Otherwise an empty string is returned. The ok value returns whether the value was explicit set in the tag string.

The convention for struct tags is usually of the form:

`key:"value" another:"set" and:"whatever"`

typeid_elem

typeid_elem :: proc(id: typeid) -> (typeid)Source

typeid_elem returns a typeid of the element-type of a type if possible, otherwise it returns itself complex32 -> f16 complex64 -> f32 complex128 -> f64 quaternion64 -> f16 quaternion128 -> f32 quaternion256 -> f64 ^T -> T [^]T -> T

soa^T -> T

[N]T -> T []T -> T [dynamic]T -> T

simd[N]T -> T

Procedure Groups

2

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.