[vala/0.46] girwriter: Append symbol-attributes to callback field rather than its type
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] girwriter: Append symbol-attributes to callback field rather than its type
- Date: Mon, 22 Jun 2020 09:06:41 +0000 (UTC)
commit b3598c2b63a68ed422829228258c27489b2e93ce
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Jun 10 14:01:05 2020 +0200
girwriter: Append symbol-attributes to callback field rather than its type
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1006
codegen/valagirwriter.vala | 68 +++++---
tests/girwriter/GirTest-1.0.gir-expected | 264 +++++++++++++++++++++++++++++++
tests/girwriter/girtest.vala | 10 ++
tests/girwriter/girtest.vapi-expected | 6 +
4 files changed, 324 insertions(+), 24 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 5df7133b0..5d54f5270 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -504,25 +504,31 @@ public class Vala.GIRWriter : CodeVisitor {
finish_name += "_finish";
write_indent ();
- buffer.append_printf("<field name=\"%s\">\n", m.name);
+ buffer.append_printf("<field name=\"%s\"", m.name);
+ write_symbol_attributes (m);
+ buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name,
get_ccode_name (m), m.get_async_begin_parameters (), new VoidType (), false, false);
+ do_write_signature (m, "callback", true, m.name,
get_ccode_name (m), m.get_async_begin_parameters (), new VoidType (), false, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
write_indent ();
- buffer.append_printf("<field name=\"%s\">\n", finish_name);
+ buffer.append_printf("<field name=\"%s\"", finish_name);
+ write_symbol_attributes (m);
+ buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, finish_name,
get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false);
+ do_write_signature (m, "callback", true, finish_name,
get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
} else {
write_indent ();
- buffer.append_printf("<field name=\"%s\">\n", m.name);
+ buffer.append_printf("<field name=\"%s\"", m.name);
+ write_symbol_attributes (m);
+ buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name,
get_ccode_name (m), m.get_parameters (), m.return_type, m.tree_can_fail, false);
+ do_write_signature (m, "callback", true, m.name,
get_ccode_name (m), m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -533,9 +539,11 @@ public class Vala.GIRWriter : CodeVisitor {
foreach (Signal sig in cl.get_signals ()) {
if (sig.default_handler != null) {
write_indent ();
- buffer.append_printf ("<field name=\"%s\">\n",
get_ccode_lower_case_name (sig));
+ buffer.append_printf ("<field name=\"%s\"", get_ccode_lower_case_name
(sig));
+ write_symbol_attributes (sig);
+ buffer.append_printf (">\n");
indent++;
- write_signature (sig.default_handler, "callback", false, true);
+ write_signature (sig.default_handler, "callback", false, true, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -675,25 +683,31 @@ public class Vala.GIRWriter : CodeVisitor {
finish_name += "_finish";
write_indent ();
- buffer.append_printf("<field name=\"%s\">\n", m.name);
+ buffer.append_printf("<field name=\"%s\"", m.name);
+ write_symbol_attributes (m);
+ buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_async_begin_parameters (), new VoidType (), false, false);
+ do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_async_begin_parameters (), new VoidType (), false, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
write_indent ();
- buffer.append_printf("<field name=\"%s\">\n", finish_name);
+ buffer.append_printf("<field name=\"%s\"", finish_name);
+ write_symbol_attributes (m);
+ buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, finish_name,
get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false);
+ do_write_signature (m, "callback", true, finish_name,
get_ccode_finish_name (m), m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
} else {
write_indent ();
- buffer.append_printf("<field name=\"%s\">\n", m.name);
+ buffer.append_printf("<field name=\"%s\"", m.name);
+ write_symbol_attributes (m);
+ buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false);
+ do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -706,9 +720,11 @@ public class Vala.GIRWriter : CodeVisitor {
if (prop.get_accessor != null) {
var m = prop.get_accessor.get_method ();
write_indent ();
- buffer.append_printf("<field name=\"%s\">\n", m.name);
+ buffer.append_printf("<field name=\"%s\"", m.name);
+ write_symbol_attributes (m);
+ buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false);
+ do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -717,9 +733,11 @@ public class Vala.GIRWriter : CodeVisitor {
if (prop.set_accessor != null && prop.set_accessor.writable) {
var m = prop.set_accessor.get_method ();
write_indent ();
- buffer.append_printf("<field name=\"%s\">\n", m.name);
+ buffer.append_printf("<field name=\"%s\"", m.name);
+ write_symbol_attributes (m);
+ buffer.append_printf (">\n");
indent++;
- do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false);
+ do_write_signature (m, "callback", true, m.name, get_ccode_name (m),
m.get_parameters (), m.return_type, m.tree_can_fail, false, false);
indent--;
write_indent ();
buffer.append_printf ("</field>\n");
@@ -1228,7 +1246,7 @@ public class Vala.GIRWriter : CodeVisitor {
return is_visibility (sym);
}
- private void write_signature (Method m, string tag_name, bool write_doc, bool instance = false) {
+ private void write_signature (Method m, string tag_name, bool write_doc, bool instance = false, bool
write_attributes = true) {
var parent = this.hierarchy.get (0);
string name;
if (m.parent_symbol != parent) {
@@ -1248,14 +1266,14 @@ public class Vala.GIRWriter : CodeVisitor {
finish_name = finish_name.substring (0, finish_name.length - "_async".length);
}
finish_name += "_finish";
- do_write_signature (m, tag_name, instance, name, get_ccode_name (m),
m.get_async_begin_parameters (), new VoidType (), false, true);
- do_write_signature (m, tag_name, instance, finish_name, get_ccode_finish_name (m),
m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false);
+ do_write_signature (m, tag_name, instance, name, get_ccode_name (m),
m.get_async_begin_parameters (), new VoidType (), false, true, write_attributes);
+ do_write_signature (m, tag_name, instance, finish_name, get_ccode_finish_name (m),
m.get_async_end_parameters (), m.return_type, m.tree_can_fail, false, write_attributes);
} else {
- do_write_signature (m, tag_name, instance, name, get_ccode_name (m), m.get_parameters
(), m.return_type, m.tree_can_fail, true);
+ do_write_signature (m, tag_name, instance, name, get_ccode_name (m), m.get_parameters
(), m.return_type, m.tree_can_fail, true, write_attributes);
}
}
- private void do_write_signature (Method m, string tag_name, bool instance, string name, string cname,
List<Vala.Parameter> params, DataType return_type, bool can_fail, bool write_comment) {
+ private void do_write_signature (Method m, string tag_name, bool instance, string name, string cname,
List<Vala.Parameter> params, DataType return_type, bool can_fail, bool write_comment, bool write_attributes =
true) {
write_indent ();
buffer.append_printf ("<%s name=\"%s\"", tag_name, name);
if (tag_name == "virtual-method") {
@@ -1269,7 +1287,9 @@ public class Vala.GIRWriter : CodeVisitor {
if (can_fail) {
buffer.append_printf (" throws=\"1\"");
}
- write_symbol_attributes (m);
+ if (write_attributes) {
+ write_symbol_attributes (m);
+ }
buffer.append_printf (">\n");
indent++;
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index c4020e580..17128d3d8 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -938,6 +938,84 @@
<type name="none"/>
</return-value>
</virtual-method>
+ <method name="method_valist" c:identifier="gir_test_abstract_object_test_method_valist"
introspectable="0">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="vargs" transfer-ownership="none">
+ <type name="va_list" c:type="va_list"/>
+ </parameter>
+ </parameters>
+ </method>
+ <virtual-method name="method_valist" invoker="method_valist" introspectable="0">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="vargs" transfer-ownership="none">
+ <type name="va_list" c:type="va_list"/>
+ </parameter>
+ </parameters>
+ </virtual-method>
+ <method name="skipped_coroutine_method"
c:identifier="gir_test_abstract_object_test_skipped_coroutine_method" introspectable="0">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="_callback_" transfer-ownership="none" allow-none="1"
closure="2" scope="async">
+ <type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback"/>
+ </parameter>
+ <parameter name="_callback__target" transfer-ownership="none" allow-none="1">
+ <type name="gpointer" c:type="void*"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="skipped_coroutine_method_finish"
c:identifier="gir_test_abstract_object_test_skipped_coroutine_method_finish" introspectable="0">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="_res_" transfer-ownership="none">
+ <type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
+ </parameter>
+ </parameters>
+ </method>
+ <virtual-method name="skipped_coroutine_method" invoker="skipped_coroutine_method"
introspectable="0">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="_callback_" transfer-ownership="none" allow-none="1"
closure="2" scope="async">
+ <type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback"/>
+ </parameter>
+ <parameter name="_callback__target" transfer-ownership="none" allow-none="1">
+ <type name="gpointer" c:type="void*"/>
+ </parameter>
+ </parameters>
+ </virtual-method>
+ <virtual-method name="skipped_coroutine_method_finish"
invoker="skipped_coroutine_method_finish" introspectable="0">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="_res_" transfer-ownership="none">
+ <type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
+ </parameter>
+ </parameters>
+ </virtual-method>
</class>
<record name="AbstractObjectTestClass" c:type="GirTestAbstractObjectTestClass"
glib:is-gtype-struct-for="AbstractObjectTest">
<field name="parent_class" readable="0" private="1">
@@ -1000,6 +1078,60 @@
</parameters>
</callback>
</field>
+ <field name="method_valist" introspectable="0">
+ <callback name="method_valist" c:type="method_valist">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="GirTest.AbstractObjectTest"
c:type="GirTestAbstractObjectTest*"/>
+ </parameter>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="vargs" transfer-ownership="none">
+ <type name="va_list" c:type="va_list"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
+ <field name="skipped_coroutine_method" introspectable="0">
+ <callback name="skipped_coroutine_method" c:type="skipped_coroutine_method">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="GirTest.AbstractObjectTest"
c:type="GirTestAbstractObjectTest*"/>
+ </parameter>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="_callback_" transfer-ownership="none" allow-none="1"
closure="3" scope="async">
+ <type name="Gio.AsyncReadyCallback"
c:type="GAsyncReadyCallback"/>
+ </parameter>
+ <parameter name="_callback__target" transfer-ownership="none"
allow-none="1">
+ <type name="gpointer" c:type="void*"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
+ <field name="skipped_coroutine_method_finish" introspectable="0">
+ <callback name="skipped_coroutine_method_finish"
c:type="skipped_coroutine_method_finish">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="GirTest.AbstractObjectTest"
c:type="GirTestAbstractObjectTest*"/>
+ </parameter>
+ <parameter name="_res_" transfer-ownership="none">
+ <type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
</record>
<record name="AbstractObjectTestPrivate" c:type="GirTestAbstractObjectTestPrivate" disguised="1"/>
<class name="ImplementionTest" c:type="GirTestImplementionTest"
glib:type-name="GirTestImplementionTest" glib:get-type="gir_test_implemention_test_get_type"
glib:type-struct="ImplementionTestClass" parent="GObject.Object">
@@ -1323,6 +1455,84 @@
</parameter>
</parameters>
</virtual-method>
+ <method name="method_valist" c:identifier="gir_test_interface_test_method_valist"
introspectable="0">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="vargs" transfer-ownership="none">
+ <type name="va_list" c:type="va_list"/>
+ </parameter>
+ </parameters>
+ </method>
+ <virtual-method name="method_valist" invoker="method_valist" introspectable="0">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="vargs" transfer-ownership="none">
+ <type name="va_list" c:type="va_list"/>
+ </parameter>
+ </parameters>
+ </virtual-method>
+ <method name="skipped_coroutine_method"
c:identifier="gir_test_interface_test_skipped_coroutine_method" introspectable="0">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="_callback_" transfer-ownership="none" allow-none="1"
closure="2" scope="async">
+ <type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback"/>
+ </parameter>
+ <parameter name="_callback__target" transfer-ownership="none" allow-none="1">
+ <type name="gpointer" c:type="void*"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="skipped_coroutine_method_finish"
c:identifier="gir_test_interface_test_skipped_coroutine_method_finish" introspectable="0">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="_res_" transfer-ownership="none">
+ <type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
+ </parameter>
+ </parameters>
+ </method>
+ <virtual-method name="skipped_coroutine_method" invoker="skipped_coroutine_method"
introspectable="0">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="_callback_" transfer-ownership="none" allow-none="1"
closure="2" scope="async">
+ <type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback"/>
+ </parameter>
+ <parameter name="_callback__target" transfer-ownership="none" allow-none="1">
+ <type name="gpointer" c:type="void*"/>
+ </parameter>
+ </parameters>
+ </virtual-method>
+ <virtual-method name="skipped_coroutine_method_finish"
invoker="skipped_coroutine_method_finish" introspectable="0">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="_res_" transfer-ownership="none">
+ <type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
+ </parameter>
+ </parameters>
+ </virtual-method>
<property name="property" writable="1" construct="1">
<type name="gint" c:type="gint"/>
</property>
@@ -1409,6 +1619,60 @@
</parameters>
</callback>
</field>
+ <field name="method_valist" introspectable="0">
+ <callback name="method_valist" c:type="method_valist">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="GirTest.InterfaceTest"
c:type="GirTestInterfaceTest*"/>
+ </parameter>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="vargs" transfer-ownership="none">
+ <type name="va_list" c:type="va_list"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
+ <field name="skipped_coroutine_method" introspectable="0">
+ <callback name="skipped_coroutine_method" c:type="skipped_coroutine_method">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="GirTest.InterfaceTest"
c:type="GirTestInterfaceTest*"/>
+ </parameter>
+ <parameter name="param" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="_callback_" transfer-ownership="none" allow-none="1"
closure="3" scope="async">
+ <type name="Gio.AsyncReadyCallback"
c:type="GAsyncReadyCallback"/>
+ </parameter>
+ <parameter name="_callback__target" transfer-ownership="none"
allow-none="1">
+ <type name="gpointer" c:type="void*"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
+ <field name="skipped_coroutine_method_finish" introspectable="0">
+ <callback name="skipped_coroutine_method_finish"
c:type="skipped_coroutine_method_finish">
+ <return-value transfer-ownership="full">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="GirTest.InterfaceTest"
c:type="GirTestInterfaceTest*"/>
+ </parameter>
+ <parameter name="_res_" transfer-ownership="none">
+ <type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
<field name="get_property">
<callback name="get_property" c:type="get_property">
<return-value transfer-ownership="none">
diff --git a/tests/girwriter/girtest.vala b/tests/girwriter/girtest.vala
index e9b3d2ae1..23daab3d9 100644
--- a/tests/girwriter/girtest.vala
+++ b/tests/girwriter/girtest.vala
@@ -71,6 +71,11 @@ namespace GirTest {
}
public virtual async void coroutine_async () {
}
+ public virtual void method_valist (int param, va_list vargs) {
+ }
+ [GIR (visible = false)]
+ public virtual async void skipped_coroutine_method (int param) {
+ }
}
[GIR (visible = false)]
@@ -268,6 +273,11 @@ namespace GirTest {
public abstract void method_int8_out (out int8 param);
public abstract void method_throw () throws ErrorTest;
+
+ public abstract void method_valist (int param, va_list vargs);
+
+ [GIR (visible = false)]
+ public abstract async void skipped_coroutine_method (int param);
}
public interface PrerequisiteTest : InterfaceTest {
diff --git a/tests/girwriter/girtest.vapi-expected b/tests/girwriter/girtest.vapi-expected
index f92e00d05..16d5de559 100644
--- a/tests/girwriter/girtest.vapi-expected
+++ b/tests/girwriter/girtest.vapi-expected
@@ -7,6 +7,9 @@ namespace GirTest {
public abstract void method_int8_inout (ref int8 param);
public abstract void method_int8_out (out int8 param);
public abstract void method_throw () throws GirTest.ErrorTest;
+ public abstract void method_valist (int param, va_list vargs);
+ [GIR (visible = false)]
+ public abstract async void skipped_coroutine_method (int param);
}
[CCode (cheader_filename = "girtest.h")]
[Compact]
@@ -110,6 +113,9 @@ namespace GirTest {
public interface InterfaceTest : GLib.Object {
public virtual async void coroutine_async ();
public virtual void int8_in (int8 param);
+ public virtual void method_valist (int param, va_list vargs);
+ [GIR (visible = false)]
+ public virtual async void skipped_coroutine_method (int param);
public abstract int property { get; set construct; }
}
[CCode (cheader_filename = "girtest.h")]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]