Support struct field tags in odin doc format

This commit is contained in:
gingerBill
2022-01-04 11:44:34 +00:00
parent f15bb0b424
commit 17613185e7
3 changed files with 14 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ String :: distinct Array(byte)
Version_Type_Major :: 0
Version_Type_Minor :: 2
Version_Type_Patch :: 1
Version_Type_Patch :: 2
Version_Type :: struct {
major, minor, patch: u8,
@@ -242,6 +242,8 @@ Type :: struct {
polymorphic_params: Type_Index,
// Used By: .Struct, .Union
where_clauses: Array(String),
// Used By: .Struct
tags: Array(String),
}
Type_Flags_Basic :: distinct bit_set[Type_Flag_Basic; u32le]

View File

@@ -15,7 +15,7 @@ struct OdinDocVersionType {
#define OdinDocVersionType_Major 0
#define OdinDocVersionType_Minor 2
#define OdinDocVersionType_Patch 1
#define OdinDocVersionType_Patch 2
struct OdinDocHeaderBase {
u8 magic[8];
@@ -137,6 +137,7 @@ struct OdinDocType {
OdinDocArray<OdinDocEntityIndex> entities;
OdinDocTypeIndex polmorphic_params;
OdinDocArray<OdinDocString> where_clauses;
OdinDocArray<OdinDocString> tags; // struct field tags
};
struct OdinDocAttribute {

View File

@@ -598,6 +598,15 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
}
doc_type.where_clauses = odin_doc_where_clauses(w, st->where_clauses);
}
auto tags = array_make<OdinDocString>(heap_allocator(), type->Struct.fields.count);
defer (array_free(&tags));
for_array(i, type->Struct.fields) {
tags[i] = odin_doc_write_string(w, type->Struct.tags[i]);
}
doc_type.tags = odin_write_slice(w, tags.data, tags.count);
}
break;
case Type_Union: