IPWriter.mesa
Copyright © 1984 Xerox Corporation. All rights reserved.
Doug Wyatt, August 22, 1984 10:14:49 am PDT
Token-level interface for writing encoded Interpress masters
DIRECTORY
IO USING [STREAM],
IPBasic USING [Op, Rational, XeroxPixelVectorType],
Rope USING [ROPE];
IPWriter: CEDAR DEFINITIONS
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
STREAM: TYPE ~ IO.STREAM;
Op: TYPE ~ IPBasic.Op;
Rational: TYPE ~ IPBasic.Rational;
ErrorCode:
TYPE ~ {
ok, -- initial value for an ErrorCode
bug, -- implementation bug
unimplemented, -- operation not currently implemented
unknownEncoding, -- the requested encoding is not implemented
illegalArgument, -- invalid argument for an operation
closed -- tried to operate on a closed writer
};
Error:
ERROR[code: ErrorCode, explanation:
ROPE ←
NIL];
Writer: TYPE ~ REF WriterRep;
WriterRep:
TYPE ~
RECORD[class: Class, stream:
STREAM];
Class: TYPE ~ REF ClassRep;
ClassRep:
TYPE ~
RECORD[
encoding: ATOM ←,
putOp: PROC[writer: Writer, op: Op] ←,
putInt: PROC[writer: Writer, value: INT] ←,
putReal: PROC[writer: Writer, value: REAL] ←,
putRational: PROC[writer: Writer, value: Rational] ←,
putIdentifier: PROC[writer: Writer, rope: ROPE] ←,
putString: PROC[writer: Writer, rope: ROPE] ←,
putInsertfile: PROC[writer: Writer, rope: ROPE] ←,
putComment: PROC[writer: Writer, rope: ROPE] ←,
putAnnotation: PROC[writer: Writer, rope: ROPE] ←,
putLargeVector:
PROC[writer: Writer, putBytes:
PROC[
STREAM],
bytesPerElement: [0..256), type: IPBasic.XeroxPixelVectorType] ←
];
Open:
PROC[name:
ROPE, encoding:
ATOM]
RETURNS[Writer];
Create the named file, write a header for the specified encoding, and return a Writer.
Create:
PROC[stream:
STREAM, encoding:
ATOM]
RETURNS[Writer];
Create a Writer for the given stream. (Does not write a header.)
PutHeader:
PROC[writer: Writer];
Write an Interpress header for the writer's encoding.
Close:
PROC[writer: Writer];
Close the writer's stream and prevent further calls on the writer.
PutOp:
PROC[writer: Writer, op: Op];
PutInt:
PROC[writer: Writer, value:
INT];
PutReal:
PROC[writer: Writer, value:
REAL];
PutRational:
PROC[writer: Writer, value: Rational];
PutIdentifier:
PROC[writer: Writer, rope:
ROPE];
PutString:
PROC[writer: Writer, rope:
ROPE];
PutComment:
PROC[writer: Writer, rope:
ROPE];
PutAnnotation:
PROC[writer: Writer, rope:
ROPE];
PutInsertfile:
PROC[writer: Writer, rope:
ROPE];
PutLargeVector:
PROC[writer: Writer,
putBytes: PROC[STREAM],
bytesPerElement: [0..256),
type: IPBasic.XeroxPixelVectorType ← $nil
];
The number of bytes put into the stream by putBytes must be a multiple of bytesPerElement.
Register:
PROC[class: Class];
END.