CDMakeProcSomeImpl.mesa (module for ChipNDale)
Copyright © 1985, 1986, 1987 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, May 9, 1985 1:58:40 pm PDT
Last edited by: Christian Jacobi, January 5, 1987 8:13:06 pm PST
DIRECTORY
CD,
CDCurves,
CDImports,
CDTexts,
CDMakeProc,
IO,
Rope;
CDMakeProcSomeImpl: CEDAR PROGRAM
IMPORTS CDMakeProc, IO, Rope, CDTexts =
BEGIN
MakeCurves: PROC [env: CDMakeProc.Environment, ob: CD.Object, useW: BOOL, key: Rope.ROPE] RETURNS [Rope.ROPE] = {
r: Rope.ROPE ← Rope.Cat["CDCurves.", key, "[points: "];
list: Rope.ROPENIL;
pp: CDCurves.CurveSpecific ← NARROW[ob.specific];
n: INT ← 0;
CDMakeProc.MakePreamble[env, "CDCurves"];
FOR pl: LIST OF CD.Position ← pp.points, pl.rest WHILE pl#NIL DO
n ← n+1;
IF n=1 THEN list ← "LIST[" ELSE list ← Rope.Cat[list, ", "];
list ← Rope.Cat[list, CDMakeProc.PosToRope[pl.first]];
ENDLOOP;
r ← Rope.Cat[r, list, "]"];
IF useW THEN r ← Rope.Cat[r, IO.PutFR[", w: %g", [integer[pp.w]]]];
r ← Rope.Cat[r, ", layer: ", CDMakeProc.MakeLayer[env, ob.layer], "].ob"];
RETURN [r];
};
MakeSplines: CDMakeProc.ObjectExpressionProc = {
RETURN [ MakeCurves[env, NARROW[x], TRUE, "CreateSpline"] ];
};
MakeLines: CDMakeProc.ObjectExpressionProc = {
RETURN [ MakeCurves[env, NARROW[x], TRUE, "CreateLine"] ];
};
MakePolygon: CDMakeProc.ObjectExpressionProc = {
RETURN [ MakeCurves[env, NARROW[x], FALSE, "CreatePolygon"] ];
};
MakeFilledCurve: CDMakeProc.ObjectExpressionProc = {
RETURN [ MakeCurves[env, NARROW[x], FALSE, "CreateFilledCurve"] ];
};
MakeText: CDMakeProc.ObjectExpressionProc = {
SupportFont: PROC [env: CDMakeProc.Environment, font: CDTexts.CDFont] RETURNS [r: Rope.ROPE] = {
x: REF;
TRUSTED { x ← LOOPHOLE[font] };
r ← CDMakeProc.GetGlobalIdent[env, x];
IF r=NIL THEN {
decl: Rope.ROPE;
CDMakeProc.MakePreamble[env, "CDTexts"];
r ← CDMakeProc.ForceGlobalIdent[env, "font", x];
decl ← Rope.Cat[r, ": CDTexts.CDFont ← CDTexts.MakeFont[name: "];
decl ← Rope.Cat[decl, CDMakeProc.RopeToRope[tp.cdFont.supposedName], ", scale: ", IO.PutFR1["%g", IO.int[tp.cdFont.scaleI]]];
decl ← Rope.Cat[decl, "];"];
CDMakeProc.PlaceDeclarationM1[env, decl];
};
};
r: Rope.ROPE ← "CDTexts.Create[text: ";
fontIdent: Rope.ROPE;
ob: CD.Object ← NARROW[x];
tp: CDTexts.TextSpecific ← NARROW[ob.specific];
flip: BOOL ← CDTexts.IsFlipText[ob];
fontIdent ← SupportFont[env, tp.cdFont];
CDMakeProc.MakePreamble[env, "CDTexts"];
r ← Rope.Cat[r, CDMakeProc.RopeToRope[tp.text], ", font: ", fontIdent];
r ← Rope.Cat[r, ", layer: ", CDMakeProc.MakeLayer[env, ob.layer]];
r ← Rope.Cat[r, ", flip: ", (IF flip THEN "TRUE" ELSE "FALSE"), "]"];
RETURN [r];
};
MakeImport: CDMakeProc.ObjectExpressionProc = {
MakeImpGenerator: PROC [env: CDMakeProc.Environment] = {
IF CDMakeProc.GetEnvironmentProp[env, $hasImports]=NIL THEN {
CDMakeProc.PutEnvironmentProp[env, $hasImports, $hasImports];
CDMakeProc.PlaceDeclarationM2[env, "imports: CDGenerate.Context ← CDGenerate.AssertTable[""IMPORT""];"];
}
};
r: Rope.ROPE;
ob: CD.Object ← NARROW[x];
ip: CDImports.ImportSpecific ← NARROW[ob.specific];
IF Rope.Find[ip.designName, "."]>=0 THEN RETURN [NIL];
MakeImpGenerator[env];
r ← Rope.Cat["CDGenerate.FetchNCall[imports, design, ", CDMakeProc.RopeToRope[Rope.Cat[ip.designName, ".", ip.objectName]], "]"];
RETURN [r];
};
CDMakeProc.RegisterObjectExpressionProc[$Polygon0, MakePolygon];
CDMakeProc.RegisterObjectExpressionProc[$FilledCurve0, MakeFilledCurve];
CDMakeProc.RegisterObjectExpressionProc[$Line0, MakeLines];
CDMakeProc.RegisterObjectExpressionProc[$Spline0, MakeSplines];
CDMakeProc.RegisterObjectExpressionProc[$RigidText, MakeText];
CDMakeProc.RegisterObjectExpressionProc[$FlipText, MakeText];
CDMakeProc.RegisterObjectExpressionProc[$Import, MakeImport];
END.