How does GLib-Gobject to create an object?



This more a conceptually question than a practical question.
I Know to work with GObject (I guess), the problem is that I am not  sure how GLib creates de instance and the class.
I can image the instances like a boxes one insade others, but my problem is with the classes.
I have been looking at the source code of gtype.c/h and gtobject.c/h but I lose me in it.

If I write this:

struct _Docum{
GObject parent;
gint code;
gchar *author;
gchar *descrip;
};

struct _DocumClass{
GObjectClass parent;
};

and knowing that:

struct  _GObject
{
  GTypeInstance g_type_instance;
...
};
struct  _GObjectClass
{
  GTypeClass   g_type_class;
...
};

and:

struct _GTypeClass
{
  GType g_type;
};
struct _GTypeInstance
{
  GTypeClass *g_class;
};

When I create a new Docum object, GLib creates a structure Docum, it's first file is a GObject structure, it's firts field is a GTypeInstace structure, that it isn't more than a number that represents the GType for DocumClass.
My problem begins now, how does GLib to create the class structures? from top to bottom classes?
It first create an DocumClass struct, it's first field is a GObjectClass struct, it's first field is a GTypeClass struct? I don't know?


Thanks.

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