Attached is a patch file for FileDialog.i. It doesn''t work 100% yet because I haven''t yet figured out how to make it put the ruby declarations in the right place. If I cut and paste the rb_define_methods into the right place this works perfectly. This patch fixes the dialogs.rb multiple select example so that get_paths and get_filenames returns a ruby array. Note that I may have broken subclassing with this as I think there were _wrap_ wrappers that got lost. Perhaps Kevin or Sean can point out what I should have done? Be gentle, it''s my first swig patch. :) Roy _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Roy Sutton wrote:> Attached is a patch file for FileDialog.i. It doesn''t work 100% yet > because I haven''t yet figured out how to make it put the ruby > declarations in the right place.Ok. First, thanks for submitting this. And I also like that it shows up as an attachment but also inline in my mail reader (thunderbird) so it''s easy for me to review without having to save to disk. Perfect! Well, that part was perfect, anyway. The diff itself is reversed (note that it tells me to remove all your new code (-) instead of adding it (+). I didn''t actually try applying it, so I''m not sure if you got the -p0 vs. -p1 thing right. I''m still a diff newbie.> This patch fixes the dialogs.rb multiple select example so that > get_paths and get_filenames returns a ruby array. Note that I may have > broken subclassing with this as I think there were _wrap_ wrappers that > got lost. Perhaps Kevin or Sean can point out what I should have done? > Be gentle, it''s my first swig patch. :)No problem. Your post sent me to the swig docs immediately. Turns out that what you''re trying to do is a common case when wrapping c/c++ with dynamic languages like Ruby. The answer is typemaps, and the latest swig docs even have a pretty similar example to work from. Take a look at section 10.7 here: http://www.swig.org/Doc1.3/Typemaps.html#Typemaps_nn42 Look at their example of the "read" function where you pass in a buffer, but from ruby you would expect to pass nothing and get a String back. You should be able to set up a typemap that avoids the need to write any functions in c/c++. I almost started to do it myself, but decided not to spoil your fun :-) Actually, it looks like FileDialog.i already has some typemaps like this which I commented out because they were causing problems for me with wx 2.5.3. It''s is *possible* that uncommenting those will make it work. If so, go ahead and submit that. Eventually I''ll want to get the typemap out of that .i file, or at least get the logic out of there. But that can be a separate step after we get it working. If you can get this working, you''ll be a hero, because I would much rather learn from a patch you submit than to have to learn through my own experiments. Thanks! Kevin
haha. I didn''t even notice I''d diff''ed ''em the wrong way. I really just copied Sean''s patch file command lines and just mixed up the order. I use Thunderbird, too, and I liked the way I can review the patches. I will go investigate typemaps. Roy Kevin Smith wrote:> Roy Sutton wrote: > >> Attached is a patch file for FileDialog.i. It doesn''t work 100% yet >> because I haven''t yet figured out how to make it put the ruby >> declarations in the right place. > > > Ok. First, thanks for submitting this. And I also like that it shows > up as an attachment but also inline in my mail reader (thunderbird) so > it''s easy for me to review without having to save to disk. Perfect! > > Well, that part was perfect, anyway. The diff itself is reversed (note > that it tells me to remove all your new code (-) instead of adding it > (+). I didn''t actually try applying it, so I''m not sure if you got the > -p0 vs. -p1 thing right. I''m still a diff newbie. > >> This patch fixes the dialogs.rb multiple select example so that >> get_paths and get_filenames returns a ruby array. Note that I may >> have broken subclassing with this as I think there were _wrap_ >> wrappers that got lost. Perhaps Kevin or Sean can point out what I >> should have done? Be gentle, it''s my first swig patch. :) > > > No problem. Your post sent me to the swig docs immediately. Turns out > that what you''re trying to do is a common case when wrapping c/c++ > with dynamic languages like Ruby. The answer is typemaps, and the > latest swig docs even have a pretty similar example to work from. Take > a look at section 10.7 here: > > http://www.swig.org/Doc1.3/Typemaps.html#Typemaps_nn42 > > Look at their example of the "read" function where you pass in a > buffer, but from ruby you would expect to pass nothing and get a > String back. You should be able to set up a typemap that avoids the > need to write any functions in c/c++. I almost started to do it > myself, but decided not to spoil your fun :-) > > Actually, it looks like FileDialog.i already has some typemaps like > this which I commented out because they were causing problems for me > with wx 2.5.3. It''s is *possible* that uncommenting those will make it > work. If so, go ahead and submit that. Eventually I''ll want to get the > typemap out of that .i file, or at least get the logic out of there. > But that can be a separate step after we get it working. > > If you can get this working, you''ll be a hero, because I would much > rather learn from a patch you submit than to have to learn through my > own experiments. > > Thanks! > > Kevin > _______________________________________________ > wxruby-users mailing list > wxruby-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > >