RegisterRefLiteral.mesa
Copyright Ó 1987, 1991 by Xerox Corporation. All rights reserved.
Mark Weiser, February 18, 1988 11:36:59 pm PST
Carl Hauser, February 19, 1988 5:37:02 pm PST
Supports the REF literals included by the compiler in compiled code. Since the compiler can't make up allocated objects for them, they must be created at module installation time.
Different types of objects must be created differently, so there is a general mechanism to register the create procedures for different types and to select the appropriate one for each literal.
DIRECTORY
SafeStorage;
RegisterRefLiteral: CEDAR DEFINITIONS
~ BEGIN
RegisteredProc: TYPE = PROC [string: LONG STRING] RETURNS [REF];
UnknownType: ERROR [type: SafeStorage.Type, string: LONG STRING];
RegisterType: PROC [p: RegisteredProc, type: SafeStorage.Type];
Registers "p" to be used to create REF literals of type "type" from LONG STRINGs.
Note that the REF type, not the referent type, is used to register the procedure.
Notice that at least in the case of Cedar REF literal types, by the time the implementation of this interface has been STARTed all of the necessary types have been registered already. No more calls to RegisterType should be required.
Create: PROC [type: SafeStorage.Type, string: LONG STRING] RETURNS [REF];
Called by the runtime during installation of each REF literal. It looks up the type, and calls the appropriate registered proc. If there isn't one, it raises an error.
Notice that Create is normally called by the installation support code. No Cedar program should need to use it. Each package supporting REF literals exports much better ways of creating objects than this!
END.