Re: [Vala] vapigen omitting arguments



On Wed, 2012-01-25 at 08:50 +0100, tomw wrote:
Hi folks,

after digging deeper into the issue last night it really seems that
vapigen does not create the vapi file correctly. As the gir [1] works
without any issues from Python I would assume that the definitions
therein are correct. As stated in my previous post, vapigen is omitting
some arguments in the gfreenect_device_new method [2]. Adding them
manually according to the gfreenect-device header like:

public async Device (int device_index, uint subdevices,
GLib.Cancellable? cancellable, GLib.AsyncReadyCallback callback);

Vala does not yet support asynchronous constructors. See
https://bugzilla.gnome.org/show_bug.cgi?id=659886

Also, the GAsyncReadyCallback argument really shouldn't be there. If
that's the argument you're talking about adding manually vapigen is
right to omit it.

does not fix the issue as I get the compiler errors in [3]:

gf_test.vala.c:63:9: error: void value not ignored as it ought to be
error: cc exited with status 256

What am I missing here? Any idea on how to tackle the issue would be
highly appreciated.

There are two relatively straightforward workarounds for this. The first
option is to use a *-custom.vala file to create an asynchronous static
method... something like

public static async GFreenect.Device @new (int device_index, uint
subdevices, GLib.Cancellable? cancellable);

This trick is used a few times in the GIO bindings.

The other option is to just circumvent this constructor by calling
GLib.Object.new directly. You can even initialize the struct
asynchronously (using GLib.AsyncInitable.init_async) if you want.
Something like this should do the trick:

GFreenect.Device device = (GFreenect.Device) GLib Object  new (typeof
(GFreenect.Device), "device-index", device_index, "subdevices",
subdevices);
yield device.init_async (priority, cancellable);

The code may not be as elegant but you don't have to modify the
bindings. Also, at least you have the option of creating the instance
synchronously.


-Evan




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