DIRECTORY CD, CDCells, CDEnvironment, CDGenerate, CDGenerateBackdoor, CDIO, CDMenuSpecials, CDOps, CDPanel, CDProperties, CDSequencer, CDValue, CDViewer, Commander, CommandTool, FileNames, Rope, TerminalIO, UserProfile; CDGenerateCommands: CEDAR PROGRAM IMPORTS CD, CDCells, --CDDirectory, CDDirectoryOps,-- CDEnvironment, CDGenerate, CDGenerateBackdoor, CDIO, CDMenuSpecials, CDOps, CDPanel, CDProperties, CDSequencer, CDValue, CDViewer, CommandTool, FileNames, Rope, TerminalIO, UserProfile SHARES CD = BEGIN ProfileKey: PROC [] RETURNS [r: Rope.ROPE] = { r _ UserProfile.Token[key: "ChipNDale.GeneratorProc", default: "DIRECTORY"] }; ContextKey: PROC [design: CD.Design] RETURNS [r: Rope.ROPE] = { r _ CDOps.ToRope[CDProperties.GetDesignProp[design, $GeneratorProc]]; IF Rope.IsEmpty[r] THEN r _ CDOps.ToRope[CDValue.Fetch[design, $GeneratorProc, global]]; IF Rope.IsEmpty[r] THEN r _ ProfileKey[]; }; InteractiveKey: PROC [key: Rope.ROPE] RETURNS [BOOL] = { IF Rope.Equal[key, doInteractive] THEN RETURN [TRUE]; IF Rope.SkipOver[key, 0, " "]=Rope.Length[key] THEN RETURN [TRUE]; RETURN [FALSE] }; Generate: PROC [comm: CDSequencer.Command] = { key: Rope.ROPE; ob: CD.Object; design: CD.Design _ comm.design; contextKey: Rope.ROPE _ ContextKey[design]; context: CDGenerate.Context _ CDGenerate.AssertContext[contextKey]; TerminalIO.PutRopes["draw object from [", contextKey, "]\n"]; key _ CDPanel.TakeDownText[design, $CDxGeneratorObName]; IF InteractiveKey[key] THEN key _ CDGenerate.SelectOneOf[context, "select generator"]; IF Rope.IsEmpty[key] THEN TerminalIO.PutRope["no name given\n"] ELSE { ob _ CDGenerate.FetchNCall[context, comm.design, key]; IF ob=NIL THEN TerminalIO.PutRope["failed\n"] ELSE { i: CD.Instance _ CDOps.IncludeObjectI[design, ob, comm.pos]; CleanUp[comm.design]; TerminalIO.PutRopes[CDOps.InstRope[i], " included\n"]; } } }; SelectGenerators: PROC [comm: CDSequencer.Command] = { key: Rope.ROPE; design: CD.Design _ comm.design; contextKey: Rope.ROPE _ ContextKey[design]; TerminalIO.PutRopes["select object generator; currently uses [", contextKey, "]\n"]; key _ CDMenuSpecials.SelectOneOf[CDGenerateBackdoor.publicContexts, "select generator"]; IF Rope.IsEmpty[key] THEN TerminalIO.PutRope["not changed\n"] ELSE { TerminalIO.PutRopes["now uses [", key, "] for generator\n"]; CDProperties.PutDesignProp[design, $GeneratorProc, key]; CDValue.Store[design, $GeneratorProc, key]; CDPanel.PutUpAll[design]; } }; FlushGenerators: PROC [comm: CDSequencer.Command] = { contextKey: Rope.ROPE _ ContextKey[comm.design]; TerminalIO.PutRopes["flush generators [", contextKey, "]\n"]; CDGenerate.FlushAll[CDGenerate.AssertContext[contextKey], comm.design]; }; commandFormat: Rope.ROPE = """CDGenerate generator {outFile|*} _ {inFile|^technology}"""; CDGenerateCommand: Commander.CommandProc = { GetDesign: PROC [name: Rope.ROPE] RETURNS [design: CD.Design _ NIL] = { IF Rope.Length[name]<1 THEN {msg _ "bad name"; RETURN}; IF Rope.Fetch[name, 0] = '^ THEN { n: Rope.ROPE _ Rope.Substr[name, 1, Rope.Length[name]]; tech: CD.Technology _ CDEnvironment.LoadTechnology[NIL, n]; IF tech=NIL THEN {result _ $Failure; msg _ "technology not loaded"; RETURN}; design _ CDOps.CreateDesign[tech]; } ELSE { design _ CDIO.ReadDesign[from: name]; IF design #NIL THEN { IF CDCells.IsPushedIn[design] THEN TerminalIO.PutRope["** pushed in\n"]; } } }; OutDesign: PROC [design: CD.Design, name: Rope.ROPE] RETURNS [done: BOOL] = { IF Rope.Equal[name, "*"] THEN done _ CDViewer.CreateViewer[design]#NIL ELSE done _ CDIO.WriteDesign[design: design, to: name, quiet: TRUE]; }; ob: CD.Object; design: CD.Design; genName: Rope.ROPE; inFile, outFile: Rope.ROPE; generator: CDGenerate.GeneratorProc; contextKey: Rope.ROPE _ ProfileKey[]; context: CDGenerate.Context _ CDGenerate.AssertContext[contextKey]; argv: CommandTool.ArgumentVector _ CommandTool.Parse[cmd, FALSE, '_ ! CommandTool.Failed => {msg _ errorMsg; GOTO die} ]; IF argv.argc#5 OR ~Rope.Equal[argv[3], "_"] THEN { msg _ Rope.Cat["command should be ", commandFormat]; GOTO die }; TerminalIO.PutRope["GeneratorProc called\n"]; genName _ argv[1]; outFile _ FileNames.ResolveRelativePath[argv[2]]; inFile _ FileNames.ResolveRelativePath[argv[4]]; generator _ CDGenerate.FetchRegistration[context, genName].generator; IF generator=NIL THEN { msg _ "generator not found"; GOTO die }; design _ GetDesign[inFile]; IF design=NIL THEN { msg _ "design not found"; GOTO die }; ob _ CDGenerate.FetchNCall[context, design, genName]; IF ob=NIL THEN { msg _ "object not created"; GOTO die }; [] _ CDOps.PlaceInst[design, ob]; CleanUp[design]; IF ~OutDesign[design, outFile] THEN { msg _ "object not created"; GOTO die }; TerminalIO.PutRope["object generated\n"]; EXITS die => result _ $Failure; }; doInteractive: Rope.ROPE ~ "_ interactive"; Init: PROC [] = { CDSequencer.ImplementCommand[$CallGenerator, Generate]; CDSequencer.ImplementCommand[$FlushGenerators, FlushGenerators]; CDSequencer.ImplementCommand[$SelectGenerators, SelectGenerators]; CDEnvironment.RegisterCommander[ key: "CDGenerate", proc: CDGenerateCommand, doc: Rope.Cat["ChipNDale object generator: ", commandFormat], clientData: $CDGenerate ]; CDValue.RegisterKey[$CDUsesGeneratorName! CD.Error => CONTINUE]; CDPanel.Button[button: [text: "generator:"], proc: SelectGenerators]; CDPanel.Label[label: [width: 110, cdValueKey: $GeneratorProc, redisplay: TRUE]]; CDValue.Store[NIL, $GeneratorProc, ProfileKey[]]; CDValue.Store[NIL, $CDxGeneratorObName, doInteractive]; CDPanel.Text[text: [cdValueKey: $CDxGeneratorObName], button: [text: "name:", xpos: 180]]; CDPanel.Line[]; }; CleanUp: PROC [design: CD.Design] = { }; Init[]; END. όCDGenerateCommands.mesa (part of ChipNDale) Copyright c 1985, 1987 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, June 5, 1985 8:02:35 pm PDT Last edited by: Christian Jacobi, May 5, 1987 5:51:54 pm PDT CDDirectory, CDDirectoryOps, [cmd: REF CommandObject] RETURNS [result: REF _ NIL, msg: ROPE _ NIL] CommandObject = [ in, out, err: STREAM, commandLine, command: ROPE, propertyList: List.AList, procData: CommandProcHandle] --we don't for now; --I believe nobody violates directory invariants anymore since ChipNDale2.5 n: INT _ CDDirectory.DirSize[design]; CDDirectoryOps.CleanUp[design]; IF n#CDDirectory.DirSize[design] THEN TerminalIO.PutF["**consistency check fixed %g objects\n", [integer[CDDirectory.DirSize[design]-n]]]; ΚE˜codešœ+™+Kšœ Οmœ7™BKšœ8™8K™˜>Kšœ˜Kšœ˜—Kšœ*žœ žœ˜@KšœE˜EKšœIžœ˜PKšœžœ ˜1Kšœžœ&˜7KšœZ˜ZK˜Kšœ˜—K˜šŸœžœ žœ ˜%Kšœ™K™KKšœžœ™%Kšœ™šžœžœ™&Kšœd™dK˜—Kšœ˜—K˜Kšœ˜Kšž˜K˜—…—( i