RefPrint.mesa
Copyright Ó 1988, 1991 by Xerox Corporation. All rights reserved.
Michael Plass, June 2, 1988 10:28:05 am PDT
This provides a place to register REF printers for various types.
DIRECTORY
SafeStorage USING [Type],
IO USING [STREAM];
RefPrint: CEDAR DEFINITIONS
~ BEGIN
PrintRefProc: TYPE ~ PROC[stream: IO.STREAM, ref: REF] RETURNS [ok: BOOL ¬ TRUE];
Register: PROC [printer: PrintRefProc, type: SafeStorage.Type];
When it is convenient to provide a SafeStorage.Type, this form of registration is prefered, as the PrintRefProc will be registerd in a hash table. The type is that of the referent.
RegisterFallback: PROC [printer: PrintRefProc];
When it is clumsy to get a SafeStorage.Type for the referent (for example, for LIST types), use this form of registration. The fallback printers are called in order (most-recently-registered first) until one of them returns TRUE.
UnRegister: PROC [printer: PrintRefProc];
Just in case.
PrintReferent: PrintRefProc;
PrintREF: PrintRefProc; -- Checks for NIL, also prints ­ before any value
END.