CDPinObjectsImpl.mesa (part of ChipNDale)
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi August 8, 1984 12:38:56 pm PDT
last edited Christian Jacobi, November 11, 1985 3:09:47 pm PST
DIRECTORY
CD,
CDInstances,
CDBasics,
CDSymbolicObjects,
CDImports,
CDPinObjects,
CDPrivate,
CDProperties,
Rope;
CDPinObjectsImpl:
CEDAR
PROGRAM
IMPORTS CDInstances, CDBasics, CDSymbolicObjects, CDPinObjects, CDPrivate, CDProperties, Rope
EXPORTS CDPinObjects
SHARES CDSymbolicObjects =
BEGIN
pinObjectsClass: PUBLIC REF CD.ObjectClass ← CDSymbolicObjects.pinClass;
pinLayer: PUBLIC CD.Layer ← CDSymbolicObjects.pinLayer;
CreatePinOb:
PUBLIC
PROC [size:
CD.Position]
RETURNS [
CD.Object] =
BEGIN
RETURN [CDSymbolicObjects.CreatePin[size]]
END;
CreatePinInstance:
PUBLIC PROC [name: Rope.
ROPE, rect:
CD.Rect, lev:
CD.Layer←
CD.combined, owner:
ATOM←
NIL]
RETURNS [
CD.Instance] =
BEGIN
pinOb: CD.Object = CreatePinOb[CDBasics.SizeOfRect[rect]];
pinInstance: CD.Instance = CDInstances.NewInstance[pinOb, CDBasics.BaseOfRect[rect]];
IF name#NIL THEN SetName[pinInstance, name];
IF lev#CD.combined THEN SetLayer[pinInstance, lev];
IF owner#NIL THEN SetOwner[pinInstance, owner];
RETURN [pinInstance]
END;
pinNameProp: ATOM ← $SignalName;
pinOwnerProp: ATOM ← $ownerOfPin;
pinLevProp: ATOM ← $layerOfPin;
SetName:
PUBLIC PROC [pinInstance:
CD.Instance, name: Rope.
ROPE] =
BEGIN
IF CDPinObjects.IsPinApp[pinInstance] THEN CDProperties.PutPropOnInstance[pinInstance, pinNameProp, name]
END;
GetName:
PUBLIC
PROC [pinInstance:
CD.Instance]
RETURNS [r: Rope.
ROPE ←
NIL] =
BEGIN
IF CDPinObjects.IsPinApp[pinInstance]
THEN {
WITH CDProperties.GetPropFromInstance[pinInstance, pinNameProp]
SELECT
FROM
n: Rope.ROPE => r ← n
ENDCASE => NULL
}
END;
SetOwner:
PUBLIC PROC [pinInstance:
CD.Instance, owner:
ATOM] =
BEGIN
IF CDPinObjects.IsPinApp[pinInstance]
THEN
CDProperties.PutPropOnInstance[pinInstance, pinOwnerProp, owner]
END;
GetOwner:
PUBLIC
PROC [pinInstance:
CD.Instance]
RETURNS [at:
ATOM←
NIL] =
BEGIN
WITH CDProperties.GetPropFromInstance[pinInstance, pinOwnerProp]
SELECT
FROM
a: ATOM => at ← a
ENDCASE => NULL
END;
SetLayer:
PUBLIC
PROC [pinInstance:
CD.Instance, lev:
CD.Layer] =
BEGIN
IF CDPinObjects.IsPinApp[pinInstance]
THEN
CDProperties.PutPropOnInstance[pinInstance, pinLevProp, CDPrivate.layers[lev]]
END;
GetLayer:
PUBLIC
PROC [pinInstance:
CD.Instance]
RETURNS [lev:
CD.Layer←
CD.combined] =
BEGIN
WITH CDProperties.GetPropFromInstance[pinInstance, pinLevProp]
SELECT
FROM
lp: CDPrivate.LayerRef => lev ← lp^.number
ENDCASE => NULL
END;
EnumeratePins:
PUBLIC
PROC [ob:
CD.Object←
NIL, eachPin: CDPinObjects.InstanceEnumerator]
RETURNS [quit:
BOOL←
FALSE] =
BEGIN
cp: CD.CellPtr;
WITH ob.specificRef
SELECT
FROM
c: CD.CellPtr => cp ← c;
ip: CDImports.ImportPtr => {
-- HACKK until imports handle pins reasonably
IF ip.boundInstance=NIL THEN RETURN [TRUE];
quit ← EnumeratePins[ip.boundInstance.ob, eachPin];
RETURN
};
ENDCASE => RETURN [TRUE];
FOR list:
CD.InstanceList ← cp.contents, list.rest
WHILE (list#
NIL
AND ~quit)
DO
IF list.first.ob.class=pinObjectsClass
THEN {
quit ← eachPin[list.first]; -- do NOT catch errors
};
ENDLOOP;
END;
FindPins:
PUBLIC
PROC [ob:
CD.Object←
NIL, pinName: Rope.
ROPE]
RETURNS [apps:
CD.InstanceList] =
BEGIN
Enumerate: CDPinObjects.InstanceEnumerator = {
IF Rope.Equal[GetName[inst], pinName] THEN apps ← CONS[inst, apps];
};
[] ← EnumeratePins[ob, Enumerate];
END;
END.