GGProps.mesa
Copyright Ó 1989 by Xerox Corporation. All rights reserved.
Last edited by Pier on June 14, 1989 4:37:28 pm PDT
Contents: General property mechanism for GG slices. A property is a [key, value] pair. The key is an ATOM. The value is a REF. Slices may have property lists.
Bier, July 17, 1989 4:17:51 pm PDT
DIRECTORY
GGSlice, IO, Prop, Rope;
GGProps: CEDAR DEFINITIONS = BEGIN
Slice: TYPE = GGSlice.Slice;
SliceParts: TYPE = GGSlice.SliceParts;
PropList: TYPE = Prop.PropList;
STREAM: TYPE = IO.STREAM;
Put: PROC [slice: Slice, parts: SliceParts, key: ATOM, val: REF];
Add the given property to the children of slice described in parts.
Get: PROC [slice: Slice, parts: SliceParts, key: ATOM] RETURNS [val: REF, isUnique: BOOLTRUE];
Get the property value matching key from the children of slice described in parts. If the children have more than one value for this property, return one of the values and isUnique = FALSE
Rem: PROC [slice: Slice, parts: SliceParts, key: ATOM] RETURNS [isUnique: BOOLTRUE];
Remove the property value matching key from all of the children of slice described in parts. If the children have more than one different value for this property, return isUnique = FALSE
Copy: PROC [key: ATOM, val: REF] RETURNS [copy: REF];
Calls the registered CopyProc, if any, for key, to make a copy of val.
PropWalkProc: TYPE = PROC [key: ATOM, val: REF] RETURNS [done: BOOLFALSE];
Used with procedure Walk to operate on all the properties of a slice
Walk: PROC [slice: Slice, parts: SliceParts, walkProc: PropWalkProc] RETURNS [aborted: BOOLFALSE];
For all properties of the children of slice described in parts, call the walkProc. Returns aborted=TRUE and aborts the walk if any call to walkProc returned TRUE.
Kill: PROC [slice: Slice, parts: SliceParts];
Remove all the properties of the children of slice described in parts
CopyAll: PROC [fromSlice, toSlice: Slice, fromParts, toParts: SliceParts ← NIL];
Copy all of the props of fromSlice to toSlice, using procedure Copy, above.
ValFormat: TYPE = {counted, delimited};
The client FileoutProc can encode the value in the following ways:
counted: a string of bytes which may have any value and must be uninterpreted. counted encodings would usually be written out preceded by a byte count.
delimited: a sting of ASCII characters, which may be written out bracketed by non-ASCII delimiters.
ToRope: PROC [key: ATOM, val: REF] RETURNS [r: Rope.ROPE, vf: ValFormat ← delimited];
Returns a ROPE describing the property and the encoding in that ROPE. Looks up key in the global IO table for a FileoutProc for this property. If a key lookup fails (no FileoutProc is registered) or the FileoutProc value is NIL, will attempt to fileout as a simple generic value (i.e. INT, REAL, BOOL, ROPE, ...).
FromRope: PROC [key: ATOM, r: Rope.ROPE] RETURNS [val: REF];
Returns a property derived from the input ROPE. Looks up key in the global IO table for a FileinProc for this property. If a key lookup fails (no FileinProc is registered) or the FileinProc value is NIL, will return the original ROPE r in val.
FileoutProc: TYPE = PROC [s: STREAM, val: REF] RETURNS [vf: ValFormat ← delimited];
Intended useage is to take an ROS stream (s) from the client and write to it a human readable encoding of the value (val). Values can have a variety of formats. See definition of TYPE ValFormat for details of format encoding. Clients can either register a FileoutProc for a given property using Register, or allow simple generic values to be delineated by type and written out.
FileinProc: TYPE = PROC [s: STREAM] RETURNS [val: REF];
Intended useage is to take an RIS stream (s) from the client and read from it a human readable encoding of the value (val), then convert the val to a datum or data structure. Clients can either register a FileinProc for a given property using Register, or allow rope valued encodings for unknown property values to be returned.
CopyProc: TYPE = PROC [val: REF] RETURNS [copy: REF];
When a slice is copied, each property on its property list is separately copied. The result of the CopyProc is placed on the new property list. If the copy proc returns NIL, the property is not placed on the new slice. The default CopyProc returns its argument.
IdentityCopy: CopyProc;
Register: PROC [key: ATOM, in: FileinProc, out: FileoutProc, copy: CopyProc];
A global table of [key, fileinProc, fileoutProc] entries is maintained. Clients who wish to have their properties filed in and out are encouraged to register appropriate procs.
END.