-- LooksReaderImpl.mesa
-- written by Bill Paxton, March 1981
-- last edit by Bill Paxton, December 22, 1981 1:30 pm
DIRECTORY
RunReader,
LooksReader,
TextNode;
LooksReaderImpl: CEDAR MONITOR
IMPORTS RunReader, LooksReader, TextNode
EXPORTS LooksReader
SHARES LooksReader =
BEGIN OPEN LooksReader;
Create: PUBLIC PROC [] RETURNS [new: Ref] = {
-- create a reader for chars and looks
new ← TextNode.pZone.NEW[Body];
new^ ← [0,0,noLooks,RunReader.Create[]] };
lksrdr1, lksrdr2, lksrdr3: Ref; -- shared looks readers
GetLooksReader: PUBLIC ENTRY PROC RETURNS [reader: Ref] = {
IF lksrdr3 # NIL THEN { reader ← lksrdr3; lksrdr3 ← NIL }
ELSE IF lksrdr2 # NIL THEN { reader ← lksrdr2; lksrdr2 ← NIL }
ELSE IF lksrdr1 # NIL THEN { reader ← lksrdr1; lksrdr1 ← NIL }
ELSE reader ← Create[] };
FreeLooksReader: PUBLIC ENTRY PROC [reader: Ref] = {
SetPosition[reader, NIL];
IF lksrdr3 = reader OR lksrdr2 = reader OR lksrdr1 = reader THEN ERROR;
IF lksrdr3 = NIL THEN lksrdr3 ← reader
ELSE IF lksrdr2 = NIL THEN lksrdr2 ← reader
ELSE IF lksrdr1 = NIL THEN lksrdr1 ← reader };
Start: PUBLIC PROC = {
};
END.