DIRECTORY Atom, CD, CDInstances, CDCommandOps, CDDirectory, PopUpMenus, CDOps, CDPrivate, CDProperties, CDRopeViewer, CDSequencer, IO, PropertyLists, Rope, RuntimeError USING [UNCAUGHT], TerminalIO, TokenIO, ViewerTools USING [TiogaContents, TiogaContentsRec]; CDPropertyCommands: CEDAR PROGRAM IMPORTS Atom, CDCommandOps, CDDirectory, CDOps, CDProperties, CDRopeViewer, CDSequencer, IO, PopUpMenus, Rope, RuntimeError, TerminalIO = BEGIN specialRights: BOOL _ FALSE; -- gives the right to access exclusive properties Atomize: PROC [r: Rope.ROPE] RETURNS [ATOM_NIL] = { IF Rope.Length[r]>1 AND Rope.Fetch[r]='$ THEN r _ Rope.Substr[r, 1, Rope.Length[r]-1]; IF ~Rope.IsEmpty[r] THEN RETURN [Atom.MakeAtom[r]] }; EnterSignalNameSP: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance _ CDCommandOps.TheInstance[comm, "read signal-name"]; IF inst#NIL THEN { name: Rope.ROPE; TerminalIO.WriteRopes[" onto ", CDCommandOps.InstRope[inst]]; name _ TerminalIO.RequestRope[" type name: "]; IF Rope.IsEmpty[name] THEN name_NIL; CDProperties.PutInstanceProp[onto: inst, prop: $SignalName, val: name]; IF name#NIL THEN TerminalIO.WriteRope[" done\n"] ELSE TerminalIO.WriteRope[" removed\n"]; } END; EnterInstanceNameSP: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance _ CDCommandOps.TheInstance[comm, "read instance-name"]; IF inst#NIL THEN { name: Rope.ROPE; TerminalIO.WriteRopes[" onto ", CDCommandOps.InstRope[inst]]; name _ TerminalIO.RequestRope[" type name: "]; IF Rope.IsEmpty[name] THEN name_NIL; CDProperties.PutInstanceProp[onto: inst, prop: $InstanceName, val: name]; IF name#NIL THEN TerminalIO.WriteRope[" done\n"] ELSE TerminalIO.WriteRope[" removed\n"]; } END; detail: INT _ 0; WriteValue: PROC [x: REF] = BEGIN ENABLE RuntimeError.UNCAUGHT => GOTO err; IF x=NIL THEN TerminalIO.WriteRope["NIL"] ELSE WITH x SELECT FROM ip: REF INT => TerminalIO.WriteF["^%g", IO.int[ip^]]; r: Rope.ROPE => TerminalIO.WriteRope[r]; a: ATOM => TerminalIO.WriteRopes["$", Atom.GetPName[a]]; ra: REF ATOM => TerminalIO.WriteRopes["^$", Atom.GetPName[ra^]]; d: CD.Design => TerminalIO.WriteRopes["design ", (IF d.name=NIL THEN "no name" ELSE d.name)]; ob: CD.Object => TerminalIO.WriteRope[CDOps.ObjectInfo[ob]]; ap: CD.Instance => TerminalIO.WriteRope[CDCommandOps.InstRope[ap]]; l: CDPrivate.LayerRef => TerminalIO.WriteRope[CDOps.LayerName[l.number]]; ENDCASE => IF detail=0 THEN TerminalIO.WriteF1["(%b)", IO.int[LOOPHOLE[x]]] ELSE TerminalIO.WriteRope[IO.PutR[IO.refAny[x]]]; EXITS err => TerminalIO.WriteRope["??"]; END; RequestValue: PROC [default: REF] RETURNS [REF] = BEGIN n: CARDINAL_0; WHILE n=0 DO n _ TerminalIO.RequestSelection["property value", LIST["leave it", "remove", "INT", "ROPE", "ATOM", "REF ANY"]]; SELECT n FROM 2 => {default _ NIL}; 3 => {default _ NEW[INT_TerminalIO.RequestInt["int > "]]}; 4 => {default _ TerminalIO.RequestRope["rope > "]}; 5 => {default _ Atomize[TerminalIO.RequestRope["atom > "]]}; 6 => { TerminalIO.WriteRope["(on crash: abort is ok)"]; default _ IO.GetRefAny[IO.RIS[TerminalIO.RequestRope["ref any > "]]] }; ENDCASE --0, 1-- => {NULL}; ENDLOOP; RETURN [default] END; PropertyDesign: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["enter property for the design\n"]; PropertyForSome[comm.design]; END; PropertyApp: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance _ CDCommandOps.TheInstance[comm, "enter property of instance"]; IF inst#NIL THEN PropertyForSome[inst]; END; PropertyOb: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance _ CDCommandOps.TheInstance[comm, "enter property for an object"]; IF inst#NIL THEN IF inst.ob.class.inDirectory OR specialRights THEN { PropertyForSome[inst.ob]; IF inst.ob.class.inDirectory THEN CDDirectory.PropagateChange[inst.ob, comm.design]; } ELSE TerminalIO.WriteRope["this object class has no user accessable properties\n"]; END; PropertyForSome: PROC [what: REF] = BEGIN value: REF; atom: ATOM _ Atomize[TerminalIO.RequestRope["type property name: "]]; IF atom=NIL THEN { TerminalIO.WriteRope[" empty name; not done\n"]; RETURN }; value _ CDProperties.GetProp[what, atom]; TerminalIO.WriteRope[" old value: "]; WriteValue[value]; TerminalIO.WriteLn[]; IF IsExclusive[atom] THEN { TerminalIO.WriteRope[" this property is used exclusively by the program; "]; IF ~specialRights THEN { TerminalIO.WriteRope["interactive access is not possible\n"]; RETURN } }; value _ RequestValue[value]; CDProperties.PutProp[onto: what, prop: atom, val: value]; TerminalIO.WriteRope[" done\n"]; END; ShowProperties: PROC [from: REF] = BEGIN WITH from SELECT FROM a: CD.Instance => ShowPropertyList[a.properties]; o: CD.Object => ShowPropertyList[o.properties]; d: CD.Design => ShowPropertyList[d.properties^]; t: CD.Technology => ShowPropertyList[t.properties^]; ENDCASE => TerminalIO.WriteRope[" no showable CD properties"]; END; ShowPropertyList: PROC [pl: CD.PropList] = BEGIN FOR list: CD.PropList _ pl, list.rest WHILE list#NIL DO WITH list.first.key SELECT FROM ra: REF ATOM => IF ra^=$MayBeRemoved THEN LOOP ENDCASE => NULL; ShowProperty[list.first]; ENDLOOP END; ShowProperty: PROC [pp: PropertyLists.KeyVal] = BEGIN TerminalIO.WriteRope[" name: "]; WriteValue[pp.key]; TerminalIO.WriteRope[" value: "]; WriteValue[pp.val]; TerminalIO.WriteLn[]; END; ShowPropertiesSP: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance _ CDCommandOps.TheInstance[comm, "show property lists"]; IF inst#NIL THEN { IF inst.properties#NIL THEN { TerminalIO.WriteRope[" --properties on instance\n"]; ShowPropertyList[inst.properties]; }; IF inst.ob.properties#NIL THEN { TerminalIO.WriteRope[" --properties on object itself\n"]; ShowPropertyList[inst.ob.properties]; }; TerminalIO.WriteRope[" --\n"]; } END; ShowPropertiesDesign: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["show properties of design\n"]; ShowPropertyList[comm.design.properties^]; TerminalIO.WriteRope[" --\n"]; END; SaveComment: CDRopeViewer.SaveProc = BEGIN IF discard THEN RETURN; CDProperties.PutProp[ onto: clientData, prop: $Tioga, val: NEW[ViewerTools.TiogaContentsRec_[contents: contents, formatting: formatting]] ] END; CommentDesignComm: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["edit comment for design\n"]; CommentSome[what: comm.design, caption: Rope.Cat["[comment for ", comm.design.name, "]"]]; END; CommentObComm: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance _ CDCommandOps.TheInstance[comm, "comment object"]; IF inst#NIL THEN { IF inst.ob.class.inDirectory THEN CommentSome[what: inst.ob, caption: Rope.Cat["Comment on ", CDOps.ObjectInfo[inst.ob]]] ELSE TerminalIO.WriteRope["this object class has no comments\n"]; } END; CommentAppComm: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance _ CDCommandOps.TheInstance[comm, "comment instance"]; IF inst#NIL THEN { CommentSome[what: inst, caption: "comment some instance (ChipNDale)"]; } END; CommentSome: PROC [what: REF, caption: Rope.ROPE] = BEGIN comment, formatting: Rope.ROPE _ NIL; WITH CDProperties.GetProp[from: what, prop: $Tioga] SELECT FROM t: ViewerTools.TiogaContents => { comment _ t.contents; formatting _ t.formatting; }; r: Rope.ROPE => comment _ r; ENDCASE => NULL; CDRopeViewer.Edit[contents: comment, formatting: formatting, caption: caption, save: SaveComment, clientData: what]; END; NameMenuComm: PROC [comm: CDSequencer.Command] = { m: PopUpMenus.Menu; x: REF; inst: CD.Instance _ CDCommandOps.TheInstance[comm, "property and name menu"]; IF inst=NIL THEN m _ mD ELSE IF inst.ob.class.inDirectory THEN m _ mFull ELSE m _ mInst; x _ PopUpMenus.Call[m, comm]; WITH x SELECT FROM a: ATOM => CDSequencer.ExecuteCommand[comm: comm, key: a] ENDCASE => NULL }; IsExclusive: PROC [a: ATOM] RETURNS [BOOL_FALSE] = { pType: CDProperties.PropertyProcs = CDProperties.FetchProcs[a]; IF pType#NIL THEN RETURN [pType.exclusive] }; Register: PROC [n: NAT, key: ATOM, entry, doc: Rope.ROPE _ NIL] = { [] _ PopUpMenus.Entry[mFull, entry, NIL, key, doc]; IF n<=1 THEN RETURN; [] _ PopUpMenus.Entry[mInst, entry, NIL, key, doc]; IF n<=2 THEN RETURN; [] _ PopUpMenus.Entry[mD, entry, NIL, key, doc]; }; mFull: PopUpMenus.Menu _ PopUpMenus.Create["Names & PropertyLists", NIL]; mInst: PopUpMenus.Menu _ PopUpMenus.Create["Names & PropertyLists", NIL]; mD: PopUpMenus.Menu _ PopUpMenus.Create["Names & PropertyLists", NIL]; CDSequencer.ImplementCommand[$CommentDesign, CommentDesignComm]; CDSequencer.ImplementCommand[$CommentApp, CommentAppComm]; CDSequencer.ImplementCommand[$CommentOb, CommentObComm]; CDSequencer.ImplementCommand[$SignalNameS, EnterSignalNameSP]; CDSequencer.ImplementCommand[$InstanceNameS, EnterInstanceNameSP]; CDSequencer.ImplementCommand[$PropertyDesign, PropertyDesign]; CDSequencer.ImplementCommand[$PropertyApp, PropertyApp]; CDSequencer.ImplementCommand[$PropertyOb, PropertyOb]; CDSequencer.ImplementCommand[$ShowPropertiesS, ShowPropertiesSP,, doQueue]; CDSequencer.ImplementCommand[$ShowPropertiesDesign, ShowPropertiesDesign,, doQueue]; Register[3, $RenameDesign, "rename design"]; Register[1, $RenameS, "rename object"]; Register[3, $PropertyDesign, "property (design)", "add/change a property"]; Register[2, $PropertyApp, "property (instance)", "add/change a property"]; Register[1, $PropertyOb, "property (object)", "add/change a property"]; Register[3, $CommentDesign, "comment (design)", "edit the comment view"]; Register[2, $CommentApp, "comment (instance)", "edit the comment view"]; Register[1, $CommentOb, "comment (object)", "edit the comment view"]; Register[2, $InstanceNameS, "instance-name", "accept an instancename"]; Register[2, $SignalNameS, "signal-name (instance)", "accept a signalname"]; Register[3, $ShowPropertiesDesign, "list prop (design)", "list properties hanging on design"]; Register[2, $ShowPropertiesS, "list prop (i&o)", " | list properties of selected object"]; Register[3, $DisplayNames, "display signal-names", " | signal names of all visible objects"]; CDSequencer.ImplementCommand[$NameMenu, NameMenuComm, , dontQueue]; END. ðCDPropertyCommands.mesa (part of ChipNDale) Copyright c 1983, 1985 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, November 7, 1983 5:39 pm Last edited by: Christian Jacobi, August 24, 1986 7:28:57 pm PDT --if name = nil, property will be removed --if name = nil, property will be removed --XXX make public on next release; probably in CDCommandOps --move this procedure to CDProperties --l: CD.LayerRef => ...; --at: ATOM => ...; -- module initialization Ê ÿ˜codešœ-™-Kšœ Ïmœ7™BKšœ8™8K™@K˜—šÏk ˜ Kšœž˜Kšžœ˜K˜ Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ žœžœ˜Kšœ ˜ Kšœ˜Kšœ žœ#˜4—K˜šÐblœžœžœ˜"Kšžœƒ˜Š—Kšž˜K˜K˜KšœžœžœÏc1˜OK˜š Ïnœžœ žœžœžœžœ˜3Kšžœžœžœ)˜VKšžœžœžœ˜2K˜—K˜š¡œžœ˜5Kšžœ˜Kšœžœ?˜Gšžœžœžœ˜Kšœ žœ˜Kšœ>˜>Kšœ.˜.Kšœ)™)Kšžœžœžœ˜$KšœG˜GKšžœžœžœ"˜2Kšžœ%˜)K˜—Kšžœ˜—K˜š¡œžœ˜7Kšžœ˜KšœžœA˜Išžœžœžœ˜Kšœ žœ˜Kšœ>˜>Kšœ.˜.Kšœ)™)Kšžœžœžœ˜$KšœI˜IKšžœžœžœ"˜2Kšžœ%˜)K˜—Kšžœ˜—K˜Kšœžœ˜Kšœ;™;š¡ œžœžœ˜Kšž˜Kšžœžœžœ˜)Kšžœžœžœ˜*šž˜šžœžœž˜Kšœžœžœžœ ˜5Kšœžœ˜(Kšœžœ1˜8Kšœžœ4˜@Kš œžœ.žœžœžœ žœ ˜^Kšœžœ6˜—Kšžœ˜—K˜š¡œžœžœ ˜*Kšž˜š žœžœžœžœž˜7šžœžœž˜Kš œžœžœžœžœž˜.Kšžœžœ˜—Kšœ˜Kšž˜—Kšžœ˜K˜—š¡ œžœ˜/Kšž˜Kšœ!˜!Kšœ˜Kšœ"˜"Kšœ˜Kšœ˜Kšžœ˜—K˜š¡œžœ˜4Kšžœ˜KšœžœB˜Jšžœžœžœ˜šžœžœžœ˜Kšœ5˜5Kšœ"˜"K˜—šžœžœžœ˜ Kšœ:˜:Kšœ%˜%K˜—Kšœ˜K˜—Kšžœ˜—K˜š¡œžœ˜8Kšžœ˜Kšœ4˜4Kšœ*˜*Kšœ˜Kšžœ˜—K˜šÏb œ˜$Kšž˜Kšžœ žœžœ˜šœ˜Kšœ˜Kšœ˜KšœžœK˜SKšœ˜—Kšžœ˜—K˜š¡œžœ˜5Kšžœ˜Kšœ2˜2KšœZ˜ZKšžœ˜—K˜š¡ œžœ˜1Kšžœ˜Kšœžœ=˜Ešžœžœžœ˜šžœžœ˜"KšœW˜W—Kšžœ=˜AKšœ˜—Kšžœ˜—K˜š¡œžœ˜2Kšžœ˜Kšœžœ?˜Gšžœžœžœ˜KšœF˜FKšœ˜—Kšžœ˜—K˜š¡ œžœžœžœ˜3Kšžœ˜Kšœžœžœ˜%šžœ0žœž˜?šœ!˜!Kšœ˜Kšœ˜K˜—Kšœžœ˜Kšžœžœ˜—Kšœt˜tKšžœ˜—K˜š¡ œžœ ˜2Kšœžœ˜KšœžœE˜MKšžœžœžœ˜Kšžœžœžœ ˜0Kšžœ ˜Kšœ˜šžœžœž˜Kšœžœ2˜9Kšžœž˜—Kšœ˜—K™š ¡ œžœžœžœžœžœ˜4Kšœ?˜?Kšžœžœžœžœ˜*Kšœ˜—J˜š ¡œžœžœžœžœžœ˜CKšœ$žœ ˜3Kšžœžœžœ˜Kšœ$žœ ˜3Kšžœžœžœ˜Kšœ!žœ ˜0K˜—K™KšœI˜IKšœI˜IKšœF˜FK™Kšœ™K˜Kšœ@˜@Kšœ:˜:Kšœ8˜8Kšœ>˜>KšœB˜BKšœ>˜>Kšœ8˜8Kšœ6˜6KšœK˜KKšœT˜TK˜Kšœ,˜,Kšœ'˜'KšœK˜KKšœJ˜JKšœG˜GKšœI˜IKšœH˜HKšœE˜EKšœG˜GKšœK˜KKšœ^˜^Kšœb˜bKšœf˜fK˜KšœC˜CKšžœ˜—…—'j5Y