]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Never skip "function" elements
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 3 Aug 2021 16:11:06 +0000 (18:11 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 5 Aug 2021 13:02:02 +0000 (15:02 +0200)
tests/girwriter/GirTest-1.0.gir-expected
tests/girwriter/girtest.vala
tests/girwriter/girtest.vapi-expected
tests/girwriter/girtest.vapigen-expected
vala/valagirparser.vala

index 74acb9b7b1df920dbf63ed6fa7e9252cbc6d3343..b40cdddae8342beff7457ffb0603789c81d49dbb 100644 (file)
                                </parameter>
                        </parameters>
                </function>
+               <function name="foo" c:identifier="gir_test_boxed_struct_init_foo">
+                       <return-value transfer-ownership="none">
+                               <type name="none" c:type="void"/>
+                       </return-value>
+                       <parameters>
+                               <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">
                        <return-value transfer-ownership="full">
                                <type name="none" c:type="void"/>
                                </parameter>
                        </parameters>
                </function>
+               <function name="foo" c:identifier="gir_test_struct_init_foo">
+                       <return-value transfer-ownership="none">
+                               <type name="none" c:type="void"/>
+                       </return-value>
+                       <parameters>
+                               <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">
                        <return-value transfer-ownership="full">
                                <type name="none" c:type="void"/>
index e9f952ef9f6b697aa49b6dcb02b3ac10a9a7a06f..0bc88d93e0f99c0afaabebc0974d58d467934e13 100644 (file)
@@ -7,6 +7,11 @@ namespace GirTest {
                public BoxedStruct () {
                }
 
+               public BoxedStruct.foo (int param1, int param2) {
+                       field_name = param1;
+                       internal_field_name = param2;
+               }
+
                public void inv () {
                }
        }
@@ -19,6 +24,11 @@ namespace GirTest {
                public Struct () {
                }
 
+               public Struct.foo (int param1, int param2) {
+                       field_name = param1;
+                       internal_field_name = param2;
+               }
+
                public void inv () {
                }
        }
index 89e794b1d7cca945fa0d5158f700aa8806842198..e2eee7fab3b93c681b9c506d2b67e4bd031e630f 100644 (file)
@@ -170,6 +170,7 @@ namespace GirTest {
                public int field_name;
                public int internal_field_name;
                public BoxedStruct ();
+               public BoxedStruct.foo (int param1, int param2);
                public void inv ();
        }
        [CCode (cheader_filename = "girtest.h")]
@@ -187,6 +188,7 @@ namespace GirTest {
                public int field_name;
                public int internal_field_name;
                public Struct ();
+               public Struct.foo (int param1, int param2);
                public void inv ();
        }
        [CCode (cheader_filename = "girtest.h")]
index 9287919f81e9f7846b4f613ca363a2a09f06c64a..e4fe02ae0fa26d7b2908fff96fc2546d9c8a9dd9 100644 (file)
@@ -197,6 +197,9 @@ namespace GirTest {
        public struct BoxedStruct {
                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 static GirTest.BoxedStruct init ();
                public void inv ();
        }
        [CCode (cheader_filename = "girtest.h", has_type_id = false)]
@@ -210,6 +213,9 @@ namespace GirTest {
        public struct Struct {
                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 static GirTest.Struct init ();
                public void inv ();
        }
        [CCode (cheader_filename = "girtest.h", cprefix = "GIR_TEST_ENUM_TEST_", type_id = "gir_test_enum_test_get_type ()")]
index 2345c355e6ddba0ec271b80024009198e41f1f31..02b5538b580a8579503bc9e7e245c41497c7ecbd 100644 (file)
@@ -2480,7 +2480,7 @@ public class Vala.GirParser : CodeVisitor {
                                        calculate_common_prefix (ref common_prefix, old_current.get_cname ());
                                }
                        } else if (reader.name == "function") {
-                               skip_element ();
+                               parse_method ("function");
                        } else if (reader.name == "function-macro") {
                                skip_element ();
                        } else {
@@ -2940,7 +2940,7 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (reader.name == "method") {
                                parse_method ("method");
                        } else if (reader.name == "function") {
-                               skip_element ();
+                               parse_method ("function");
                        } else if (reader.name == "function-macro") {
                                skip_element ();
                        } else if (reader.name == "union") {
@@ -3584,7 +3584,7 @@ public class Vala.GirParser : CodeVisitor {
                                        unref_method = old_current;
                                }
                        } else if (reader.name == "function") {
-                               skip_element ();
+                               parse_method ("function");
                        } else if (reader.name == "function-macro") {
                                skip_element ();
                        } else if (reader.name == "union") {
@@ -3673,7 +3673,7 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (reader.name == "method") {
                                parse_method ("method");
                        } else if (reader.name == "function") {
-                               skip_element ();
+                               parse_method ("function");
                        } else if (reader.name == "function-macro") {
                                skip_element ();
                        } else if (reader.name == "record") {