CDGenerate.mesa (part of ChipNDale)
Copyright © 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, June 5, 1985 8:02:35 pm PDT
Last Edited by Christian Jacobi, September 19, 1985 4:19:51 am PDT
DIRECTORY
CD, Rope, SymTab;
CDGenerate: CEDAR DEFINITIONS =
BEGIN
Common interface for object generators. A Table is a name space of generators.
Table:
TYPE =
REF
READONLY TableRep;
TableRep:
TYPE =
RECORD [rep:
PRIVATE
REF, case:
BOOL, cache:
BOOL];
GeneratorProc: TYPE = PROC [design: CD.Design, key: Rope.ROPE, table: Table, data: REF] RETURNS [ob: CD.Object←NIL];
Create:
PROC [case:
BOOL ←
TRUE, cache:
BOOL ←
TRUE]
RETURNS [Table];
--creates a new, empty table
Clear:
PROC [table: Table];
--undo all registrations
Register:
PROC[table: Table, key: Rope.
ROPE, generator: GeneratorProc, cache:
BOOL←
TRUE, data:
REF←
NIL]
RETURNS [first:
BOOL];
--first if key did not already exist
--cache: tries to cache the result
--data: passed through to FetchNCall calling generator
Caching genenerated objects: to avoid multiple generation of aequivalent objects.
The user assumes that he might reuse an object instead of creating a new object,
whenever he uses the caching scheme...
FetchRegistration:
PROC[table: Table, key: Rope.
ROPE]
RETURNS [generator: GeneratorProc, cache:
BOOL, data:
REF];
--fetch the registration of a generator key
--generator NIL if not found
FetchCached:
PROC[table: Table, design: CD.Design, key: Rope.
ROPE]
RETURNS [CD.Object];
--fetch a generated object if it is cached.
--returns NIL if not found, not cached or looks different
FetchNCall:
PROC[table: Table, design:
CD.Design, key: Rope.
ROPE, cache:
BOOL←
TRUE]
RETURNS [
CD.Object];
--fetch a generator and invoke it
--returns NIL if not found or generated
--caching only if generator and this call want caching
Flush:
PROC [table: Table, design: CD.Design, key: Rope.
ROPE];
--Removes this entry from the cache
FlushAll:
PROC [table: Table, design: CD.Design];
--Removes all entries from the cache
--convenient procedures
SelectOneOf:
PROC[table: Table, label: Rope.
ROPE]
RETURNS [key: Rope.
ROPE];
--Interactive selection
--NIL if discarded
AssertTable:
PROC [project: Rope.
ROPE]
RETURNS [Table];
--Fetches a table; if not done then create one and store it for next call of AssertTable.
--This table can be imported by lots of unknown applications...
publicTables:
PRIVATE SymTab.Ref;
--space for tables to be returned or created using AssertTable
END.