mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-20 13:25:19 +00:00
Support struct field tags in odin doc format
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user