CDProperties.mesa a ChipNDale module
Copyright © 1983, 1986 by Xerox Corporation. All rights reserved.
by Ch. Jacobi, September 27, 1983 2:06 pm
last edited Christian Jacobi, March 25, 1986 12:58:12 pm PST
DIRECTORY
CD;
CDProperties: CEDAR DEFINITIONS =
BEGIN
Rules for property usage
A property list requires following the ChipNDale access and registration rules when it is of type CD.PropList, CDProperties.PropList, CD.PropRef, CDProperties.PropRef or a derived type from one of those.
Violating access rules will cause chaos for ChipNDale at some time.
Violating registration rules might prevent correct behaviour of unrelated ChipNDale tools; it is considered unfair.
Violating user restrictions will cause only the violator to fail; ChipNDale does not care.
Access rules
Don't modify ChipNDale PropList's directly with PropertyLists; (PutProp can not monitor writing back the result parameter)
Registration rules
Atoms which start with the letters "CDX" or "CDx" (e.g. $CDxNMosTransitors) must be manual registered by the registrar and RegisterProperty must not be used.
Atoms which start with the letters "CDY" or "CDy" (e.g. $CDyNMosTransitors) must not be registered, and there is no waranty of non-conflict. These may be used for debugging only.
Atoms which start with other letters must be registered with RegisterProperty. RegisterProperty allows a registrationKey to enable re-registration. Use your name or the module name of the module you are implementing as registrationKey.
Other REF-types need not be registered, since no conflicts may occur.
Every module is allowed to introduce only a finite (fixed at compile time) number of "property names"s; they are kept in a table for "ever".
--Types and registration
PropList: TYPE = CD.PropList;
PropRef: TYPE = CD.PropRef; --ABSOLUTELY NEVER NIL
--Use only CDProperties to modify ChipNDale PropList's; Never PropertyLists directly.
InitPropRef: PROC [] RETURNS [PropRef] = INLINE {
--Initialization value for a PropRef
--An object MUST be NOT accessible for ChipNDale until all its PropRef's are initialized.
RETURN [NEW[PropList←NIL]]
};
RegisterProperty: PROC [prop: REF, registrationKey: REF←NIL] RETURNS [first: BOOL];
--Registers "prop" for usage; any program which wants to use an ATOM as a "prop" can
--make sure it is the only user of this "prop".
--If registrationKey#NIL and registrationKey is equal to registrationKey of previous
--registration, a property may be multiple registered.
--Otherwise raise CD.Error[doubleRegistration] if prop was already registered.
--Property names cannot be removed, since they may reside somewhere in the
--stored data.
--Usage
PutProp: PROC [onto: REF, prop: REF, val: REFNIL];
--Puts a prop val pair on a property list
--onto must NOT be of type PropList
--a NIL val removes the property
GetProp: PROC [from: REF, prop: REF] RETURNS [REF];
--Fetches a value from a property list; NIL if not found
GetListProp: PROC [propList: PropList, prop: REF] RETURNS [REF];
--Fetches a value from a property list; NIL if not found
--PutProp and GetProp "understand" the following types:
 CD
.Instance
 CD
.Object
 CD.PropRef (CDProperties.PropRef)
 some more types which are only of secondary importance.
--Speed ups and special cases
PutInstanceProp: PROC [onto: CD.Instance, prop: REF, val: REFNIL];
--a NIL val removes the property
PutDesignProp: PROC [onto: CD.Design, prop: REF, val: REFNIL];
--a NIL val removes the property
PutTechnologyProp: PROC [onto: CD.Technology, prop: REF, val: REFNIL];
--a NIL val removes the property
PutAtomProp: PROC [onto: ATOM, prop: REF, val: REFNIL];
--this property is NOT fetchable with Atom.GetProp
--The onto Atom need not be registered anywhere, the registration of the
--prop is enough to prevent conflicts.
--a NIL val removes the property
PutObjectProp: PROC [onto: CD.Object, prop: REF, val: REFNIL];
--a NIL val removes the property
--warning: different objects may share bits, property owners loose!
PutLayerProp: PROC [onto: CD.Layer, prop: REF, val: REFNIL];
--a NIL val removes the property
PutPRefProp: PROC [onto: CD.PropRef, prop: REF, val: REFNIL];
--a NIL val removes the property
GetInstanceProp: PROC [from: CD.Instance, prop: REF] RETURNS [REF] = INLINE {
--NIL if prop is not found
RETURN [GetListProp[from.properties, prop]]
};
GetDesignProp: PROC [from: CD.Design, prop: REF] RETURNS [REF] = INLINE {
--NIL if prop is not found
RETURN [GetListProp[from.properties^, prop]]
};
GetTechnologyProp: PROC [from: CD.Technology, prop: REF] RETURNS [REF] = INLINE {
--NIL if prop is not found
RETURN [GetListProp[from.properties^, prop]]
};
GetAtomProp: PROC [from: ATOM, prop: REF] RETURNS [REF];
--does NOT fetch properties put on an ATOM with Atom.PutProp
--The from Atom need not be registered anywhere, the registration of the
--prop is enough to prevent conflicts
--NIL if prop is not found
GetObjectProp: PROC [from: CD.Object, prop: REF] RETURNS [REF] = INLINE {
--NIL if prop is not found
--warning: different objects may share bits, property owners loose!
RETURN [GetListProp[from.properties, prop]]
};
GetLayerProp: PROC [from: CD.Layer, prop: REF] RETURNS [REF];
--NIL if prop is not found
GetPRefProp: PROC [from: CD.PropRef, prop: REF] RETURNS [REF] = INLINE {
--NIL if prop is not found
RETURN [GetListProp[from^, prop]]
};
--general property procedures
InstallProcs: PROC [prop: REF, new: PropertyProcsRec ← [properties: NIL]];
--Installs procedures for a property registration
--Overwrites values for which new has non NIL entries (except key).
--prop must be registered and yours.
--Exceptional: The actual parameter new.properties might have been
-- created with PropertyLists directly.
FetchProcs: PROC [prop: REF] RETURNS [PropertyProcs];
--Fetches the procedures on the property registration
--Don't copy PropertyProcs^; it can be extended by future calls of InstallProcs
RegisterAndInstall: PROC [prop: REF, new: PropertyProcsRec ← [properties: NIL], registrationKey: REF NIL] RETURNS [first: BOOL];
--Short cut for conveniance
--Registers property and, if this was the first registration then installs procedures.
--Parameters and raised exceptions are the same as in RegisterProperty and InstallProcs
PropertyProcs: TYPE = REF PropertyProcsRec;
PropertyProcsRec: TYPE = RECORD [
makeCopy: MakeCopyProc ← NIL,
internalWrite: InternalPWriteProc ← NIL,
internalRead: InternalPReadProc ← NIL,
exclusive: BOOLFALSE, --the implementation requests others not too fool with
autoRem: BOOLFALSE, --removed on edits
reserved: BOOLFALSE, --for experiments
key: REFNIL, --the prop field of registration
properties: PropList ← NIL
];
MakeCopyProc: TYPE = PROC [prop: REF, val: REF, purpose: REFNIL] RETURNS [valCopy: REF];
--valCopy: may be NIL if property should not be copied
--purpose:
-- copy procs will not recognize most purposes...
-- but a particular property might want a particular handling from some tool
InternalPWriteProc: TYPE = PROC [prop: REF, val: REF];
InternalPReadProc: TYPE = PROC [prop: ATOM] RETURNS [val: REF];
--The procedure types of PropertyProcs will be called within CDProperties monitor lock.
--They must not call any other procedure from CDProperties (wedges!!); But they may
--call PropertyLists directly.
CopyProps: PROC [propList: PropList, putOnto: REF, purpose: REFNIL];
--Copies properties individually using their MakeCopyProc's and defaults for some types
--The resulting propList is put on putOnto
AppendProps: PROC [winner, looser: PropList←NIL, putOnto: REF, purpose: REFNIL];
--Copies properties individually using their MakeCopyProc's and defaults for some types.
--Works like first copying looser, then copying winner.
--copy is a different list from both, looser and winner
--The resulting propList copy is put on putOnto
DCopyProps: PROC [propList: PropList, purpose: REFNIL] RETURNS [copy: PropList];
--Like CopyProps, but returns PropList;
--Consider: if you assign the copy to somewhere, the previous PropList might have been
--changed after making the copy and before the assignment is finished.
DAppendProps: PROC [winner, looser: PropList←NIL, purpose: REFNIL] RETURNS [copy: PropList];
--Like AppendProps, but returns PropList;
--Consider: if you assign the copy to somewhere, the previous PropList might have been
--changed after making the copy and before the assignment is finished.
DoWithinLock: PRIVATE PROC [p: PROC];
--Executes arbitrary code within CDProperties monitor lock. Dangerous.
--Must not call any other procedure from CDProperties (wedges!!)
--May call PropertyLists directly
--particular property procedures for implementors
DontCopy: PROC [prop: REF, val: REF, purpose: REFNIL] RETURNS [nil: REF];
--to be shure that no copy is made; trivial procedure
CopyVal: PROC [prop: REF, val: REF, purpose: REFNIL] RETURNS [valCopy: REF];
--copy of val; trivial procedure; is for some types a default anyway
RopePWrite: PROC [prop: REF, val: REF];
RopePRead: PROC [prop: ATOM] RETURNS [val: REF];
IntPWrite: PROC [prop: REF, val: REF];
IntPRead: PROC [prop: ATOM] RETURNS [val: REF];
AtomPWrite: PROC [prop: REF, val: REF];
AtomPRead: PROC [prop: ATOM] RETURNS [val: REF];
SomePWrite: PROC [prop: REF, val: REF];
SomePRead: PROC [prop: ATOM] RETURNS [val: REF];
END.
Design considerations
A registeration procedure for property names is needed to prevent the same property name beeing used by two independent modules.
Props are unique, and not used per technology since they hang on objects where the technology does not hang and some procs haven't a design or technology parameter.