Oberon || Library || Module Index || Search Engine || Definition || Module
CONST definition = 0; CONST module = 1; CONST defmod = 2; TYPE SourceKind = SHORTINT; (* definition .. defmod *)
TYPE Header = POINTER TO HeaderRec; TYPE HeaderRec = RECORD (PersistentDisciplines.ObjectRec) modname: ConstStrings.String; kind: SourceKind; date: Times.Time; (* date of last modification *) srcid: ConstStrings.String; (* sth unique *) args: Args.Arguments; (* for compilation *) END;
Source = POINTER TO SourceRec; SourceRec = RECORD (PersistentDisciplines.ObjectRec) header: Header; END;
TYPE OpenProc = PROCEDURE (source: Source; VAR s: Streams.Stream) : BOOLEAN; TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD (Objects.ObjectRec) open: OpenProc; END;
PROCEDURE Init(source: Source; if: Interface); PROCEDURE CreateHeader(VAR header: Header; modname: ConstStrings.String; kind: SourceKind; date: Times.Time; srcid: ConstStrings.String; args: Args.Arguments); PROCEDURE Open(source: Source; VAR s: Streams.Stream) : BOOLEAN; PROCEDURE GetSource(s: Streams.Stream; VAR source: Source);
Sources consist of a byte sequence (accessible as stream) and a header record containing following fields:
Init initializes a source object (that has to be created before) and associates it with if. The open procedure of if is expected to open a source for reading and should return a stream capable of seek operations (important for printing error messages that include source code). Multiple independent stream connections to the same source object must be supported. CreateHeader creates and initializes a persistent header object.
Open opens source for reading. Multiple open operations are permitted. GetSource returns the source object associated with s, if any. Note that GetSource works even for streams imported by RemoteObjects.
GetSource sets source to NIL if it is not associated with a source.
Oberon || Library || Module Index || Search Engine || Definition || Module