[vala] GIR writer: Fix generation of async methods
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] GIR writer: Fix generation of async methods
- Date: Sun, 27 Sep 2009 13:36:18 +0000 (UTC)
commit d477db1288902ad87b702b386abc672eceecfce9
Author: Jan Hudec <bulb ucw cz>
Date: Sat Sep 26 10:57:46 2009 +0200
GIR writer: Fix generation of async methods
GObject-Introspection does not have any special support for async
methods, so we need to write them out as two entries corresponding to
the .begin and .end submethods respectively.
To avoid code duplication, the Vala.GirWriter.write_signature method is
split in two. The inner one takes all attributes that differ between
sync and async.begin/end methods as additional arguments and is called
twice for the async methods.
Signed-off-by: Jan Hudec <bulb ucw cz>
codegen/valagirwriter.vala | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index 029a949..8b65267 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -562,16 +562,30 @@ public class Vala.GIRWriter : CodeVisitor {
}
private void write_signature (Method m, string tag_name, bool instance = false) {
+ if (m.coroutine) {
+ string finish_name = m.name;
+ if (finish_name.has_suffix ("_async")) {
+ finish_name = finish_name.substring (0, finish_name.length - "_async".length);
+ }
+ finish_name += "_finish";
+ do_write_signature (m, tag_name, instance, m.name, m.get_cname (), m.get_async_begin_parameters (), new VoidType (), false);
+ do_write_signature (m, tag_name, instance, finish_name, m.get_finish_cname (), m.get_async_end_parameters (), m.return_type, m.tree_can_fail);
+ } else {
+ do_write_signature (m, tag_name, instance, m.name, m.get_cname (), m.get_parameters (), m.return_type, m.tree_can_fail);
+ }
+ }
+
+ private void do_write_signature (Method m, string tag_name, bool instance, string name, string cname, Gee.List<Vala.FormalParameter> params, DataType return_type, bool can_fail) {
write_indent ();
- stream.printf ("<%s name=\"%s\"", tag_name, m.name);
+ stream.printf ("<%s name=\"%s\"", tag_name, name);
if (tag_name == "virtual-method") {
- stream.printf (" invoker=\"%s\"", m.name);
+ stream.printf (" invoker=\"%s\"", name);
} else if (tag_name == "callback") {
- stream.printf (" c:type=\"%s\"", m.get_cname ());
+ stream.printf (" c:type=\"%s\"", cname);
} else {
- stream.printf (" c:identifier=\"%s\"", m.get_cname ());
+ stream.printf (" c:identifier=\"%s\"", cname);
}
- if (m.tree_can_fail) {
+ if (can_fail) {
stream.printf (" throws=\"1\"");
}
stream.printf (">\n");
@@ -584,9 +598,9 @@ public class Vala.GIRWriter : CodeVisitor {
instance_type = CCodeBaseModule.get_data_type_for_symbol ((TypeSymbol) m.parent_symbol);
}
- write_params (m.get_parameters (), instance_type);
+ write_params (params, instance_type);
- write_return_type (m.return_type);
+ write_return_type (return_type);
indent--;
write_indent ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]