[vala] Fix use of N_ in constant initializers



commit 1ad9c108cd772cfd652183af1af3c6afae575ae8
Author: Jürg Billeter <j bitron ch>
Date:   Mon Oct 11 21:07:34 2010 +0200

    Fix use of N_ in constant initializers

 vala/valamethodcall.vala |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 23a109a..5a3b8dd 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]