mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 21:10:30 +00:00
Add fixed capacity dynamic array to the doc-format
This commit is contained in:
@@ -12,7 +12,7 @@ String :: distinct Array(byte)
|
||||
|
||||
Version_Type_Major :: 0
|
||||
Version_Type_Minor :: 3
|
||||
Version_Type_Patch :: 1
|
||||
Version_Type_Patch :: 2
|
||||
|
||||
Version_Type :: struct {
|
||||
major, minor, patch: u8,
|
||||
@@ -168,32 +168,33 @@ Attribute :: struct {
|
||||
}
|
||||
|
||||
Type_Kind :: enum u32le {
|
||||
Invalid = 0,
|
||||
Basic = 1,
|
||||
Named = 2,
|
||||
Generic = 3,
|
||||
Pointer = 4,
|
||||
Array = 5,
|
||||
Enumerated_Array = 6,
|
||||
Slice = 7,
|
||||
Dynamic_Array = 8,
|
||||
Map = 9,
|
||||
Struct = 10,
|
||||
Union = 11,
|
||||
Enum = 12,
|
||||
Parameters = 13,
|
||||
Proc = 14,
|
||||
Bit_Set = 15,
|
||||
Simd_Vector = 16,
|
||||
SOA_Struct_Fixed = 17,
|
||||
SOA_Struct_Slice = 18,
|
||||
SOA_Struct_Dynamic = 19,
|
||||
Relative_Pointer = 20,
|
||||
Relative_Multi_Pointer = 21,
|
||||
Multi_Pointer = 22,
|
||||
Matrix = 23,
|
||||
Soa_Pointer = 24,
|
||||
Bit_Field = 25,
|
||||
Invalid = 0,
|
||||
Basic = 1,
|
||||
Named = 2,
|
||||
Generic = 3,
|
||||
Pointer = 4,
|
||||
Array = 5,
|
||||
Enumerated_Array = 6,
|
||||
Slice = 7,
|
||||
Dynamic_Array = 8,
|
||||
Map = 9,
|
||||
Struct = 10,
|
||||
Union = 11,
|
||||
Enum = 12,
|
||||
Parameters = 13,
|
||||
Proc = 14,
|
||||
Bit_Set = 15,
|
||||
Simd_Vector = 16,
|
||||
SOA_Struct_Fixed = 17,
|
||||
SOA_Struct_Slice = 18,
|
||||
SOA_Struct_Dynamic = 19,
|
||||
Relative_Pointer = 20,
|
||||
Relative_Multi_Pointer = 21,
|
||||
Multi_Pointer = 22,
|
||||
Matrix = 23,
|
||||
Soa_Pointer = 24,
|
||||
Bit_Field = 25,
|
||||
Fixed_Capacity_Dynamic_Array = 26,
|
||||
}
|
||||
|
||||
Type_Elems_Cap :: 4
|
||||
@@ -219,13 +220,14 @@ Type :: struct {
|
||||
custom_align: String,
|
||||
|
||||
// Used by:
|
||||
// .Array - 1 count: 0=len
|
||||
// .Enumerated_Array - 1 count: 0=len
|
||||
// .SOA_Struct_Fixed - 1 count: 0=len
|
||||
// .Bit_Set - 2 count: 0=lower, 1=upper
|
||||
// .Simd_Vector - 1 count: 0=len
|
||||
// .Matrix - 2 count: 0=row_count, 1=column_count
|
||||
// .Struct - <=2 count: 0=min_field_align, 1=max_field_align
|
||||
// .Array - 1 count: 0=len
|
||||
// .Enumerated_Array - 1 count: 0=len
|
||||
// .SOA_Struct_Fixed - 1 count: 0=len
|
||||
// .Bit_Set - 2 count: 0=lower, 1=upper
|
||||
// .Simd_Vector - 1 count: 0=len
|
||||
// .Matrix - 2 count: 0=row_count, 1=column_count
|
||||
// .Struct - <=2 count: 0=min_field_align, 1=max_field_align
|
||||
// .Fixed_Capacity_Dynamic_Array - 1 count: 0=cap
|
||||
elem_count_len: u32le,
|
||||
elem_counts: [Type_Elems_Cap]i64le,
|
||||
|
||||
@@ -234,27 +236,28 @@ Type :: struct {
|
||||
calling_convention: String,
|
||||
|
||||
// Used by:
|
||||
// .Named - 1 type: 0=base type
|
||||
// .Generic - <1 type: 0=specialization
|
||||
// .Pointer - 1 type: 0=element
|
||||
// .Array - 1 type: 0=element
|
||||
// .Enumerated_Array - 2 types: 0=index and 1=element
|
||||
// .Slice - 1 type: 0=element
|
||||
// .Dynamic_Array - 1 type: 0=element
|
||||
// .Map - 2 types: 0=key, 1=value
|
||||
// .SOA_Struct_Fixed - 1 type: underlying SOA struct element
|
||||
// .SOA_Struct_Slice - 1 type: underlying SOA struct element
|
||||
// .SOA_Struct_Dynamic - 1 type: underlying SOA struct element
|
||||
// .Union - 0+ types: variants
|
||||
// .Enum - <1 type: 0=base type
|
||||
// .Proc - 2 types: 0=parameters, 1=results
|
||||
// .Bit_Set - <=2 types: 0=element type, 1=underlying type (Underlying_Type flag will be set)
|
||||
// .Simd_Vector - 1 type: 0=element
|
||||
// .Relative_Pointer - 2 types: 0=pointer type, 1=base integer
|
||||
// .Multi_Pointer - 1 type: 0=element
|
||||
// .Matrix - 1 type: 0=element
|
||||
// .Soa_Pointer - 1 type: 0=element
|
||||
// .Bit_Field - 1 type: 0=backing type
|
||||
// .Named - 1 type: 0=base type
|
||||
// .Generic - <1 type: 0=specialization
|
||||
// .Pointer - 1 type: 0=element
|
||||
// .Array - 1 type: 0=element
|
||||
// .Enumerated_Array - 2 types: 0=index and 1=element
|
||||
// .Slice - 1 type: 0=element
|
||||
// .Dynamic_Array - 1 type: 0=element
|
||||
// .Map - 2 types: 0=key, 1=value
|
||||
// .SOA_Struct_Fixed - 1 type: underlying SOA struct element
|
||||
// .SOA_Struct_Slice - 1 type: underlying SOA struct element
|
||||
// .SOA_Struct_Dynamic - 1 type: underlying SOA struct element
|
||||
// .Union - 0+ types: variants
|
||||
// .Enum - <1 type: 0=base type
|
||||
// .Proc - 2 types: 0=parameters, 1=results
|
||||
// .Bit_Set - <=2 types: 0=element type, 1=underlying type (Underlying_Type flag will be set)
|
||||
// .Simd_Vector - 1 type: 0=element
|
||||
// .Relative_Pointer - 2 types: 0=pointer type, 1=base integer
|
||||
// .Multi_Pointer - 1 type: 0=element
|
||||
// .Matrix - 1 type: 0=element
|
||||
// .Soa_Pointer - 1 type: 0=element
|
||||
// .Bit_Field - 1 type: 0=backing type
|
||||
// .Fixed_Capacity_Dynamic_Array - 1 type: 0=element
|
||||
types: Array(Type_Index),
|
||||
|
||||
// Used by:
|
||||
|
||||
@@ -15,7 +15,7 @@ struct OdinDocVersionType {
|
||||
|
||||
#define OdinDocVersionType_Major 0
|
||||
#define OdinDocVersionType_Minor 3
|
||||
#define OdinDocVersionType_Patch 1
|
||||
#define OdinDocVersionType_Patch 2
|
||||
|
||||
struct OdinDocHeaderBase {
|
||||
u8 magic[8];
|
||||
@@ -59,31 +59,31 @@ struct OdinDocPosition {
|
||||
};
|
||||
|
||||
enum OdinDocTypeKind : u32 {
|
||||
OdinDocType_Invalid = 0,
|
||||
OdinDocType_Basic = 1,
|
||||
OdinDocType_Named = 2,
|
||||
OdinDocType_Generic = 3,
|
||||
OdinDocType_Pointer = 4,
|
||||
OdinDocType_Array = 5,
|
||||
OdinDocType_EnumeratedArray = 6,
|
||||
OdinDocType_Slice = 7,
|
||||
OdinDocType_DynamicArray = 8,
|
||||
OdinDocType_Map = 9,
|
||||
OdinDocType_Struct = 10,
|
||||
OdinDocType_Union = 11,
|
||||
OdinDocType_Enum = 12,
|
||||
OdinDocType_Tuple = 13,
|
||||
OdinDocType_Proc = 14,
|
||||
OdinDocType_BitSet = 15,
|
||||
OdinDocType_SimdVector = 16,
|
||||
OdinDocType_SOAStructFixed = 17,
|
||||
OdinDocType_SOAStructSlice = 18,
|
||||
OdinDocType_SOAStructDynamic = 19,
|
||||
|
||||
OdinDocType_MultiPointer = 22,
|
||||
OdinDocType_Matrix = 23,
|
||||
OdinDocType_SoaPointer = 24,
|
||||
OdinDocType_BitField = 25,
|
||||
OdinDocType_Invalid = 0,
|
||||
OdinDocType_Basic = 1,
|
||||
OdinDocType_Named = 2,
|
||||
OdinDocType_Generic = 3,
|
||||
OdinDocType_Pointer = 4,
|
||||
OdinDocType_Array = 5,
|
||||
OdinDocType_EnumeratedArray = 6,
|
||||
OdinDocType_Slice = 7,
|
||||
OdinDocType_DynamicArray = 8,
|
||||
OdinDocType_Map = 9,
|
||||
OdinDocType_Struct = 10,
|
||||
OdinDocType_Union = 11,
|
||||
OdinDocType_Enum = 12,
|
||||
OdinDocType_Tuple = 13,
|
||||
OdinDocType_Proc = 14,
|
||||
OdinDocType_BitSet = 15,
|
||||
OdinDocType_SimdVector = 16,
|
||||
OdinDocType_SOAStructFixed = 17,
|
||||
OdinDocType_SOAStructSlice = 18,
|
||||
OdinDocType_SOAStructDynamic = 19,
|
||||
OdinDocType_MultiPointer = 22,
|
||||
OdinDocType_Matrix = 23,
|
||||
OdinDocType_SoaPointer = 24,
|
||||
OdinDocType_BitField = 25,
|
||||
OdinDocType_FixedCapacityDynamicArray = 26,
|
||||
};
|
||||
|
||||
enum OdinDocTypeFlag_Basic : u32 {
|
||||
@@ -144,13 +144,14 @@ struct OdinDocType {
|
||||
OdinDocString custom_align;
|
||||
|
||||
// Used by:
|
||||
// .Array - 1 count: 0=len
|
||||
// .Enumerated_Array - 1 count: 0=len
|
||||
// .SOA_Struct_Fixed - 1 count: 0=len
|
||||
// .Bit_Set - 2 count: 0=lower, 1=upper
|
||||
// .Simd_Vector - 1 count: 0=len
|
||||
// .Matrix - 2 count: 0=row_count, 1=column_count
|
||||
// .Struct - <=2 count: 0=min_field_align, 1=max_field_align
|
||||
// .Array - 1 count: 0=len
|
||||
// .Enumerated_Array - 1 count: 0=len
|
||||
// .SOA_Struct_Fixed - 1 count: 0=len
|
||||
// .Bit_Set - 2 count: 0=lower, 1=upper
|
||||
// .Simd_Vector - 1 count: 0=len
|
||||
// .Matrix - 2 count: 0=row_count, 1=column_count
|
||||
// .Struct - <=2 count: 0=min_field_align, 1=max_field_align
|
||||
// .Fixed_Capacity_Dynamic_Array - 1 count: 0=cap
|
||||
u32 elem_count_len;
|
||||
i64 elem_counts[OdinDocType_ElemsCap];
|
||||
|
||||
@@ -159,27 +160,28 @@ struct OdinDocType {
|
||||
OdinDocString calling_convention;
|
||||
|
||||
// Used by:
|
||||
// .Named - 1 type: 0=base type
|
||||
// .Generic - <1 type: 0=specialization
|
||||
// .Pointer - 1 type: 0=element
|
||||
// .Array - 1 type: 0=element
|
||||
// .Enumerated_Array - 2 types: 0=index and 1=element
|
||||
// .Slice - 1 type: 0=element
|
||||
// .Dynamic_Array - 1 type: 0=element
|
||||
// .Map - 2 types: 0=key, 1=value
|
||||
// .SOA_Struct_Fixed - 1 type: underlying SOA struct element
|
||||
// .SOA_Struct_Slice - 1 type: underlying SOA struct element
|
||||
// .SOA_Struct_Dynamic - 1 type: underlying SOA struct element
|
||||
// .Union - 0+ types: variants
|
||||
// .Enum - <1 type: 0=base type
|
||||
// .Proc - 2 types: 0=parameters, 1=results
|
||||
// .Bit_Set - <=2 types: 0=element type, 1=underlying type (Underlying_Type flag will be set)
|
||||
// .Simd_Vector - 1 type: 0=element
|
||||
// .Relative_Pointer - 2 types: 0=pointer type, 1=base integer
|
||||
// .Multi_Pointer - 1 type: 0=element
|
||||
// .Matrix - 1 type: 0=element
|
||||
// .Soa_Pointer - 1 type: 0=element
|
||||
// .Bit_Field - 1 type: 0=backing type
|
||||
// .Named - 1 type: 0=base type
|
||||
// .Generic - <1 type: 0=specialization
|
||||
// .Pointer - 1 type: 0=element
|
||||
// .Array - 1 type: 0=element
|
||||
// .Enumerated_Array - 2 types: 0=index and 1=element
|
||||
// .Slice - 1 type: 0=element
|
||||
// .Dynamic_Array - 1 type: 0=element
|
||||
// .Map - 2 types: 0=key, 1=value
|
||||
// .SOA_Struct_Fixed - 1 type: underlying SOA struct element
|
||||
// .SOA_Struct_Slice - 1 type: underlying SOA struct element
|
||||
// .SOA_Struct_Dynamic - 1 type: underlying SOA struct element
|
||||
// .Union - 0+ types: variants
|
||||
// .Enum - <1 type: 0=base type
|
||||
// .Proc - 2 types: 0=parameters, 1=results
|
||||
// .Bit_Set - <=2 types: 0=element type, 1=underlying type (Underlying_Type flag will be set)
|
||||
// .Simd_Vector - 1 type: 0=element
|
||||
// .Relative_Pointer - 2 types: 0=pointer type, 1=base integer
|
||||
// .Multi_Pointer - 1 type: 0=element
|
||||
// .Matrix - 1 type: 0=element
|
||||
// .Soa_Pointer - 1 type: 0=element
|
||||
// .Bit_Field - 1 type: 0=backing type
|
||||
// .Fixed_Capacity_Dynamic_Array - 1 type: 0=element
|
||||
OdinDocArray<OdinDocTypeIndex> types;
|
||||
|
||||
// Used by:
|
||||
|
||||
@@ -576,6 +576,12 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type, bool ca
|
||||
doc_type.kind = OdinDocType_DynamicArray;
|
||||
doc_type.types = odin_doc_type_as_slice(w, type->DynamicArray.elem);
|
||||
break;
|
||||
case Type_FixedCapacityDynamicArray:
|
||||
doc_type.kind = OdinDocType_FixedCapacityDynamicArray;
|
||||
doc_type.elem_count_len = 1;
|
||||
doc_type.elem_counts[0] = type->FixedCapacityDynamicArray.capacity;
|
||||
doc_type.types = odin_doc_type_as_slice(w, type->FixedCapacityDynamicArray.elem);
|
||||
break;
|
||||
case Type_Map:
|
||||
doc_type.kind = OdinDocType_Map;
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user