From: Rico Tzschichholz Date: Sun, 5 Apr 2020 09:02:01 +0000 (+0200) Subject: codegen: Correctly handle transformation of translated string-literal constants X-Git-Tag: 0.49.1~203 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d02167aff9da38e85d7cdc21fff2b91ba9e35e9d;p=thirdparty%2Fvala.git codegen: Correctly handle transformation of translated string-literal constants The required header includes were not emited to the correct declaration space. --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 405d600f7..0883018e6 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -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);