Add generic count of arrays to to doc-format

This commit is contained in:
gingerBill
2026-03-15 18:18:02 +00:00
parent c4ae436ba6
commit 4b95e8a040
3 changed files with 28 additions and 6 deletions

View File

@@ -239,7 +239,7 @@ Type :: struct {
// .Named - 1 type: 0=base type
// .Generic - <1 type: 0=specialization
// .Pointer - 1 type: 0=element
// .Array - 1 type: 0=element
// .Array - 1 type: 0=element (and 1=generic index (if exists))
// .Enumerated_Array - 2 types: 0=index and 1=element
// .Slice - 1 type: 0=element
// .Dynamic_Array - 1 type: 0=element
@@ -257,7 +257,7 @@ Type :: struct {
// .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
// .Fixed_Capacity_Dynamic_Array - 1 type: 0=element (and 1=generic index (if exists))
types: Array(Type_Index),
// Used by:

View File

@@ -163,7 +163,7 @@ struct OdinDocType {
// .Named - 1 type: 0=base type
// .Generic - <1 type: 0=specialization
// .Pointer - 1 type: 0=element
// .Array - 1 type: 0=element
// .Array - 1 type: 0=element (and 1=generic index (if exists))
// .Enumerated_Array - 2 types: 0=index and 1=element
// .Slice - 1 type: 0=element
// .Dynamic_Array - 1 type: 0=element
@@ -181,7 +181,7 @@ struct OdinDocType {
// .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
// .Fixed_Capacity_Dynamic_Array - 1 type: 0=element (and 1=generic index (if exists))
OdinDocArray<OdinDocTypeIndex> types;
// Used by:

View File

@@ -472,6 +472,14 @@ gb_internal OdinDocArray<OdinDocTypeIndex> odin_doc_type_as_slice(OdinDocWriter
return odin_write_item_as_slice(w, index);
}
gb_internal OdinDocArray<OdinDocTypeIndex> odin_doc_type2_as_slice(OdinDocWriter *w, Type *type0, Type *type1, bool cache=true) {
OdinDocTypeIndex indices[2] = {};
indices[0] = odin_doc_type(w, type0, cache);
indices[1] = odin_doc_type(w, type1, cache);
return odin_write_slice(w, indices, gb_count_of(indices));
}
gb_internal OdinDocArray<OdinDocEntityIndex> odin_doc_add_entity_as_slice(OdinDocWriter *w, Entity *e) {
OdinDocEntityIndex index = odin_doc_add_entity(w, e);
return odin_write_item_as_slice(w, index);
@@ -555,7 +563,13 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type, bool ca
doc_type.kind = OdinDocType_Array;
doc_type.elem_count_len = 1;
doc_type.elem_counts[0] = type->Array.count;
doc_type.types = odin_doc_type_as_slice(w, type->Array.elem);
if (type->Array.generic_count != nullptr) {
doc_type.types = odin_doc_type2_as_slice(w,
type->Array.elem,
type->Array.generic_count);
} else {
doc_type.types = odin_doc_type_as_slice(w, type->Array.elem);
}
break;
case Type_EnumeratedArray:
doc_type.kind = OdinDocType_EnumeratedArray;
@@ -580,7 +594,15 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type, bool ca
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);
if (type->FixedCapacityDynamicArray.generic_capacity != nullptr) {
doc_type.types = odin_doc_type2_as_slice(w,
type->FixedCapacityDynamicArray.elem,
type->FixedCapacityDynamicArray.generic_capacity);
} else {
doc_type.types = odin_doc_type_as_slice(w, type->FixedCapacityDynamicArray.elem);
}
break;
case Type_Map:
doc_type.kind = OdinDocType_Map;