WriteToFile:
PROC [cellType: Core.CellType] ~ {
cellName: Rope.ROPE ← CoreOps.GetCellTypeName[cellType];
s: IO.STREAM ← FS.StreamOpen[fileName: Rope.Cat[cellName, ".spice"], accessOptions: create];
convData: SpiceOps.ConvData ← SpiceOps.CreateConvData[s, s];
convData.rootCell ← cellType;
SpiceOps.WriteSpiceDeck[cellType, convData];
};
ExtractSelectedObjAndSpiceIt:
PROC [comm: CDSequencer.Command] = {
msg: Rope.ROPE;
selected: CD.Instance;
multiple: BOOL;
stdStr, errStr: IO.STREAM;
cellType: Core.CellType;
cellName: Rope.ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
cellType ← NARROW [SinixOps.ExtractCDInstance[selected, comm.design, Sisyph.mode].result];
IF local THEN {WriteToFile[cellType]; RETURN;};
cellName ← CoreOps.GetCellTypeName[cellType];
TerminalIO.PutRopes["SpiceOps on ", cellName, " ."];
[stdStr, errStr, msg] ← Rsh.RemoteShell[host, cmd, TRUE];
IF stdStr#
NIL
THEN {
ENABLE
ABORTED => {
IO.PutChar[errStr, SIGTERM];
IO.Flush[errStr];
IO.Close[errStr];
IO.Close[stdStr];
TerminalIO.PutRopes["SpiceOps Failure : ", msg, "\n"];
GOTO Failed
};
convData: SpiceOps.ConvData ← SpiceOps.CreateConvData[stdStr, stdStr];
convData.rootCell ← cellType;
IF msg#NIL THEN ERROR ABORTED;
IF debug THEN [] ← CedarProcess.Fork[action: WatchErrors, data: stdStr]
ELSE [] ← CedarProcess.Fork[ReadOutput, convData, [inheritProperties: TRUE]];
[] ← CedarProcess.Fork[action: WatchErrors, data: errStr];
SpiceOps.WriteSpiceDeck[cellType, convData];
IO.Flush[stdStr];
IO.Close[stdStr];
TerminalIO.PutRope["."];
};
EXITS Failed => {};
};
ReadOutput:
PROC [data:
REF]
RETURNS [result:
REF ←
NIL] ~ {
line: Rope.ROPE ← NIL;
convData: SpiceOps.ConvData ← NARROW[data];
stdStr: IO.STREAM ← convData.inS;
fileName: Rope.ROPE ← Rope.Cat[CoreOps.GetCellTypeName[convData.rootCell], ".spo"];
file: IO.STREAM ← FS.StreamOpen[fileName, create];
WHILE
NOT
IO.EndOf[stdStr]
DO
c: CHAR ← IO.GetChar[stdStr];
IF c = '\l
THEN {
IO.PutRope[file, line];
IO.PutChar[file, '\n];
line ← NIL;
}
ELSE line ← Rope.Concat[line, Rope.FromChar[c]];
ENDLOOP;
IF line#NIL THEN IO.PutRope[file, line];
IO.Close[file];
convData.inS ← FS.StreamOpen[fileName];
TerminalIO.PutRopes[".finished, ", fileName, " created.\n"];
SpiceOps.DisplaySpiceListing[convData ! IO.EndOfStream => {
TerminalIO.PutRope["\n\n\n ***** Spice ERROR: open the .spo file **** \n\n\n"];
CONTINUE;
}];
};
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];
};