[vala] vapigen: Support async attribute for methods
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] vapigen: Support async attribute for methods
- Date: Sun, 27 Sep 2009 20:31:36 +0000 (UTC)
commit 45a1917ff0c0c322a4347c553a3f354e8bac4176
Author: Philipp Zabel <philipp zabel gmail com>
Date: Sun Sep 27 22:30:06 2009 +0200
vapigen: Support async attribute for methods
vapigen/valagidlparser.vala | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index f133bf6..62dd434 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -1152,7 +1152,13 @@ public class Vala.GIdlParser : CodeVisitor {
void handle_async_methods (ObjectTypeSymbol type_symbol) {
foreach (Method m in type_symbol.get_methods ()) {
if (m.coroutine) {
- var finish_method = type_symbol.scope.lookup (m.name.substring (0, m.name.length - "_async".length) + "_finish") as Method;
+ string finish_method_base;
+ if (m.name.has_suffix ("_async")) {
+ finish_method_base = m.name.substring (0, m.name.length - "_async".length);
+ } else {
+ finish_method_base = m.name;
+ }
+ var finish_method = type_symbol.scope.lookup (finish_method_base + "_finish") as Method;
if (finish_method != null) {
m.return_type = finish_method.return_type.copy ();
foreach (var param in finish_method.get_parameters ()) {
@@ -1524,6 +1530,11 @@ public class Vala.GIdlParser : CodeVisitor {
}
} else if (nv[0] == "vfunc_name") {
m.vfunc_name = eval (nv[1]);
+ } else if (nv[0] == "async") {
+ if (eval (nv[1]) == "1") {
+ // force async function, even if it doesn't end in _async
+ m.coroutine = true;
+ }
}
}
}
@@ -1562,7 +1573,7 @@ public class Vala.GIdlParser : CodeVisitor {
}
}
- if (param type interface == "GAsyncReadyCallback" && symbol.has_suffix ("_async")) {
+ if (param type interface == "GAsyncReadyCallback" && (symbol.has_suffix ("_async") || m.coroutine)) {
// async method
m.coroutine = true;
continue;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]