NodeProps.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
written by Paxton. January 1981
last written by Paxton. December 28, 1982 11:11 am
Doug Wyatt, March 2, 1985 4:05:08 pm PST
Michael Plass, April 1, 1985 3:43:17 pm PST
Rick Beach, March 27, 1985 10:45:41 am PST
DIRECTORY
Rope USING [ROPE],
TextNode USING [Ref];
NodeProps: CEDAR DEFINITIONS
~ BEGIN
ROPE: TYPE = Rope.ROPE;
true: REF BOOL;
false: REF BOOL;
Get, Put, Map properties on a node
PutProp: PROC [n: TextNode.Ref, name: ATOM, value: REF];
NIL is a valid value. Use RemProp to remove property. (Although GetProp will not distinguish between property value NIL and no property present, it is useful to be able to have NIL values to avoid creating garbage. Setting to NIL doesn't release the property record, so don't need to reallocate when next set to a non-NIL value.
GetProp: PROC [n: TextNode.Ref, name: ATOM] RETURNS [REF];
RemProp: PROC [n: TextNode.Ref, name: ATOM];
MapPropsAction: TYPE = PROC [name: ATOM, value: REF] RETURNS [quit: BOOLFALSE];
MapProps: PROC [n: TextNode.Ref, action: MapPropsAction, formatFlag,
commentFlag: BOOLTRUE] RETURNS [quit: BOOL];
apply the action to each name & value pair for the node
returns true if&when an action returns true
if commentFlag is false, skips Comment property; ditto for formatFlag
hack to accelerate Inherit and PutFile operations
Read, Write, Copy Props
ReadSpecsProc: TYPE = PROC [name: ATOM, specs: ROPE] RETURNS [value: REF];
WriteSpecsProc: TYPE = PROC [name: ATOM, value: REF] RETURNS [specs: ROPE];
CopyInfoProc: TYPE = PROC [name: ATOM, value: REF] RETURNS [new: REF];
Register: PROC [name: ATOM,
reader: ReadSpecsProc, writer: WriteSpecsProc, copier: CopyInfoProc];
registers these procs for this property name
they will be called by DoSpecs, GetSpecs, and CopyInfo
NullRead: ReadSpecsProc; -- returns NIL always
NullWrite: WriteSpecsProc; -- returns NIL always
NullCopy: CopyInfoProc; -- returns NIL always
DoSpecs: ReadSpecsProc;
used when reading files
calls the registered reader for this property name
returns specs if no reader is registered
GetSpecs: WriteSpecsProc;
used when writing files
calls the registered writer for this property name
if no writer is registered, returns value if it is a rope, NIL otherwise
CopyInfo: CopyInfoProc;
used when copying nodes
calls the registered copier for this property name
if no copier is registered, returns old value
END.