summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2021-08-03 18:11:06 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2021-08-05 15:02:02 +0200
commitf3a8f1a6444ae0ab59ec4bd6496a7c1025785ad4 (patch)
tree5985cc688e04425e7238d6825c7fea9fad2cf032
parentf25b5b124124776eeab6e59396e91e93a9c11f1d (diff)
downloadvala-f3a8f1a6444ae0ab59ec4bd6496a7c1025785ad4.tar.gz
girparser: Never skip "function" elements
-rw-r--r--tests/girwriter/GirTest-1.0.gir-expected32
-rw-r--r--tests/girwriter/girtest.vala10
-rw-r--r--tests/girwriter/girtest.vapi-expected2
-rw-r--r--tests/girwriter/girtest.vapigen-expected6
-rw-r--r--vala/valagirparser.vala8
5 files changed, 54 insertions, 4 deletions
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index 74acb9b7b..b40cdddae 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -2760,6 +2760,22 @@
</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"/>
@@ -2788,6 +2804,22 @@
</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"/>
diff --git a/tests/girwriter/girtest.vala b/tests/girwriter/girtest.vala
index e9f952ef9..0bc88d93e 100644
--- a/tests/girwriter/girtest.vala
+++ b/tests/girwriter/girtest.vala
@@ -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 () {
}
}
diff --git a/tests/girwriter/girtest.vapi-expected b/tests/girwriter/girtest.vapi-expected
index 89e794b1d..e2eee7fab 100644
--- a/tests/girwriter/girtest.vapi-expected
+++ b/tests/girwriter/girtest.vapi-expected
@@ -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")]
diff --git a/tests/girwriter/girtest.vapigen-expected b/tests/girwriter/girtest.vapigen-expected
index 9287919f8..e4fe02ae0 100644
--- a/tests/girwriter/girtest.vapigen-expected
+++ b/tests/girwriter/girtest.vapigen-expected
@@ -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 ()")]
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 2345c355e..02b5538b5 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -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") {