[MacRuby-devel] Added NSNotification support to HotCocoa
Laurent Sansonetti
lsansonetti at apple.com
Fri Sep 19 12:10:01 PDT 2008
On Sep 19, 2008, at 11:47 AM, Jordan K. Hubbard wrote:
> On Sep 19, 2008, at 6:22 AM, Richard Kilmer wrote:
>
>> I added the ability to easily support notification posting and
>> subscribing in HotCocoa:
>
> Nice! Very nice!
>
> This makes me wonder though... Since we're now into the area of
> inter-application messaging, how might the ScriptingBridge APIs look
> once suitably "HotCocoa'd"? More concise than RubyOSA, I'd imagine,
> and perhaps capable of recapturing some of the ease-of-use we lost
> when transitioning from RubyOSA to ScriptingBridge... Just a random
> thought, and aimed mostly at Laurent. :)
ScriptingBridge works as it is under MacRuby. Off the top of my mind,
the main advantages compared to RubyOSA are
1) objects returned by SB do not need to be boxed (since they are
native!)
2) unicode strings!
As an example, here is a script that lists all songs in iTunes. I have
quite a few songs with Japanese titles and they show up perfectly in
the terminal.
framework 'ScriptingBridge'
itunes =
SBApplication.applicationWithBundleIdentifier('com.apple.itunes')
itunes.sources[0].playlists[0].tracks.each do |t|
puts t.name, t.artist, '---'
end
Obviously one could write some HotCocoa mappings for ScriptingBridge.
For example, the [SBApplication applicationWithBundleIdentifier:]
incantation is just too verbose, compared to RubyOSA's app('iTunes').
It would be a nice idea, though I'm not sure if we would be able to
offer the same user experience than RubyOSA, given that all the
scriptable APIs are generated on the fly and RubyOSA takes care of
creating Ruby-like methods. Also, it is still impossible to access
enumerations via ScriptingBridge, because it does not expose them.
I would actually prefer to work on making MacRuby a real OSA language
and bundling an OSA bridge similar to RubyOSA in the core.
Laurent
More information about the MacRuby-devel
mailing list