[MacRuby-devel] RubyCocoa layer

Eloy Duran eloy.de.enige at gmail.com
Tue Jun 24 07:37:10 PDT 2008


Ah ok, but that is not what is needed for the layer.
The behaviour I'm talking about is behaviour that works in RubyCocoa.
So it still fails... :)

Eloy

On 24 jun 2008, at 16:09, Laurent Sansonetti wrote:

> It's because you subclass NSObject. Try subclassing Object, and it
> will work.
>
> $ ./miniruby -ve "class Foo; def initialize; p 42; end; end;
> Foo.alloc.init"
> MacRuby version 0.3 (ruby 1.9.0 2008-06-03) [universal-darwin9.0]
> 42
>
> The machinery is implemented in Object.
>
> # You should not subclass NSObject from MacRuby. An exception will
> probably be raised in the future.
>
> Laurent
>
> On Jun 24, 2008, at 5:20 PM, Eloy Duran wrote:
>
>> Oh serious? It is still failing in my tests.
>> Here's the output of running the tests:
>>
>> D..F........F........
>> Finished in 1.439062 seconds.
>>
>>  1) should load AppKit when the osx/cocoa file is loaded is disabled
>>
>>  2) Failure:
>> test_spec {NSObject additions} 002 [should call initialize from init
>> if it exists](NSObject additions)
>> method block (2 levels) in <main> in rubycocoa_test.rb at line 76
>> method run in test_case_adapter.rb at line 19
>> <"represent!"> expected but was
>> <nil>.
>>
>>  3) Failure:
>> test_spec {NSObject additions} 011 [should be possible to call
>> super_foo type methods](NSObject additions)
>> method block (2 levels) in <main> in rubycocoa_test.rb at line 123
>> method run in test_case_adapter.rb at line 19
>> Exception raised:
>> Class: <NoMethodError>
>> Message: <"undefined method `super_init' for
>> #<TestRubyCocoaStyleSuperMethod:
>> 0x26ec2f0>:TestRubyCocoaStyleSuperMethod">
>> ---Backtrace---
>> /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/ 
>> 1.9.0/
>> osx/rubycocoa.rb:67:in `method_missing'
>> /Users/eloy/Documents/DEVELOPMENT/RubyCocoa/src/MacRuby/src/test-
>> macruby/rubycocoa_test.rb:36:in `init'
>> /Users/eloy/Documents/DEVELOPMENT/RubyCocoa/src/MacRuby/src/test-
>> macruby/rubycocoa_test.rb:123:in `block (3 levels) in <main>'
>> /Users/eloy/Documents/DEVELOPMENT/RubyCocoa/src/MacRuby/src/test-
>> macruby/rubycocoa_test.rb:123:in `block (2 levels) in <main>'
>> /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/
>> site_ruby/mocha/test_case_adapter.rb:19:in `run'
>> ---------------
>>
>> 21 tests, 36 assertions, 2 failures, 0 errors
>>
>> The first failure tests if #initialize was called:
>>
>> class NSObjectSubclassWithInitialize < OSX::NSObject
>>  attr_reader :set_from_initialize
>>  def initialize
>>    @set_from_initialize = 'represent!'
>>  end
>> end
>>
>> NSObjectSubclassWithInitialize.alloc.init.set_from_initialize.should
>> == 'represent!'
>>
>> And as you can see that still fails.... :/
>>
>> Eloy
>>
>> On 24 jun 2008, at 02:52, Laurent Sansonetti wrote:
>>
>>> This one was fixed a couple of days ago :)
>>>
>>> Laurent
>>>
>>> On Jun 24, 2008, at 6:24 AM, Eloy Duran wrote:
>>>
>>>> Oh and also the problem that #initialize isn't called from #init
>>>> should be fixed :)
>>>>
>>>> Eloy
>>>>
>>>> On 23 jun 2008, at 23:20, Eloy Duran wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Today I merged my code for the RubyCocoa layer.
>>>>> It's still very premature. There are some notes in sample-macruby/
>>>>> RubyCocoa/README
>>>>> about what still needs to to be done.
>>>>>
>>>>> 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.
>>>>>
>>>>> For now the main issues are the super_foo style methods and also
>>>>> some method missing like behaviour
>>>>> for objc methods that check if a method exists before dispatching.
>>>>> The latter is currently being worked around,
>>>>> but that should definitely move out.
>>>>>
>>>>> Cheers,
>>>>> Eloy
>>>>
>>>> _______________________________________________
>>>> MacRuby-devel mailing list
>>>> MacRuby-devel at lists.macosforge.org
>>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>>
>>> _______________________________________________
>>> MacRuby-devel mailing list
>>> MacRuby-devel at lists.macosforge.org
>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list