CDMakeProcSomeImpl.mesa (module for ChipNDale)
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, May 9, 1985 1:58:40 pm PDT
Last edited by: Christian Jacobi, October 22, 1986 5:11:14 pm PDT
DIRECTORY
CD,
CDCurves,
CDImports,
CDTexts,
CDMakeProcPrivate,
IO,
Rope;
CDMakeProcSomeImpl: CEDAR PROGRAM
IMPORTS CDMakeProcPrivate, IO, Rope, CDTexts =
BEGIN
MakeCurves: PROC [env: CDMakeProcPrivate.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;
CDMakeProcPrivate.IncludeDirectory[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, CDMakeProcPrivate.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: ", CDMakeProcPrivate.LayerIdent[env, ob.layer], "].ob"];
RETURN [r];
};
MakeSplines: CDMakeProcPrivate.ExpressionProc = {
RETURN [ MakeCurves[env, NARROW[x], TRUE, "CreateSpline"] ];
};
MakeLines: CDMakeProcPrivate.ExpressionProc = {
RETURN [ MakeCurves[env, NARROW[x], TRUE, "CreateLine"] ];
};
MakePolygon: CDMakeProcPrivate.ExpressionProc = {
RETURN [ MakeCurves[env, NARROW[x], FALSE, "CreatePolygon"] ];
};
MakeFilledCurve: CDMakeProcPrivate.ExpressionProc = {
RETURN [ MakeCurves[env, NARROW[x], FALSE, "CreateFilledCurve"] ];
};
MakeText: CDMakeProcPrivate.ExpressionProc = {
SupportFont: PROC [env: CDMakeProcPrivate.Environment, font: CDTexts.CDFont] RETURNS [r: Rope.ROPE] = {
x: REF;
TRUSTED { x ← LOOPHOLE[font] };
r ← CDMakeProcPrivate.GlobalIdent[env, x];
IF r=NIL THEN {
decl: Rope.ROPE;
CDMakeProcPrivate.IncludeDirectory[env, "CDTexts"];
r ← CDMakeProcPrivate.RequestGlobalIdent[env, "font", x];
decl ← Rope.Cat[r, ": CDTexts.CDFont ← CDTexts.MakeFont[name: "];
decl ← Rope.Cat[decl, CDMakeProcPrivate.RopeToRope[tp.cdFont.supposedName], ", scale: ", IO.PutFR1["%g", IO.int[tp.cdFont.scaleI]]];
decl ← Rope.Cat[decl, "];"];
CDMakeProcPrivate.GlobalDeclaration1[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];
CDMakeProcPrivate.IncludeDirectory[env, "CDTexts"];
r ← Rope.Cat[r, CDMakeProcPrivate.RopeToRope[tp.text], ", font: ", fontIdent];
r ← Rope.Cat[r, ", layer: ", CDMakeProcPrivate.LayerIdent[env, ob.layer]];
r ← Rope.Cat[r, ", flip: ", (IF flip THEN "TRUE" ELSE "FALSE"), "]"];
RETURN [r];
};
MakeImport: CDMakeProcPrivate.ExpressionProc = {
MakeImpGenerator: PROC [env: CDMakeProcPrivate.Environment] = {
IF CDMakeProcPrivate.GetEnvironmentProp[env, $hasImports]=NIL THEN {
CDMakeProcPrivate.PutEnvironmentProp[env, $hasImports, $hasImports];
CDMakeProcPrivate.GlobalDeclaration2[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, ", CDMakeProcPrivate.RopeToRope[Rope.Cat[ip.designName, ".", ip.objectName]], "]"];
RETURN [r];
};
CDMakeProcPrivate.RegisterExpressionProc[$Polygon0, MakePolygon];
CDMakeProcPrivate.RegisterExpressionProc[$FilledCurve0, MakeFilledCurve];
CDMakeProcPrivate.RegisterExpressionProc[$Line0, MakeLines];
CDMakeProcPrivate.RegisterExpressionProc[$Spline0, MakeSplines];
CDMakeProcPrivate.RegisterExpressionProc[$RigidText, MakeText];
CDMakeProcPrivate.RegisterExpressionProc[$FlipText, MakeText];
CDMakeProcPrivate.RegisterExpressionProc[$Import, MakeImport];
END.