[vala/staging] methodcall: Don't try to remove N_/NC_ while they are properly handled in C
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] methodcall: Don't try to remove N_/NC_ while they are properly handled in C
- Date: Wed, 30 Nov 2016 18:38:01 +0000 (UTC)
commit 40b6794fa7ab2a4a2f96364b33eab8b1787684c2
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Nov 30 19:27:17 2016 +0100
methodcall: Don't try to remove N_/NC_ while they are properly handled in C
This avoids messing around with the ownership and properly invokes copying
if needed.
https://bugzilla.gnome.org/show_bug.cgi?id=642350
tests/Makefile.am | 1 +
tests/methods/bug642350.vala | 28 ++++++++++++++++++++++++++++
tests/testrunner.sh | 2 +-
vala/valamethodcall.vala | 19 -------------------
4 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c94096d..ba88951 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -59,6 +59,7 @@ TESTS = \
methods/bug622570.vala \
methods/bug626783.vala \
methods/bug639054.vala \
+ methods/bug642350.vala \
methods/bug642885.vala \
methods/bug642899.vala \
methods/bug646345.vala \
diff --git a/tests/methods/bug642350.vala b/tests/methods/bug642350.vala
new file mode 100644
index 0000000..b1180f5
--- /dev/null
+++ b/tests/methods/bug642350.vala
@@ -0,0 +1,28 @@
+const string[] FOO = { "foo", N_ ("bar") };
+const string[] BAR = { "foo", NC_ ("valac", "bar") };
+
+struct Foo {
+ public string foo;
+ public string bar;
+}
+
+struct Bar {
+ public unowned string foo;
+ public unowned string bar;
+}
+
+void main () {
+ Foo f1 = { "foo", N_ ("bar") };
+ Foo f2 = { "foo", NC_ ("valac", "bar") };
+ Bar b1 = { "foo", N_ ("bar") };
+ Bar b2 = { "foo", NC_ ("valac", "bar") };
+
+ string s1 = N_ ("bar");
+ s1 = N_ (s1);
+
+ unowned string s2 = N_ ("bar");
+ s2 = N_ (s2);
+
+ string[] a1 = FOO;
+ unowned string[] a2 = FOO;
+}
diff --git a/tests/testrunner.sh b/tests/testrunner.sh
index aecc847..3d680c7 100755
--- a/tests/testrunner.sh
+++ b/tests/testrunner.sh
@@ -29,7 +29,7 @@ vapidir=$topsrcdir/vapi
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"
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 7bf0e49..4e9d474 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -672,25 +672,6 @@ 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]