MakeDoBasic2Impl.Mesa
Copyright Ó 1989 by Xerox Corporation. All rights reserved.
Last tweaked by Mike Spreitzer on March 23, 1990 8:31 am PST
Carl Hauser, April 11, 1985 3:43:34 pm PST
Eduardo Pelegri-Llopart November 18, 1988 6:22:48 am PST
JKF January 11, 1989 9:54:46 am PST
Bill Jackson (bj) January 16, 1989 1:37:55 pm PST
Modified to just export one type of reporters
DIRECTORY Ascii, Commander, IO, MakeDoBasics, RefTab, Rope;
MakeDoBasic2Impl: CEDAR PROGRAM
IMPORTS Ascii, RefTab
EXPORTS MakeDoBasics
INVARIANT
The integrity of the aux box data structure.
=
BEGIN OPEN MakeDoBasics;
UnknownRegistration: ERROR = CODE;
ROPE: TYPE ~ Rope.ROPE;
registrationTable: RefTab.Ref ~ RefTab.Create[];
MakeDoReporter: ROPE ~ "MakeDo.Reporter";
currentReporter: MakeDoBasics.Reporter ← NIL;
DestroyAuxBox: PUBLIC PROC = {
IF currentReporter = NIL THEN SelectReporter[];
currentReporter.destroyAuxBox[];
};
AuxBoxDestroyed: PUBLIC PROC RETURNS [BOOL] = {
IF currentReporter = NIL THEN SelectReporter[];
RETURN [currentReporter.auxBoxDestroyed[]];
};
Buffer: PUBLIC PROC [e: Execution] = {
IF currentReporter = NIL THEN SelectReporter[];
currentReporter.buffer[e];
};
Msg: PUBLIC PROC [ch: Commander.Handle, format: ROPE, v1, v2, v3, v4, v5: IO.Value ← [null[]]] = {
IF currentReporter = NIL THEN SelectReporter[];
currentReporter.msg[ch, format, v1, v2, v3, v4, v5];
};
Flush: PUBLIC PROC [e: Execution, long, abandon: BOOL, asRope: ROPE] = {
IF currentReporter = NIL THEN SelectReporter[];
currentReporter.flush[e, long, abandon, asRope];
};
RegisterReporter: PUBLIC PROC [key: ATOM, reporter: Reporter] = {
IF NOT registrationTable.Store[key, reporter] THEN ERROR;
currentReporter ← reporter; --thus order of starting is important
};
Upper: PROC [old: CHAR] RETURNS [new: CHAR] ~ {
RETURN [Ascii.Upper[old]];
};
SelectReporter: PROC ~ {
ERROR UnknownRegistration;
<<
Assign to currentReporter whatever the user profile requests
reporterTypeRope: ROPE ~ Rope.Translate[
base: UserProfile.Token[MakeDoReporter, MakeDoBasics.defaultReporter],
translator: Upper];
reporterType: ATOM ~ Convert.AtomFromRope[reporterTypeRope];
val: RefTab.Val;
found: BOOL;
[found: found, val: val] ← registrationTable.Fetch[reporterType];
IF NOT found THEN ERROR UnknownRegistration;
currentReporter ← NARROW[val];
>>
};
END.