mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-19 16:42:33 +00:00
Merge remote-tracking branch 'origin/bill/rexcode' into bill/rexcode
This commit is contained in:
@@ -370,7 +370,7 @@ gb_internal OdinDocString odin_doc_pkg_doc_string(OdinDocWriter *w, AstPackage *
|
||||
if (pkg == nullptr) {
|
||||
return {};
|
||||
}
|
||||
auto buf = array_make<u8>(permanent_allocator(), 0, 0); // Minor leak
|
||||
auto buf = array_make<u8>(heap_allocator(), 0, 0);
|
||||
|
||||
for_array(i, pkg->files) {
|
||||
AstFile *f = pkg->files[i];
|
||||
@@ -380,31 +380,37 @@ gb_internal OdinDocString odin_doc_pkg_doc_string(OdinDocWriter *w, AstPackage *
|
||||
}
|
||||
}
|
||||
|
||||
return odin_doc_write_string_without_cache(w, make_string(buf.data, buf.count));
|
||||
String str = string_intern_string(make_string(buf.data, buf.count));
|
||||
array_free(&buf);
|
||||
return odin_doc_write_string_without_cache(w, str);
|
||||
}
|
||||
|
||||
gb_internal OdinDocString odin_doc_comment_group_string(OdinDocWriter *w, CommentGroup *g) {
|
||||
if (g == nullptr) {
|
||||
return {};
|
||||
}
|
||||
auto buf = array_make<u8>(permanent_allocator(), 0, 0); // Minor leak
|
||||
auto buf = array_make<u8>(heap_allocator(), 0, 0);
|
||||
|
||||
odin_doc_append_comment_group_string(&buf, g);
|
||||
|
||||
return odin_doc_write_string_without_cache(w, make_string(buf.data, buf.count));
|
||||
String str = string_intern_string(make_string(buf.data, buf.count));
|
||||
array_free(&buf);
|
||||
return odin_doc_write_string_without_cache(w, str);
|
||||
}
|
||||
|
||||
gb_internal OdinDocString odin_doc_expr_string(OdinDocWriter *w, Ast *expr) {
|
||||
gb_internal OdinDocString odin_doc_expr_string(OdinDocWriter *w, Ast *expr, bool use_shorthand=false) {
|
||||
if (expr == nullptr) {
|
||||
return {};
|
||||
}
|
||||
gbString s = write_expr_to_string( // Minor leak
|
||||
gb_string_make(permanent_allocator(), ""),
|
||||
gbString s = write_expr_to_string(
|
||||
gb_string_make(heap_allocator(), ""),
|
||||
expr,
|
||||
build_context.cmd_doc_flags & CmdDocFlag_Short
|
||||
use_shorthand || (build_context.cmd_doc_flags & CmdDocFlag_Short)
|
||||
);
|
||||
String str = string_intern_string(make_string(cast(u8 *)s, gb_string_length(s)));
|
||||
gb_string_free(s);
|
||||
|
||||
return odin_doc_write_string(w, make_string(cast(u8 *)s, gb_string_length(s)));
|
||||
return odin_doc_write_string(w, str);
|
||||
}
|
||||
|
||||
gb_internal OdinDocArray<OdinDocAttribute> odin_doc_attributes(OdinDocWriter *w, Array<Ast *> const &attributes) {
|
||||
@@ -920,7 +926,16 @@ gb_internal OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e)
|
||||
|
||||
OdinDocString init_string = {};
|
||||
if (init_expr) {
|
||||
init_string = odin_doc_expr_string(w, init_expr);
|
||||
bool use_shorthand = false;
|
||||
if (e->kind == Entity_Variable) {
|
||||
Ast *expr = init_expr;
|
||||
if (expr->kind == Ast_CompoundLit) {
|
||||
if (expr->CompoundLit.elems.count > 512) {
|
||||
use_shorthand = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
init_string = odin_doc_expr_string(w, init_expr, use_shorthand);
|
||||
} else {
|
||||
if (e->kind == Entity_Constant) {
|
||||
if (e->Constant.flags & EntityConstantFlag_ImplicitEnumValue) {
|
||||
@@ -928,7 +943,10 @@ gb_internal OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e)
|
||||
} else if (e->Constant.param_value.original_ast_expr) {
|
||||
init_string = odin_doc_expr_string(w, e->Constant.param_value.original_ast_expr);
|
||||
} else {
|
||||
init_string = odin_doc_write_string(w, make_string_c(exact_value_to_string(e->Constant.value)));
|
||||
gbString s = exact_value_to_string(e->Constant.value);
|
||||
String str = string_intern_string(make_string(cast(u8 *)s, gb_string_length(s)));
|
||||
gb_string_free(s);
|
||||
init_string = odin_doc_write_string(w, str);
|
||||
}
|
||||
} else if (e->kind == Entity_Variable) {
|
||||
if (e->Variable.param_value.original_ast_expr) {
|
||||
|
||||
Reference in New Issue
Block a user