XlAssoc.mesa
Copyright Ó 1988, 1991 by Xerox Corporation. All rights reserved.
Christian Jacobi, April 29, 1988 0:30:03 am PDT
Christian Jacobi, March 7, 1991 4:57 pm PST
DIRECTORY Xl USING [Window, nullWindow];
XlAssoc: CEDAR DEFINITIONS
~ BEGIN OPEN Xl;
Package implements hash tables for association of windows with REF values.
All windows must belong to the same server [name space].
This packages does not generate requests to the X server, nor does it get events in case windows are destroyed.
The nullWindow acts as universal root; it can not be included or removed, but its children can be enumerated and it can hold data.
Table: TYPE = REF AssocTabRep;
AssocTabRep: TYPE = MONITORED RECORD [impl: REF AssocTabImplRep];
AssocTabImplRep: TYPE;
ParentUnknown: ERROR;
NullWindowUsed: ERROR;
Create: PROC [mod: NAT ¬ 17] RETURNS [Table];
creates new table with suggested number of windows.
GetSize: PROC [x: Table] RETURNS [INT];
returns number of windows in table [the nullWindow is not counted]
InsertWindow: PROC [x: Table, window: Window, parent: Window ¬ nullWindow, val: REF ¬ NIL] RETURNS [done: BOOL];
introduces new window and stores value, if window is not already known
parent must be already inserted or nullWindow.
window will be removed whenever parent is removed
returns TRUE if inserted, FALSE if previously known
may raise ParentUnknown or NullWindowUsed
StoreWindow: PROC [x: Table, window: Window, parent: Window ¬ nullWindow] RETURNS [new: BOOL];
introduces window or change parent
parent must be already inserted or nullWindow.
window will be removed whenever parent is removed
leaves associated value as it was, or, NIL if not previously known
returns TRUE if newly inserted, FALSE if previously known
may raise ParentUnknown or NullWindowUsed
RemoveWindow: PROC [x: Table, window: Window] RETURNS [found: BOOL];
removes window and all its descendants from table
may raise NullWindowUsed
FetchValue: PROC [x: Table, window: Window] RETURNS [found: BOOL, parent: Window, val: REF];
looks up window in table, returns associated value and parent (if window in table)
if window found: found = TRUE, val = associated value, parent = parent of window
if window not found: found = FALSE, val = NIL, parent = nullWindow
parent as introduced with window; not checked with X server
StoreValue: PROC [x: Table, window: Window, val: REF ¬ NIL] RETURNS [found: BOOL];
stores new value for window;
returns TRUE if window known (=in table), FALSE otherwise
EachChildAction: TYPE = PROC [window: Window, val: REF, parent: Window, data: REF] RETURNS [quit: BOOL ¬ FALSE];
Recurse: TYPE = {oneLevelOnly, topDown, bottomUp};
EnumerateChildren: PROC [x: Table, window: Window, action: EachChildAction, recurse: Recurse ¬ oneLevelOnly, data: REF ¬ NIL] RETURNS [found: BOOL, quit: BOOL];
enumerates children, each level in unspecified order
children inserted/deleted during enumeration may or may not be seen
applies action to each child until action returns TRUE or no more children
returns found: window is found in table; quit: some action returned TRUE
Erase: PROC [x: Table];
removes all windows and data from table
[and breaks circularities]
END.