|
From: Kevin S. <kev...@ho...> - 2001-08-17 15:43:16
|
On Fri, 17 Aug 2001, Takaaki Tateishi wrote:
> I see. you think about making the class like:
>
> class RBFl_Xxxx : Fl_Xxxx {
> public:
> VALUE rb_object;
> ....
> }
Exactly.
> and making the structure for the Ruby class,
>
> struct rb_fl_data {
> RBFl_Xxxxx *widget;
> }
I'm not sure what we would store in *widget. RBFI_Xxxx already contains a
pointer to the C++ object (this). Unless you mean to store the passed
callback data here, but I would store that as a void* or long.
> > 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.
That's good. I'm still learning about how ruby manages memory. But I'm
still not sure that the rb_fl_data struct need to own anything. Also, is
there a difference between keeping a copy of a VALUE and being the one who
allocates it? In ruby, I don't think there really is, but I'm not sure.
One other note: I'm not really happy with RBFl_ as a prefix. I would much
prefer one of the following, as they seem more consistent:
1. RBFL_Xxx
2. RubyFltkXxx
Personally, I dislike underscores, but I realize they're the standard in
both ruby AND in FLTK. So I like #2, but probably #1 would be better.
Kevin
|