From: Masao M. <mu...@hi...> - 2002-10-22 10:33:32
|
Hi, > > Ruby/GLib provides cool macros for other libraries which use GObject system. > > They help you. See "How to implement Ruby-GNOME2" on our Website. > > (http://ruby-gnome2.sourceforge.net/howto_gnome.html). > > > > Also many of hints are already existed in Ruby/GLib2 and Ruby/GTK2 source codes. > > It may be better to study some classes in Ruby/GTK2 before you start your project. > > #Especially the classes which inherited GLib::Object, GLib::Boxed directory is helpful. > > > ok, i haven't really dug deep into the whole GLib thing, but i am > wondering why we need things such as GLib::Boxed. i mean when will we > need it in Ruby? GLib::Boxed is apparently for wrapping C structs to > GObjects right? and when is this useful from Ruby? am i missing > something in the abstraction layers here? Good question. But I may be not able to answer well in my poor English ... GLib/GTK+ have three type of C Structure which make GLib/GTK+ classes. #Of course there are some other classes like GSignal, GParamSpec. #But I don't tell about them here. 1. GOBject subclasses - follow GType system. 2. GBoxed subclasses - follow GType system. 3. others - not follow GType system. GLib::Boxed is not GObject. Both of them follow GType system, but the mechanism are quite different. GObject is: - follow GType system. - have properties using GParamSpec. - reference counting. - have some other useful methods. - others:->. GBoxed is: - follow GType system. - don't have parent classes. - provide copy()/free() but not reference counting. So I think we can't merge them in a GObject or GBoxed. We may be able to inherit both of them from common abstract class, but I didn't think it's better way(I thought it was overdoing). ---- 3. others which are not follow GType system We can implement them using Ruby's standard APIs, as Data_Make/Get_Struct. But it is very complicated to implement with GType macros. So we re-implemented these C structs as GBoxed object. (It's very easy. implement copy, free, get_type and G*_TYPE_* macro. See gtk/src/rbgdkgeometry.c and others). The other side, Ruby users viewpoint, GLib::Boxed, GLib::Object both have own methods. Usually it'll be used. But sometimes you may need them. #Usually abstract classes are not used necessarily by user, I think;->. P.S. "GLib::Boxed" may be bad name. Because it isn't native GBoxed only. And general Ruby-GNOME2 users may be not able to understand why they are 'Boxed'. The name may be changed something like "GLib::Data" in the future. However, I think the priority is low for the moment. Cheers, Masao -- .:% Masao Mutoh<mu...@hi...> |