Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Appendix A - Built-in Script Support / WorldScript II


How Calls Are Dispatched

WorldScript II does not implement all of the script utilities because some of them (such as GetScriptManagerVariable) are handled by the script management system itself. The script utilities that the script management system does not handle are listed in Table A-11 on page A-26. For those, the script management system passes execution to the WorldScript II dispatch routine, which in turn uses the script system's dispatch table to call the appropriate utility routine in WorldScript II.

When the WorldScript II dispatch routine calls a script utility, it replaces the selector of a normal script utility call with the address of the script record of the font script. It then calls the script utility. For instance:

  1. In assembly language, when you call CharacterByteType, you typically call it through a macro in the following way:

    subq.w   #2, sp        ; room for result.
    move.l textPtr,-(sp) ; push text pointer.
    clr.w -(sp) ; push text offset.
    CharacterByteType ; find out whether it is 1-byte or
    ; 2-byte character.
    tst.w (sp)+ ; is it 1-byte?
  2. The CharacterByteType macro expands into

    move.l   $82060010,-(sp)      ; push the selector.
    ScriptUtil ; call Script Manager trap.
  3. For this example, the stack looks like the following when the trap has been called:
     return address(long) <-- top of stack
     routine selector(long)
     text offset(word)
     text pointer(long)
     result(word)
  4. If the Script Manager does not handle the call, it passes the call to the current script's dispatch routine. The dispatch routine figures out by the value of the routine selector whether the call is in the range of calls it handles. If it is not, the dispatch routine strips the stack and returns without doing anything.
  5. If the call is in the valid range, the dispatch routine performs these tasks:

    1. It gets the address of the WorldScript II version of the script utility from the script's dispatch table.
    2. It gets the address of the script record and replaces the selector on the stack with the address of the script record.
    3. It jumps into the routine.

  6. So the stack becomes
     return address(long) <-- top of stack
     address of script record(long)
     text offset(word)
     text pointer(long)
     result(word)

The script's dispatch routine passes the script record to the WorldScript II script utilities so that they can use the script-specific information (such as the byte-type tables) in the script's international resources.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996