Re: g_type_query necessary



On Saturday, September 16, 2000 at 15:20, Owen Taylor wrote:
> > A g_type_query (as in gtk_type_query) is necessary for the Java bindings
> > of GTK+. This is because the size of a class is used when replacing the
> > class structure (to allow subclassing).
> 
> (Though I don't really understand how you can subclass the class
> structure very well without knowing details about the class like where
> the function pointers for the virtual functions are.) 

I know those details, at least they are hard-coded into the Java
classes. Using something like sizeof(GtkXXXClass) is probably not
good, since some Gtk classes may store extra data outside the
class struct (yielding class_size != sizeof(GtkXXXClass)).

By the way, I am assuming that once you know the class size, you
can do something like this

  GObject* obj;
  GTypeClass* oldclass = obj->g_type_instance->g_class;
  GTypeClass* newclass = g_malloc(class_size);

  memcpy(newclass, oldclass, class_size);
  obj->g_type_instance->g_class = newclass;

without creating a new type for the class. Is this OK?

Oskar Liljeblad (osk hem passagen se)




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