--- /dev/null
+const string[] FOO = { N_ ("foo"), NC_ ("valac", "bar") };
+const string BAZ = N_ ("bar");
+
+struct Foo {
+ public string foo;
+ public unowned string bar;
+}
+
+class Bar : Object {
+ public static string foo = N_ ("foo");
+ public string bar { get { return N_ ("bar"); } }
+ public string get_baz () { return N_ ("baz"); }
+}
+
+const Foo STRUCT = { "foo", N_ ("bar") };
+
+void main () {
+ assert (FOO[1] == "bar");
+ assert (BAZ == "bar");
+ assert (STRUCT.bar == "bar");
+
+ const string[] LOCAL_FOO = { N_ ("foo"), N_ ("bar") };
+ assert (LOCAL_FOO[1] == "bar");
+ const string LOCAL_BAZ = N_ ("bar");
+ assert (LOCAL_BAZ == "bar");
+ const Foo LOCAL_STRUCT = { "foo", N_ ("bar") };
+ assert (LOCAL_STRUCT.bar == "bar");
+
+ Foo f = { N_ ("foo"), NC_ ("valac", "bar") };
+ assert (f.foo == "foo");
+ assert (f.bar == "bar");
+
+ Bar b = new Bar ();
+ assert (b.foo == "foo");
+ assert (b.bar == "bar");
+ assert (b.get_baz () == "baz");
+
+ string s1 = N_ ("bar");
+ assert (s1 == "bar");
+ s1 = N_ (s1);
+ assert (s1 == "bar");
+
+ unowned string s2 = N_ ("bar");
+ assert (s2 == "bar");
+ s2 = N_ (s2);
+ assert (s2 == "bar");
+
+ string[] a1 = FOO;
+ assert (a1[1] == "bar");
+ unowned string[] a2 = FOO;
+ assert (a2[0] == "foo");
+}
export G_DEBUG=fatal_warnings
VALAC=$topbuilddir/compiler/valac$EXEEXT
-VALAFLAGS="--vapidir $vapidir --disable-warnings --main main --save-temps -X -g -X -O0 -X -pipe -X -lm -X -Werror=return-type -X -Werror=init-self -X -Werror=implicit -X -Werror=sequence-point -X -Werror=return-type -X -Werror=uninitialized -X -Werror=pointer-arith -X -Werror=int-to-pointer-cast -X -Werror=pointer-to-int-cast -X -Wformat -X -Werror=format-security -X -Werror=format-nonliteral -X -Werror=redundant-decls"
+VALAFLAGS="--vapidir $vapidir --disable-warnings --main main --save-temps -X -g -X -O0 -X -pipe -X -lm -X -DGETTEXT_PACKAGE=valac -X -Werror=return-type -X -Werror=init-self -X -Werror=implicit -X -Werror=sequence-point -X -Werror=return-type -X -Werror=uninitialized -X -Werror=pointer-arith -X -Werror=int-to-pointer-cast -X -Werror=pointer-to-int-cast -X -Wformat -X -Werror=format-security -X -Werror=format-nonliteral -X -Werror=redundant-decls"
VAPIGEN=$topbuilddir/vapigen/vapigen$EXEEXT
VAPIGENFLAGS="--vapidir $vapidir"
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);