IOUtils.mesa
Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved.
MBrown on September 18, 1983 6:57 pm
Russ Atkinson (RRA) February 2, 1985 1:01:03 pm PST
Beach, February 27, 1985 10:22:33 am PST
Doug Wyatt, November 18, 1986 5:48:34 pm PST
Procedures of interest to STREAM implementors.
DIRECTORY
IO,
Rope;
IOUtils: CEDAR DEFINITIONS
SHARES IO
= BEGIN
ROPE: TYPE = Rope.ROPE;
STREAM: TYPE = IO.STREAM;
StreamProcs: TYPE = IO.StreamProcs;
Printing
The following procedures are used to change PutF's interpretation of the format string or its error handling. Note that PFProcs are bound to a stream instance, not to a stream class or globally.
PFProcs: TYPE = REF PFProcsRecord;
PFProcsRecord: TYPE;
CopyPFProcs: PROC [stream: STREAM] RETURNS [new: PFProcs];
SetPFProcs: PROC [stream: STREAM, pfProcs: PFProcs] RETURNS [previous: PFProcs];
SetPFCodeProc: PROC [pfProcs: PFProcs, char: CHAR, codeProc: PFCodeProc]
RETURNS [previous: PFCodeProc];
! IO.Error [PFInvalidPFProcs, NIL]: pfProcs = NIL (pfProcs was not obtained from CopyPFProcs.)
! IO.Error [PFInvalidCode, NIL]: char is not IN ['A..'Z] or ['a..'z].
PFCodeProc: TYPE = PROC [stream: STREAM, val: IO.Value, format: Format, char: CHAR];
Format: TYPE = RECORD [form: ROPE, first: INT];
SetPFErrorProc: PROC [pfProcs: PFProcs, errorProc: PFErrorProc]
RETURNS[previous: PFErrorProc];
PFErrorProc: TYPE = PROC [error: IO.ErrorCode, stream: STREAM];
PFErrorPrintPounds: PFErrorProc;
PFErrorNoop: PFErrorProc;
PFErrorError: PFErrorProc;
The following procedures are used to change PutF's interpretation of the format string or its error handling. Note that PFProcs are bound to a stream instance, not to a stream class or globally.
SetDefaultPFCodeProc: PROC [char: CHAR, codeProc: PFCodeProc]
RETURNS [previous: PFCodeProc];
SetDefaultPFErrorProc: PROC [errorProc: PFErrorProc] RETURNS [previous: PFErrorProc];
The following procedure establishes the implementation of PrintRefAny to be used by Put and PutF (the default implementation just prints the REF itself, in octal):
RegisterPrintRefAny: PROC [printRefAnyProc: PrintRefAnyProc];
PrintRefAnyProc: TYPE = PROC [stream: STREAM, refAny: REF READONLY ANY,
depth: INT, width: INT, verbose: BOOL];
Implementing a stream class
closedStreamProcs: READONLY REF StreamProcs;
Procs for a closed stream (variety = $inputOutput, class = $Closed): Reset and Close are no-op, other procs raise ERROR IO.Error[$StreamClosed, self].
GetCharViaUnsafeGetBlock: PROC [self: STREAM] RETURNS [CHAR];
GetBlockViaGetChar: PROC [self: STREAM, block: REF TEXT, startIndex: NAT, count: NAT]
RETURNS [nBytesRead: NAT];
GetBlockViaUnsafeGetBlock: PROC [self: STREAM, block: REF TEXT,
startIndex: NAT, count: NAT] RETURNS [nBytesRead: NAT];
UnsafeGetBlockViaGetChar: UNSAFE PROC [self: STREAM, block: IO.UnsafeBlock]
RETURNS [nBytesRead: INT];
PutCharViaUnsafePutBlock: PROC [self: STREAM, char: CHAR];
PutBlockViaPutChar: PROC [self: STREAM, block: REF READONLY TEXT,
startIndex: NAT, count: NAT];
PutBlockViaUnsafePutBlock: PROC [self: STREAM, block: REF READONLY TEXT,
startIndex: NAT, count: NAT];
UnsafePutBlockViaPutChar: PROC [self: STREAM, block: IO.UnsafeBlock];
AmbushStream: PROC [self: STREAM, streamProcs: REF IO.StreamProcs,
streamData: REF ANY, reusing: STREAM ¬ NIL];
UnAmbushStream: PROC [self: STREAM];
Property list manipulation
StoreData: PROC [self: STREAM, key: ATOM, data: REF ANY];
LookupData: PROC [self: STREAM, key: ATOM] RETURNS [REF ANY];
RemoveData: PROC [self: STREAM, key: ATOM];
StoreProc: PROC [class: REF StreamProcs, key: ATOM, procRef: REF ANY];
LookupProc: PROC [self: STREAM, key: ATOM] RETURNS [procRef: REF ANY];
END.
CHANGE LOG
Created by MBrown on August 31, 1983 9:55 am