-- PutGet.mesa; written by Bill Paxton, May 1981
-- edited by McGregor. February 14, 1983 10:03 am
-- edited by Paxton. June 14, 1983 3:55 pm
Last Edited by: Lamming, June 7, 1983 9:03 am
DIRECTORY
File,
Rope,
IO,
TiogaNode;
PutGet: CEDAR DEFINITIONS = BEGIN
Offset: TYPE = TiogaNode.Offset;
MaxLen: Offset = LAST[Offset];
RefBranchNode: TYPE = TiogaNode.RefBranchNode;
ROPE: TYPE = Rope.ROPE;
-- **** File Input/Output
ToFile: PROC [
fileName: ROPE, node: RefBranchNode, start: Offset ← 0, flatten, textOnly: BOOLFALSE]
RETURNS [dataLen, count: Offset];
ToFileC: PROC [
file: File.Capability, node: RefBranchNode, start: Offset ← 0,
flatten, textOnly: BOOLFALSE] RETURNS [dataLen, count: Offset];
-- write the node on the specified file
-- starts writing at given address in file
-- returns dataLen = number of data bytes at start of file,
-- and count = the total number of bytes written
FromFile: PROC [
fileName: ROPE, start: Offset ← 0, len: Offset ← MaxLen, okToMapFile: BOOLFALSE]
RETURNS [RefBranchNode];
FromFileC: PROC [
file: File.Capability, start: Offset ← 0, len: Offset ← MaxLen, okToMapFile: BOOLFALSE]
RETURNS [RefBranchNode];
-- create node from the contents of a file
-- starts reading at given start address in file
-- pretends that start+len is the end of the file
-- if file was not created by ToFile (i.e., password not correct)
-- then returns a simple document containing the ASCII contents of the file
-- set okToMapFile to TRUE if you will not want to overwrite the contents later
FromFileError: ERROR;
Tioga2FileFormatError: SIGNAL;     -- raised for all format faults
ClassNotAvailable: SIGNAL;      -- raised when item class not registered
WriteMesaFilePlain: PROC [fileName: ROPE, root: RefBranchNode];
This is like WriteFilePlain, but adds initial dashes to comments if necessary.
WriteFilePlain: PROC [fileName: ROPE, root: RefBranchNode];
WriteFileCPlain: PROC [file: File.Capability, root: RefBranchNode];
-- gives text of file with CR after each node and TABs before according to nesting
-- **** Input/Output using ropes instead of files
ToRope: PROC [node: RefBranchNode, flatten, textOnly: BOOLEANFALSE]
RETURNS [dataLen, count: Offset, output: ROPE];
-- resulting rope contains same representation of node as would be put on file
FromRope: PROC [rope: ROPE, start: Offset ← 0, len: Offset ← MaxLen] RETURNS [RefBranchNode];
-- reads rope to construct node
WriteRopePlain: PROC [node: RefBranchNode] RETURNS [output: ROPE];
-- **** IO Operations ****
ToStream: PROC [stream: IO.Handle, node: RefBranchNode, flatten, textOnly: BOOLFALSE]
RETURNS [dataLen, count: Offset];
-- does a series of IO.PutBlock's
-- returns number of bytes written
FromStream: PROC [stream: IO.Handle, len: Offset ← MaxLen] RETURNS [RefBranchNode];
-- reads up to len chars from stream (via GetBlock's) to construct a node
The following is a property record used by the incremental parse routine: CreateInternalRep to save parse state for future calls.
SpanInfo: PUBLIC TYPE = REF SpanInfoRec;
SpanInfoRec: PUBLIC TYPE = RECORD [
charsStart: Offset,
charsLen: Offset,
ctrlStart: Offset,
ctrlLen: Offset,
externalRepRope: ROPE];
CreateInternalRep: PROC [br:RefBranchNode, wholeTree:BOOLFALSE] ;
creates a valid internal representation
If wholeTree=TRUE then the branch will be cracked down to the leaves. If wholeTree=FALSE only the branch will be parsed, and stubs generated for the children. The children can then be parsed using the same mechanism.
GCBigInterval: PROC ;
Set the collection interval large to minimise chance of GC
GCRestoreInterval: PROC ;
Restore the previous interval
END.