aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2025-06-02 17:09:59 +0200
committerGitHub <noreply@github.com>2025-06-02 17:09:59 +0200
commit8135dda2fc42b3c474f0a77d7f03126b2eb8c034 (patch)
tree12350c2d659a37efa189006eca443649d0833db8 /src
parentd4a1670b93a174056b309db7e0e851e5e516bccb (diff)
parent912018b427407af95c8b4d83a0ed584a93fe6bc7 (diff)
Merge pull request #5258 from laytan/fix-docs-writer
fix package docs in a "hacky" way
Diffstat (limited to 'src')
-rw-r--r--src/docs_writer.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp
index a92ffc7ad..1f2325980 100644
--- a/src/docs_writer.cpp
+++ b/src/docs_writer.cpp
@@ -43,7 +43,7 @@ struct OdinDocWriter {
};
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>
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);
}
-gb_internal OdinDocArray<OdinDocTypeIndex> odin_doc_type_as_slice(OdinDocWriter *w, Type *type) {
- OdinDocTypeIndex index = odin_doc_type(w, type);
+gb_internal OdinDocArray<OdinDocTypeIndex> odin_doc_type_as_slice(OdinDocWriter *w, Type *type, bool cache=true) {
+ OdinDocTypeIndex index = odin_doc_type(w, type, cache);
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) {
return 0;
}
@@ -491,10 +491,13 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
}
}
- u64 type_hash = type_hash_canonical_type(type);
- OdinDocTypeIndex *found = map_get(&w->type_cache, type_hash);
- if (found) {
- return *found;
+ u64 type_hash = {0};
+ if (cache) {
+ type_hash = type_hash_canonical_type(type);
+ 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 = {};
OdinDocTypeIndex type_index = 0;
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) {
case Type_Basic:
@@ -527,7 +532,10 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
doc_type.kind = OdinDocType_Generic;
doc_type.name = odin_doc_write_string(w, name);
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;
@@ -1163,4 +1171,4 @@ gb_internal void odin_doc_write(CheckerInfo *info, char const *filename) {
gb_internal bool is_in_doc_writer(void) {
return g_in_doc_writer.load();
-} \ No newline at end of file
+}