mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
fix package docs in a "hacky" way
This commit is contained in:
+19
-11
@@ -43,7 +43,7 @@ struct OdinDocWriter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
gb_internal OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e);
|
gb_internal OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e);
|
||||||
gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type);
|
gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type, bool cache);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
gb_internal void odin_doc_writer_item_tracker_init(OdinDocWriterItemTracker<T> *t, isize size) {
|
gb_internal void odin_doc_writer_item_tracker_init(OdinDocWriterItemTracker<T> *t, isize size) {
|
||||||
@@ -467,8 +467,8 @@ gb_internal OdinDocArray<OdinDocString> odin_doc_where_clauses(OdinDocWriter *w,
|
|||||||
return odin_write_slice(w, clauses.data, clauses.count);
|
return odin_write_slice(w, clauses.data, clauses.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
gb_internal OdinDocArray<OdinDocTypeIndex> odin_doc_type_as_slice(OdinDocWriter *w, Type *type) {
|
gb_internal OdinDocArray<OdinDocTypeIndex> odin_doc_type_as_slice(OdinDocWriter *w, Type *type, bool cache=true) {
|
||||||
OdinDocTypeIndex index = odin_doc_type(w, type);
|
OdinDocTypeIndex index = odin_doc_type(w, type, cache);
|
||||||
return odin_write_item_as_slice(w, index);
|
return odin_write_item_as_slice(w, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ gb_internal OdinDocArray<OdinDocEntityIndex> odin_doc_add_entity_as_slice(OdinDo
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type, bool cache=true) {
|
||||||
if (type == nullptr) {
|
if (type == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -491,10 +491,13 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 type_hash = type_hash_canonical_type(type);
|
u64 type_hash = {0};
|
||||||
OdinDocTypeIndex *found = map_get(&w->type_cache, type_hash);
|
if (cache) {
|
||||||
if (found) {
|
type_hash = type_hash_canonical_type(type);
|
||||||
return *found;
|
OdinDocTypeIndex *found = map_get(&w->type_cache, type_hash);
|
||||||
|
if (found) {
|
||||||
|
return *found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -502,7 +505,9 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
|||||||
OdinDocType doc_type = {};
|
OdinDocType doc_type = {};
|
||||||
OdinDocTypeIndex type_index = 0;
|
OdinDocTypeIndex type_index = 0;
|
||||||
type_index = odin_doc_write_item(w, &w->types, &doc_type, &dst);
|
type_index = odin_doc_write_item(w, &w->types, &doc_type, &dst);
|
||||||
map_set(&w->type_cache, type_hash, type_index);
|
if (cache) {
|
||||||
|
map_set(&w->type_cache, type_hash, type_index);
|
||||||
|
}
|
||||||
|
|
||||||
switch (type->kind) {
|
switch (type->kind) {
|
||||||
case Type_Basic:
|
case Type_Basic:
|
||||||
@@ -527,7 +532,10 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
|||||||
doc_type.kind = OdinDocType_Generic;
|
doc_type.kind = OdinDocType_Generic;
|
||||||
doc_type.name = odin_doc_write_string(w, name);
|
doc_type.name = odin_doc_write_string(w, name);
|
||||||
if (type->Generic.specialized) {
|
if (type->Generic.specialized) {
|
||||||
doc_type.types = odin_doc_type_as_slice(w, type->Generic.specialized);
|
// NOTE(laytan): do not look at the cache for the specialization, it would resolve
|
||||||
|
// to the same entry as the type itself because `default_type` resolves to the
|
||||||
|
// specialization of a generic type.
|
||||||
|
doc_type.types = odin_doc_type_as_slice(w, type->Generic.specialized, cache=false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1163,4 +1171,4 @@ gb_internal void odin_doc_write(CheckerInfo *info, char const *filename) {
|
|||||||
|
|
||||||
gb_internal bool is_in_doc_writer(void) {
|
gb_internal bool is_in_doc_writer(void) {
|
||||||
return g_in_doc_writer.load();
|
return g_in_doc_writer.load();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user