-- RefAnyStream.mesa: an interface for applications
-- of a simple REF ANY stream abstraction
-- Last Modified On 21-Jan-82 12:03:03 By Paul Rovner
RefAnyStream: DEFINITIONS =
{
--TYPEs
Handle: TYPE = REF Object;
Object: TYPE = RECORD[
procs: ObjectProcsHandle,
data: REF ANY ← NIL
];
ObjectProcsHandle: TYPE = REF ObjectProcs;
ObjectProcs: TYPE = RECORD[
get: PROC[Handle] RETURNS[REF ANY],
put: PROC[Handle, REF ANY],
putBack: PROC[Handle, REF ANY],
flush: PROC[Handle],
close: PROC[Handle],
endOf: PROC[Handle] RETURNS[BOOLEAN],
empty: PROC[Handle] RETURNS[BOOLEAN]
];
-- ERRORs
Error: ERROR [ec: ErrorCode];
ErrorCode: TYPE = {
NotImplementedForThisStream,
EndOfStream,
-- attempt to do a get at end of stream
StreamClosed,
-- raised by operations after close (except flush, reset, close.)
BadIndex
--negative length or index to SetIndex
};
-- PROCs
-- These are here for convenience. They are examples of
-- PROCs that create RefAnyStream.Objects. They use PORTs
-- in their implementations.
CreateCoForkedProducerStream:
PROC[producer: PROC[self: REF ANY, sink: Handle--for use by the producer--],
data: REF ANY]
RETURNS[Handle--for use by the consumer--];
CreateCoForkedConsumerStream:
PROC[consumer: PROC[self: REF ANY, source: Handle--for use by the consumer--],
data: REF ANY]
RETURNS[Handle--for use by the producer--];
}.