mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 13:00:28 +00:00
Add reflect.bit_fields_zipped
This commit is contained in:
@@ -1699,3 +1699,26 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_
|
||||
runtime.print_string("\n")
|
||||
return true
|
||||
}
|
||||
|
||||
Bit_Field :: struct {
|
||||
name: string,
|
||||
type: ^Type_Info,
|
||||
size: uintptr,
|
||||
offset: uintptr,
|
||||
tag: Struct_Tag,
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
bit_fields_zipped :: proc(T: typeid) -> (fields: #soa[]Bit_Field) {
|
||||
ti := runtime.type_info_base(type_info_of(T))
|
||||
if s, ok := ti.variant.(runtime.Type_Info_Bit_Field); ok {
|
||||
return soa_zip(
|
||||
name = s.names[:s.field_count],
|
||||
type = s.types[:s.field_count],
|
||||
size = s.bit_sizes[:s.field_count],
|
||||
offset = s.bit_offsets[:s.field_count],
|
||||
tag = ([^]Struct_Tag)(s.tags)[:s.field_count],
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user