TiogaSelectionAllocImpl.mesa Edited by Paxton on June 17, 1983 1:32 pm
DIRECTORY
TiogaDocument USING [Selection, SelectionRec],
TiogaSelection;
TiogaSelectionAllocImpl: CEDAR MONITOR EXPORTS TiogaSelection = BEGIN
OPEN TiogaSelection;
pSel: PUBLIC TiogaDocument.Selection ← Create[];
sSel: PUBLIC TiogaDocument.Selection ← Create[];
fSel: PUBLIC TiogaDocument.Selection ← Create[];
oldSel: PUBLIC TiogaDocument.Selection ← Create[];
nilSel: PUBLIC TiogaDocument.Selection ← Create[];
tSel1, tSel2, tSel3: TiogaDocument.Selection; -- cache of temporary selection records
Create: PUBLIC PROC RETURNS [TiogaDocument.Selection] = {
RETURN [NEW[TiogaDocument.SelectionRec]] };
Alloc: PUBLIC ENTRY PROC RETURNS [tSel: TiogaDocument.Selection] = {
ENABLE UNWIND => NULL;
IF tSel3 # NIL THEN { tSel ← tSel3; tSel3 ← NIL }
ELSE IF tSel2 # NIL THEN { tSel ← tSel2; tSel2 ← NIL }
ELSE IF tSel1 # NIL THEN { tSel ← tSel1; tSel1 ← NIL }
ELSE tSel ← Create[] };
Free: PUBLIC ENTRY PROC [tSel: TiogaDocument.Selection] = {
ENABLE UNWIND => NULL;
IF tSel3 = tSel OR tSel2 = tSel OR tSel1 = tSel THEN ERROR;
IF tSel3 = NIL THEN tSel3 ← tSel
ELSE IF tSel2 = NIL THEN tSel2 ← tSel
ELSE IF tSel1 = NIL THEN tSel1 ← tSel };
Copy: PUBLIC ENTRY PROC [source, dest: TiogaDocument.Selection] = {
ENABLE UNWIND => NULL;
dest^ ← source^ };
END.