CDDirectoryOps.mesa (a ChipNDale module)
Copyright © 1985, 1987 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, June 3, 1985 7:04:20 pm PDT
Last edited by: Christian Jacobi, April 3, 1987 2:05:09 pm PST
DIRECTORY
CD USING [Design, Object],
RefTab USING [Ref],
Rope USING [ROPE];
CDDirectoryOps: CEDAR DEFINITIONS =
BEGIN
Higher level directory functions.
RemoveIfUnused: PROC [design: CD.Design, ob: CD.Object] RETURNS [done: BOOL, msg: Rope.ROPE];
--Removes ob from the directory,
--but succeeds only if the object is not used anywhere else in the design.
--msg←NIL if succeded without problem.
PruneDirectory: PROC [design: CD.Design, askFirst: BOOLFALSE, pattern: Rope.ROPENIL];
--Removes objects which are not used in the design from the directory.
--pattern: If ~NIL, only objects which match pattern are considered.
--askFirst makes it interactive
ReplaceTagged: PROC [design: CD.Design, replaceBy: REF, rename: BOOLTRUE, key: REFNIL];
--Every object in the design is checked whether it has a replaceBy property pointing to
--an other object. Every instance of the object is then replaced by the other object.
--Directory invariants must hold (except for objects which will be replaced).
-- The object used for replacement must already be in the designs directory.
-- No funny object classes.
--rename: tries to rename replacing objects by name of replaced object
--key: a property key which will be used freely... NIL is ok
RemoveProperties: PROC [design: CD.Design, key: REF];
--Tries to remove the propertiy "key" from all objects of "design";
--May be delayed or incomplete
CleanUp: PROC [design: CD.Design, rootOb: CD.Object←NIL];
--General clean up of designs created using lazy programs.
--Not all invariants are checked, but some; clean up is not an excuse for
--incorrect object creation, but a means for ChipNDale to survive such.
--IF rootOb#NIL only rootOb and its descendants are cleaned up
-- (but the replace step might check the whole design anyway)
--Objects of funny classes might be replaced in place
--Objects which are not included in a directory but could might be included or copied.
-- Those objects must therefore not be used by other processes [callers responsibility].
--Objects which are in the directory of some other design might be replaced with a copy
-- or might cause a crash.
--This procedure might do excessive copying, it is only a survival hack for ChipnDale
-- around bad clients.
IncludeDescribedObjects: PROC [design: CD.Design, ob: CD.Object, visited: RefTab.Ref←NIL];
-- Composed objects or subobjects which have a $Describe property are
-- included in the directory. Objects already in directory will not be renamed.
-- On name conflict, fiddles name.
-- visited: read-write cache of already visited object. Normally use NIL!
END.