DIRECTORY CD USING [ApplicationPtr, DrawRef, ObPtr], CDDirectory, CDEnvironment, CDConditions, CDProperties; CDEnvironmentImpl: CEDAR PROGRAM IMPORTS CDConditions, CDDirectory, CDProperties EXPORTS CDEnvironment = BEGIN GetProp: PUBLIC PROC [environment: CD.DrawRef, prop: REF, skipInnerMost: NAT_0] RETURNS [REF] = BEGIN IF environment.nestDepth>0 THEN { FOR c: INT _ environment.nestDepth-1, c-1 WHILE c>=0 DO ap: CD.ApplicationPtr = environment.nesting.table[c]; x: REF _ CDProperties.GetPropFromApplication[ap, prop]; IF x#NIL THEN IF skipInnerMost=0 THEN RETURN [x] ELSE skipInnerMost _ skipInnerMost-1; IF ~InlinePropagates[ap.ob] THEN EXIT; ENDLOOP; }; RETURN [NIL] END; GetIntProp: PUBLIC PROC[environment: CD.DrawRef, prop: REF, skipInnerMost: NAT_0, ifNotFound: INT_0] RETURNS [INT] = BEGIN x: INT _ ifNotFound; WITH GetProp[environment: environment, prop: prop, skipInnerMost: skipInnerMost] SELECT FROM intP: REF INT => x _ intP^; ENDCASE => NULL; RETURN [x] END; Propagates: PUBLIC PROC [ob: CD.ObPtr] RETURNS [BOOL] = BEGIN RETURN [InlinePropagates[ob]]; END; InlinePropagates: PROC [ob: CD.ObPtr] RETURNS [BOOL] = INLINE BEGIN RETURN [ ob.p.reservedForCDEnvironment AND ( CDConditions.IsCondition[ob] OR CDProperties.GetPropFromObject[ob, $CDxPropagate]=$CDxPropagate ) ]; END; AllowPropagation: PUBLIC PROC [ob: CD.ObPtr, propagates: BOOL] = BEGIN IF ~ob.p.inDirectory THEN ERROR; CDProperties.PutPropOnObject[ onto: ob, prop: $CDxPropagate, val: (IF propagates THEN $CDxPropagate ELSE NIL) ]; IF propagates THEN ob.p.reservedForCDEnvironment _ TRUE; CDDirectory.PropagateChange[ob, NIL]; END; SomeChildPropagates: PUBLIC PROC [ob: CD.ObPtr] RETURNS [yes: BOOL_FALSE] = BEGIN CheckAChild: CDDirectory.EnumerateObjectsProc = { IF me.p.inDirectory AND InlinePropagates[me] THEN yes _ TRUE }; CDDirectory.EnumerateChildObjects[me: ob, p: CheckAChild, x: NIL]; RETURN [yes] END; END. CDEnvironmentImpl.mesa (part of ChipNDale) Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. by Christian Jacobi, December 18, 1984 12:26:50 pm PST last edited by Christian Jacobi, April 16, 1985 11:55:52 am PST -- Accessing the nesting environment of objects while drawing. -- Access propertylists of nesting applications while a draw process... -- Finds nested-most occurance of property prop. -- skipInnerMost: the "skipInnerMost" most nested occurences of the property are ignored. -- Returns NIL if prop is not found. -- Does not return properties from the environment of an object which does not propagate. -- it is good practice to use an impossible value for "ifNotFound"; defaulting is -- dangerous because it could hide bugs. -- propagates TRUE means GetProp (et al) will access properties of outer levels. -- propagates FALSE means GetProp (et al) will not access properties of outer levels. -- default if not called at all is FALSE -- Only allowed to objects with "inDirectory" TRUE ÊŘšœ1™1Jšœ Ïmœ7™BJšœ8™8Jšœ?™?—J˜šÏk ˜ Jšžœžœ"˜*Jšœ ˜ Jšœ˜Jšœ ˜ Jšœ ˜ J˜—šÏbœžœžœ˜!Jšžœ(˜/Jšžœ˜—Jšž˜J˜J™>J˜šÏnœž œžœžœžœžœžœ˜_Jšœ#Ÿ œ™GJ™0JšœY™YJšœ$™$J™YJšž˜šžœžœ˜!šžœžœ žœž˜7Jšœžœ/˜5Jšœžœ1˜7šžœžœžœ˜Jšžœžœžœžœ!˜H—Jšžœžœžœ˜&Jšžœ˜ —J˜—Jšžœžœ˜ Jšžœ˜—J˜š  œž œžœžœžœžœžœžœ˜tJšœR™RJšœ(™(Jšž˜Jšœžœ˜šžœMžœž˜\Jšœžœžœ˜Jšžœžœ˜—Jšžœ˜ Jšžœ˜J˜—š   œžœžœžœžœžœ˜7Jšž˜Jšžœ˜Jšžœ˜—J˜š  œžœžœžœžœž˜=JšœP™PJšœU™UJšž˜šžœ˜šœžœ˜$Jšœž˜Jšœ?˜?J˜—Jšœ˜—Jšžœ˜—J˜š  œžœžœžœžœ˜@Jšœ(™(J™2Jšž˜Jšžœžœžœ˜ šœ˜Jšœ ˜ Jšœ˜Jš œžœ žœžœžœ˜0Jšœ˜—Jšžœ žœ!žœ˜8Jšœ žœ˜%Jšžœ˜—J˜š  œž œžœžœžœžœ˜KJšž˜šŸ œ&˜1Jšžœžœžœž˜