Eloy Duran
eloy.****@gmail*****
Tue Jul 31 23:11:20 JST 2007
Merci Laurent! I very much enjoyed the setFoo -> foo= syntax and will now also enjoy the isFoo -> foo? syntax. Cheers, Eloy On 7/31/07, Laurent Sansonetti <lsans****@apple*****> wrote: > Hi, > > I added 2 things in SVN very recently. > > 1/ informal protocol methods registration > > Now, RubyCocoa will automatically register the informal protocol > methods you define in Ruby to the Objective-C runtime. This means that > the old code path ([RBObject -forwardInvocation:] will not be called > anymore, but the Ruby method will be directly called since we > registered the closure. > > This renders the informal protocol method calls faster, and also more > robust. WebKit3 doesn't seem to like when you pass it a NSProxy-based > delegate for example, for a strange reason I admit (I will investigate > this later). > > 2/ isFoo -> foo? conversion > > This is an idea from Eloy. We already convert foo= to setFoo, and Eloy > suggested to do the same for boolean methods. > > Example. Instead of writing > > OSX::NSBundle.mainBundle.isLoaded > > You can now write > > OSX::NSBundle.mainBundle.loaded? > > I implemented this in r1983. This change should be very safe, but if > you find any problem with it let's discuss. We can remove it if > necessary. The lines are > > # convert foo? to isFoo > orig_sel = m_args.size > 0 ? m_name.sub(/[^_:]$/, '\0_') : > m_name > unless ocm_responds?(orig_sel) > m_name = 'is' + m_name[0].chr.upcase + m_name[1..-1] > end > > (in oc_wrapper.rb) > > To implement this idea, I had to also implement the automatic Ruby > method registration (OCM_AUTO_REGISTER in mdl_objwrapper.c) for > methods that end with '?'. This is a good change, now this kind of > methods will be called in a much faster way. > > Laurent > > _______________________________________________ > Rubycocoa-devel mailing list > Rubyc****@lists***** > http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel >