]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Correctly handle transformation of translated string-literal constants
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 5 Apr 2020 09:02:01 +0000 (11:02 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 20 Apr 2020 19:20:26 +0000 (21:20 +0200)
The required header includes were not emited to the correct declaration space.

codegen/valaccodebasemodule.vala

index 98c8adba13e25194ca1401f6341df8aba7abdd72..5e13088589b0c5cf81768a9582267fa269826351 100644 (file)
@@ -1003,6 +1003,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                decl_space.add_constant_declaration (cdecl);
                        } else {
+                               if (c.value is StringLiteral && ((StringLiteral) c.value).translate) {
+                                       // translated string constant
+                                       var m = (Method) root_symbol.scope.lookup ("GLib").scope.lookup ("_");
+                                       add_symbol_declaration (decl_space, m, get_ccode_name (m));
+                               }
+
                                var cdefine = new CCodeMacroReplacement.with_expression (get_ccode_name (c), get_cvalue (c.value));
                                decl_space.add_type_member_declaration (cdefine);
                        }
@@ -4214,10 +4220,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                if (expr.translate) {
                        // translated string constant
-
-                       var m = (Method) root_symbol.scope.lookup ("GLib").scope.lookup ("_");
-                       add_symbol_declaration (cfile, m, get_ccode_name (m));
-
                        var translate = new CCodeFunctionCall (new CCodeIdentifier ("_"));
                        translate.add_argument (get_cvalue (expr));
                        set_cvalue (expr, translate);