[MacRuby-devel] Framework callbacks in macirb

Laurent Sansonetti lsansonetti at apple.com
Wed Feb 4 21:37:07 PST 2009


Hi Barry,

On Feb 4, 2009, at 7:46 PM, Barry Walker wrote:

> I'm clearly in over my head here, but I'm hoping macruby can  
> simplify some complexity.
>
> I've cobbled together an objective c framework with a class that  
> handles some IO Kit transactions.  The framework seems to work with  
> objective c  cocoa applications.
>
> I would like to use this framework from macirb or a simple  
> standalone ruby script.  The framework appears to load from macirb  
> and I can make an object and call it's methods.  I can see packets  
> sent out the FireWire port as expected.
>
> A key feature of the framework is accepting callbacks from IO kit.   
> Certain FireWire packets on the bus should invoke method callbacks.   
> The callbacks do not seem to make it to the objects created in  
> macirb or a simple script.
>
> I'm researching run loops and threads and trying to understand if  
> macirb or macruby uses NSApplication and its run loop, but I'm not  
> getting very far and I may be way off base.

Neither macirb or macruby start the CF/Cocoa runloop for you by  
default [1], so you will have to start it by yourself. You can call  
NSApplication.sharedApplication.run or NSRunLoop.currentRunLoop.run.

If you do this from macirb it will block as expected and you won't be  
able to evaluate expressions. I would then recommend using an irb-like  
Cocoa app that already uses the runloop under the covers (like http://github.com/vincentisambart/hotconsole/tree/master 
  for example).

HTH,
Laurent

[1] but this will be fixed in the next-next release :-)


More information about the MacRuby-devel mailing list