[vala/staging: 2/3] girwriter: Fix ctype of out/ref and array parameters
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 2/3] girwriter: Fix ctype of out/ref and array parameters
- Date: Fri, 19 Oct 2018 15:25:18 +0000 (UTC)
commit dcac4aabd0ec6c492aeb34087673a26bebd8424a
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Oct 19 17:21:39 2018 +0200
girwriter: Fix ctype of out/ref and array parameters
codegen/valagirwriter.vala | 5 +++--
tests/girwriter/GirTest-1.0.gir-expected | 34 ++++++++++++++++----------------
2 files changed, 20 insertions(+), 19 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 7c2ebc7f0..cab520ac6 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -1312,6 +1312,7 @@ public class Vala.GIRWriter : CodeVisitor {
} else if (index != -1) {
buffer.append_printf (" length=\"%i\"", index);
}
+ buffer.append_printf (" c:type=\"%s%s\"", get_ccode_name (array_type.element_type),
direction == ParameterDirection.IN ? "*" : "**");
buffer.append_printf (">\n");
indent++;
@@ -1325,7 +1326,7 @@ public class Vala.GIRWriter : CodeVisitor {
buffer.append_printf ("<type name=\"none\"/>\n");
} else if (type is PointerType) {
write_indent ();
- buffer.append_printf ("<type name=\"gpointer\" c:type=\"%s\"/>\n", get_ccode_name
(type));
+ buffer.append_printf ("<type name=\"gpointer\" c:type=\"%s%s\"/>\n", get_ccode_name
(type), direction == ParameterDirection.IN ? "" : "*");
} else if (type.data_type != null) {
write_indent ();
string type_name = gi_type_name (type.data_type);
@@ -1353,7 +1354,7 @@ public class Vala.GIRWriter : CodeVisitor {
} else if (type is DelegateType) {
var deleg_type = (DelegateType) type;
write_indent ();
- buffer.append_printf ("<type name=\"%s\" c:type=\"%s\"/>\n", gi_type_name
(deleg_type.delegate_symbol), get_ccode_name (type));
+ buffer.append_printf ("<type name=\"%s\" c:type=\"%s%s\"/>\n", gi_type_name
(deleg_type.delegate_symbol), get_ccode_name (type), direction == ParameterDirection.IN ? "" : "*");
} else if (type is GenericType) {
// generic type parameters not supported in GIR
write_indent ();
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index 18f275596..2b372d3ba 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -217,7 +217,7 @@
</return-value>
<parameters>
<parameter name="array" transfer-ownership="none">
- <array length="1">
+ <array length="1" c:type="gint*">
<type name="gint" c:type="gint"/>
</array>
</parameter>
@@ -232,7 +232,7 @@
</return-value>
<parameters>
<parameter name="array" direction="inout" transfer-ownership="full">
- <array length="1">
+ <array length="1" c:type="gint**">
<type name="gint" c:type="gint"/>
</array>
</parameter>
@@ -247,7 +247,7 @@
</return-value>
<parameters>
<parameter name="array" direction="out" transfer-ownership="full">
- <array length="1">
+ <array length="1" c:type="gint**">
<type name="gint" c:type="gint"/>
</array>
</parameter>
@@ -258,7 +258,7 @@
</method>
<method name="array_return" c:identifier="gir_test_object_test_array_return">
<return-value transfer-ownership="full">
- <array length="0">
+ <array length="0" c:type="gint*">
<type name="gint" c:type="gint"/>
</array>
</return-value>
@@ -280,7 +280,7 @@
<type name="gint" c:type="gint"/>
</parameter>
<parameter name="array" direction="out" transfer-ownership="full">
- <array length="3">
+ <array length="3" c:type="gint**">
<type name="gint" c:type="gint"/>
</array>
</parameter>
@@ -291,7 +291,7 @@
</method>
<method name="int_in_int_in_array_return"
c:identifier="gir_test_object_test_int_in_int_in_array_return">
<return-value transfer-ownership="full">
- <array length="2">
+ <array length="2" c:type="gint*">
<type name="gint" c:type="gint"/>
</array>
</return-value>
@@ -313,7 +313,7 @@
</return-value>
<parameters>
<parameter name="array" direction="out" transfer-ownership="full">
- <array length="1">
+ <array length="1" c:type="gchar***">
<type name="utf8" c:type="gchar*"/>
</array>
</parameter>
@@ -324,7 +324,7 @@
</method>
<method name="string_array_return" c:identifier="gir_test_object_test_string_array_return">
<return-value transfer-ownership="full">
- <array length="0">
+ <array length="0" c:type="gchar**">
<type name="utf8" c:type="gchar*"/>
</array>
</return-value>
@@ -345,10 +345,10 @@
</return-value>
<parameters>
<parameter name="result_target" direction="out" transfer-ownership="none"
allow-none="1">
- <type name="gpointer" c:type="void*"/>
+ <type name="gpointer" c:type="void**"/>
</parameter>
<parameter name="result_target_destroy_notify" direction="out"
transfer-ownership="none" scope="call">
- <type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
+ <type name="GLib.DestroyNotify" c:type="GDestroyNotify*"/>
</parameter>
</parameters>
</method>
@@ -361,7 +361,7 @@
<type name="gint" c:type="gint"/>
</parameter>
<parameter name="a" direction="out" transfer-ownership="full">
- <array length="2">
+ <array length="2" c:type="gint**">
<type name="gint" c:type="gint"/>
</array>
</parameter>
@@ -369,16 +369,16 @@
<type name="gint" c:type="gint*"/>
</parameter>
<parameter name="result_target" direction="out" transfer-ownership="none"
allow-none="1">
- <type name="gpointer" c:type="void*"/>
+ <type name="gpointer" c:type="void**"/>
</parameter>
<parameter name="result_target_destroy_notify" direction="out"
transfer-ownership="none" scope="call">
- <type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
+ <type name="GLib.DestroyNotify" c:type="GDestroyNotify*"/>
</parameter>
</parameters>
</method>
<method name="array_return_int_in_delegate_out"
c:identifier="gir_test_object_test_array_return_int_in_delegate_out">
<return-value transfer-ownership="full">
- <array length="4">
+ <array length="4" c:type="gint*">
<type name="gint" c:type="gint"/>
</array>
</return-value>
@@ -387,13 +387,13 @@
<type name="gint" c:type="gint"/>
</parameter>
<parameter name="d" direction="out" transfer-ownership="none" closure="2"
scope="notified" destroy="3">
- <type name="GirTest.DelegateTest" c:type="GirTestDelegateTest"/>
+ <type name="GirTest.DelegateTest" c:type="GirTestDelegateTest*"/>
</parameter>
<parameter name="d_target" direction="out" transfer-ownership="none"
allow-none="1">
- <type name="gpointer" c:type="void*"/>
+ <type name="gpointer" c:type="void**"/>
</parameter>
<parameter name="d_target_destroy_notify" direction="out"
transfer-ownership="none" scope="call">
- <type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
+ <type name="GLib.DestroyNotify" c:type="GDestroyNotify*"/>
</parameter>
<parameter name="result_length1" direction="out" transfer-ownership="none">
<type name="gint" c:type="gint*"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]