DIRECTORY TerminalIO, CD, CDSequencer, CDOps, CDCommandOps, CDBasics, Commander USING [CommandProc, Handle, Register], IO, SweepCollectableStorage USING [InfoProc, EnumerateCollectableStorage]; CDCountCommands: CEDAR PROGRAM IMPORTS TerminalIO, CD, CDSequencer, CDOps, CDCommandOps, Commander, IO, SweepCollectableStorage = BEGIN rectCounter, childCounter: INT; MyDrawChild: CD.DrawProc = { childCounter _ childCounter+1; inst.ob.class.drawMe[inst: inst, pos: inst.location, orient: inst.orientation, pr: pr]; }; MyDrawRect: CD.DrawRectProc = { rectCounter _ rectCounter+1; }; ProtectedCount: PROC [comm: CDSequencer.Command] = { myDrawRef: CD.DrawRef _ CD.CreateDrawRef[[ interestClip: CDBasics.universe, drawChild: MyDrawChild, drawRect: MyDrawRect, design: comm.design ]]; rectCounter _ childCounter _ 0; CDOps.DrawDesign[design: comm.design, pr: myDrawRef]; myDrawRef _ NIL; TerminalIO.WriteRope[IO.PutFR["rectangles %g objects %g\n", IO.int[rectCounter], IO.int[childCounter] ]]; }; CountFlatComm: PROC [comm: CDSequencer.Command] = { TerminalIO.WriteRope["flat count rectangles\n"]; [] _ CDCommandOps.CallWithResource[ProtectedCount, comm, $myDrawRef, NEW[BOOL_FALSE]]; }; Count: PROC [out: IO.STREAM] = { EachObject: SweepCollectableStorage.InfoProc = { IF type=CODE[CD.InstanceRep] THEN inst _ inst+1 ELSE IF type=CODE[CD.ObjectRep] THEN ob _ ob+1 ELSE IF type=CODE[CD.CellRep] THEN cell _ cell+1 ELSE IF type=CODE[CD.ObjectClassRec] THEN obClasses _ obClasses+1 ELSE IF type=CODE[CD.DesignRec] THEN design _ design+1 ELSE others _ others+1; RETURN [TRUE]; }; others, inst, ob, cell, obClasses, design: INT _ 0; TRUSTED { SweepCollectableStorage.EnumerateCollectableStorage[EachObject] }; out.PutF["instances = %g\n", IO.int[inst]]; out.PutF["objects = %g\n", IO.int[ob]]; out.PutF["cells = %g\n", IO.int[cell]]; out.PutF["object classes = %g\n", IO.int[obClasses]]; out.PutF["designs = %g\n", IO.int[design]]; out.PutF["others = %g\n", IO.int[others]]; }; CountTypesCommand: Commander.CommandProc = { Count[cmd.out]; }; CountTypesComm: PROC [comm: CDSequencer.Command] = { TerminalIO.WriteRope["count types using SweepCollectableStorage\n"]; Count[TerminalIO.TOS[]]; }; CDSequencer.ImplementCommand[$CountRects, CountFlatComm,, dontQueue]; CDSequencer.ImplementCommand[$CountTypes, CountTypesComm,, dontQueue]; Commander.Register[key: "///Commands/CDCount", proc: CountTypesCommand, doc: "Count features of ChipNDale"]; END. ΊCDCountCommands.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Created by: Christian Jacobi, February 20, 1985 10:41:19 am PST Last edited by: Christian Jacobi, October 20, 1986 12:30:39 pm PDT --the global variables mare monitored using CDCommandOps.CallWithResource; --these variables are global so they can be used by MyDrawChild --PROC [type: SafeStorage.Type, size: INT, object: ..] RETURNS [continue: BOOL] ΚW˜code™Kšœ Οmœ1™Kšžœ˜Kšžœ˜Kšœ˜—Kšœ˜—K™š‘ œžœ ˜3Kšœ1˜1KšœEžœžœžœ˜VKšœ˜K˜—š‘œžœžœžœ˜ K˜š  œ&˜0KšœQ™QKšžœžœžœžœ˜/Kš žœžœžœžœ žœ ˜.Kš žœžœžœžœ žœ˜0Kš žœžœžœžœžœ˜AKš žœžœžœžœ žœ˜6Kšžœ˜Kšžœžœ˜Kšœ˜—K˜Kšœ+žœ˜3KšžœE˜LKšœžœ ˜+Kšœžœ ˜'Kšœžœ ˜'Kšœ"žœ˜5Kšœžœ˜+Kšœžœ˜*Kšœ˜—K˜š‘œ˜,Kšœ˜K˜K˜—š‘œžœ ˜4KšœE˜EKšœžœ˜Kšœ˜—K˜KšœE˜EKšœF˜FKšœl˜lKšžœ˜K˜—…— š«