DIRECTORY Rope USING [ROPE], CD USING [Design, Object, Position, ObjectClass]; CDDirectory: CEDAR DEFINITIONS = BEGIN Fetch: PROC [design: CD.Design, name: Rope.ROPE] RETURNS [found: BOOL, object: CD.Object]; Remove: PROC [design: CD.Design, name: Rope.ROPE, expectObject: CD.Object_NIL] RETURNS [done: BOOL]; Include: PROC [design: CD.Design, object: CD.Object, alternateName: Rope.ROPE_NIL, fiddleName: BOOL_TRUE] RETURNS [done: BOOL]; Rename: PROC [design: CD.Design, object: CD.Object, newName: Rope.ROPE _ NIL, fiddleName: BOOL_FALSE] RETURNS [done: BOOL]; Enumerate: PROC [design: CD.Design, action: EachEntryAction] RETURNS [quit: BOOL]; EachEntryAction: TYPE = PROC [name: Rope.ROPE, ob: CD.Object] RETURNS [quit: BOOL_FALSE]; EnumerateChildObjects: PROC[me: CD.Object, p: EnumerateObjectsProc, x: REF_NIL] = INLINE { IF me.class.inDirectory THEN ObToDirectoryProcs[me].enumerateChildObjects[me, p, x] }; Name: PROC[me: CD.Object] RETURNS [Rope.ROPE] = INLINE { RETURN [IF me.class.inDirectory THEN ObToDirectoryProcs[me].name[me] ELSE NIL] }; Another: PROC [me: CD.Object, from, to: CD.Design] RETURNS [CD.Object]; Expand: PROC [me: CD.Object, from, to: CD.Design] RETURNS [CD.Object]; ExpandHard: PROC [me: CD.Object, from, to: CD.Design] RETURNS [CD.Object]; ExpandByDraw: PROC [me: CD.Object, from, to: CD.Design] RETURNS [CD.Object]; DirectoryProcs: TYPE = PRIVATE RECORD [ name: RopeProc, enumerateChildObjects: EnumerateChildObjectsProc, replaceDirectChilds: ReplaceDChildsProc, another: AnotherProc, --may be defaulted: --results in crazy another proc which makes a copy of the object-definition expand: AnotherProc, --may be defaulted setName: SetRopeProc, -- but name must be same as Include used includeEtAll: IncludeEtAllProc ]; ObToDirectoryProcs: PRIVATE PROC [ob: CD.Object] RETURNS [REF DirectoryProcs] = INLINE { RETURN [NARROW[ob.class.directoryProcs, REF DirectoryProcs]] }; InstallDirectoryProcs: PRIVATE PROC [type: REF CD.ObjectClass] RETURNS [REF DirectoryProcs]; EnumerateChildObjectsProc: TYPE = PROC [me: CD.Object, p: EnumerateObjectsProc, x: REF]; EnumerateObjectsProc: TYPE = PROC [me: CD.Object, x: REF]; RopeProc: TYPE = PROC [me: CD.Object] RETURNS [Rope.ROPE]; SetRopeProc: TYPE = PROC [me: CD.Object, r: Rope.ROPE]; IncludeEtAllProc: TYPE = PROC [me: CD.Object, design: CD.Design, name: Rope.ROPE]; ReplaceList: TYPE = LIST OF REF ReplaceRec; ReplaceRec: TYPE = RECORD [ old: CD.Object, oldSize: CD.Position, -- never changed new: CD.Object, newSize: CD.Position, -- will be computed once before calling client procedures off: CD.Position ]; ReplaceDChildsProc: TYPE = PROC [ me: CD.Object, design: CD.Design, replace: ReplaceList ] RETURNS [changed: BOOL_FALSE]; AnotherProc: TYPE = PROC[me: CD.Object, from: CD.Design, to: CD.Design_NIL] RETURNS [CD.Object]; RepositionObject: PROC [design: CD.Design, ob: CD.Object, oldSize: CD.Position, baseOff: CD.Position_[0, 0] ]; ReplaceObject: PROC [design: CD.Design, old: CD.Object, new: CD.Object, off: CD.Position_[0, 0] ]; DoReplaceDirectChild: ReplaceDChildsProc; PropagateChange: PROC [ob: CD.Object, design: CD.Design]; END. ΐCDDirectory.mesa (a ChipNDale module) Copyright c 1983, 1985 by Xerox Corporation. All rights reserved. by Christian Jacobi, 23-Aug-83 last edited Christian Jacobi, September 19, 1985 2:55:15 am PDT directory: designs have a directory of named objects. The directory actually contains all object which are built using other objects. This is necessary for enumeration and for repositioning. Calls handling the same design must be sequential, otherwise the design can be clobbered. -- basic procedures -- search for object in directory -- if expectObject#NIL removes name only, iff named object=expectObject. -- if removed objects are still used, they are neither enumerated correctly anymore, -- nor repositioned if internal objects change -- it is an ERROR to include an object into several design's. -- even if it fiddles the name, it does not change the first character. -- this includes object into design's directory; it does not make an instance. -- enumerates objects currently in directory in unspecified order. -- objects inserted/deleted during enumeration may or may not be seen. -- applies action to each object until action returns TRUE or no more objects. -- returns quit: TRUE if some action returns TRUE --class procedures --CAUTION: goes only one Layer deep; caller MUST go down the hierachy and --replace children if from#to; name might change due to conflicts --May succeed or not, returns NIL if no success; --returned object is of expand-simpler object class (half ordered); but -- it will generate exactly the same mask. --When "me" later changes, this has no influence on result; --Each call delivers a new copy of result --goes only one Layer deep; caller MUST go down the hierachy and --replace children if from#to; name might change due to conflicts --calls Expand first, but if doesn't succeed and makes sense it calls ExpandByDraw --does not check environment dependency or inDirectory -- implementation of compound objects --at least once, but eventualy duplications; only its immediate childs or --descendants as soon as it is included in directory, --and set type.inDirectory --objects which are in the directory must not cause drawing with a context directly --Repositioning and exchanging objects --CHANGES THE OBJECT ! --all over in the design tries to reposition ob; --may be delayed; --does notify Event $reposition; x of type ReplaceRec --all over in the design replace old by new --may be delayed -- processes an CDEvent $AfterChange Κ%˜codešœ'™'Kšœ Οmœ7™BKšœ™Kšœ?™?K˜—šΟk ˜ Kšœžœžœ˜Kšžœžœ)˜1—K˜KšΡblnΠbl œžœž œ˜!Kšž˜K˜šœ›™›K™—K˜K™K˜šΟnœžœ žœžœžœ žœ žœ ˜ZKšœ!™!K™—š‘œžœ žœžœžœžœžœžœ˜dKšœH™HK™TK™.K˜—š‘œžœ žœžœ ˜5Kš œžœžœžœžœžœžœ˜JKšœ=™=K™GK™NK™—š‘œžœ žœžœ ˜4Kš œžœžœžœžœžœžœ˜GK˜—š ‘ œžœ žœ"žœžœ˜RKšœB™BKšœF™FKšœN™NKšœ1™1K˜Kš œžœžœ žœžœ žœž œ˜Z—K˜K™K˜š ‘œžœžœ%žœžœ˜ZKšžœžœ7˜SK˜K˜—š ‘œžœžœ žœžœžœ˜8Kš žœžœžœ!žœžœ˜NK˜K˜—š ‘œžœžœžœ žœžœž˜GK™IKšœA™AK˜—š ‘œžœžœžœ žœžœ ˜FKšœ0™0K™HK™+Kšœ;™;Kšœ)™)K™@KšœA™AK˜—š ‘ œžœžœžœ žœžœž˜JKšœR™RK˜—š ‘ œžœžœžœ žœžœ ˜LKšœ6™6K™—K™Kšœ%™%K™šœžœžœ˜'Kšœ˜˜1KšœI™IKšœ6™6—Kšœ(˜(šœΟc˜*Kšœ’I˜K—Kšœ’˜'Kšœ’(˜>K˜K˜K˜K˜—š ‘œž œžœ žœžœžœ˜XKšžœžœžœ˜