Re: What's a boxed type? (was Re: binding how-to)
- From: muppet <scott asofyet org>
- To: gtk-perl list <gtk-perl-list gnome org>
- Subject: Re: What's a boxed type? (was Re: binding how-to)
- Date: Fri, 15 Aug 2003 22:55:48 -0400
On Friday, August 15, 2003, at 06:33 PM, Joe Smith wrote:
muppet wrote:
...(Some crazy stuff ;-) ...
Cool.
So, Glib provides the abstract class which Gdk/Gtk uses to wrap things
like X or OS structures so the (wrapped) structs can be used by
methods designed to operate on GObjects.
not quite --- it is indeed for use with other people's structures, but
it doesn't wrap them *in* anything, and you can't use GBoxed types
wherever GObjects are expected. there is no actual GBoxed structure,
the type id is separate from the structure. for example, SV is part
of perl, but GType.xs (part of the Glib module) defines a boxed wrapper
for SVs so they can be used as GtkTreeModel column types. (i thought
of using some C code to explain, but it was too big to be useful.)
GObject comes into play by using GValues, which use GBoxed wrappers to
pass C structures around.
for a prime example, a GtkTreeModel stores its data in columns with
specific types. in some instances, the correct thing to do is copy the
value in the column. the treemodel code looks at the type id, and sees
that it's a derivative of G_TYPE_BOXED; then it knows it can copy the
value with g_boxed_copy (typeid, pointer).
Then, on top of that, Gtk2-Perl provides a Perl wrapper, which may be
a simple SV wrapper around a C pointer, or an interface to/from a Perl
hash or array.
yes.
Is that close?
<dumbledore> yes... and no... </dumbledore>
What's the purpose (for Glib now) in providing a generic 'GBoxed'
class over a GObject with the struct attached as user data?
if i understand correctly, you're asking why we use something other
than the GObject wrapping mechanism for perl interface to GBoxed
derivatives.
well... fundamentally, boxed types are not GObjects, so why use the
same wrapper functions to make it look like they are? as for using a
GObject-based wrapper (to implement the vtable-capable wrapper, rather
than to be the binding), the BoxedWrapper is lighter and simpler.
this whole thing is actually rather simple. i fear i've made it far
too complicated in the explanation.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]