GLib/perl and GArray, GType


I've been using GObject and the GLib perl module to write some
object/relational mapper. Mostly for fun (stop looking at me weird!),
but it's working out quite well.

One thing I'm not very happy about is the way I have to work with
GArrays and GTypes in the XS API. Every time my API returns more than
one object, it uses GArrays to do this (although I'm thinking of
changing that to GLists). As far as I can see in "perldoc Glib::xsapi",
the perl module doesn't do any black magic to make sure that GArrays (or
GLists, or GSLists, or whatever) are automatically converted from and to
perl lists. Is this correct? If so, it's not a huge deal--I can live
with having to allocate an array and deallocate after having converted
it to a perl list, but it would be nice to not have to do this *every
time*. It gets boring :-)

Secondly, "perldoc Glib" suggests that every time you want to use a
GType, the Perl version will be that you use a package name. A
particular part of my API has a property that is a GType; it uses
g_param_spec_gtype(), and this works from C. Unfortunately, the Glib
module doesn't see this; I get errors about "Foo::Bar" not being a valid
integer (despite it having been registered as a GObject package). Is
there any way to make this work, other than an ugly hack of adding a
perl-specific 'foo_bar_get_type_property' sub in the XS file?


Wouter Verhelst
Louizastraat 14, 2800 Mechelen
T: +32 15 27 69 50 / F: +32 15 27 69 51 / M: +32 486 836 198

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