<> <> <> <> <<>> <<>> <<>> <> <<>> <> DIRECTORY CD, CDCells, CDCommandOps, CDIO, CDOps, CDSequencer, Core, CoreOps, DAToolsExample, FS, IO, Rope, SinixOps, Sisyph, TerminalIO; DAToolsExampleImpl: CEDAR PROGRAM IMPORTS CDCells, CDCommandOps, CDIO, CDOps, CoreOps, FS, IO, Rope, SinixOps, Sisyph, TerminalIO EXPORTS DAToolsExample ~ BEGIN ROPE: TYPE = Rope.ROPE; CellType: TYPE = Core.CellType; <> ExtractSelectedObj: PROC [comm: CDSequencer.Command] ~ { selected: CD.Instance; multiple: BOOL; wDir: ROPE _ CDIO.GetWorkingDirectory[design: comm.design]; fileName, shortFN: ROPE; cellType: CellType; [selected, multiple] _ CDOps.SelectedInstance[design: comm.design]; IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN; cellType _ NARROW [SinixOps.ExtractCDInstance[ instance: selected, design: comm.design, mode: Sisyph.mode].result]; WHILE SinixOps.IsIcon[decoration: Sisyph.mode.decoration, cell: cellType] DO cellType _ CoreOps.Recast[me: cellType]; ENDLOOP; IF CoreOps.GetCellTypeName[cellType]=NIL THEN shortFN _ "Example" ELSE shortFN _ CoreOps.GetCellTypeName[cellType]; fileName _ Rope.Cat[r1: wDir, r2: shortFN, r3: ".coreList"]; WriteToFile[cellType, fileName, TRUE] }; WriteToFile: PUBLIC PROC [cellType: CellType, fileName: ROPE, msgOk: BOOLEAN _ FALSE] ~ { out: IO.STREAM; out _ FS.StreamOpen[fileName: fileName, accessOptions: $create]; CoreOps.PrintCellType[cellType, out]; IO.Close[self: out]; IF msgOk THEN TerminalIO.PutRopes[t1: fileName, t2: " created\n"] }; <> IsSingleSelectedAndCell: PROC [selected: CD.Instance, multiple: BOOL] RETURNS [BOOL] ~ { IF ~IsSingleSelected[selected, multiple] THEN RETURN [FALSE]; IF ~CDCells.IsCell[ob: selected.ob] THEN { TerminalIO.PutRope["\n** Selected instance is not a cellcan't do it.\n"]; RETURN[FALSE]; }; RETURN[TRUE]; }; IsSingleSelected: PROC [selected: CD.Instance, multiple: BOOL] RETURNS [BOOL] ~ { IF selected=NIL THEN { TerminalIO.PutRope["\n** No current selection-- can't do it.\n"]; RETURN[FALSE]; }; IF multiple THEN { TerminalIO.PutRope["\n** Multiple instances selected-- can't do it.\n"]; RETURN[FALSE]; }; RETURN[TRUE]; }; <> CDCommandOps.RegisterWithMenu[ menu: $OtherProgramMenu, entry: "Sisyph Write Extraction To File", doc: "A single cell must be selected", proc: ExtractSelectedObj, key: $ExtractAndWrite]; END.