]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girwriter: Fix ctype of out/ref and array parameters
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 19 Oct 2018 15:21:39 +0000 (17:21 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 19 Oct 2018 15:23:05 +0000 (17:23 +0200)
codegen/valagirwriter.vala
tests/girwriter/GirTest-1.0.gir-expected

index 7c2ebc7f0cecd5559ef76aba01b3328097578451..cab520ac61c724102d74e199b9cead04c255b766 100644 (file)
@@ -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 ();
index 18f275596322ed13f25da2b1a5903cb002a8ebfa..2b372d3ba5777df581c5415f4ceb7c85ca85724a 100644 (file)
                        </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>
                        </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>
                        </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>
                </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>
                                        <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>
                </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>
                        </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>
                </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>
                        </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>
                                        <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>
                                        <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>
                                        <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*"/>