diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-01 13:17:43 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-01 13:17:43 -0400 |
| commit | ee020c72d92c3807fa4afcd1e170d3df81688b97 (patch) | |
| tree | 60d0bd641db08bab082bbbb7f10f72d29995cdfe /src/compile/structs.c | |
| parent | c0c6fe863f8e074cbe8297b5da2a476f455b6518 (diff) | |
Switch to using Texts(x) instead of Texts(String(x)) when possible
Diffstat (limited to 'src/compile/structs.c')
| -rw-r--r-- | src/compile/structs.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/compile/structs.c b/src/compile/structs.c index 526c11c7..8560a790 100644 --- a/src/compile/structs.c +++ b/src/compile/structs.c @@ -18,7 +18,7 @@ Text_t compile_struct_typeinfo(env_t *env, type_t *t, const char *name, arg_ast_ ? Text$from_str(name) : Texts("struct ", namespace_name(env, env->namespace, Texts(name, "$$struct"))); - int num_fields = 0; + int64_t num_fields = 0; for (arg_ast_t *f = fields; f; f = f->next) num_fields += 1; const char *short_name = name; @@ -33,9 +33,9 @@ Text_t compile_struct_typeinfo(env_t *env, type_t *t, const char *name, arg_ast_ ", " ".tag=StructInfo, .StructInfo.name=\"", short_name, "\"", is_secret ? Text(", .StructInfo.is_secret=true") : EMPTY_TEXT, - is_opaque ? Text(", .StructInfo.is_opaque=true") : EMPTY_TEXT, ", .StructInfo.num_fields=", String(num_fields)); + is_opaque ? Text(", .StructInfo.is_opaque=true") : EMPTY_TEXT, ", .StructInfo.num_fields=", num_fields); if (fields) { - typeinfo = Texts(typeinfo, ", .StructInfo.fields=(NamedType_t[", String(num_fields), "]){"); + typeinfo = Texts(typeinfo, ", .StructInfo.fields=(NamedType_t[", num_fields, "]){"); for (arg_ast_t *f = fields; f; f = f->next) { type_t *field_type = get_arg_ast_type(env, f); typeinfo = Texts(typeinfo, "{\"", f->name, "\", ", compile_type_info(field_type), "}"); @@ -70,8 +70,7 @@ Text_t compile_struct_header(env_t *env, ast_t *ast) { Text_t struct_code = def->external ? EMPTY_TEXT : Texts(type_code, " {\n", fields, "};\n"); type_t *t = Table$str_get(*env->types, def->name); - Text_t unpadded_size = - def->opaque ? Texts("sizeof(", type_code, ")") : Text$from_str(String((int64_t)unpadded_struct_size(t))); + Text_t unpadded_size = def->opaque ? Texts("sizeof(", type_code, ")") : Texts((int64_t)unpadded_struct_size(t)); Text_t typeinfo_code = Texts("extern const TypeInfo_t ", typeinfo_name, ";\n"); Text_t optional_code = EMPTY_TEXT; if (!def->opaque) { |
