On Sat, 04 Sep 2004 00:39:27 +1000, Russell Shaw <rjshaw netspace net au> wrote:
I understand that, and is what i do. What i mean is that most
objects do in class_init something like:
gobject_class->dispose=myobject_dispose;
But this makes the original dispose code in gobject
inaccessible. Same for gobject_class->dispose=myobject_finalize.
That assignment isn't overwriting gobject's dispose, it's setting the
gobject dispose for this class. If you have a class called myclass
derived from gobject, then that class has two ->dispose() function
pointers: the standard gobject one, and the one you set. That's
because every time you make a class, you get a fresh copy of every
class above this one in the inheritance hierarchy.
Classes and class instances don't behave the same. When you make a
class instance, you are building a single big, overlapping struct. You
can override things in your parent classes.
When you derive a new class, you build a lot of structs: one for each
class in the hierarchy. When you chain up at the end of dispose,
you're jumping up one struct in this pile of structs.