PWPins.mesa 
Copyright © 1985 by Xerox Corporation. All rights reversed.
Created by Bertrand Serlet and Louis Monier, June 4, 1985 11:27:01 am PDT
Last Edited by: Serlet, June 27, 1985 3:51:34 pm PDT
DIRECTORY
CD USING [ApplicationPtr, Design, ObPtr],
CDPinObjects USING [AppEnumerator],
Rope USING [ROPE];
PWPins: CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
Side: TYPE = [0 .. 3]; -- INT interval is better than enumerated type, for we can save this property value on file
bottom: Side = 0; right: Side = 1; top: Side = 2; left: Side = 3; -- must be a rotation on the edges. Some programs may depend on the representation of the Side.
The convention for getting the side of a pin is to see if the pin is located on the border of the InterestRect of the ob. For pins at a corner, the biggest direction is the relevant one. This is not a Hack, because in fact only the dimension parallel to the side of the pin is meaningful.
GetSide: PROC [ob: CD.ObPtr, pin: CD.ApplicationPtr] RETURNS [isOnBorder: BOOL, side: Side];
This proc enumerates in random order all pins, even the ones found in the deepest levels of the hierarchy of ob. The applications passed to eachPin are new applications, with all properties (e.g. the name) copied, so that the coordinate system refers to the one of ob. EnumerateDeepPins uses the expand proc for objects of unknown class. Changes on pins while the enumeration may or may not be seen. If the flag stopEnumerateDeepPins is TRUE, the recursion stops on instances of cells which have a non-nil $StopEnumerateDeepPins property, i.e. those instances will not be enumerated.
EnumerateDeepPins: PROC [ob: CD.ObPtr, eachPin: AppEnumerator, stopEnumerateDeepPins: BOOLTRUE] RETURNS [quit: BOOL];
AppEnumerator: TYPE = CDPinObjects.AppEnumerator; -- [app: CD.ApplicationPtr] RETURNS [quit: BOOL ← FALSE]
The following function is a speed up of EnumerateDeepPins when the only pins wanted are the ones which intersect the boarder of the InterestRect, i.e. pins such as GetSide.isOnBorder is TRUE.
EnumerateEdgePins: PROC [ob: CD.ObPtr, eachPin: AppEnumerator, stopEnumerateDeepPins: BOOLTRUE] RETURNS [quit: BOOL];
Parses an object, extract all pins along the edges, and creates a new cell having an instance of the object, and renamed pins. Pins renamed to NIL are not copied. If the flag stopEnumerateDeepPins is TRUE, the property $StopEnumerateDeepPins is added on the instance, so that EnumerateDeepPins will only enumerate the copied pins next call.
RenamePins: PUBLIC PROC [design: CD.Design, ob: CD.ObPtr, renameProc: RenameProc ← DefaultRenameProc, stopEnumerateDeepPins: BOOLTRUE] RETURNS [cell: CD.ObPtr];
RenameProc: TYPE = PROC [oldRope: ROPE] RETURNS [newRope: ROPE];
DefaultRenameProc: RenameProc; -- {newRope ← oldRope}; Identity renaming
Useful in many RenameProcs for indexing names. e.g. Index["foo", 4]="foo[4]"
Index: PROC [rope: ROPE, index: INT] RETURNS [indexedRope: ROPE];
END.