About a year ago (ouch!), Robert Carlin submitted a ported version of the wxPython demo/sample. I hoped to include it in wxruby2, but it relies on SplitterWindow, which isn''t in wxruby2 yet. I tried to implement SplitterWindow myself, but got such strange results that I''m thinking I did something wrong. Even though the generated C++ code specified a variable number of arguments to the constructor, Ruby would always insist that it needed exactly one parameter. It called the swig wrapped object allocator, but never called the swig wrapped constructor. Below is my sample app, and the results. I am intentionally not showing my .i file in case I did something subtly wrong that you might copy. I did make one correction to the .h file (and checked it in), but otherwise it looks fine. If you plan to spend more than a few minutes on this, please post a note to the list so you don''t duplicate effort. Thanks, Kevin ---- kevins@aria:~/work/wxruby2$ cat samples/testsplitter.rb require ''wx'' include Wx class MyFrame < Frame def initialize(title,pos,size,style=DEFAULT_FRAME_STYLE) super(nil,-1,title,pos,size,style) splitter = SplitterWindow.new(self, -1) end end class RbApp < App def on_init frame = MyFrame.new("Spliter Tester",Point.new(50, 50), Size.new(450, 340)) frame.show(TRUE) end end a = RbApp.new a.main_loop() kevins@aria:~/work/wxruby2$ ruby samples/testsplitter.rb Our Initialize was called Their Initialize returned 1 samples/testsplitter.rb:8:in `initialize'': wrong # of arguments(2 for 1) (ArgumentError) from samples/testsplitter.rb:8:in `new'' from samples/testsplitter.rb:8:in `initialize'' from samples/testsplitter.rb:15:in `new'' from samples/testsplitter.rb:15:in `on_init'' from samples/testsplitter.rb:21:in `main_loop'' from samples/testsplitter.rb:21 kevins@aria:~/work/wxruby2$
Roy Sutton
2005-Aug-18 10:39 UTC
[Wxruby-users] Volunteer requested: Implement SplitterWindow
Interesting problem here. The initialize isn''t being called for SplitterWindow. It must be bubbling down somewhere else. I''ll spend a few minutes looking into this later Roy Kevin Smith wrote:> About a year ago (ouch!), Robert Carlin submitted a ported version of > the wxPython demo/sample. I hoped to include it in wxruby2, but it > relies on SplitterWindow, which isn''t in wxruby2 yet. > > I tried to implement SplitterWindow myself, but got such strange > results that I''m thinking I did something wrong. Even though the > generated C++ code specified a variable number of arguments to the > constructor, Ruby would always insist that it needed exactly one > parameter. It called the swig wrapped object allocator, but never > called the swig wrapped constructor. > > Below is my sample app, and the results. I am intentionally not > showing my .i file in case I did something subtly wrong that you might > copy. I did make one correction to the .h file (and checked it in), > but otherwise it looks fine. > > If you plan to spend more than a few minutes on this, please post a > note to the list so you don''t duplicate effort. > > Thanks, > > Kevin > > ---- > kevins@aria:~/work/wxruby2$ cat samples/testsplitter.rb > require ''wx'' > include Wx > > class MyFrame < Frame > def initialize(title,pos,size,style=DEFAULT_FRAME_STYLE) > super(nil,-1,title,pos,size,style) > > splitter = SplitterWindow.new(self, -1) > end > > end > > class RbApp < App > def on_init > frame = MyFrame.new("Spliter Tester",Point.new(50, 50), > Size.new(450, 340)) > frame.show(TRUE) > end > end > > a = RbApp.new > a.main_loop() > kevins@aria:~/work/wxruby2$ ruby samples/testsplitter.rb > Our Initialize was called > Their Initialize returned 1 > samples/testsplitter.rb:8:in `initialize'': wrong # of arguments(2 for > 1) (ArgumentError) > from samples/testsplitter.rb:8:in `new'' > from samples/testsplitter.rb:8:in `initialize'' > from samples/testsplitter.rb:15:in `new'' > from samples/testsplitter.rb:15:in `on_init'' > from samples/testsplitter.rb:21:in `main_loop'' > from samples/testsplitter.rb:21 > kevins@aria:~/work/wxruby2$ > _______________________________________________ > wxruby-users mailing list > wxruby-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > >
Roy Sutton
2005-Aug-18 23:11 UTC
[Wxruby-users] Volunteer requested: Implement SplitterWindow
Kevin, You''ll kick yourself when you see it. I should kick myself for spending so long staring at it without figuring it out. Attached is a SplitterWindow.i that should work. Roy Kevin Smith wrote:> About a year ago (ouch!), Robert Carlin submitted a ported version of > the wxPython demo/sample. I hoped to include it in wxruby2, but it > relies on SplitterWindow, which isn''t in wxruby2 yet. > > I tried to implement SplitterWindow myself, but got such strange > results that I''m thinking I did something wrong. Even though the > generated C++ code specified a variable number of arguments to the > constructor, Ruby would always insist that it needed exactly one > parameter. It called the swig wrapped object allocator, but never > called the swig wrapped constructor. > > Below is my sample app, and the results. I am intentionally not > showing my .i file in case I did something subtly wrong that you might > copy. I did make one correction to the .h file (and checked it in), > but otherwise it looks fine. > > If you plan to spend more than a few minutes on this, please post a > note to the list so you don''t duplicate effort. > > Thanks, > > Kevin > > ---- > kevins@aria:~/work/wxruby2$ cat samples/testsplitter.rb > require ''wx'' > include Wx > > class MyFrame < Frame > def initialize(title,pos,size,style=DEFAULT_FRAME_STYLE) > super(nil,-1,title,pos,size,style) > > splitter = SplitterWindow.new(self, -1) > end > > end > > class RbApp < App > def on_init > frame = MyFrame.new("Spliter Tester",Point.new(50, 50), > Size.new(450, 340)) > frame.show(TRUE) > end > end > > a = RbApp.new > a.main_loop() > kevins@aria:~/work/wxruby2$ ruby samples/testsplitter.rb > Our Initialize was called > Their Initialize returned 1 > samples/testsplitter.rb:8:in `initialize'': wrong # of arguments(2 for > 1) (ArgumentError) > from samples/testsplitter.rb:8:in `new'' > from samples/testsplitter.rb:8:in `initialize'' > from samples/testsplitter.rb:15:in `new'' > from samples/testsplitter.rb:15:in `on_init'' > from samples/testsplitter.rb:21:in `main_loop'' > from samples/testsplitter.rb:21 > kevins@aria:~/work/wxruby2$ > _______________________________________________ > wxruby-users mailing list > wxruby-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > >-------------- next part -------------- # Copyright 2004-2005 by Kevin Smith # released under the MIT-style wxruby2 license %include "../common.i" %module(directors="1") wxSplitterWindow %rename(Init) Initialize(wxWindow* window ) ; %{ #include <wx/splitter.h> %} %include "include/wxSplitterWindow.h"
Roy Sutton
2005-Aug-18 23:37 UTC
[Wxruby-users] Volunteer requested: Implement SplitterWindow
I forgot to note that we''ll probably have to document that somewhere. Roy Sutton wrote:> Kevin, > > You''ll kick yourself when you see it. I should kick myself for > spending so long staring at it without figuring it out. > > Attached is a SplitterWindow.i that should work. > > Roy > > Kevin Smith wrote: > >> About a year ago (ouch!), Robert Carlin submitted a ported version of >> the wxPython demo/sample. I hoped to include it in wxruby2, but it >> relies on SplitterWindow, which isn''t in wxruby2 yet. >> >> I tried to implement SplitterWindow myself, but got such strange >> results that I''m thinking I did something wrong. Even though the >> generated C++ code specified a variable number of arguments to the >> constructor, Ruby would always insist that it needed exactly one >> parameter. It called the swig wrapped object allocator, but never >> called the swig wrapped constructor. >> >> Below is my sample app, and the results. I am intentionally not >> showing my .i file in case I did something subtly wrong that you >> might copy. I did make one correction to the .h file (and checked it >> in), but otherwise it looks fine. >> >> If you plan to spend more than a few minutes on this, please post a >> note to the list so you don''t duplicate effort. >> >> Thanks, >> >> Kevin >> >> ---- >> kevins@aria:~/work/wxruby2$ cat samples/testsplitter.rb >> require ''wx'' >> include Wx >> >> class MyFrame < Frame >> def initialize(title,pos,size,style=DEFAULT_FRAME_STYLE) >> super(nil,-1,title,pos,size,style) >> >> splitter = SplitterWindow.new(self, -1) >> end >> >> end >> >> class RbApp < App >> def on_init >> frame = MyFrame.new("Spliter Tester",Point.new(50, 50), >> Size.new(450, 340)) >> frame.show(TRUE) >> end >> end >> >> a = RbApp.new >> a.main_loop() >> kevins@aria:~/work/wxruby2$ ruby samples/testsplitter.rb >> Our Initialize was called >> Their Initialize returned 1 >> samples/testsplitter.rb:8:in `initialize'': wrong # of arguments(2 for >> 1) (ArgumentError) >> from samples/testsplitter.rb:8:in `new'' >> from samples/testsplitter.rb:8:in `initialize'' >> from samples/testsplitter.rb:15:in `new'' >> from samples/testsplitter.rb:15:in `on_init'' >> from samples/testsplitter.rb:21:in `main_loop'' >> from samples/testsplitter.rb:21 >> kevins@aria:~/work/wxruby2$ >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users@rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> >> >> >------------------------------------------------------------------------ > ># Copyright 2004-2005 by Kevin Smith ># released under the MIT-style wxruby2 license > >%include "../common.i" > >%module(directors="1") wxSplitterWindow > >%rename(Init) Initialize(wxWindow* window ) ; > >%{ >#include <wx/splitter.h> >%} > >%include "include/wxSplitterWindow.h" > > >------------------------------------------------------------------------ > >_______________________________________________ >wxruby-users mailing list >wxruby-users@rubyforge.org >http://rubyforge.org/mailman/listinfo/wxruby-users > >
Kevin Smith
2005-Aug-19 00:01 UTC
[Wxruby-users] Volunteer requested: Implement SplitterWindow
Roy Sutton wrote:>> Kevin, >> >> You''ll kick yourself when you see it. I should kick myself for >> spending so long staring at it without figuring it out. >> >> Attached is a SplitterWindow.i that should work.Doh! Thank you, thank you, thank you. I''m not sure how long it would have taken me to figure that out. I put in a couple hours on it the other night. What a relief. For those who haven''t looked at the .i file, wxSplitterWindow defines a method named ''initialize'', which was (of course) conflicting with ruby''s constructor name. Roy %rename''d it to ''init'' in the .i file, which makes perfect sense.> I forgot to note that we''ll probably have to document that somewhere.I put a note near the bottom of README where other quirks are listed. It should be more prominent when we create the wxruby api docs. I have committed SplitterWindow. Thanks! Kevin
Roy Sutton
2005-Aug-19 00:10 UTC
[Wxruby-users] Debugging Extension (was Re: Volunteer requested: Implement SplitterWindow)
I meant to ask... Does anyone know how to debug an extension using MSVC? I tried attaching to the ruby process and single stepping around but I never ended up anywhere inside the library. It was a waste of a good 45 minutes or so. There must be a way to do it. I suppose I could recompile ruby in debug, too. Kevin Smith wrote:> Roy Sutton wrote: > >>> Kevin, >>> >>> You''ll kick yourself when you see it. I should kick myself for >>> spending so long staring at it without figuring it out. >>> >>> Attached is a SplitterWindow.i that should work. >> > > Doh! Thank you, thank you, thank you. I''m not sure how long it would > have taken me to figure that out. I put in a couple hours on it the > other night. What a relief. > > For those who haven''t looked at the .i file, wxSplitterWindow defines > a method named ''initialize'', which was (of course) conflicting with > ruby''s constructor name. Roy %rename''d it to ''init'' in the .i file, > which makes perfect sense. > >> I forgot to note that we''ll probably have to document that somewhere. > > > I put a note near the bottom of README where other quirks are listed. > It should be more prominent when we create the wxruby api docs. > > I have committed SplitterWindow. > > Thanks! > > Kevin > _______________________________________________ > wxruby-users mailing list > wxruby-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > >
Doing a quick grep on the wxWindows source indicates we''ll run into Initialize again in other code. It almost seems like Swig Ruby should catch this. Should we take steps in our filters to catch this? It would have been much more insidious if the argument counts had happened to match. Roy Kevin Smith wrote:> Roy Sutton wrote: > >>> Kevin, >>> >>> You''ll kick yourself when you see it. I should kick myself for >>> spending so long staring at it without figuring it out. >>> >>> Attached is a SplitterWindow.i that should work. >> > > Doh! Thank you, thank you, thank you. I''m not sure how long it would > have taken me to figure that out. I put in a couple hours on it the > other night. What a relief. > > For those who haven''t looked at the .i file, wxSplitterWindow defines > a method named ''initialize'', which was (of course) conflicting with > ruby''s constructor name. Roy %rename''d it to ''init'' in the .i file, > which makes perfect sense. > >> I forgot to note that we''ll probably have to document that somewhere. > > > I put a note near the bottom of README where other quirks are listed. > It should be more prominent when we create the wxruby api docs. > > I have committed SplitterWindow. > > Thanks! > > Kevin > _______________________________________________ > wxruby-users mailing list > wxruby-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > >
Roy Sutton wrote:> Doing a quick grep on the wxWindows source indicates we''ll run into > Initialize again in other code. It almost seems like Swig Ruby should > catch this. Should we take steps in our filters to catch this? It > would have been much more insidious if the argument counts had happened > to match.Good thinking! Yeah, we should probably do it in the renamer.rb post-processor. I think the right place would be as an addtional if inside fix_define_method, where if the result was "initialize", convert it to "init". I have added a TODO entry so we don''t forget, but feel free to do this at any time if you feel motivated. Thanks, Kevin