DIRECTORY Pipal, RefTab; PipalModify: CEDAR DEFINITIONS = BEGIN World: TYPE = REF WorldRec; WorldRec: TYPE = RECORD [ object: Pipal.Object, state: REF _ NIL, undoEvents: Events _ NIL, -- first undoable event head of list redoEvents: Events _ NIL, -- first redoable event head of list selected: LIST OF Pipal.Object _ NIL -- must be children of the object ]; Event: TYPE = REF EventRec; EventRec: TYPE = RECORD [ message: Pipal.ROPE, object: Pipal.Object _ NIL, state: REF _ NIL ]; Events: TYPE = LIST OF Event; Undo: PROC [world: World]; Redo: PROC [world: World]; Reset: PROC [world: World]; Commit: PROC [world: World]; Do: PROC [world: World, message: Pipal.ROPE, newObject: Pipal.Object _ NIL, newState: REF _ NIL]; Reachable: PROC [root, candidate: Pipal.Object] RETURNS [BOOL]; ReachableFromRoots: PROC [roots: Pipal.Objects, candidate: Pipal.Object] RETURNS [BOOL]; replaceMethod: Pipal.Method; ReplaceProc: TYPE = PROC [parent: Pipal.Object, table: RefTab.Ref] RETURNS [newParent: Pipal.Object]; Replace: ReplaceProc; TransitiveReplace: PROC [oldRoots: Pipal.Objects, table: RefTab.Ref] RETURNS [newRoots: Pipal.Objects]; ReplaceInWorld: PROC [world: World, oldChild, newChild: Pipal.Object _ NIL]; END. ςPipalModify.mesa Copyright Σ 1988 by Xerox Corporation. All rights reserved. Bertrand Serlet January 26, 1988 1:22:24 am PST Louis Monier January 25, 1988 9:41:33 am PST Theory This modules define how to modify Pipal "worlds". World Generic Operations on Worlds Undoes while possible. Flushes undoEvents and redoEvents. Stacks a new event containing the current object and state on the undo list and modifies current state and object. Transitive Closure Transitive closure is a common operation that has to be efficient. Is candidate object reachable by enumeration from the root object? Is candidate object reachable by enumeration from any root object? Replacement Replaces each child of parent found in table. Table maps [old child] -> [new child]. No replaceMethod method => crash and burn. If no child of parent is found in table, it is possible but not imperative that newParent=parent. Short cut for applying the replace method. No replace method => crash and burn. Replaces every child by its matching object everywhere reachable from oldRoots. Recursively replaces each parent. If no first is reachable from oldRoots then newRoots=oldRoots. Temporary Hack .... Short cut for applying the replacing everywhere in world oldChild by newChild. Κ˜– "Cedar" stylešœ™Jšœ<™KšœœŸ$˜>Kšœ œœœŸ"˜HK˜K˜—Kšœœœ ˜šœ œœ˜Kšœœ˜Kšœœ˜Kšœœ˜K˜—Kšœœœœ˜—™šžœœ˜J˜—šžœœ˜J˜—šžœœ˜J™J˜—šžœœ˜Jšœ"™"J™—š žœœœœ œœ˜aJ™r——™šœC™CM™—šž œœ!œœ˜?K™BK™—šžœœ1œœ˜XK™B——™ ˜K˜—šœ œœ+œ˜eKšœ-™-K™&Kšœ*™*Kšœa™aJ™—šžœ˜K™*K™$K™—šžœœ.œ˜gKšœ²™²——™šžœœ3œ˜LKšœN™NK™——Jšœ˜J˜—…—Θ I