DAToolsExampleImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Christian Le Cocq April 27, 1987 1:24:55 pm PDT
Bland, May 14, 1987 10:52:18 am PDT
This CEDAR program registers a new command with the CDSequencer that will appear on the OSpace menu. The new command, Sisyph Write Extraction To File, writes a single, selected ChipNDale cell to a file. The filename is cellname.coreList. If the cell does not have a name, the default filename, example.coreList, is used.
To run the program, first compile it and DAToolsExample.mesa on your machine, then execute the command, run DAToolsExampleImpl.mesa. To test the program, select a cell in a ChipNDale Viewer, call up the OSpace menu, and select the "Sisyph Write Extraction To File" entry.

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;
Command Proc
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: BOOLEANFALSE] ~ {
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"]
};
Internal Utilities
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 cell—can'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];
};
Initialization
CDCommandOps.RegisterWithMenu[
menu: $OtherProgramMenu,
entry: "Sisyph Write Extraction To File",
doc: "A single cell must be selected",
proc: ExtractSelectedObj,
key: $ExtractAndWrite];
END.