On Fri, Jan 20, 2012 at 12:07:47PM +0000, Matthew Booth wrote:
There are a couple of points in here I'm still not 100% happy
with.
Specifically the handling of FBuffer and the Cancellable flag. Both
are explained below. I'm interested in suggestions.
A parallel struct is created for each libguestfs struct type. A
boxed type is created for each parallel struct. It's field types are
all mapped trivially to gobject basic types (e.g. gchar *, gint32)
except FBuffer. FBuffer is mapped as:
guint8 *<field>
guint32 <field>_size
Unfortunately I can see no way to attach annotation to these fields,
so the bindings do not appreciate that these fields are related. I'm
not happy with this at all, so I may try manual tweaking of the .gir
to see if we can turn these into a single returned array where
possible.
Those two fields look just like GByteArray
struct GByteArray {
guint8 *data;
guint len;
};
Can you just outpout that - I expect bindings will already know
how to deal with that.
Cancellation:
*************
Certain apis are cancellable. These all take a GCancellable as the
final argument before GError **. This can be passed NULL if
cancellation is not required. While I have written cancellation, I
have not yet tested it *at all* other than it compiles and works
correctly when NULL is passed in.
We recently made Cancellable an explicit flag whereas before it was
implicit if the api had a FileIn or FileOut argument. This means it
is now possible to break the GObject api without breaking the C api
with the addition of a Cancellable flag. What potential solutions
are there to this problem? I can see:
• Live with breaking the GObject api if it ever comes up.
• Never add Cancellable to an existing api.
• Automatically add a GCancellable argument to all GObject apis,
just in case.
I think option 2 is the only long term viable approach. If any existing
APIs needs to be made cancellable, then define a new API that is the
same, but with the cancellable flag set.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|