[vala/staging] codegen: Nullable ValueType requires POINTER as marshaller signature
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Nullable ValueType requires POINTER as marshaller signature
- Date: Sat, 17 Jun 2017 19:05:46 +0000 (UTC)
commit 40732437777d00598fe9fcd35a2a9bf22eeb8f8a
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jun 17 19:57:49 2017 +0200
codegen: Nullable ValueType requires POINTER as marshaller signature
This is missing in https://bugzilla.gnome.org/show_bug.cgi?id=758816
https://bugzilla.gnome.org/show_bug.cgi?id=783897
codegen/valaccodeattribute.vala | 2 +
codegen/valagsignalmodule.vala | 12 +-------
tests/Makefile.am | 1 +
tests/objects/bug783897.vala | 57 +++++++++++++++++++++++++++++++++++++++
4 files changed, 62 insertions(+), 10 deletions(-)
---
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index 491b42a..d3a97d5 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -969,6 +969,8 @@ public class Vala.CCodeAttribute : AttributeCache {
} else {
return "POINTER";
}
+ } else if (node is ValueType && ((ValueType) node).nullable) {
+ return "POINTER";
} else if (node is PointerType || ((DataType) node).type_parameter != null) {
return "POINTER";
} else if (node is ErrorType) {
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 1c0eff4..306c374 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -36,11 +36,7 @@ public class Vala.GSignalModule : GObjectModule {
}
}
- if (return_type is ValueType && return_type.nullable) {
- ret = "%s_POINTER_".printf (prefix);
- } else {
- ret = "%s_%s_".printf (prefix, get_ccode_marshaller_type_name (return_type));
- }
+ ret = "%s_%s_".printf (prefix, get_ccode_marshaller_type_name (return_type));
if (params == null || params.size == 0) {
ret = ret + "_VOID";
@@ -93,11 +89,7 @@ public class Vala.GSignalModule : GObjectModule {
private string get_marshaller_signature (List<Parameter> params, DataType return_type) {
string signature;
- if (return_type is ValueType && return_type.nullable) {
- signature = "POINTER:";
- } else {
- signature = "%s:".printf (get_ccode_marshaller_type_name (return_type));
- }
+ signature = "%s:".printf (get_ccode_marshaller_type_name (return_type));
if (params == null || params.size == 0) {
signature = signature + "VOID";
} else {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0611849..b29e121 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -230,6 +230,7 @@ TESTS = \
objects/bug779038-3.test \
objects/bug779219.vala \
objects/bug779955.vala \
+ objects/bug783897.vala \
errors/errors.vala \
errors/bug567181.vala \
errors/bug579101.vala \
diff --git a/tests/objects/bug783897.vala b/tests/objects/bug783897.vala
new file mode 100644
index 0000000..58e1ab9
--- /dev/null
+++ b/tests/objects/bug783897.vala
@@ -0,0 +1,57 @@
+enum Baz {
+ VALUE = 42;
+}
+
+struct Bar {
+ public int i;
+}
+
+class Foo {
+ public signal void signal_enum (Baz? e);
+ public signal void signal_simple_type (int? t);
+ public signal void signal_struct (Bar? s);
+ public signal void signal_custom (Foo f, Baz? e, int? t, Bar? s);
+ public signal void signal_custom2 (Foo f, Baz e, int t, Bar s);
+
+ public void run () {
+ signal_enum (Baz.VALUE);
+ signal_simple_type (23);
+ signal_struct ({ 4711 });
+ signal_custom (this, Baz.VALUE, 23, { 4711 });
+ signal_custom2 (this, Baz.VALUE, 23, { 4711 });
+ }
+}
+
+void callback_enum (Baz? e) {
+ assert (e == Baz.VALUE);
+}
+
+void callback_simple_type (int? t) {
+ assert (t == 23);
+}
+
+void callback_struct (Bar? s) {
+ assert (s.i == 4711);
+}
+
+void callback_custom (Foo f, Baz? e, int? t, Bar? s) {
+ assert (e == Baz.VALUE);
+ assert (t == 23);
+ assert (s.i == 4711);
+}
+
+void callback_custom2 (Foo f, Baz e, int t, Bar s) {
+ assert (e == Baz.VALUE);
+ assert (t == 23);
+ assert (s.i == 4711);
+}
+
+void main() {
+ var foo = new Foo ();
+ foo.signal_enum.connect (callback_enum);
+ foo.signal_simple_type.connect (callback_simple_type);
+ foo.signal_struct.connect (callback_struct);
+ foo.signal_custom.connect (callback_custom);
+ foo.signal_custom2.connect (callback_custom2);
+ foo.run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]