Re: gtype introspection
- From: Tim Janik <timj gtk org>
- To: Matthias Clasen <maclas gmx de>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: gtype introspection
- Date: Sun, 20 Oct 2002 01:30:01 +0200 (CEST)
On 20 Oct 2002, Matthias Clasen wrote:
> On Wed, 2002-10-16 at 15:52, Tim Janik wrote:
> > On Tue, 15 Oct 2002, Owen Taylor wrote:
> >
> > >
> > > Matthias Clasen <maclas gmx de> writes:
> > >
> > > > I'm currently looking into making gtk-doc emit more information about
> > > > the type hierarchy and found that some things are simply not available
> > > > at all. E.g. there seems to be no way to find the prerequisites of an
> > > > interface. Ok to add the following ?
> > >
> > > Looks fine to me. I wouldn't necessarily name it or design
> > > it this way on its own, but it does look like you've done it
> > > in the way that is most consistent with what is already there.
> > > (g_type_children(), g_type_interface_peek_parent()).
> >
> > the patch looks good to me. matthias, did you actually give it some testing?
>
> Well, looking closer I found prerequisites *are* used in gtk, e.g. in
> GtkCellEditable. This allowed me to quickly verify that
> g_type_interface_prerequisites does work. But I was a bit surprised to
> see GtkCellEditable report GObject, GtkObject and GtkWidget as
> prerequisites when only GtkWidget is explicitly added as a prerequisite.
> Why is it necessary to add all supers of an instantiatable type to the
> prerequisites when the type itself is added ? It looks a bit confusing
> to list all three as prerequisites in the docs for GtkCellEditable and
> manually removing redundant supers from the prerequisites in gtk-doc
> does not sound like the right solution...
it is. as for why the code does this, a check like "does iface foo conform
to GtkObject" on an iface foo having GtkWidget as prerequisite couldn't be
implemented as binary search if all supers of GtkWidget are not added to the
prerequisite list.
the deduping should however be implemented in gtype.c. you need something
like this to fill the returned type array with prerequisite types:
TypeNode *inode = NULL;
guint i, n = 0;
for (i = 0; i < n_prerequisites; i++)
{
TypeNode *node = lookup_type_node_I (prerequisites[i]);
if (node->is_instantiatable &&
(!inode || type_node_is_a_L (node, inode)))
inode = node;
else
types[n++] = NODE_TYPE (node);
}
if (inode)
types[n++] = NODE_TYPE (inode);
n is the amount of returned types and <= n_prerequisites and a read
lock must be held around the code.
>
> Matthias
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]