ApplyDoPage:
PUBLIC
PROC [self: JaM.State] ~ {
OPEN JaM;
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[self];
rope: ROPE ~ PopRope[self];
x: Any ~ Pop[self];
action:
PROC [dc: Imager.Context] ~ {
Imager.ScaleT[dc, 0.0254/72];
info.ipenabled← TRUE;
info.ipdc← dc;
Execute[self, x];
info.ipenabled← FALSE;
};
ref: ImagerInterpress.Ref = ImagerInterpress.Create[rope];
IF info = NIL THEN ERROR;
ImagerInterpress.DoPage[ref, action ! UNWIND => info.ipenabled← FALSE];
ImagerInterpress.Close[ref];
};
ApplyWriteInterpress:
PUBLIC
PROC [self: JaM.State] ~ {
OPEN JaM;
info: JaMIPrivate.Info ← JaMIPrivate.GetInfo[self];
x: Any ← Pop[self];
decl: Array ~ PopArray[self];
rope: ROPE ~ PopRope[self];
quit: INT ← 0;
pageNumber: INT ← 1;
action:
PROC [dc: Imager.Context] ~ {
Imager.ScaleT[dc, 0.0254/72];
info.ipenabled← TRUE;
info.ipdc← dc;
JaM.PushInt[self, pageNumber];
Execute[self, x];
quit ← JaM.PopInt[self];
info.ipenabled← FALSE;
};
ref: ImagerInterpress.Ref = ImagerInterpress.Create[rope];
IF info = NIL THEN ERROR;
FOR i:
NAT
IN [decl.start..decl.start+decl.length)
DO
d: Any ← JaM.AGet[decl, i];
WITH d
SELECT
FROM
font: Imager.Font => ImagerInterpress.DeclareFont[ref, font];
color: Imager.Color => ImagerInterpress.DeclareColor[ref, color];
pixelArray: Imager.PixelArray => ImagerInterpress.DeclarePixelArray[ref, pixelArray];
colorOperator: Imager.ColorOperator => ImagerInterpress.DeclareColorOperator[ref, colorOperator];
ENDCASE => ERROR JaM.Error[WrongType, Rope.Cat["wrong type: element ", Convert.RopeFromInt[i], " of declaration"]];
ENDLOOP;
UNTIL quit # 0
DO
ImagerInterpress.DoPage[ref, action ! UNWIND => info.ipenabled ← FALSE];
pageNumber ← pageNumber + 1;
ENDLOOP;
ImagerInterpress.Close[ref];
};
RegisterInterpress:
PUBLIC
PROC [self: JaM.State] ~ {
JaM.Register[self, ".makeinterpress", ApplyDoPage];
JaM.Register[self, ".writeinterpress", ApplyWriteInterpress];
};