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

Re: [Libguestfs] [PATCH] Non-working support for GObject Introspection.



On Tue, Mar 16, 2010 at 02:42:27PM +0000, Richard W.M. Jones wrote:
> +GObject Introspection bindings
> +------------------------------
> +
> +Although we add the necessary annotations for GObject Introspection to
> +the <guestfs*.h> header files, we have not yet had satisfactory
> +results using them.
> +
> +In theory this should allow you to call libguestfs from languages
> +which we don't yet support, notably Javascript (using GJS or Seed).
> +
> +Here is how you can build the GIR bindings.  First you have to build
> +libguestfs normally, then:
> +
> +  cd gir
> +  g-ir-scanner -n Guestfs --nsversion 0.0 \
> +    -L ../src/.libs -lguestfs \
> +    ../src/guestfs.h > Guestfs-0.0.gir
> +  g-ir-compiler Guestfs-0.0.gir > Guestfs-0.0.typelib
> +
> +If that went OK, then copy 'Guestfs-0.0.typelib' into the public
> +directory '/usr/lib{,64}/girepository-1.0/' (or you can make a symlink
> +which works just as well).
> +
> +In theory you should be able to use this immediately from gjs-console:
> +
> +  LIBGUESTFS_DEBUG=1 gjs-console
> +  gjs> const Guestfs = imports.gi.Guestfs;
> +  gjs> g = Guestfs.create ();
> +
> +Currently this gives the following error:
> +
> +  new guestfs handle 0x2537d00
> +  Error: No exception was set, but object construction failed somehow
> +
> +Because the 'new guestfs handle 0x..' debug message was printed, we
> +know in fact that construction succeeded!
> +
> +It seems we need to "register" the guestfs_h handle with GObject.  I
> +can't get any straight answer to how that would be done.

GObject is the primary root object, but things don't neccessarily need
to inherit from GObject. Since you're trying to directly expose libguestfs'
own object(s) you'll probably need to register them as base types  using
the GType APIs. This section of the API docs gives a semi-useful intro to
GTypes

  http://library.gnome.org/devel/gobject/stable/chapter-gtype.html

Ultimately this comes down to a call to g_type_register_static()

  http://library.gnome.org/devel/gobject/stable/gobject-Type-Information.html#g-type-register-static

but it is not very well documented because 99% of apps just inherit
from GObject instead of introducing new base types like libguestfs
would need todo.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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