CDSomeImplementorsImpl.mesa (part of ChipNDale)
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
by Ch. Jacobi, September 10, 1984 9:20:09 am PDT
last edited by Ch. Jacobi, May 29, 1985 11:04:16 am PDT
DIRECTORY
CD,
CDBasics,
CDProperties,
CDSomeImplementors,
TokenIO;
CDSomeImplementorsImpl: CEDAR PROGRAM
IMPORTS CD, CDBasics, CDProperties, TokenIO
EXPORTS CDSomeImplementors =
BEGIN
SimpleSetOrigin: PUBLIC PROC[ob: CD.Object, new: CD.Position] =
BEGIN
--we handle the val of the originProperty property as readonly; and may share records
IF ~ob.class.inDirectory THEN ERROR;
CDProperties.PutPropOnObject[ob, originProperty, NEW[CD.Position←new]]
END;
SimpleGetOrigin: PUBLIC PROC[ob: CD.Object] RETURNS [CD.Position] =
BEGIN
IF ob.class.inDirectory THEN
WITH CDProperties.GetPropFromObject[ob, originProperty] SELECT FROM
pp: REF CD.Position => RETURN [pp^]
ENDCASE => NULL;
RETURN [ CDBasics.BaseOfRect[CD.InterestRect[ob]] ]
END;
InternalWriteProperty: PROC [prop: REF, val: REF] =
BEGIN
p: REF CD.Position = NARROW[val];
TokenIO.WriteInt[p.x];
TokenIO.WriteInt[p.y];
END;
InternalReadProperty: PROC [prop: ATOM] RETURNS [val: REF] =
BEGIN
x: INT = TokenIO.ReadInt[];
y: INT = TokenIO.ReadInt[];
val ← NEW[CD.Position ← [x, y]]
END;
originProperty: ATOM = $simpleOrigin;
[] ← CDProperties.RegisterProperty[originProperty];
CDProperties.InstallProcs[prop: originProperty,
new: CDProperties.PropertyProcsRec[
makeCopy: CDProperties.CopyVal, --because we treat the coordinates readonly
internalWrite: InternalWriteProperty,
internalRead: InternalReadProperty,
exclusive: TRUE
]
];
END.