GenerateAuxInterface.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Bill Jackson (bj) September 25, 1986 3:15:00 am PDT
DIRECTORY
BasicTime USING [],
FS USING [StreamOpen],
HashTable USING [EachPairAction, Pairs, Value],
IO USING [STREAM, int, rope, Close, PutF, PutFR],
Rope USING [ROPE, Cat],
SiroccoPrivate USING [AquireState, CComponent, CType, FileHeader, Handle, Nest, TABLES, UnDoable];
GenerateAuxInterface: CEDAR PROGRAM
IMPORTS FS, HashTable, IO, Rope, SiroccoPrivate
EXPORTS SiroccoPrivate ~ {
OPEN SiroccoPrivate;
Copied Types
ROPE: TYPE ~ Rope.ROPE;
Value: TYPE ~ HashTable.Value;
Procs
Heading: PROC [out: IO.STREAM, programKeyWD: ROPE] ~ {
SiroccoPrivate.FileHeader[out, Rope.Cat[programKeyWD, "Aux.Mesa"]];
IO.PutF[out, Nest["DIRECTORY", 1]];
IO.PutF[out, Nest["%g;", 0], IO.rope[programKeyWD]];
IO.PutF[out, Nest["", 0]];
IO.PutF[out, Nest["%gAux: CEDAR DEFINITIONS ~ {", 1], IO.rope[programKeyWD]];
IO.PutF[out, Nest["OPEN %g;", 1], IO.rope[programKeyWD]];
};
GenAuxDefs: PUBLIC PROC ~ {
aux: IO.STREAM;
failure: BOOLEAN;
h: Handle;
programKeyWD: ROPE;
GenerateInterfaceItem: HashTable.EachPairAction ~ {
name: ROPENARROW [key];
entry: CType ← NARROW [value];
item: ROPE;
local: BOOLEAN;
[item, local] ← UnDoable[name, programKeyWD];
IF (local) THEN {
SELECT entry.class FROM
boolean,
cardinal,
integer,
longCardinal,
longInteger,
string,
unspecified => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PROC [p: %g, level: NAT] RETURNS [x: ROPE];",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 1]];
};
array => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PROC [a: %g, level: NAT] RETURNS [x: ROPE];",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 1]];
};
choice => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PROC [c: %g, level: NAT] RETURNS [x: ROPE];",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 1]];
};
enumeration => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PROC [e: %g, level: NAT] RETURNS [x: ROPE];",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 1]];
};
record => {
fieldList: CComponent ← entry.children;
Handle Empty Record as a special case because of compiler bug
IF (fieldList = NIL) THEN {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PROC [--r: %g,-- level: NAT] RETURNS [x: ROPE];",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 1]];
RETURN;
};
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PROC [r: %g, level: NAT] RETURNS [x: ROPE];",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 1]];
};
sequence => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PROC [s: %g, level: NAT] RETURNS [x: ROPE];",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 1]];
};
error => { NULL }; -- always a constant!
procedure => { NULL }; -- always a constant!
ENDCASE => {
ERROR;
};
};
};
GenAuxDefs MAIN
h ← SIGNAL AquireState[];
programKeyWD ← IO.PutFR["%gP%gV%g",
IO.rope[h.programName],
IO.int[h.programNo],
IO.int[h.versionNo]
];
aux ← FS.StreamOpen[Rope.Cat[programKeyWD, "Aux.Mesa"], $create];
Heading[aux, programKeyWD];
failure ← HashTable.Pairs[h.allTheTables.typeTable, GenerateInterfaceItem];
IO.PutF[aux, Nest["", 0]];
IO.PutF[aux, Nest["}...", 0]];
IO.Close[aux];
};
}.