From: Kevin Smith Date: 2001-11-30T02:40:47+09:00 Subject: [ruby-talk:26941] Interfacing to a C++ library (was: overload possible?) --- ts wrote: > >>>>> "Y" == Yee Keat writes: > > Y> Hehe, sorry, yeah, thats the package that I downloaded > and played around with > Y> when I say I played around with Ruby/QT, but still it > contains some > Y> complications and the two actually doesn't interface > cleanly. > > You have another example in the interface to fltk I was surprised at how difficult it was to write a clean wrapper to a C++ library. It's not that Ruby itself makes it hard. It's that you have two inheritance trees--one in C++ and another in Ruby. For example, you might have a C++ Widget, and Button which inherits from Widget. Now on the Ruby side, you want a Ruby Widget that inherits from the C++ Widget, and you want a Ruby Button that inherits from the C++ Button, BUT ALSO inherits from the Ruby Button. At least with FLTK, this was necessary because we wanted people to be able to extend the Ruby Widget class and have it affect Ruby Button. But we also wanted the Ruby Button event handler to be able to invoke 'super' and have it route to the C++ Button default handler. We discussed several possible ways to structure the code, and internally it ended up being fairly weird. But, I think we were able to hide the weirdness from people who just use Ruby/FLTK. Hopefully, from the outside, it just works. Kevin __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1