PATH
Previous | Chapter contents | Next | Book PDF
As depicted in Scripting Subsystems , the architecture for AppleScript support in Mac OS X relies on a number of interdependent subsystems.
As in the Mac OS, an AppleScript script in the Blue Box is sent to the AppleScript engine for execution. The engine converts the statements in the script into discrete Apple events and sends these to the Apple event manager (which receives Apple events from other sources as well). The manager coalesces sends the events to the destination application using the Program-to-Program Communication toolbox (PPC) as dispatcher.
It is at the PPC level that the architecture begins to diverge from the Mac OS model. The PPC sends Apple events to the applications they are destined for. As in the Mac OS, it sends scripting Apple events to Blue Box (Mac OS) applications. But for Mac OS X, the PPC has been modified to notice if Apple events are meant for Yellow Box applications. If the PPC encounters such an Apple event, it hands it off to the Blue Abstraction Layer (BAL). The BAL packages the Apple event as a distributed object and, through the Distributed Object (DO) mechanism, transports the Apple event to the target Yellow Box application.
The Yellow Box application dynamically links in several frameworks that comprise the subsystems supporting scripting on the Yellow Box side. (Scriptable applications must link against the Scripting and AppKitScripting frameworks.) The first of these subsystems called into play is the Apple event manager for the Yellow Box. This manager receives from the Blue Box a distributed object "wrapping" an Apple event; it converts this object back to an Apple event and dispatches the event appropriately. If the Apple event is related to scripting, the manager sends it to the Apple event translator; the manager knows when to do this because the translator registers with the manager all Apple events it knows to be script commands.
Using the script terminologies loaded by the application, the Apple event translator converts the Apple event into a script command (that is, an NSScriptCommand object). The script command is executed in the script execution context (a single, shared instance of NSScriptExecution context). For details on what happens just before and during command execution, see " How a Command Is Composed and Executed ."
The flow of commands and Apple events is bi-directional in this architecture. Script commands often define return values; when these commands are executed, values of a specified type are returned to the originating script. To get back to the script, the return value follows the same path as the original command.
Previous | Chapter contents | Next | Book PDF