]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix use of N_ in constant initializers
authorJürg Billeter <j@bitron.ch>
Mon, 11 Oct 2010 19:07:34 +0000 (21:07 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 11 Oct 2010 19:07:34 +0000 (21:07 +0200)
vala/valamethodcall.vala

index 23a109a49e6de3605194b039a2a45d4a93fa0e45..5a3b8dd189fea6e12f8b16befd86bdc9b47b81fe 100644 (file)
@@ -710,6 +710,25 @@ public class Vala.MethodCall : Expression {
        public override void emit (CodeGenerator codegen) {
                var method_type = call.value_type as MethodType;
 
+               if (method_type != null) {
+                       // N_ and NC_ do not have any effect on the C code,
+                       // they are only interpreted by xgettext
+                       // this means that it is ok to use them in constant initializers
+                       // however, we must avoid generating regular method call code
+                       // as that may include temporary variables
+                       if (method_type.method_symbol.get_full_name () == "GLib.N_") {
+                               // first argument is string
+                               argument_list[0].emit (codegen);
+                               this.target_value = argument_list[0].target_value;
+                               return;
+                       } else if (method_type.method_symbol.get_full_name () == "GLib.NC_") {
+                               // second argument is string
+                               argument_list[1].emit (codegen);
+                               this.target_value = argument_list[1].target_value;
+                               return;
+                       }
+               }
+
                if (method_type != null && method_type.method_symbol.parent_symbol is Signal) {
                        var signal_access = ((MemberAccess) call).inner;
                        signal_access.emit (codegen);