Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
Loader


NAME

Loader - load and initialize modules

SYNOPSIS

TYPE LoadProc = PROCEDURE (module: ARRAY OF CHAR;
                           errors: RelatedEvents.Object) : BOOLEAN;
TYPE LoadServiceProc = PROCEDURE (service, for: ARRAY OF CHAR;
                                  errors: RelatedEvents.Object) : BOOLEAN;
TYPE Interface = POINTER TO InterfaceRec;
TYPE InterfaceRec =
   RECORD
      load: LoadProc;
      loadService: LoadServiceProc;
   END;


CONST noInterface = 0; CONST moduleNotLoaded = 1; CONST servicesNotSupported = 2; CONST serviceNotLoaded = 3; CONST errorcodes = 4; TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: SHORTINT; module: Events.Message; (* module or service name *) for: Events.Message; (* type name for serviceNotLoaded *) END; VAR errormsg: ARRAY errorcodes OF Events.Message; VAR error: Events.EventType;

PROCEDURE SetInterface(if: Interface);

PROCEDURE Load(module: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN; PROCEDURE LoadService(service, for: ARRAY OF CHAR; errors: RelatedEvents.Object) : BOOLEAN;

DESCRIPTION

Loader provides a system-independent interface to the module loader. Some implementations provide a dynamic module loader while others are only able to look for the module in a statically linked execution image.

SetInterface should be called during the initialization of the module which performs load operations. The load procedure component is expected to meet the specification of Load. The interface procedure loadService is optional and may be set to NIL.

Load tries to load and initialize the given module. LoadService tries to locate a module which offers the given service (see Services) for the type named for, and, if successful, to load it.

Note that Loader calls Services.InitLoader during its initialization.

DIAGNOSTICS

Load and LoadService return FALSE in error case. Errors lead to events which are related to the errors parameter:
noInterface
SetInterface has not been called yet.
moduleNotLoaded
The interface procedure load returned FALSE.
serviceNotLoaded
The interface procedure loadService returned FALSE.
servicesNotSupported
is returned if the loader is not able to locate service offers (i.e. if the loadService interface procedure was NIL).

SEE ALSO

Services
definition of services and type names
SysLoader
the system-dependent implementation of this interface

Edited by: borchert, last change: 1996/09/16, revision: 1.2, converted to HTML: 1997/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module