PropListImpl.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, April 9, 1992 11:48:58 am PDT
Christian Jacobi, April 15, 1992 3:25 pm PDT
DIRECTORY
PropList, UnsafePropList;
PropListImpl:
CEDAR
PROGRAM
IMPORTS UnsafePropList
EXPORTS PropList ~
BEGIN OPEN PropList;
ListContainer:
PUBLIC
TYPE = UnsafePropList.PropListContainer;
IsPropList:
PUBLIC
PROC [x:
REF]
RETURNS [
BOOL] = {
RETURN [ISTYPE[x, REF ListContainer]]
};
NarrowPropList:
PUBLIC
PROC [x:
REF]
RETURNS [List] = {
RETURN [NARROW[x, REF ListContainer]]
};
NewPropList:
PUBLIC PROC []
RETURNS [List] = {
RETURN [NEW[ListContainer]];
};
GetProp:
PUBLIC
PROC [list: List, key:
REF]
RETURNS [
REF] = {
RETURN [UnsafePropList.GetProp[LOOPHOLE[list], key]]
};
PutProp:
PUBLIC
PROC [list: List, key, val:
REF]
RETURNS [old:
REF] = {
old ¬ UnsafePropList.PutProp[LOOPHOLE[list], key, val];
};
RemProp:
PUBLIC
PROC [list: List, key:
REF]
RETURNS [old:
REF] = {
old ¬ UnsafePropList.RemProp[LOOPHOLE[list], key];
};
TrustedAddNewProp:
PUBLIC
PROC [list: List, key, val:
REF] = {
UnsafePropList.TrustedAddNewProp[LOOPHOLE[list], key, val];
};
ConditionalPutProp:
PUBLIC
PROC [list: List, key, expect, new:
REF]
RETURNS [val:
REF, done:
BOOL] = {
[val, done] ← UnsafePropList.ConditionalPutProp[LOOPHOLE[list], key, expect, new];
};
NiloutPropList:
PUBLIC
PROC [list: List] = {
IF list#NIL THEN UnsafePropList.NiloutPropList[LOOPHOLE[list]];
};
GetPropOrInit:
PUBLIC
PROC [list: List, key:
REF, init: InitializeProcType, data:
REF ¬
NIL]
RETURNS [val:
REF, done:
BOOL] = {
[val, done] ¬ UnsafePropList.GetPropOrInit[LOOPHOLE[list], key, init, data];
};
Enumerate:
PUBLIC
PROC [list: List, map: EachPropProc, data:
REF]
RETURNS [quit:
BOOL ¬
FALSE] = {
RETURN [UnsafePropList.Enumerate[LOOPHOLE[list], map, data] ];
};
Copy1: UnsafePropList.EachPropProc = {
UnsafePropList.TrustedAddNewProp[LOOPHOLE[data], key, val];
};
NewCopy: PUBLIC PROC [list: List] RETURNS [copy: List ¬ NEW[ListContainer]] = {
IF list#NIL THEN
[] ¬ UnsafePropList.Enumerate[LOOPHOLE[list], Copy1, copy];
};
NewCopy:
PUBLIC
PROC [list: List]
RETURNS [copy: List ¬
NEW[ListContainer]] = {
IF list#NIL THEN UnsafePropList.CopyPropList[LOOPHOLE[copy], LOOPHOLE[list]];
};
END.