CD.mesa; Main definitions for Chipndale
by Ch. Jacobi June 24, 1983 3:54 pm
last edited Christian Jacobi February 16, 1984 10:55 am
DIRECTORY
Graphics USING [Context, Color, PaintMode, black],
List USING [AList],
MBQueue USING [Queue],
RefTab USING [Ref],
Rope USING [ROPE],
SymTab USING [Ref];
CD: CEDAR DEFINITIONS =
--CD stands for ChipnDale,
BEGIN
-- measures
-- independent of cordinate system
Number: TYPE = INT;
Position: TYPE = RECORD [x, y: Number];
Rect: TYPE = RECORD [x1, y1, x2, y2: Number];
--a Rect is called normalized if (x1>x2) OR (y1>y2) means that the Rect is empty.
--all Rects are normalized, except if a special comment denies
--Rect's are closed: they include all the endpoints; as you expect, points have size 0.
-- design coordinates
DesignNumber: TYPE = Number;
DesignPosition: TYPE = Position;
DesignRect: TYPE = Rect;
lambda: DesignNumber = 2;
--your program must not depend on the value of lambda
Orientation: TYPE = [0..15] ← 0;
--Module CDOrient exports all you probably need about Orientations;
--If your program depends on the representation of Orientation, it
--is probably wrong.
original: Orientation = 0;
-- Errors
Error: ERROR [ec: ErrorCode ← programmingError, explanation: Rope.ROPENIL];
ErrorCode: TYPE = {programmingError, callingError, noResource, doubleRegistration, missingRegistration, other};
-- properties
Properties: TYPE = List.AList;
--friendly use expected: don't assign properties without first register
--their names with CDProperties.
--use only CDProperties to access Properties
-- levels
levelNumber: NAT = 256;
Level: TYPE = [0..levelNumber);
combined: Level = 0; -- level used for object containing different or unknown levels
highLightShade: Level = 1; -- visualization; not for generating masks
highLightError: Level = 2; -- visualization; not for generating masks
NewLevel: PROC [technology: Technology, uniqueKey: ATOM] RETURNS [Level];
--may raise Error[noResource] and others
--the technolgy implementation must guarantee for uniqueness of uniqueKey's
-- (unique only for the technology)
FetchLevel: PROC [t: Technology, uniqueKey: ATOM] RETURNS [Level];
LevelTechnology: PROC [l: Level] RETURNS [Technology];
LevelKey: PROC [l: Level] RETURNS [ATOM];
--object, cells, applications
markNum: NAT = 256;
ObPtr: TYPE = REF ObjectDefinition;
ObjectDefinition: TYPE = RECORD [
p: REF READONLY ObjectProcs, -- never modify p nor p^
size: DesignPosition ← [lambda, lambda],
level: Level ← combined,
marked: [0..markNum) ← 0,
specificRef: REF ANYNIL,
properties: Properties ← NIL -- see warning
];
--Several applications may point to same object: consider on modifications.
--Some implementors of object-types share the bits of different objectdefinitions
--if they are the same, excluding properties. User of properties loose.
CellPtr: TYPE = REF CellRecord;
CellRecord: TYPE = RECORD [
contents: ApplicationList ← NIL,
name: Rope.ROPENIL,
key: Rope.ROPENIL,
simplifyOn: NATLAST[NAT]
];
RectPtr: TYPE = REF RectRecord;
RectRecord: TYPE = RECORD [filler: PRIVATE REF];
ApplicationList: TYPE = LIST OF ApplicationPtr←NIL;
ApplicationPtr: TYPE = REF Application;
Application: TYPE = RECORD [
ob: ObPtr,
location: DesignPosition,
orientation: Orientation,
selected: BOOLEAN,
properties: Properties ← NIL
];
ObjectProcs: TYPE = RECORD [ -- generic procedures for an object
quickDrawMe: DrawProc,
drawMe: DrawProc,
showMeSelected: DrawProc,
hitInside: HitInsideProc, -- if called, aptr.ob.p.hitInside MUST be the called procedure itself
insideRect: RectProc,
further: PRIVATE RefTab.Ref,
technology: PRIVATE Technology, -- dont rely on it, it is often NIL
objectType: ATOM,
hasChildren: BOOL, -- if hasChildren then included in directory
directoryProcs: REFNIL,
wireTyped: BOOL, -- if wiretyped then insideRect.y corresponds length
internalWrite: InternalWriteProc,
internalRead: InternalReadProc,
match: MatchProc←NIL,
describe: DescribeProc←NIL
];
DrawProc: TYPE = PROC [aptr: ApplicationPtr, pos: DesignPosition, orient: Orientation, pr: REF DrawInformation];
--ignores aptr.location and aptr.orientation, may use aptr.properties
HitInsideProc: TYPE = PROC [aptr: ApplicationPtr, hitRect: DesignRect] RETURNS [BOOL];
RectProc: TYPE = PROC [ob: ObPtr] RETURNS [DesignRect];
InternalWriteProc: TYPE = PROC [me: ObPtr];
InternalReadProc: TYPE = PROC [] RETURNS [ObPtr];
DescribeProc: TYPE = PROC [me: ObPtr] RETURNS [Rope.ROPE];
MatchProc: TYPE = PROC [me: ObPtr, r: DesignRect, level: Level, prim: BOOL, horz: BOOL] RETURNS [BOOL];
RegisterObjectType: PROC [objectType: ATOM, technology: Technology←NIL]
RETURNS [REF ObjectProcs];
--may raise Error[doubleRegistration] and others
--Also initializes procedures with default values
--An object type may be used either in arbitrary technology or technology-independent.
--This should be the only way to create data of type ObjectProcsRec
FetchObjectProcs: PROC [objectType: REF, technology: Technology←NIL]
RETURNS [REF --READONLY-- ObjectProcs];
--may raise Error[missingRegistration]
--consider ObjectProcs as readonly if you are not the implementor of the object type
-- Design
PushRec: TYPE = RECORD [
dummyCell: ApplicationPtr,
originally a copy of mightReplace; warning: size may be wrong
mightReplace: ApplicationPtr←NIL,
specific: CellPtr, -- cache of dummyCell.ob.specificRef
changed: BOOLFALSE,
indirectlyChanged: BOOLFALSE,
deletedList: REFNIL
];
Design: TYPE = REF DesignRec;
DesignRec: TYPE = RECORD [ -- use only CDOps.CreateDesign to create record
actual: LIST OF PushRec, -- actual.first is most deeply pushed cell;
cellDirectory: PRIVATE CellTableRef,
-- pushed cells are copied and not part of the cellDirectory
name: Rope.ROPENIL,
technology: Technology←NIL,
designValues: DesignValues←NIL, --CDValue
queue: MBQueue.Queue,
seqPrivate: SequencerRef,
properties: Properties←NIL
--CDValue supports more fields
];
SequencerRef: TYPE = REF SequencerDesignPrivate;
SequencerDesignPrivate: TYPE;
CellTableRef: PRIVATE TYPE = SymTab.Ref;
DesignValues: TYPE = REF DesignValuesRep; --CDValue
DesignValuesRep: TYPE; --CDValue
-- Technology
Technology: TYPE = REF TechnologyRec;
TechnologyRec: TYPE = RECORD [ -- use RegisterTechnology to create record
key: ATOMNIL,
name: Rope.ROPENIL,
technologyPrivate: PRIVATE TechnologyPrivate,
technologyValues: TechnologyValues, --CDValue
technologyCommands: TechnologyCommands, --CDSequencer
usedLevels: LIST OF Level, -- without constant levels defined in CD
properties: Properties←NIL
--CDValue supports more fields
];
TechnologyValues: TYPE = REF TechnologyValuesRep; --CDValue
TechnologyCommands: TYPE = REF TechnologyCommandsRep; --CDSequencer
TechnologyPrivate: TYPE = PRIVATE REF TechnologyPrivateRep;
TechnologyValuesRep: TYPE; --CDValue
TechnologyCommandsRep: TYPE; --CDSequencer
TechnologyPrivateRep: TYPE;
RegisterTechnology: PROC [key: ATOM, name: Rope.ROPENIL] RETURNS [Technology];
--This must be the only way to create data of type TechnologyRec
--may raise Error[doubleRegistration] and others
--[Implementors of technologies: look further rules in CDTechnology]
FetchTechnology: PROC [key: ATOM] RETURNS [Technology];
--may raise Error[missingRegistration] and others
-- drawing
DrawRef: TYPE = REF DrawInformation;
DrawInformation: TYPE = RECORD [
worldClip: DesignRect, -- in doubt is larger than device
minimalSize: Number, -- if xyz<minimalSize; xyz is not drawn the normal way (Cells)
scaleHint: REAL, -- to monitor simplifications; 0 means no simplifications
drawChild: DrawProc,
drawRect: DrawRectProc, -- still world coordinates, how many bits do device coordinates use?
saveRect: DrawRectProc,
outLineProc: OutLineProc, -- usefull for visualization only; not for generating masks
drawComment: DrawCommentProc,
stopFlag: REF BOOL,
devicePrivate: REF, -- differentiate among multiple (viewers) with same drawProc's
viewerPrivate: ViewerPrivate←NIL, -- speed up for viewers devicePrivate
contextFilter: REF ContextFilter←NIL,
suppressOutsidePushedCell, b1, b2: BOOLFALSE, -- reserved for some experiment
--state of redrawing
deviceContext: PRIVATE Graphics.Context,
viewerSave: ViewerSave←NIL, -- speed up for viewers saveRect's internal's
design: Design,
nesting: ApplicationList, -- shares Application's but not ApplicationPtr's
pushLevel: CARDINAL ← 0
];
--DrawInformation records should not be copied unless the state of drawing is
--separately initialized (including viewerSave for viewers).
ViewerPrivate: TYPE = REF ViewerPrivateRep;
ViewerPrivateRep: TYPE;
ViewerSave: TYPE = REF ViewerSaveRep;
ViewerSaveRep: TYPE;
DrawRectProc: TYPE = PROC [r: DesignRect, l: Level, pr: DrawRef];
OutLineProc: TYPE = PROC [r: DesignRect, pr: DrawRef];
DrawCommentProc: TYPE = PROC [r: DesignRect, comment: Rope.ROPE, pr: DrawRef];
ContextFilter: TYPE = ARRAY Level OF RECORD [
doit: BOOLFALSE,
paintMode: Graphics.PaintMode ← opaque,
color: Graphics.Color ← Graphics.black
];
ContextDraw: TYPE = PROC [context: Graphics.Context];
DrawToContext: PROC[pr: DrawRef, proc: ContextDraw, level: Level];
--calls proc which may use context; mode and color are set to level's need
--call is suppressed if level does not need drawing; this is default.
--on recursive calls, the context may or may not include previous transformations
NewNullDeviceDrawRef: PROC [design: Design, deviceContext: Graphics.Context←NIL] RETURNS [DrawRef];
--for conveniance; usefull null procedures and default values
--DrawRef's may also be created differently, if state of redrawing
--gets proper initialization
END.