<> <> <> <> 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.