-- StreamAlto.mesa, HGM, May 21, 1980  9:24 PM
-- StreamImpl.mesa (last edited by: Gobbel on: July 9, 1979  11:59 AM) --
DIRECTORY
  Environment,
  Stream;

StreamAlto: PROGRAM EXPORTS Stream =
  BEGIN OPEN Stream;
  -- procedures (listed alphabetically)
  GetByte: PUBLIC PROCEDURE [sH: Handle] RETURNS [Byte] =
    -- Gets one byte by calling sH.get with locally defined parameters
    BEGIN
    array: PACKED ARRAY [0..2) OF Byte;
    bl: Block = [@array, 0, 1];
    options: InputOptions = [FALSE, FALSE, FALSE, TRUE, TRUE];
    [] ← sH.get[sH, bl, options];
    RETURN[array[0]];
    END; --GetByte

  GetChar: PUBLIC PROCEDURE [sH: Handle] RETURNS [CHARACTER] = LOOPHOLE[GetByte];
  -- Gets one character by calling sH.get with locally defined parameters
  GetWord: PUBLIC PROCEDURE [sH: Handle] RETURNS [word: Word] =
    -- Gets one word by calling sH.get with locally defined parameters
    BEGIN
    bl: Block = [@word, 0, 2];
    options: InputOptions = [FALSE, FALSE, FALSE, TRUE, TRUE];
    [] ← sH.get[sH, bl, options];
    END; --GetWord

  PutByte: PUBLIC PROCEDURE [sH: Handle, byte: Byte] =
    -- Puts one byte by calling sH.put with locally defined parameters
    BEGIN
    array: PACKED ARRAY [0..2) OF Byte;
    bl: Block = [@array, 0, 1];
    array[0] ← byte;
    sH.put[sH, bl, FALSE];
    END; --PutByte

  PutChar: PUBLIC PROCEDURE [sH: Handle, char: CHARACTER] = LOOPHOLE[PutByte];
  -- Puts one character by calling sH.put with locally defined parameters
  PutWord: PUBLIC PROCEDURE [sH: Handle, word: Word] =
    -- Puts one word by calling sH.put with locally defined parameters
    BEGIN bl: Block = [@word, 0, 2]; sH.put[sH, bl, FALSE]; END; --PutWord
  -- Signals and Errors (listed alphabetically)

  EndOfStream: PUBLIC SIGNAL [nextIndex: CARDINAL] = CODE;
  LongBlock: PUBLIC SIGNAL [nextIndex: CARDINAL] = CODE;
  ShortBlock: PUBLIC ERROR = CODE;
  SSTChange: PUBLIC SIGNAL [sst: SubSequenceType, nextIndex: CARDINAL] = CODE;
  StartIndexGreaterThanStopIndexPlusOne: PUBLIC ERROR = CODE;
  TimeOut: PUBLIC SIGNAL [nextIndex: CARDINAL] = CODE;
  END.