From: Philipp Zabel Date: Sun, 27 Sep 2009 20:30:06 +0000 (+0200) Subject: vapigen: Support async attribute for methods X-Git-Tag: 0.7.7~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45a1917ff0c0c322a4347c553a3f354e8bac4176;p=thirdparty%2Fvala.git vapigen: Support async attribute for methods --- diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala index f133bf69e..62dd43459 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;