SpiceCDCmds.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Created by Pradeep Sindhu, March 31, 1986 6:25:43 pm PST
Pradeep Sindhu, April 29, 1986 0:19:46 am PDT
Bertrand Serlet October 17, 1986 10:46:42 pm PDT
Christian Jacobi, January 7, 1987 2:58:17 pm PST
Christian LeCocq February 6, 1987 4:24:14 pm PST
DIRECTORY
CD, CDCells, CDCommandOps, CDIO, CDOps, CDSequencer, Core, CoreOps, Rope, SinixOps, Sisyph, TerminalIO, SpiceOps;
SpiceCDCmds: CEDAR PROGRAM
IMPORTS CDCells, CDCommandOps, CDIO, CDOps, CoreOps, Rope, SinixOps, Sisyph, TerminalIO, SpiceOps = BEGIN
ROPE: TYPE = Rope.ROPE;
Command Procs
ExtractSelectedObjAndSpiceIt: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
cellType: Core.CellType;
wDir: ROPECDIO.GetWorkingDirectory[comm.design];
fileName: ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
cellType ← NARROW [SinixOps.ExtractCDInstance[selected, comm.design, Sisyph.mode].result];
WHILE SinixOps.IsIcon[Sisyph.mode.decoration, cellType] DO
cellType ← CoreOps.Recast[cellType];
ENDLOOP;
IF CoreOps.GetCellTypeName[cellType]=NIL
THEN fileName ← Rope.Cat[wDir, "SpiceInputDeck.spice"]
ELSE fileName ← Rope.Cat[wDir, CoreOps.GetCellTypeName[cellType], ".spice"];
SpiceOps.WriteSpiceDeck[cellType, fileName];
};
Internal Utilities
IsSingleSelectedAndCell: PROC [selected: CD.Instance, multiple: BOOL] RETURNS [BOOL] = {
IF ~IsSingleSelected[selected, multiple] THEN RETURN [FALSE];
IF ~CDCells.IsCell[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 -> Spice", proc: ExtractSelectedObjAndSpiceIt, key: $ExtractToSpice]
END.