DiabloStreamsImpl.mesa
Copyright © 1985, Xerox Corporation. All rights reserved.
Last edited by Eric Nickell, June 5, 1985 9:37:25 am PDT
Tim Diebert: September 25, 1985 6:07:43 pm PDT
DIRECTORY
Ascii,
Diablo USING [PutChar],
DiabloStreams,
IO USING [CreateStream, CreateStreamProcs, StreamProcs],
IOUtils USING [closedStreamProcs]
;
DiabloStreamsImpl:
CEDAR
MONITOR
IMPORTS Diablo, IO, IOUtils
EXPORTS DiabloStreams
= BEGIN
OPEN DiabloStreams;
StreamProcs: TYPE ~ IO.StreamProcs;
Busy: PUBLIC ERROR = CODE;
DiabloProcs: REF StreamProcs ← NIL;
theStream: STREAM ← NIL; --The STREAM currently writing to Diablo
inUse: BOOL ← FALSE;
StreamOpen:
PUBLIC
ENTRY
PROC
RETURNS [stream:
STREAM] ~ {
ENABLE UNWIND => NULL;
IF inUse THEN ERROR Busy;
stream ← IO.CreateStream[DiabloProcs, NIL];
inUse ← TRUE;
};
Init:
PROC ~ {
DiabloProcs ←
IO.CreateStreamProcs [
variety: output,
class: $Diablo,
putChar: PutChar,
reset: Reset,
flush: Flush,
close: Close
];
theStream ← IO.CreateStream[DiabloProcs, NIL];
};
PutChar:
PROC [self:
STREAM, char:
CHAR] ~ {
ENABLE UNWIND => NULL;
Diablo.PutChar[char];
};
Reset:
PROC [self:
STREAM] ~ {
OPEN Ascii;
ENABLE UNWIND => NULL;
Diablo.PutChar[ESC];
Diablo.PutChar[CR];
Diablo.PutChar['P];
};
Flush:
PROC [self:
STREAM] ~ {
ENABLE UNWIND => NULL;
Diablo.PutChar['\030];
};
Close:
ENTRY PROC [self:
STREAM, abort:
BOOL ←
FALSE] ~ {
ENABLE UNWIND => NULL;
inUse ← FALSE;
self.streamProcs ← IOUtils.closedStreamProcs;
};
Init[];
END.....