From: Takaaki T. <tt...@ja...> - 2001-08-17 09:40:51
|
At Thu, 16 Aug 2001 23:47:48 -0700, > No, wait. I just remembered that we're thinking of creating our own wrapper > class for each FLTK C++ class. We can add a local member variable there > that contains the ruby object. No hash table needed, and simpler memory > management. I see. you think about making the class like: class RBFl_Xxxx : Fl_Xxxx { public: VALUE rb_object; .... } and making the structure for the Ruby class, struct rb_fl_data { RBFl_Xxxxx *widget; } and we can create ruby objects using Data_Make_Struct macro like: struct rb_fl_data *data; VALUE rb_cFl_Xxxxx = rb_define_class("ClassName"); VALUE obj = Data_Make_Struct(rb_cFl_Xxxx, ...., data); data->widget = new RBFl_Xxxxx(....); data->widget->rb_object = obj; now we can obtain the ruby object `obj'. Is this right? > We could also store callback data there. But as I mentioned, I think > there's value in keeping the C++ code to a minimum, and doing as much as we > can in ruby. I think it is also possible. but I heard that it is not recommended that VALUE data is owned by the structure like `rb_fl_data' and class `RBFl_Xxxx'. if we adopt such mechanism, we would carefully deal with the both of the ruby object and C++ object. I will ask some ruby developers this issues. -- Takaaki Tateishi <tt...@ja...> |