[MacRuby-devel] RubyCocoa layer

Pierce T. Wetter III pierce at twinforces.com
Tue Jun 24 08:36:39 PDT 2008


On Jun 24, 2008, at 1:27 AM, Eloy Duran wrote:

>>> Also it is now in lib/osx/rubycocoa.rb and there's a osx/cocoa.rb.
>>> The latter will probably be removed as to not have RubyCocoa
>>> applications work by default.
>>> This needs to be discussed further.
>>
>> As I said earlier I don't think osx/cocoa.rb is a good idea, I would
>> prefer rubycocoa.rb instead.

> I don't completely agree with you on these points.
> As for now I do not intend to completely port my apps to MacRuby,
> also because I simply don't have the time. But I would like to be
> able to develop further on MacRuby while still being able to use RC if
> it's necessary.
> So this is I guess the main difference in our points of view.
>
> But to get back to the real issue at hand,
> sure I understand it's better to remind developers that
> using the layer is not the optimal way of using MacRuby.

   I kind of think you're both right...

   As a developer, I need a way to dip my toe into MacRuby without  
having to port too much code. At least until Laurent says "MacRuby is  
farther along then RubyCocoa".

   However, since MacRuby requires a different project file anyways,  
what if everything went through a layer of indirection. That is, you  
setup both projects so that the RubyCocoa projects included one shim  
file, and the MacRuby project includes a different shim file (or you  
do a similar thing via require). So 99% of your code can be tweaked to  
run on both platforms. The MacRubyShim would look like this:



class ShimObject < Object

end

While the RubyCocoaShim would look like this

require 'osx/cocoa'

class ShimObject < NSObject

end


So then I search and replace all my NSObject inheritances into  
ShimObject, and they work in both places.

Just an idea.

Pierce



More information about the MacRuby-devel mailing list