Two patches here: First one removes virtual from a function that shouldn''t have been virtual. Second one applies a typemap to catch GetRectFromChildWindow. For reasons that are completely beyond me the standard ruby OUTPUT typemaps don''t define directorargouts. I will take a stab at patching SWIG''s default typemaps someday so we get this fixed for free on all our OUTPUT typemaps. Roy _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Committed, thanks. For reference, does directorargout apply to any method called on a director? Or methods which return director instances? The ruby SWIG docs are pretty thin on this topic... alex Roy Sutton wrote:> Two patches here: > > First one removes virtual from a function that shouldn''t have been > virtual. > > Second one applies a typemap to catch GetRectFromChildWindow. For > reasons that are completely beyond me the standard ruby OUTPUT > typemaps don''t define directorargouts. I will take a stab at patching > SWIG''s default typemaps someday so we get this fixed for free on all > our OUTPUT typemaps. > > Roy > ------------------------------------------------------------------------ > > Index: wxruby2/swig/classes/include/wxWindow.h > ==================================================================> --- wxruby2/swig/classes/include/wxWindow.h (revision 574) > +++ wxruby2/swig/classes/include/wxWindow.h (working copy) > @@ -446,7 +446,7 @@ > * \param int* > */ > > - virtual void GetPosition(int* x , int* y ) const; > + void GetPosition(int* x , int* y ) const; > /** > * \brief This gets the position of the window in pixels, relative to the parent window > for the child windows or relative to the display origin for the top level > > ------------------------------------------------------------------------ > > Index: wxruby2/swig/typemap.i > ==================================================================> --- wxruby2/swig/typemap.i (revision 574) > +++ wxruby2/swig/typemap.i (working copy) > @@ -454,3 +454,15 @@ > %typemap(out) wxSystemMetric { > $result = INT2NUM((int)$1); > } > + > +%apply int *OUTPUT { int * x , int * y , int * w, int * h }; > + > +%typemap(directorargout) ( int * x , int * y , int * w, int * h ) { > + if((TYPE(result) == T_ARRAY) && (RARRAY(result)->len == 4)) > + { > + *$1 = ($*1_ltype)NUM2INT(rb_ary_entry(result,0)); > + *$2 = ($*2_ltype)NUM2INT(rb_ary_entry(result,1)); > + *$3 = ($*3_ltype)NUM2INT(rb_ary_entry(result,2)); > + *$4 = ($*4_ltype)NUM2INT(rb_ary_entry(result,3)); > + } > +} > > ------------------------------------------------------------------------ > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users
Alex Fenton wrote:> For reference, does directorargout apply to any method called on a > director? Or methods which return director instances? The ruby SWIG docs > are pretty thin on this topic... >Pretty thin is generous. directorargout puts code after the internal call to a ruby function (when it''s called back from either C or ruby) to handle any ''argument'' ''out''puts. It''s required on pretty much every function that returns something through a pointer argument. Unwrapped pointers will work OK because the underlying SWIG wrapper just passes them through as the pointer type and we can''t (generally) call them from Ruby. The big issue arises when we muck with the returns, like putting them into a list. Roy
Roy, Thanks for the fix, I can finally run the Big demo again on OS X. This was one of the most annoying bugs for me. Sean On 9/20/06, Roy Sutton <roys at mindspring.com> wrote:> Alex Fenton wrote: > > For reference, does directorargout apply to any method called on a > > director? Or methods which return director instances? The ruby SWIG docs > > are pretty thin on this topic... > > > Pretty thin is generous. directorargout puts code after the internal > call to a ruby function (when it''s called back from either C or ruby) to > handle any ''argument'' ''out''puts. It''s required on pretty much every > function that returns something through a pointer argument. Unwrapped > pointers will work OK because the underlying SWIG wrapper just passes > them through as the pointer type and we can''t (generally) call them from > Ruby. The big issue arises when we muck with the returns, like putting > them into a list. > > Roy > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >