aboutsummaryrefslogtreecommitdiff
path: root/structs.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-11 17:49:04 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-11 17:49:04 -0400
commit1f6e586b2a3fe7f8ca32ce95659032bafef0ad24 (patch)
tree49b6633bf0693952153f12e8ed4dce1dae1443cc /structs.c
parentfb2d7b5379663e929ffabfbd8428de5b35ad67c4 (diff)
Support external structs with namespaced methods (also C-strings are now
`const char*` instead of `char*`)
Diffstat (limited to 'structs.c')
-rw-r--r--structs.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/structs.c b/structs.c
index 27f3a295..fe57f472 100644
--- a/structs.c
+++ b/structs.c
@@ -51,15 +51,12 @@ CORD compile_struct_header(env_t *env, ast_t *ast)
type_t *field_t = get_arg_ast_type(env, field);
fields = CORD_all(fields, compile_declaration(field_t, field->name), field_t->tag == BoolType ? ":1" : CORD_EMPTY, ";\n");
}
- CORD struct_code = CORD_all("struct ", full_name, "$$struct {\n");
- struct_code = CORD_all(struct_code, "};\n");
+ CORD struct_code = def->external ? CORD_EMPTY : CORD_all("struct ", full_name, "$$struct {\n", fields, "};\n");
type_t *t = Table$str_get(*env->types, def->name);
return CORD_all(
- "struct ", full_name, "$$struct {\n",
- fields,
- "};\n",
+ struct_code,
"DEFINE_OPTIONAL_TYPE(", compile_type(t), ", ", heap_strf("%zu", unpadded_struct_size(t)),
- ", ", namespace_prefix(env, env->namespace), "$Optional", def->name, "$$type);\n"
+ ", ", namespace_prefix(env, env->namespace), "$Optional", def->name, "$$type);\n"
"extern const TypeInfo_t ", full_name, "$$info;\n");
}