From: Lyle J. <ly...@kn...> - 2004-04-07 23:16:02
|
On Apr 4, 2004, at 3:25 PM, meinrad recheis wrote: > i studied the FXRuby src and interfaces, because i am going to wrap > some C++ modules derived from Fox classes for ruby. OK. > i am quite new to "wrapping" and SWIG so i would like to ask you the > things that the SWIG docu left unclear to me: > > * why did you prefer writing whole "shadow classes" (i.e FXRbGLCanvas > for FXGLCanvas) rather than using SWIG's typemaps? > * the /FX*Virtuals/ confuse me; why is "re-declaration" of virtual > functions necessary? Both of these are for the same fundamental reason: I wanted the Ruby programmer to be able to override the virtual functions declared in C++ base classes. For example, if you subclass FXMainWindow to make your own main window class: class MyMainWindow < FXMainWindow end and then override the base class create() method with one of your own: def create super puts "Here I am, in MyMainWindow#create!" end this should work exactly as it would in the corresponding C++ code. That is, if you were to construct an instance of your main window class and then call the application's create() method: myMainWin = MyMainWindow.new(theApp, ...) theApp.create It should land in your overridden version of create() instead of FXMainWindow#create. As of the latest SWIG development versions, this capability is built-in using the so-called "director classes" feature; but it was not available in SWIG when I first started developing FXRuby several years ago. Hope this helps, Lyle |