[vala] Allow use of N_("foo") in constant initializer lists
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Allow use of N_("foo") in constant initializer lists
- Date: Wed, 9 Feb 2011 11:02:42 +0000 (UTC)
commit 37a2304a9570715f180365baea063f89d9423bd7
Author: Jürg Billeter <j bitron ch>
Date: Wed Feb 9 12:01:25 2011 +0100
Allow use of N_("foo") in constant initializer lists
vala/valamethodcall.vala | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 73c8171..23329bd 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -102,6 +102,25 @@ public class Vala.MethodCall : Expression {
}
}
+ public override bool is_constant () {
+ 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
+ if (method_type.method_symbol.get_full_name () == "GLib.N_") {
+ // first argument is string
+ return argument_list[0].is_constant ();
+ } else if (method_type.method_symbol.get_full_name () == "GLib.NC_") {
+ // second argument is string
+ return argument_list[1].is_constant ();
+ }
+ }
+
+ return false;
+ }
+
public override bool is_pure () {
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]