CoreProperties.mesa
Copyright © 1985 by Xerox Corporation. All rights reversed.
Barth, September 29, 1986 2:45:02 pm PDT
Spreitzer, August 12, 1985 6:05:07 pm PDT
Bertrand Serlet October 18, 1986 8:46:03 pm PDT
Pradeep Sindhu February 7, 1986 4:00:28 pm PST
Mike Spreitzer March 6, 1987 1:50:49 pm PST
Operations
GetProp:
PROC [from: Properties, prop:
ATOM]
RETURNS [value:
REF
ANY ←
NIL];
If value is NIL then no such property.
PutProp:
PROC [on: Properties, prop:
ATOM, value:
REF
ANY ←
NIL]
RETURNS [new: Properties];
If value is NIL then the property is deleted.
Enumerate:
PROC [props: Properties, consume:
PROC [
ATOM,
REF
ANY]];
consume is called with each (prop, value) pair.
PrintProperties:
PROC [props: Properties, out:
STREAM ←
NIL, indent:
NAT ← 0, cr:
BOOL ←
TRUE, level:
NAT ← 2];
Uses the property's propPrint property to print each item. If no propPrint property exists and the value is of a well-known type, will print appropriately for that type.
GetPropPrintProc:
PROC [prop:
ATOM, val:
REF
ANY]
RETURNS [PropPrintProc];
Returns the procedure that would be used to print the given property-value pair.
Registration
RegisterProperty:
PROC [prop:
ATOM, properties: Properties ←
NIL]
RETURNS [sameProp:
ATOM];
Should be called by every tool that defines a property which needs property's properties. Sets the property's properties as given in the second argument. Returns the same prop so that definition and registration can occur in the same line of Cedar code.
RegisterUnprintableProperty:
PROC [prop:
ATOM, properties: Properties ←
NIL]
RETURNS [sameProp:
ATOM];
Purely convenience; shorthand for RegisterProperty[prop, PutProp[properties, propPrint, PropDontPrint]]
StoreProperties:
PROC [prop:
ATOM, properties: Properties];
Store a property list on a property.
FetchProperties:
PROC [prop:
ATOM]
RETURNS [properties: Properties];
Fetch the property list of a property.
propPrint:
ATOM;
Value should be REF to PropPrintProc.
PropPrintProc:
TYPE =
PROC [to:
STREAM, prop:
ATOM, val:
REF
ANY, indent, level:
NAT, cr:
BOOL];
PropDontPrint: REF PropPrintProc; -- Does not print anything
Inheritance of Properties
InheritCellTypeProp:
PROC [from: CellType, prop:
ATOM]
RETURNS [value:
REF
ANY ←
NIL];
This is the proper way to get a property from a cell type for props that use inheritance. It takes into account the two standard Core property propagation mechanisms: one is from cell class to cell type, and the other is through cell types whose class has layersProps TRUE. Looks for a property with key prop on from, and, if none, looks on the class of from. If not found and cellType.class.layersProps then the celltype is recasted and the process repeated.
InheritPublicProp:
PROC [cellType: CellType, from: Wire, prop:
ATOM]
RETURNS [value:
REF
ANY ←
NIL];
This is the proper way to get a property from a public sub-wire for props that use inheritance. It takes into account the standard Core property propagation mechanisms. Looks for a property with key prop on from. If cellType.class.layersProps then the wire corresponding to from in the public of Recast[cellType] is searched for prop. This process is repeated until the search succeeds or the result of the recast has a class in which layersProps is FALSE.
Short Cuts
PropertyLiteral:
TYPE =
RECORD [key:
ATOM, val:
REF
ANY ←
NIL];
Props: PROC [lit1, lit2, lit3, lit4, lit5, lit6: PropertyLiteral ← []] RETURNS [properties: Properties];
The following get & put procs are equivalent to directly manipulating the properties fields of various data types. Thus, they are not always appropriate, since Core defines some more complex property propagation mechanisms.
GetWireProp:
PROC [from: Wire, prop:
ATOM]
RETURNS [value:
REF
ANY ←
NIL];
Not always appropriate for getting properties from public wires --- see InheritPublicProp above.
PutWireProp:
PROC [on: Wire, prop:
ATOM, value:
REF
ANY ←
NIL];
When a property might be placed on a public of a celltype which is the result of the recast of a celltype whose class has layersProps FALSE then the property should be placed on the nonrecasted celltype's public, in addition to or in instead of placement upon the recasted cell type's public. This allows the property inheritance mechanism to work correctly.
GetCellClassProp:
PROC [from: CellClass, prop:
ATOM]
RETURNS [value:
REF
ANY ←
NIL];
PutCellClassProp:
PROC [on: CellClass, prop:
ATOM, value:
REF
ANY ←
NIL];
GetCellTypeProp:
PROC [from: CellType, prop:
ATOM]
RETURNS [value:
REF
ANY ←
NIL];
Not always appropriate for getting properties from public wires --- see InheritCellTypeProp above.
PutCellTypeProp:
PROC [on: CellType, prop:
ATOM, value:
REF
ANY ←
NIL];
When a property might be placed on a celltype which is the result of the recast of a celltype whose class has layersProps FALSE then the property should be placed on the nonrecasted celltype, in addition to or in instead of placement upon the recasted cell type. This allows the property inheritance mechanism to work correctly.
GetCellInstanceProp:
PROC [from: CoreClasses.CellInstance, prop:
ATOM]
RETURNS [value:
REF
ANY ←
NIL];
PutCellInstanceProp:
PROC [on: CoreClasses.CellInstance, prop:
ATOM, value:
REF
ANY ←
NIL];