From 27c0cafdfc66ce731156bf076644716f240318d4 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Tue, 27 Jan 2026 13:19:23 +0000 Subject: Support for custom attributes --- src/codegen/codegen_decl.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/codegen/codegen_decl.c') diff --git a/src/codegen/codegen_decl.c b/src/codegen/codegen_decl.c index eb53911..5fb9f54 100644 --- a/src/codegen/codegen_decl.c +++ b/src/codegen/codegen_decl.c @@ -388,6 +388,38 @@ void emit_struct_defs(ParserContext *ctx, ASTNode *node, FILE *out) { fprintf(out, " __attribute__((visibility(\"default\")))"); } + + if (node->strct.attributes) + { + fprintf(out, " __attribute__(("); + Attribute *custom = node->strct.attributes; + int first = 1; + while (custom) + { + if (!first) + { + fprintf(out, ", "); + } + fprintf(out, "%s", custom->name); + if (custom->arg_count > 0) + { + fprintf(out, "("); + for (int i = 0; i < custom->arg_count; i++) + { + if (i > 0) + { + fprintf(out, ", "); + } + fprintf(out, "%s", custom->args[i]); + } + fprintf(out, ")"); + } + first = 0; + custom = custom->next; + } + fprintf(out, "))"); + } + fprintf(out, ";\n\n"); } else if (node->type == NODE_ENUM) -- cgit v1.2.3