CDImportCommands2.mesa (part of ChipNDale)
Copyright © 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi, December 31, 1984 4:24:51 pm PST
last edited Christian Jacobi, December 31, 1984 5:05:32 pm PST
DIRECTORY
CD,
CDImports,
CDIO,
CDMenus,
CDProperties,
CDSequencer,
Rope,
TerminalIO,
UserProfile;
CDImportCommands2: CEDAR PROGRAM
IMPORTS CDImports, CDIO, CDMenus, CDSequencer, Rope, TerminalIO, UserProfile =
BEGIN
--Implements a command for quick import of multiple designs; this is thought for painless
--imports of SIL libraries.
LoadAllImps: PROC[importerDesign: CD.Design] =
--Tries to import all designs which are used for importerDesign;
--Does not allow any conflicts, nor overloading.
--Search in the userprofile for filenames corresponding to the design names.
--Quite talky on TerminalIO, but not interactive
BEGIN
TryToImport: PROC [ri: REF CDImports.Import] =
BEGIN
Check: PROC [design: CD.Design] RETURNS [ok: BOOL] =
--call back procedure for CDIO.ReadDesign
--uses intermediate level variable importerDesign
BEGIN
ok ← design.technology=importerDesign.technology;
IF NOT ok THEN {
TerminalIO.WriteRope[" Technology missmatch: is "];
TerminalIO.WriteRope[design.technology.name];
RETURN
};
ok ← Rope.Equal[ri.importeeName, CDIO.DesignInReadOperation[].name];
IF NOT ok THEN {
TerminalIO.WriteRope[" not the expected design but "];
TerminalIO.WriteRope[CDIO.DesignInReadOperation[].name];
};
END;
--TryToImport
wDir: Rope.ROPECDIO.GetWorkingDirectory[importerDesign];
done: BOOLFALSE;
design: CD.Design;
fileName: Rope.ROPE ← UserProfile.Token[Rope.Cat["ChipNDale.ImportFor.", ri.importeeName], NIL];
IF Rope.IsEmpty[fileName] THEN fileName ← ri.importeeName;
fileName ← CDIO.MakeName[base: fileName, ext: ".dale", wDir: wDir];
CDSequencer.CheckAborted[importerDesign];
design ← CDIO.ReadDesign[fileName, Check];
IF design=NIL THEN TerminalIO.WriteRope[" not done"]
ELSE {
CDSequencer.CheckAborted[importerDesign];
done ← CDImports.DoImport[design: importerDesign, importee: design, allowOverload: false, allowConflicts: false];
IF done THEN TerminalIO.WriteRope[" imported"]
ELSE TerminalIO.WriteRope[" not imported"]
};
END;
HandleOneImport: PROC [ri: REF CDImports.Import] =
BEGIN
TerminalIO.WriteRope[" "];
TerminalIO.WriteRope[ri.importeeName];
TerminalIO.WriteRope[" "];
IF ri.importee#NIL THEN
TerminalIO.WriteRope[" already imported"]
ELSE
TryToImport[ri];
TerminalIO.WriteLn[];
END;
--LoadAllImps
FOR list: LIST OF REF CDImports.Import ← CDImports.GetImportList[importerDesign]^, list.rest WHILE list#NIL DO
HandleOneImport[list.first]
ENDLOOP;
END;
LoadAllImpsCommand: PROC [comm: CDSequencer.Command] =
--Load all imports
--Checks first for an userprofile entry;
--checks then for filename=designname
BEGIN
TerminalIO.WriteRope["load all imported designs\n"];
LoadAllImps[comm.design];
TerminalIO.WriteRope[" --\n"];
END;
CDSequencer.ImplementCommand[$LoadAllImps, LoadAllImpsCommand,, doQueue];
CDMenus.CreateEntry[$IOMenu, "load all imports", $LoadAllImps];
END.