SpinifexInvert.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Written by: Mark Shand, August 9, 1984 8:38:33 pm PDT
Last Edited by: Shand, August 24, 1984 0:32:23 am PDT
DIRECTORY
CD USING [Design, ApplicationPtr, ObPtr, DesignPosition, Orientation],
SpinifexCellPredicates USING [IsLogicalCell, CellPredicateProc]
;
SpinifexInvert: CEDAR DEFINITIONS
IMPORTS SpinifexCellPredicates
~ BEGIN
Invert takes a list of ChipNDale applications (appls) which form the roots of a forest and inverts it to give an inverted tree in which each cell in the hierarchy, contains a list of Inversions whose corresponding cells include that cell directly as a child, the list of Inversions for cells in the original list of roots contain in addition a reference to a pseudo-Inversion which acts a ultimate parent to all cells. Clients may attach thier own data to each cell in the inversion through ClientData, this PROC is called when a cell is first encounted. The IsCell PROC allows the client to determine the objects which are to act as nodes in the hierarchy, rather than simply those which `have children' in the chipNDale sense.
Invert: PROCEDURE [design: CD.Design, appls: LIST OF CD.ApplicationPtr, ClientData: ClientDataProc ← NIL, IsCell: SpinifexCellPredicates.CellPredicateProc ← SpinifexCellPredicates.IsLogicalCell] RETURNS [leaves: LIST OF REF Inversion];
Inversion: TYPE ~ RECORD [
cell: CD.ObPtr, -- this cell, NIL for the pseudo-Inversion root.
childCount: CARDINAL, -- Number of distinct sub-cells with this cell as a parent.
parents: LIST OF REF Inversion, -- Cells which have this cell as a child.
data: REF ANYNIL -- Client data.
];
ClientDataProc: TYPE ~ PROCEDURE [design: CD.Design, appl: CD.ApplicationPtr, pos: CD.DesignPosition, orient: CD.Orientation, parent: REF Inversion] RETURNS [data: REF ANYNIL];
END.