Re: Best practise inheritance
- From: "S. Jacobi" <sjacobi mailueberfall de>
- To: gtk-app-devel-list gnome org
- Subject: Re: Best practise inheritance
- Date: Tue, 21 Mar 2017 18:27:42 +0100
On Mon, 20 Mar 2017 16:01:39 +0000
Tristan Van Berkom <tristan vanberkom codethink co uk> wrote:
Use instance private data, this will not need any priv pointer and
can be done with th G_DEFINE_TYPE_WITH_PRIVATE() macro, and another
to lookup your private data inside your C file (under the hood, this
uses negative instance offsets with power nter arithmatic, so public
and private data are on the same allocated memory slice)
This is still a bit unclear to me, because I found no good reference
what instance private data really is, apart from a patch on the mailing
list. So is it just GObject "magic" that puts private fields into
special memory locations and can therefore retain ABI compatibility?
Because from what I read, I define my structs the same way.
struct _MyType
{
GtkWidget parent;
MyTypePriv *priv;
}
G_DEFINE_TYPE (MyType, my_type, GTK_TYPE_WIDGET)
and
struct _MyType
{
GtkWidget parent;
MyTypePriv *priv;
}
G_DEFINE_TYPE_WITH_PRIVATE (MyType, my_type, GTK_TYPE_WIDGET)
would be first a struct with "normal" private data and second a struct
with instance private data. Or am I completely on the wrong track here?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]