CDPropertyCommands.mesa (part of Chipndale)
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi November 7, 1983 5:39 pm
last edited Christian Jacobi November 27, 1984 1:03:09 pm PST
DIRECTORY
Atom,
CD,
CDApplications,
CDCommandOps,
CDMenus,
CDOps,
CDProperties,
CDRopeViewer,
CDSequencer,
IO,
Rope,
RuntimeError USING [UNCAUGHT],
TerminalIO,
TokenIO,
ViewerTools USING [TiogaContents, TiogaContentsRec];
CDPropertyCommands:
CEDAR
PROGRAM
IMPORTS Atom, CDCommandOps, CDMenus, CDOps, CDProperties, CDRopeViewer, CDSequencer, IO, Rope, RuntimeError, TerminalIO =
BEGIN
specialRights: BOOL ← FALSE; -- gives the right to access exclusive properties
EnterSignalNameSP:
PROC [comm: CDSequencer.Command] =
BEGIN
aptr: CD.ApplicationPtr ← CDCommandOps.TheApplication[comm, "read signal-name"];
IF aptr#
NIL
THEN {
name: Rope.ROPE;
TerminalIO.WriteRope[" onto "];
CDCommandOps.WriteInfo[aptr];
name ← TerminalIO.RequestRope[" type name: "];
--if name = nil, property will be removed
IF Rope.IsEmpty[name] THEN name←NIL;
CDProperties.PutPropOnApplication[onto: aptr, prop: $SignalName, val: name];
IF name#NIL THEN TerminalIO.WriteRope[" done\n"]
ELSE TerminalIO.WriteRope[" removed\n"];
}
END;
EnterInstanceNameSP:
PROC [comm: CDSequencer.Command] =
BEGIN
aptr: CD.ApplicationPtr ← CDCommandOps.TheApplication[comm, "read instance-name"];
IF aptr#
NIL
THEN {
name: Rope.ROPE;
TerminalIO.WriteRope[" onto "];
CDCommandOps.WriteInfo[aptr];
name ← TerminalIO.RequestRope[" type name: "];
--if name = nil, property will be removed
IF Rope.IsEmpty[name] THEN name←NIL;
CDProperties.PutPropOnApplication[onto: aptr, prop: $InstanceName, val: name];
IF name#NIL THEN TerminalIO.WriteRope[" done\n"]
ELSE TerminalIO.WriteRope[" removed\n"];
}
END;
RemoveDollar:
PROC [r: Rope.
ROPE]
RETURNS [Rope.
ROPE] =
BEGIN
IF Rope.Length[r]>1 AND Rope.Fetch[r]='$ THEN r ← Rope.Substr[r, 1, Rope.Length[r]-1];
RETURN [r]
END;
detail: INT ← 0;
--XXX make public on next release; probably in CDCommandOps
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.WriteRope[IO.PutFR["^%g", IO.int[ip^]]];
r: Rope.ROPE => TerminalIO.WriteRope[r];
a: ATOM => TerminalIO.WriteRope[Rope.Concat["$", Atom.GetPName[a]]];
ra: REF ATOM => TerminalIO.WriteRope[Rope.Concat["^$", Atom.GetPName[ra^]]];
d: CD.Design => TerminalIO.WriteRope[Rope.Concat["design ", (IF d.name=NIL THEN "no name" ELSE d.name)]];
ob: CD.ObPtr => TerminalIO.WriteRope[CDOps.Info[ob]];
ap: CD.ApplicationPtr => CDCommandOps.WriteInfo[ap];
ENDCASE =>
IF detail=0 THEN TerminalIO.WriteRope[IO.PutFR["(%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𡤀
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 ← Atom.MakeAtom[RemoveDollar[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
aptr: CD.ApplicationPtr ← CDCommandOps.TheApplication[comm, "enter property of instance"];
IF aptr#NIL THEN PropertyForSome[aptr];
END;
PropertyOb:
PROC [comm: CDSequencer.Command] =
BEGIN
aptr: CD.ApplicationPtr ← CDCommandOps.TheApplication[comm, "enter property for an object"];
IF aptr#
NIL
THEN
IF aptr.ob.p.inDirectory OR specialRights THEN PropertyForSome[aptr.ob]
ELSE TerminalIO.WriteRope["this object class has no user accessable properties\n"];
END;
PropertyForSome:
PROC [what:
REF] =
BEGIN
pType: CDProperties.PropertyProcs;
atom: ATOM;
value: REF;
name: Rope.ROPE ← RemoveDollar[TerminalIO.RequestRope["type property name: "]];
IF Rope.IsEmpty[name]
THEN {
TerminalIO.WriteRope[" empty name; not done\n"];
RETURN
};
atom ← Atom.MakeAtom[name];
value ← CDProperties.GetProp[what, atom];
TerminalIO.WriteRope[" old value: "];
WriteValue[value];
TerminalIO.WriteLn[];
pType ← CDProperties.FetchProcs[atom];
IF pType#
NIL
AND pType.exclusive
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;
--move this procedure to CDProperties
ShowProperties:
PROC [from:
REF] =
BEGIN
WITH from
SELECT
FROM
a: CD.ApplicationPtr => ShowPropertyList[a.properties];
o: CD.ObPtr => ShowPropertyList[o.properties];
d: CD.Design => ShowPropertyList[d.properties];
t: CD.Technology => ShowPropertyList[t.properties];
--l: CD.LevelRef => ...;
--at: ATOM => ...;
ENDCASE => TerminalIO.WriteRope[" no showable CD properties"];
END;
ShowPropertyList:
PROC [pl:
CD.Properties] =
BEGIN
FOR list:
CD.Properties ← pl, list.rest
WHILE list#
NIL
DO
ShowProperty[list.first]
ENDLOOP
END;
ShowProperty:
PROC [pp: Atom.DottedPair] =
BEGIN
TerminalIO.WriteRope[" name: "];
WriteValue[pp.key];
TerminalIO.WriteRope[" value: "];
WriteValue[pp.val];
TerminalIO.WriteLn[];
END;
ShowPropertiesSP:
PROC [comm: CDSequencer.Command] =
BEGIN
aptr: CD.ApplicationPtr ← CDCommandOps.TheApplication[comm, "Show Properties"];
IF aptr#
NIL
THEN {
IF aptr.properties#
NIL
THEN {
TerminalIO.WriteRope[" --properties on instance\n"];
ShowPropertyList[aptr.properties];
};
IF aptr.ob.properties#
NIL
THEN {
TerminalIO.WriteRope[" --properties on object itself\n"];
ShowPropertyList[aptr.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
aptr: CD.ApplicationPtr ← CDCommandOps.TheApplication[comm, "comment object"];
IF aptr#
NIL
THEN {
IF aptr.ob.p.inDirectory
THEN
CommentSome[what: aptr.ob, caption: Rope.Cat["Comment on ", CDOps.Info[aptr.ob]]]
ELSE TerminalIO.WriteRope["this object class has no comments\n"];
}
END;
CommentAppComm:
PROC [comm: CDSequencer.Command] =
BEGIN
aptr: CD.ApplicationPtr ← CDCommandOps.TheApplication[comm, "comment instance"];
IF aptr#
NIL
THEN {
CommentSome[what: aptr, 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] =
BEGIN
aptr: CD.ApplicationPtr ← CDCommandOps.TheApplication[comm, "property and name menu"];
IF aptr=
NIL
THEN
CDSequencer.ExecuteCommand[comm: comm, as: $NameMenuOnlyDesign]
ELSE
IF aptr.ob.p.inDirectory
THEN
CDSequencer.ExecuteCommand[comm: comm, as: $NameMenuFull]
ELSE
CDSequencer.ExecuteCommand[comm: comm, as: $NameMenuOnlyApp]
END;
-- module initialization
Registration of properties removed from this place, to port this module to commandlevel
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];
[] ← CDMenus.CreateMenu["Names & Properties", $NameMenuFull];
CDMenus.ImplementMenuCommand[$NameMenuFull, $NameMenuFull];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Property (design)", key: $PropertyDesign];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Property (instance)", key: $PropertyApp];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Property (object)", key: $PropertyOb];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Comment (design)", key: $CommentDesign];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Comment (instance)", key: $CommentApp];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Comment (object)", key: $CommentOb];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Rename design", key: $RenameDesign]; --CDMoveCopyCommands
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Instance-name", key: $InstanceNameS];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Object-name", key: $RenameS]; --CDCellCommands
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Signal-name (instance)", key: $SignalNameS];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Show prop (design)", key: $ShowPropertiesDesign];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Show prop (i&o)", key: $ShowPropertiesS];
CDMenus.CreateEntry[menu: $NameMenuFull, entry: "Display signal-names", key: $DisplayNames]; --CDVCommands
[] ← CDMenus.CreateMenu["Names & Properties", $NameMenuOnlyApp];
CDMenus.ImplementMenuCommand[$NameMenuOnlyApp, $NameMenuOnlyApp];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Property (design)", key: $PropertyDesign];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Property (instance)", key: $PropertyApp];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Comment (design)", key: $CommentDesign];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Comment (instance)", key: $CommentApp];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Rename design", key: $RenameDesign]; --CDMoveCopyCommands
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Instance-name (instance)", key: $InstanceNameS];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Signal-name (instance)", key: $SignalNameS];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Show prop (design)", key: $ShowPropertiesDesign];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Show prop (i&o)", key: $ShowPropertiesS];
CDMenus.CreateEntry[menu: $NameMenuOnlyApp, entry: "Display signal-names", key: $DisplayNames]; --CDVCommands
[] ← CDMenus.CreateMenu["Names & Properties", $NameMenuOnlyDesign];
CDMenus.ImplementMenuCommand[$NameMenuOnlyDesign, $NameMenuOnlyDesign];
CDMenus.CreateEntry[menu: $NameMenuOnlyDesign, entry: "Property (design)", key: $PropertyDesign];
CDMenus.CreateEntry[menu: $NameMenuOnlyDesign, entry: "Comment (design)", key: $CommentDesign];
CDMenus.CreateEntry[menu: $NameMenuOnlyDesign, entry: "Rename design", key: $RenameDesign]; --CDMoveCopyCommands
CDMenus.CreateEntry[menu: $NameMenuOnlyDesign, entry: "Show prop (design)", key: $ShowPropertiesDesign];
CDMenus.CreateEntry[menu: $NameMenuOnlyDesign, entry: "Display signal-names", key: $DisplayNames]; --CDVCommands
CDSequencer.ImplementCommand[$NameMenu, NameMenuComm];
CDSequencer.ImplementCommand[$EnterNameS, NameMenuComm];
CDSequencer.ImplementCommand[$EnterPropertyS, NameMenuComm];
END.