[vala/staging] girwriter: Fix position of "result" parameter for struct constructor
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] girwriter: Fix position of "result" parameter for struct constructor
- Date: Thu, 5 Aug 2021 15:19:59 +0000 (UTC)
commit 35b3b43fda3da31f7439a87fc65a1811b930fd96
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Aug 5 17:14:48 2021 +0200
girwriter: Fix position of "result" parameter for struct constructor
Thanks to Princeton Ferro
codegen/valagirwriter.vala | 9 +++++++--
tests/girwriter/GirTest-1.0.gir-expected | 12 ++++++------
tests/girwriter/girtest.vapigen-expected | 4 ++--
3 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 49a8112a2..10504c225 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -1202,6 +1202,11 @@ public class Vala.GIRWriter : CodeVisitor {
}
}
+ if (constructor && ret_is_struct) {
+ // struct constructor has its result as first parameter
+ write_param_or_return (return_type, "parameter", ref index, false, "result",
return_comment, ParameterDirection.OUT, constructor, true);
+ }
+
if (type_params != null) {
foreach (var p in type_params) {
write_type_parameter (p, "parameter");
@@ -1215,10 +1220,10 @@ public class Vala.GIRWriter : CodeVisitor {
write_implicit_params (param.variable_type, ref index, get_ccode_array_length
(param), get_ccode_name (param), param.direction);
}
- if (ret_is_struct) {
+ if (!constructor && ret_is_struct) {
// struct returns are converted to parameters
write_param_or_return (return_type, "parameter", ref index, false, "result",
return_comment, ParameterDirection.OUT, constructor, true);
- } else {
+ } else if (!constructor) {
write_implicit_params (return_type, ref index, return_array_length, "result",
ParameterDirection.OUT);
}
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index b40cdddae..65ee2edd0 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -2765,15 +2765,15 @@
<type name="none" c:type="void"/>
</return-value>
<parameters>
+ <parameter name="result" direction="out" transfer-ownership="full"
caller-allocates="1">
+ <type name="GirTest.BoxedStruct" c:type="GirTestBoxedStruct*"/>
+ </parameter>
<parameter name="param1" transfer-ownership="none">
<type name="gint" c:type="gint"/>
</parameter>
<parameter name="param2" transfer-ownership="none">
<type name="gint" c:type="gint"/>
</parameter>
- <parameter name="result" direction="out" transfer-ownership="full"
caller-allocates="1">
- <type name="GirTest.BoxedStruct" c:type="GirTestBoxedStruct*"/>
- </parameter>
</parameters>
</function>
<method name="inv" c:identifier="gir_test_boxed_struct_inv">
@@ -2809,15 +2809,15 @@
<type name="none" c:type="void"/>
</return-value>
<parameters>
+ <parameter name="result" direction="out" transfer-ownership="full"
caller-allocates="1">
+ <type name="GirTest.Struct" c:type="GirTestStruct*"/>
+ </parameter>
<parameter name="param1" transfer-ownership="none">
<type name="gint" c:type="gint"/>
</parameter>
<parameter name="param2" transfer-ownership="none">
<type name="gint" c:type="gint"/>
</parameter>
- <parameter name="result" direction="out" transfer-ownership="full"
caller-allocates="1">
- <type name="GirTest.Struct" c:type="GirTestStruct*"/>
- </parameter>
</parameters>
</function>
<method name="inv" c:identifier="gir_test_struct_inv">
diff --git a/tests/girwriter/girtest.vapigen-expected b/tests/girwriter/girtest.vapigen-expected
index e4fe02ae0..686780a4d 100644
--- a/tests/girwriter/girtest.vapigen-expected
+++ b/tests/girwriter/girtest.vapigen-expected
@@ -198,7 +198,7 @@ namespace GirTest {
public int field_name;
public int internal_field_name;
[CCode (cname = "gir_test_boxed_struct_init_foo")]
- public static GirTest.BoxedStruct foo (int param1, int param2);
+ public void foo (int param1, int param2);
public static GirTest.BoxedStruct init ();
public void inv ();
}
@@ -214,7 +214,7 @@ namespace GirTest {
public int field_name;
public int internal_field_name;
[CCode (cname = "gir_test_struct_init_foo")]
- public static GirTest.Struct foo (int param1, int param2);
+ public void foo (int param1, int param2);
public static GirTest.Struct init ();
public void inv ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]