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

codegen/valaccodebasemodule.vala

index 405d600f7bb69ffa91ab666d76fc1a7e7c9bb329..0883018e67a6fdae84788be62b520753f8c859c0 100644 (file)
@@ -994,6 +994,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);
                        }
@@ -4269,10 +4275,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);