From 4b95e8a040447a2ab939e0faf6ed094701d0a10e Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 15 Mar 2026 18:18:02 +0000 Subject: [PATCH] Add generic count of arrays to to doc-format --- core/odin/doc-format/doc_format.odin | 4 ++-- src/docs_format.cpp | 4 ++-- src/docs_writer.cpp | 26 ++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/core/odin/doc-format/doc_format.odin b/core/odin/doc-format/doc_format.odin index 3ae75a3f8..28552b346 100644 --- a/core/odin/doc-format/doc_format.odin +++ b/core/odin/doc-format/doc_format.odin @@ -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: diff --git a/src/docs_format.cpp b/src/docs_format.cpp index 4db85b481..30dcf40b9 100644 --- a/src/docs_format.cpp +++ b/src/docs_format.cpp @@ -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 types; // Used by: diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp index d021b3fc2..5e9c25016 100644 --- a/src/docs_writer.cpp +++ b/src/docs_writer.cpp @@ -472,6 +472,14 @@ gb_internal OdinDocArray odin_doc_type_as_slice(OdinDocWriter return odin_write_item_as_slice(w, index); } +gb_internal OdinDocArray 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 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;