On Tue, 21 Mar 2017 20:53:04 +0000
Emmanuele Bassi <eba...@gmail.com> wrote:

> 
> Also, do not store a private pointer in your instance structure, and
> use the get_private_instance() function that the G_DEFINE_TYPE macro
> creates for you.
> 
So you say whenever I need access to the objects private data I should
call G_TYPE_INSTANCE_GET_PRIVATE, despite the mentioned overhead?

> The GObject tutorial has a good introduction on how to define types
> and how to use them.
> 
Indeed. It took me a while to walk through it. However, the example
given in [3] has the comment /* Other members, including private data.
*/, which would contradict your opinion, or is at least a bit unclear,
because final and derivable types are handled a bit differently.

[3] https://developer.gnome.org/gobject/stable/howto-gobject-code.html

> Ciao,
>  Emmanuele.
> On Tue, 21 Mar 2017 at 19:57, Nicola Fontana <n...@entidi.it> wrote:
> 
> >
> > the lookup indeed is quite expensive, and looking at the
> > implementation [1] it is not that straightforward.
> >
> > The very same example provided by the official documentation [2]
> > caches that pointer into the instance struct.
> >
> > [1] https://git.gnome.org/browse/glib/tree/gobject/gtype.c#n4709
> > [2]
> > https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#g-type-class-add-private
> >
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to