[Vala] Async constructors



How do I use async constructors?

Take for example, the relatively recent DBusProxy.for_bus [1].  I do
the following:

DBusProxy obj = yield new DBusProxy.for_bus(BusType.SESSION, ...

but all I get is:

Operation.vala:222.33-222.41: error: syntax error, expected `('
      DBusProxy obj = yield new DBusProxy.for_bus(BusType.SESSION, ...
                                ^^^^^^^^^

Without the "yield", I get a C-compilor error (valac tries to use
non-async function arguments):

Operation.c: In function ‘deja_dup_operation_set_session_inhibited_co’:
Operation.c:720: warning: passing argument 8 of
‘g_dbus_proxy_new_for_bus’ from incompatible pointer type
/usr/include/glib-2.0/gio/gdbusproxy.h:109: note: expected
‘GAsyncReadyCallback’ but argument is of type ‘struct GError **’
Operation.c:720: error: too few arguments to function ‘g_dbus_proxy_new_for_bus’
make: *** [Operation.lo] Error 1


How is this syntax supposed to look?


[1] Defined in gio-2.0.vapi:
[CCode (type = "void", has_construct_function = false)]
public async DBusProxy.for_bus (GLib.BusType bus_type,
GLib.DBusProxyFlags flags, GLib.DBusInterfaceInfo info, string name,
string object_path, string interface_name, GLib.Cancellable?
cancellable = null) throws GLib.Error;


-mt

P.S. "GLib.DBusInterfaceInfo info" should be allow-none.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]