PATH
Previous | Chapter contents | Next | Book PDF
When the Apple event translator composes a script command, it evaluates an AppleScript statement and converts any reference forms in it to a nested series of NSObjectSpecifier objects (or, simply, object specifiers). It packages these nested object specifiers as the receivers of a command and possibly as the arguments of the command. An application evaluates these object specifiers in its own context to discover the "real" objects so referenced.
A reference form is an expression such as:
words whose color is blue of paragraph 3 of front document
AppleScript recognizes many types of reference forms; the Yellow Box has subclasses of the abstract NSObjectSpecifier class for most of them.
Most object specifiers have a reference to their "container specifier"--that is, the parent object specifier that "contains" it in the object hierarchy; the resolution of the container specifier must occur to establish a context in which the current object specifier can be evaluated. An object specifier knows how to evaluate itself in the context of its container specifier. (An object specifier also knows its "child specifier"--that is, the object specifier it is a container for.) An object that has no container specifier is known as the "top-level specifier"; in most cases, the top-level specifier is the application itself.
Evaluation starts with the top-level specifier and proceeds down the chain of object specifiers, evaluating and resolving each until it determines the identify of the final, nested "child" object. This object is a receiver (or receivers) of the command or one of the command's arguments. Key-value coding is used as the mechanism for evaluation: An object specifier queries its evaluated container (using the valueForKey: method or an extension of this method) for the value of the key associated with the object specifier. The key is typically something like "filename" or "windows." The value is the evaluated object, such as an NSString representing a file system path or an NSArray of NSWindow objects. If the object reference has a child reference, the evaluated object is used as the basis for the next query, made on behalf of the child reference. (See " Make Objects Responsive to Key-Value Coding " for an overview of key-value coding.)
Previous | Chapter contents | Next | Book PDF