Wow. Look what SWIG does to GetTextExtent in Grid.cpp: void SwigDirector_wxGrid::GetTextExtent(wxString const &string, int *x, int *y, int *descent, int *externalLeading, wxFont const *font) const { ... if (swig_get_up()) { wxWindow::GetTextExtent(string,x,y,descent,externalLeading,font); return; } obj0 = rb_str_new2((const char *)(&string)->mb_str()); obj1 = SWIG_NewPointerObj(x, SWIGTYPE_p_int, 0); result = rb_funcall(swig_get_self(), rb_intern("get_text_extent"), 2,obj0,obj1); Wow. That''s just so wrong. It only converts two parameters and the one it chooses to convert shouldn''t be passed in any case. Any suggestions on this one? Roy
Roy Sutton wrote:> Wow. Look what SWIG does to GetTextExtent in Grid.cpp:> obj0 = rb_str_new2((const char *)(&string)->mb_str()); > obj1 = SWIG_NewPointerObj(x, SWIGTYPE_p_int, 0); > result = rb_funcall(swig_get_self(), rb_intern("get_text_extent"), > 2,obj0,obj1); > > Wow. That''s just so wrong. It only converts two parameters and the one > it chooses to convert shouldn''t be passed in any case. Any suggestions > on this one?It does the same thing in Window (where GetTextExtent is defined). I suspect we need a directorout typemap here, to "remind" SWIG what we already told it about this method signature. Kevin
Roy or Kevin. Have you gotten the GetTextExtent problem worked out? I am running up against it in a program I am writting and need to fix it but don''t want to repeat any completed work. Sean On 10/9/05, Kevin Smith <wxruby at qualitycode.com> wrote:> Roy Sutton wrote: > > Wow. Look what SWIG does to GetTextExtent in Grid.cpp: > > > obj0 = rb_str_new2((const char *)(&string)->mb_str()); > > obj1 = SWIG_NewPointerObj(x, SWIGTYPE_p_int, 0); > > result = rb_funcall(swig_get_self(), rb_intern("get_text_extent"), > > 2,obj0,obj1); > > > > Wow. That''s just so wrong. It only converts two parameters and the one > > it chooses to convert shouldn''t be passed in any case. Any suggestions > > on this one? > > It does the same thing in Window (where GetTextExtent is defined). > > I suspect we need a directorout typemap here, to "remind" SWIG what we > already told it about this method signature. > > Kevin > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >
I don''t have it fixed yet. Sean Long wrote:> Roy or Kevin. > > Have you gotten the GetTextExtent problem worked out? I am running up > against it in a program I am writting and need to fix it but don''t > want to repeat any completed work. > > Sean > > > On 10/9/05, Kevin Smith <wxruby at qualitycode.com> wrote: > >> Roy Sutton wrote: >> >>> Wow. Look what SWIG does to GetTextExtent in Grid.cpp: >>> >>> obj0 = rb_str_new2((const char *)(&string)->mb_str()); >>> obj1 = SWIG_NewPointerObj(x, SWIGTYPE_p_int, 0); >>> result = rb_funcall(swig_get_self(), rb_intern("get_text_extent"), >>> 2,obj0,obj1); >>> >>> Wow. That''s just so wrong. It only converts two parameters and the one >>> it chooses to convert shouldn''t be passed in any case. Any suggestions >>> on this one? >>> >> It does the same thing in Window (where GetTextExtent is defined). >> >> I suspect we need a directorout typemap here, to "remind" SWIG what we >> already told it about this method signature. >> >> Kevin >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> >> > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > >
I also have not worked on it more, and won''t be able to for at least a few days. Hopefully you can fix it with one directorout typemap. Kevin Roy Sutton wrote:> I don''t have it fixed yet. > > Sean Long wrote: > >>Roy or Kevin. >> >>Have you gotten the GetTextExtent problem worked out? I am running up >>against it in a program I am writting and need to fix it but don''t >>want to repeat any completed work. >> >>Sean >> >> >>On 10/9/05, Kevin Smith <wxruby at qualitycode.com> wrote: >> >> >>>Roy Sutton wrote: >>> >>> >>>>Wow. Look what SWIG does to GetTextExtent in Grid.cpp: >>>> >>>> obj0 = rb_str_new2((const char *)(&string)->mb_str()); >>>> obj1 = SWIG_NewPointerObj(x, SWIGTYPE_p_int, 0); >>>> result = rb_funcall(swig_get_self(), rb_intern("get_text_extent"), >>>>2,obj0,obj1); >>>> >>>>Wow. That''s just so wrong. It only converts two parameters and the one >>>>it chooses to convert shouldn''t be passed in any case. Any suggestions >>>>on this one? >>>> >>> >>>It does the same thing in Window (where GetTextExtent is defined). >>> >>>I suspect we need a directorout typemap here, to "remind" SWIG what we >>>already told it about this method signature. >>> >>>Kevin >>>_______________________________________________ >>>wxruby-users mailing list >>>wxruby-users at rubyforge.org >>>http://rubyforge.org/mailman/listinfo/wxruby-users >>> >>> >> >>_______________________________________________ >>wxruby-users mailing list >>wxruby-users at rubyforge.org >>http://rubyforge.org/mailman/listinfo/wxruby-users >> >> >> >> > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users
One directorout does not fix it. I was just looking over the typemaps and wondering if these typemaps are causing the problem, they are part of the GetTextExtent signature. %typemap(in,numinputs=0) (int * x , int * y , int * descent, int * externalLeading) (int a, int b, int c, int d) { $1=&a; $2=&b; $3=&c; $4=&d; } %typemap(argout) (int * x , int * y , int * descent, int * externalLeading) { $result = rb_ary_new(); rb_ary_push($result, INT2NUM(*$1)); rb_ary_push($result, INT2NUM(*$2)); rb_ary_push($result, INT2NUM(*$3)); rb_ary_push($result, INT2NUM(*$4)); } I will look into it. Sean On 10/11/05, Kevin Smith <wxruby at qualitycode.com> wrote:> I also have not worked on it more, and won''t be able to for at least a > few days. > > Hopefully you can fix it with one directorout typemap. > > Kevin > > Roy Sutton wrote: > > I don''t have it fixed yet. > > > > Sean Long wrote: > > > >>Roy or Kevin. > >> > >>Have you gotten the GetTextExtent problem worked out? I am running up > >>against it in a program I am writting and need to fix it but don''t > >>want to repeat any completed work. > >> > >>Sean > >> > >> > >>On 10/9/05, Kevin Smith <wxruby at qualitycode.com> wrote: > >> > >> > >>>Roy Sutton wrote: > >>> > >>> > >>>>Wow. Look what SWIG does to GetTextExtent in Grid.cpp: > >>>> > >>>> obj0 = rb_str_new2((const char *)(&string)->mb_str()); > >>>> obj1 = SWIG_NewPointerObj(x, SWIGTYPE_p_int, 0); > >>>> result = rb_funcall(swig_get_self(), rb_intern("get_text_extent"), > >>>>2,obj0,obj1); > >>>> > >>>>Wow. That''s just so wrong. It only converts two parameters and the one > >>>>it chooses to convert shouldn''t be passed in any case. Any suggestions > >>>>on this one? > >>>> > >>> > >>>It does the same thing in Window (where GetTextExtent is defined). > >>> > >>>I suspect we need a directorout typemap here, to "remind" SWIG what we > >>>already told it about this method signature. > >>> > >>>Kevin > >>>_______________________________________________ > >>>wxruby-users mailing list > >>>wxruby-users at rubyforge.org > >>>http://rubyforge.org/mailman/listinfo/wxruby-users > >>> > >>> > >> > >>_______________________________________________ > >>wxruby-users mailing list > >>wxruby-users at rubyforge.org > >>http://rubyforge.org/mailman/listinfo/wxruby-users > >> > >> > >> > >> > > > > > > _______________________________________________ > > wxruby-users mailing list > > wxruby-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/wxruby-users > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >
Ok. I got it working by doing the following: - comment out the two typemaps in last message - add the following directorout typemaps (not sure if they are actually needed, I believe the two typemaps that I commented out were the problem) %typemap(directorout) wxString { $result = wxString(STR2CSTR($1), wxConvUTF8); } %typemap(directorout) const wxString& { $result = new wxString(STR2CSTR($1), wxConvUTF8); } Now the question is do we need the two type maps that I commented out? I did a quick search and could not find what they were for. Also when I have a patch ready do you want it for darcs or cvs? Sean On 10/11/05, Sean Long <sean.m.long at gmail.com> wrote:> One directorout does not fix it. > > I was just looking over the typemaps and wondering if these typemaps > are causing the problem, they are part of the GetTextExtent signature. > > %typemap(in,numinputs=0) (int * x , int * y , int * descent, int * > externalLeading) (int a, int b, int c, int d) { > $1=&a; > $2=&b; > $3=&c; > $4=&d; > } > > %typemap(argout) (int * x , int * y , int * descent, int * externalLeading) { > $result = rb_ary_new(); > rb_ary_push($result, INT2NUM(*$1)); > rb_ary_push($result, INT2NUM(*$2)); > rb_ary_push($result, INT2NUM(*$3)); > rb_ary_push($result, INT2NUM(*$4)); > } > > I will look into it. > > Sean > > On 10/11/05, Kevin Smith <wxruby at qualitycode.com> wrote: > > I also have not worked on it more, and won''t be able to for at least a > > few days. > > > > Hopefully you can fix it with one directorout typemap. > > > > Kevin > > > > Roy Sutton wrote: > > > I don''t have it fixed yet. > > > > > > Sean Long wrote: > > > > > >>Roy or Kevin. > > >> > > >>Have you gotten the GetTextExtent problem worked out? I am running up > > >>against it in a program I am writting and need to fix it but don''t > > >>want to repeat any completed work. > > >> > > >>Sean > > >> > > >> > > >>On 10/9/05, Kevin Smith <wxruby at qualitycode.com> wrote: > > >> > > >> > > >>>Roy Sutton wrote: > > >>> > > >>> > > >>>>Wow. Look what SWIG does to GetTextExtent in Grid.cpp: > > >>>> > > >>>> obj0 = rb_str_new2((const char *)(&string)->mb_str()); > > >>>> obj1 = SWIG_NewPointerObj(x, SWIGTYPE_p_int, 0); > > >>>> result = rb_funcall(swig_get_self(), rb_intern("get_text_extent"), > > >>>>2,obj0,obj1); > > >>>> > > >>>>Wow. That''s just so wrong. It only converts two parameters and the one > > >>>>it chooses to convert shouldn''t be passed in any case. Any suggestions > > >>>>on this one? > > >>>> > > >>> > > >>>It does the same thing in Window (where GetTextExtent is defined). > > >>> > > >>>I suspect we need a directorout typemap here, to "remind" SWIG what we > > >>>already told it about this method signature. > > >>> > > >>>Kevin > > >>>_______________________________________________ > > >>>wxruby-users mailing list > > >>>wxruby-users at rubyforge.org > > >>>http://rubyforge.org/mailman/listinfo/wxruby-users > > >>> > > >>> > > >> > > >>_______________________________________________ > > >>wxruby-users mailing list > > >>wxruby-users at rubyforge.org > > >>http://rubyforge.org/mailman/listinfo/wxruby-users > > >> > > >> > > >> > > >> > > > > > > > > > _______________________________________________ > > > wxruby-users mailing list > > > wxruby-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/wxruby-users > > > > _______________________________________________ > > wxruby-users mailing list > > wxruby-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/wxruby-users > > >
Sean Long wrote:> Ok. I got it working by doing the following: > > - comment out the two typemaps in last message > - add the following directorout typemaps (not sure if they are > actually needed, I believe the two typemaps that I commented out were > the problem)I suspect you are correct. Please test without these new wxString directorout typemaps, and omit them from a patch if they are not needed.> Now the question is do we need the two type maps that I commented out? > I did a quick search and could not find what they were for.>>%typemap(in,numinputs=0) (int * x , int * y , int * descent, int * >>externalLeading) (int a, int b, int c, int d) { >> $1=&a; >> $2=&b; >> $3=&c; >> $4=&d; >>} >> >>%typemap(argout) (int * x , int * y , int * descent, int * externalLeading) { >> $result = rb_ary_new(); >> rb_ary_push($result, INT2NUM(*$1)); >> rb_ary_push($result, INT2NUM(*$2)); >> rb_ary_push($result, INT2NUM(*$3)); >> rb_ary_push($result, INT2NUM(*$4)); >>} We definitely need something like these. The first one says that calls from Ruby can omit the x, y, descent and externalLeading parameters. which matches C++ wx, where they are ignored as input values. The second one says that the values that came back in those parameters should be converted to normal ruby return values. I think we should match whatever wxPython did. So I think by removing these typemaps, the code compiles and runs, but really doesn''t do what it needs to do. Can you share the directorout you used to try to solve the problem, along with a description of why it didn''t work. You should be able to use a directorout typemap to generate code that converts the values returned by the actual C++ wx method to exactly match the values returned by the new swig wrapper function. Hm. You might need a directorin too, I guess. I would need to look closer at the C++ code where the wrapper checks swigup and invokes the director. I may have time to look at this in a day or two.> Also when I have a patch ready do you want it for darcs or cvs?Either will work, but darcs patches are more fun for me, and sometimes are easier for me to apply. So darcs for now, if that''s convenient for you. Thanks, Kevin
Here is a patch with only: %typemap(in,numinputs=0) (int * x , int * y , int * descent, int * externalLeading) (int a, int b, int c, int d and the other type map commented out Just having those commented out fix the crash with get_text_extent. I tried it on both Windows and Mac. these are the 3 typemaps I had in there that did not make any difference so they were removed. %typemap(directorout) wxString { $result = wxString(STR2CSTR($1), wxConvUTF8); } %typemap(directorout) wxString& { $result = new wxString(STR2CSTR($1), wxConvUTF8); } %typemap(directorout) const wxString& { $result = new wxString(STR2CSTR($1), wxConvUTF8); } Sean On 10/12/05, Kevin Smith <wxruby at qualitycode.com> wrote:> Sean Long wrote: > > Ok. I got it working by doing the following: > > > > - comment out the two typemaps in last message > > - add the following directorout typemaps (not sure if they are > > actually needed, I believe the two typemaps that I commented out were > > the problem) > > I suspect you are correct. Please test without these new wxString > directorout typemaps, and omit them from a patch if they are not needed. > > > Now the question is do we need the two type maps that I commented out? > > I did a quick search and could not find what they were for. > > >>%typemap(in,numinputs=0) (int * x , int * y , int * descent, int * > >>externalLeading) (int a, int b, int c, int d) { > >> $1=&a; > >> $2=&b; > >> $3=&c; > >> $4=&d; > >>} > >> > >>%typemap(argout) (int * x , int * y , int * descent, int * > externalLeading) { > >> $result = rb_ary_new(); > >> rb_ary_push($result, INT2NUM(*$1)); > >> rb_ary_push($result, INT2NUM(*$2)); > >> rb_ary_push($result, INT2NUM(*$3)); > >> rb_ary_push($result, INT2NUM(*$4)); > >>} > > We definitely need something like these. The first one says that calls > from Ruby can omit the x, y, descent and externalLeading parameters. > which matches C++ wx, where they are ignored as input values. The second > one says that the values that came back in those parameters should be > converted to normal ruby return values. I think we should match whatever > wxPython did. > > So I think by removing these typemaps, the code compiles and runs, but > really doesn''t do what it needs to do. > > Can you share the directorout you used to try to solve the problem, > along with a description of why it didn''t work. You should be able to > use a directorout typemap to generate code that converts the values > returned by the actual C++ wx method to exactly match the values > returned by the new swig wrapper function. Hm. You might need a > directorin too, I guess. I would need to look closer at the C++ code > where the wrapper checks swigup and invokes the director. > > I may have time to look at this in a day or two. > > > Also when I have a patch ready do you want it for darcs or cvs? > > Either will work, but darcs patches are more fun for me, and sometimes > are easier for me to apply. So darcs for now, if that''s convenient for you. > > Thanks, > > Kevin > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-------------- next part -------------- A non-text attachment was scrubbed... Name: get_text_extent.darcs_patch Type: application/octet-stream Size: 826 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-users/attachments/20051012/b4c18729/get_text_extent.obj
True, they won''t make any difference with that function. But they will be needed elsewhere. I hope to add ''em back in some time. Roy Sean Long wrote:> Here is a patch with only: > %typemap(in,numinputs=0) (int * x , int * y , int * descent, int * > externalLeading) (int a, int b, int c, int d > > and the other type map commented out > > Just having those commented out fix the crash with get_text_extent. I > tried it on both Windows and Mac. > > these are the 3 typemaps I had in there that did not make any > difference so they were removed. > > %typemap(directorout) wxString { > $result = wxString(STR2CSTR($1), wxConvUTF8); > } > > %typemap(directorout) wxString& { > $result = new wxString(STR2CSTR($1), wxConvUTF8); > } > > %typemap(directorout) const wxString& { > $result = new wxString(STR2CSTR($1), wxConvUTF8); > } > > Sean > > On 10/12/05, Kevin Smith <wxruby at qualitycode.com> wrote: > >> Sean Long wrote: >> >>> Ok. I got it working by doing the following: >>> >>> - comment out the two typemaps in last message >>> - add the following directorout typemaps (not sure if they are >>> actually needed, I believe the two typemaps that I commented out were >>> the problem) >>> >> I suspect you are correct. Please test without these new wxString >> directorout typemaps, and omit them from a patch if they are not needed. >> >> >>> Now the question is do we need the two type maps that I commented out? >>> I did a quick search and could not find what they were for. >>> >> >>%typemap(in,numinputs=0) (int * x , int * y , int * descent, int * >> >>externalLeading) (int a, int b, int c, int d) { >> >> $1=&a; >> >> $2=&b; >> >> $3=&c; >> >> $4=&d; >> >>} >> >> >> >>%typemap(argout) (int * x , int * y , int * descent, int * >> externalLeading) { >> >> $result = rb_ary_new(); >> >> rb_ary_push($result, INT2NUM(*$1)); >> >> rb_ary_push($result, INT2NUM(*$2)); >> >> rb_ary_push($result, INT2NUM(*$3)); >> >> rb_ary_push($result, INT2NUM(*$4)); >> >>} >> >> We definitely need something like these. The first one says that calls >> from Ruby can omit the x, y, descent and externalLeading parameters. >> which matches C++ wx, where they are ignored as input values. The second >> one says that the values that came back in those parameters should be >> converted to normal ruby return values. I think we should match whatever >> wxPython did. >> >> So I think by removing these typemaps, the code compiles and runs, but >> really doesn''t do what it needs to do. >> >> Can you share the directorout you used to try to solve the problem, >> along with a description of why it didn''t work. You should be able to >> use a directorout typemap to generate code that converts the values >> returned by the actual C++ wx method to exactly match the values >> returned by the new swig wrapper function. Hm. You might need a >> directorin too, I guess. I would need to look closer at the C++ code >> where the wrapper checks swigup and invokes the director. >> >> I may have time to look at this in a day or two. >> >> >>> Also when I have a patch ready do you want it for darcs or cvs? >>> >> Either will work, but darcs patches are more fun for me, and sometimes >> are easier for me to apply. So darcs for now, if that''s convenient for you. >> >> Thanks, >> >> Kevin >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >>