CDSequencer.mesa (A ChipNDale module)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, June 29, 1983 2:34 pm
last edited by Christian Jacobi, September 19, 1985 3:51:27 am PDT
Executing and queueing commands
DIRECTORY
CD,
Rope USING [ROPE];
CDSequencer: CEDAR DEFINITIONS =
BEGIN
Implementation of interactive commands. Monitoring commands to be sequential.
Command: TYPE = REF CommandRec;
CommandRec: TYPE = RECORD [
a: ATOMNIL,
design: CD.Design ← NIL,
l: CD.Layer ← CD.combined,
n: CD.Number ← 0,
pos: CD.Position ← [0, 0], -- final position of command
sPos: CD.Position ← [0, 0], -- special position, start position, (exceptional: size)
orient: CD.Orientation ← CD.original,
b: BOOLEANFALSE,
ref: REFNIL, --typically describes who issued the command (viewers data field)
data: REFNIL, --reserved for command implementor
fetched: --PRIVATE-- REF READONLY CommDescriptor ← NIL --private for CDSequencerImpl
];
CommandProc: TYPE = PROC[Command];
QueueMethod: TYPE = {doQueueAndMark, doQueue, dontQueue, useDefault};
--doQueueAndMark: mark the design as changed
--the queued executions are also forked
CommDescriptor: TYPE = RECORD [p: CommandProc, qm: QueueMethod];
ExecuteProc: PROC [comm: CDSequencer.Command ← NIL, design: CD.Design ← NIL, proc: CommandProc, queue: QueueMethod ← doQueue];
--Executes a command procedure proc.
--if design#NIL it replaces comm.design
--proc must be global
--To transfer data to proc use: "comm: NEW[CommandRec ← [data: ..]]"
ExecuteCommand: PROC [comm: CDSequencer.Command ← NIL, design: CD.Design ← NIL, command: ATOM NIL, queue: QueueMethod ← useDefault];
--Fetches and executes a command.
--if command#NIL it replaces comm.a
--if design#NIL replaces comm.design
ImplementCommand: PROC [a: ATOM, p: CommandProc, technology: CD.Technology←NIL, queue: QueueMethod ← doQueueAndMark];
--Registeres a command
--If technology is NIL implement for all technologies.
--Reimplementing the same atom in a technology overwrites the command;
--If the same atom is specified for a particular technology and all technologies,
--the more specific implementation wins independent of order.
--There is a (finite, short) list of atoms you can NOT use.
FetchCommand: PROC [a: ATOM, technology: CD.Technology] RETURNS [REF READONLY CommDescriptor];
--Fetches a registered command
--NIL if not defined
MarkChanged: PROC [design: CD.Design];
--mark the design as changed; it should be saved some time again...
--check for aborts
QuitCommand: PROC [message: Rope.ROPE];
--write message and terminates execution of the command of this process
--never returns
AbortTheCommand: PROC [design: CD.Design];
--called from any process
Aborted: PROC [design: CD.Design] RETURNS [BOOL];
--checks if the current command on design has been aborted
CheckAborted: PROC [design: CD.Design];
--IF Aborted[design] THEN SIGNAL TerminalIO.UserAbort
END.