Re: Snow Leopard AppleScript Release Notes
Re: Snow Leopard AppleScript Release Notes
- Subject: Re: Snow Leopard AppleScript Release Notes
- From: has <email@hidden>
- Date: Tue, 1 Sep 2009 19:34:29 +0100
On 28 Aug 2009, at 23:50, Christopher Nebel wrote:
On Aug 28, 2009, at 1:41 PM, has wrote:
3. The ASObjC release notes provide some information on the AS-ObjC
bridging. Offhand, one thing I don't see is covered is implementing
class methods in AppleScript. (The docs state "AppleScript handlers
defined in the 'script' block are equivalent to the **instance**
methods of an Objective-C object" [my emphasis].) Am I correct in
thinking this is not supported?
I should fix that sentence. In fact, a handler serves as both an
instance method *and* a class method; you can invoke it either way.
OK. What if you need to define both class and instance methods with
the same name? (I don't know what the chances of needing to do that
are, but it'd be good to clarify the corner cases.)
4. What other limitations are imposed by the bridge? For example:
- Can ObjC classes inherit from AppleScript 'classes' (top-level
script objects)?
No, because there's nothing the Obj-C linker can see. (Technically,
you could create a class dynamically that inherited from an
AppleScript-based class, but that's more trouble than most people
want to deal with.)
OK. (To be honest, I can't think of a practical reason you'd want to
do it anyway.)
- Can AppleScript 'classes' inherit from other AppleScript
'classes' using the 'property parent : class "CLASSNAME"'
mechanism? If not, can they still inherit via the traditional
AppleScript approach?
I believe that both work, though in the former case you have to be
careful about load order.
How would you control the load order? Presumably putting multiple
script objects in the same file would work. What about if they're in
different files?
- When mutable objects cross the bridge, are they copied or shared?
I'm assuming they're shared, yes?
Shared. Obj-C objects stay Obj-C objects when they cross; there is
no automatic "boxing" of, say, NSStrings to AppleScript text.
OK. So if AppleScript receives an NSString, can you ask for character/
word/paragraph elements using standard AppleScript idioms, or do you
have to coerce it to an AppleScript text object first, or are you
limited to using its Cocoa methods? And what about AppleScript objects
that cross to the ObjC side?
5. I expect I'll have more questions as I investigate ASObjC
further. What's the best forum to use? Here or the Studio list? Or
are there plans to create an AppleScriptObjC mailing list?
For now, use the Studio list; we'll look at creating a separate list
in the future.
Will do.
Oh, and one other question: am I right in thinking there's no way to
access Cocoa via AppleScriptObjC outside of an Xcode project? e.g. In
Python, you can bring in PyObjC at any time with a simple 'import'
statement, which is handy if you're writing a batch processsing script
(for which a full-blown app would be complete overkill) that just
needs to tap Cocoa for a bit of functionality.
Many thanks,
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden