CommandRep:
TYPE ~
RECORD[
SELECT type: *
FROM
DoSave => [body: CommandList, all: BOOL],
SetInt => [key: IntKey, val: INT],
SetReal => [key: RealKey, val: REAL],
SetT => [m: Transformation],
SetFont => [font: Font],
SetColor => [color: Color],
SetClipper => [clipper: Clipper],
SetStrokeDashes => [strokeDashes: StrokeDashes],
GetInt => [key: IntKey] RETURNS[INT],
GetReal => [key: RealKey] RETURNS[REAL],
GetT => [] RETURNS[Transformation],
GetFont => [] RETURNS[Font],
GetColor => [] RETURNS[Color],
GetClipper => [] RETURNS[Clipper],
GetStrokeDashes => [] RETURNS[StrokeDashes],
ConcatT => [m: Transformation],
Scale2T => [s: VEC],
RotateT => [a: REAL],
TranslateT => [t: VEC],
Move => [rounded: BOOL],
SetXY => [p: VEC],
SetXYRel => [v: VEC],
Show => [string: XStringSeq, xrel: BOOL],
ShowText => [text: REF READONLY TEXT, start, len: NAT, xrel: BOOL],
StartUnderline => [],
MaskUnderline => [dy, h: REAL],
CorrectMask => [],
CorrectSpace => [v: VEC],
Space => [x: REAL],
SetCorrectMeasure => [v: VEC],
SetCorrectTolerance => [v: VEC],
Correct => [body: CommandList],
DontCorrect => [body: CommandList, saveCP: BOOL],
SetGray => [f: REAL],
SetSampledColor => [pa: PixelArray,
m: Transformation, colorOperator: ColorOperator],
SetSampledBlack => [pa: PixelArray,
m: Transformation, clear: BOOL],
MaskFill => [path: Path, parity: BOOL],
MaskRectangle => [r: Rectangle],
MaskRectangleI => [x, y, w, h: INTEGER],
MaskStroke => [path: Path, closed: BOOL],
MaskVector => [p1, p2: VEC],
MaskPixel => [pa: PixelArray],
MaskBits => [bits: Bits],
DrawBits => [bits: Bits],
Clip => [path: Path, parity: BOOL, exclude: BOOL],
ClipRectangle => [r: Rectangle, exclude: BOOL],
ClipRectangleI => [x, y, w, h: INTEGER, exclude: BOOL]
GetCP => [rounded: BOOL] RETURNS[VEC],
GetBoundingRectangle => [] RETURNS[Rectangle],
ENDCASE
];
Memory Context Procs
Bits:
TYPE ~
RECORD [
wordsPerLine, sMin, fMin, sSize, fSize: NAT,
tx, ty: INTEGER,
data: REF BitsData
];
BitsData: TYPE ~ RECORD [SEQUENCE size: CARDINAL OF WORD];
MakeBits:
PROC [base:
LONG
POINTER, wordsPerLine:
NAT, sMin, fMin, sSize, fSize:
NAT, tx, ty:
INTEGER]
RETURNS [bits: Bits] ~ {
bits ← [wordsPerLine, sMin, fMin, sSize, fSize, tx, ty, NEW[BitsData[wordsPerLine*sSize]]];
TRUSTED {PrincOpsUtils.LongCopy[from: base, to: LOOPHOLE[bits.data], nwords: wordsPerLine*sSize];}
};
MemoryDoSave:
PROC[context: Context, action:
PROC, all:
BOOL] ~ {
body: CommandList ~ GetBody[context, action];
Append[NARROW[context.data], [DoSave [body, all]]];
};
MemorySetInt:
PROC[context: Context, key: IntKey, val:
INT] ~ {
Append[NARROW[context.data], [SetInt [key, val]]];
};
MemorySetReal:
PROC[context: Context, key: RealKey, val:
REAL] ~ {
Append[NARROW[context.data], [SetReal [key, val]]];
};
MemorySetT:
PROC[context: Context, m: Transformation] ~ {
Append[NARROW[context.data], [SetT [m]]];
};
MemorySetFont:
PROC[context: Context, font: Font] ~ {
Append[NARROW[context.data], [SetFont [font]]];
};
MemorySetColor:
PROC[context: Context, color: Color] ~ {
Append[NARROW[context.data], [SetColor [color]]];
};
MemorySetClipper:
PROC[context: Context, clipper: Clipper] ~ {
Append[NARROW[context.data], [SetClipper [clipper]]];
};
MemorySetStrokeDashes:
PROC[context: Context, strokeDashes: StrokeDashes] ~ {
Append[NARROW[context.data], [SetStrokeDashes [strokeDashes]]];
};
MemoryGetInt:
PROC[context: Context, key: IntKey]
RETURNS[
INT] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
MemoryGetReal:
PROC[context: Context, key: RealKey]
RETURNS[
REAL] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
MemoryGetT:
PROC[context: Context]
RETURNS[Transformation] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
MemoryGetFont:
PROC[context: Context]
RETURNS[Font] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
MemoryGetColor:
PROC[context: Context]
RETURNS[Color] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
MemoryGetClipper:
PROC[context: Context]
RETURNS[Clipper] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
MemoryGetStrokeDashes:
PROC[context: Context]
RETURNS[StrokeDashes] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
MemoryConcatT:
PROC[context: Context, m: Transformation] ~ {
Append[NARROW[context.data], [ConcatT [m]]];
};
MemoryScale2T:
PROC[context: Context, s:
VEC] ~ {
Append[NARROW[context.data], [Scale2T [s]]];
};
MemoryRotateT:
PROC[context: Context, a:
REAL] ~ {
Append[NARROW[context.data], [RotateT [a]]];
};
MemoryTranslateT:
PROC[context: Context, t:
VEC] ~ {
Append[NARROW[context.data], [TranslateT [t]]];
};
MemoryMove:
PROC[context: Context, rounded:
BOOL] ~ {
Append[NARROW[context.data], [Move [rounded]]];
};
MemorySetXY:
PROC[context: Context, p:
VEC] ~ {
Append[NARROW[context.data], [SetXY [p]]];
};
MemorySetXYRel:
PROC[context: Context, v:
VEC] ~ {
Append[NARROW[context.data], [SetXYRel [v]]];
};
MemoryShow:
PROC[context: Context, string: XStringProc, xrel:
BOOL] ~ {
CountXChars: ImagerFont.XCharProc ~ {
n ← n+1;
};
InstallXChar: ImagerFont.XCharProc ~ {
xString[n] ← char;
n ← n+1;
};
xString: XStringSeq;
n: INT ← 0;
string[CountXChars]; --Count number of chars fed back
xString ← NEW[XStringSeqRec[n]];
n ← 0;
string[InstallXChar]; --Install each character
Append[NARROW[context.data], [Show [string: xString, xrel: xrel]]];
};
MemoryShowText:
PROC[context: Context, text:
REF
READONLY
TEXT, start, len:
NAT, xrel:
BOOL] ~ {
newText: REF TEXT ~ Rope.ToRefText[Rope.FromRefText[text]];
Append[NARROW[context.data], [ShowText [newText, start, len, xrel]]];
};
MemoryStartUnderline:
PROC[context: Context] ~ {
Append[NARROW[context.data], [StartUnderline []]]};
MemoryMaskUnderline:
PROC[context: Context, dy, h:
REAL] ~ {
Append[NARROW[context.data], [MaskUnderline [dy, h]]];
};
MemoryCorrectMask:
PROC[context: Context] ~ {
Append[NARROW[context.data], [CorrectMask []]]};
MemoryCorrectSpace:
PROC[context: Context, v:
VEC] ~ {
Append[NARROW[context.data], [CorrectSpace [v]]];
};
MemorySpace:
PROC[context: Context, x:
REAL] ~ {
Append[NARROW[context.data], [Space [x]]];
};
MemorySetCorrectMeasure:
PROC[context: Context, v:
VEC] ~ {
Append[NARROW[context.data], [SetCorrectMeasure [v]]];
};
MemorySetCorrectTolerance:
PROC[context: Context, v:
VEC] ~ {
Append[NARROW[context.data], [SetCorrectTolerance [v]]];
};
MemoryCorrect:
PROC[context: Context, action:
PROC] ~ {
body: CommandList ~ GetBody[context, action];
Append[NARROW[context.data], [Correct [body]]];
};
MemoryDontCorrect:
PROC[context: Context, action:
PROC, saveCP:
BOOL] ~ {
body: CommandList ~ GetBody[context, action];
Append[NARROW[context.data], [DontCorrect [body, saveCP]]];
};
MemorySetGray:
PROC[context: Context, f:
REAL] ~ {
Append[NARROW[context.data], [SetGray [f]]];
};
MemorySetSampledColor:
PROC[context: Context, pa: PixelArray, m: Transformation, colorOperator: ColorOperator] ~ {
Append[NARROW[context.data], [SetSampledColor [pa, m, colorOperator]]];
};
MemorySetSampledBlack:
PROC[context: Context, pa: PixelArray, m: Transformation, clear:
BOOL] ~ {
Append[NARROW[context.data], [SetSampledBlack [pa, m, clear]]];
};
MemoryMaskFill:
PROC[context: Context, path: PathProc, parity:
BOOL] ~ {
pathList: Path ~ GetPath[path];
Append[NARROW[context.data], [MaskFill [pathList, parity]]];
};
MemoryMaskRectangle:
PROC[context: Context, r: Rectangle] ~ {
Append[NARROW[context.data], [MaskRectangle [r]]];
};
MemoryMaskRectangleI:
PROC[context: Context, x, y, w, h:
INTEGER] ~ {
Append[NARROW[context.data], [MaskRectangleI [x, y, w, h]]];
};
MemoryMaskStroke:
PROC[context: Context, path: PathProc, closed:
BOOL] ~ {
pathList: Path ~ GetPath[path];
Append[NARROW[context.data], [MaskStroke [pathList, closed]]];
};
MemoryMaskVector:
PROC[context: Context, p1, p2:
VEC] ~ {
Append[NARROW[context.data], [MaskVector [p1, p2]]];
};
MemoryMaskPixel:
PROC[context: Context, pa: PixelArray] ~ {
Append[NARROW[context.data], [MaskPixel [pa]]];
};
MemoryMaskBits:
PROC[context: Context, base:
LONG
POINTER, wordsPerLine:
NAT, sMin, fMin, sSize, fSize:
NAT, tx, ty:
INTEGER] ~ {
bits: Bits ~ MakeBits[base, wordsPerLine, sMin, fMin, sSize, fSize, tx, ty];
Append[NARROW[context.data], [MaskBits [bits]]];
};
MemoryDrawBits:
PROC[context: Context, base:
LONG
POINTER, wordsPerLine:
NAT, sMin, fMin, sSize, fSize:
NAT, tx, ty:
INTEGER] ~ {
bits: Bits ~ MakeBits[base, wordsPerLine, sMin, fMin, sSize, fSize, tx, ty];
Append[NARROW[context.data], [DrawBits [bits]]];
};
MemoryClip:
PROC[context: Context, path: PathProc, parity:
BOOL, exclude:
BOOL] ~ {
pathList: Path ~ GetPath[path];
Append[NARROW[context.data], [Clip [pathList, parity, exclude]]];
};
MemoryClipRectangle:
PROC[context: Context, r: Rectangle, exclude:
BOOL] ~ {
Append[NARROW[context.data], [ClipRectangle [r, exclude]]];
};
MemoryClipRectangleI:
PROC[context: Context, x, y, w, h:
INTEGER, exclude:
BOOL] ~ {
Append[NARROW[context.data], [ClipRectangleI [x, y, w, h, exclude]]];
};
MemoryGetCP:
PROC[context: Context, rounded:
BOOL]
RETURNS[
VEC] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
MemoryGetBoundingRectangle:
PROC[context: Context]
RETURNS[Rectangle] ~ {
Imager.Error[[$unimplemented, "Not implemented"]]};
memoryClass: Class ~
NEW[ClassRep ← [
type: $Memory,
DoSave: MemoryDoSave,
SetInt: MemorySetInt,
SetReal: MemorySetReal,
SetT: MemorySetT,
SetFont: MemorySetFont,
SetColor: MemorySetColor,
SetClipper: MemorySetClipper,
SetStrokeDashes: MemorySetStrokeDashes,
GetInt: MemoryGetInt,
GetReal: MemoryGetReal,
GetT: MemoryGetT,
GetFont: MemoryGetFont,
GetColor: MemoryGetColor,
GetClipper: MemoryGetClipper,
GetStrokeDashes: MemoryGetStrokeDashes,
ConcatT: MemoryConcatT,
Scale2T: MemoryScale2T,
RotateT: MemoryRotateT,
TranslateT: MemoryTranslateT,
Move: MemoryMove,
SetXY: MemorySetXY,
SetXYRel: MemorySetXYRel,
Show: MemoryShow,
ShowText: MemoryShowText,
StartUnderline: MemoryStartUnderline,
MaskUnderline: MemoryMaskUnderline,
CorrectMask: MemoryCorrectMask,
CorrectSpace: MemoryCorrectSpace,
Space: MemorySpace,
SetCorrectMeasure: MemorySetCorrectMeasure,
SetCorrectTolerance: MemorySetCorrectTolerance,
Correct: MemoryCorrect,
DontCorrect: MemoryDontCorrect,
SetGray: MemorySetGray,
SetSampledColor: MemorySetSampledColor,
SetSampledBlack: MemorySetSampledBlack,
MaskFill: MemoryMaskFill,
MaskRectangle: MemoryMaskRectangle,
MaskRectangleI: MemoryMaskRectangleI,
MaskStroke: MemoryMaskStroke,
MaskVector: MemoryMaskVector,
MaskPixel: MemoryMaskPixel,
MaskBits: MemoryMaskBits,
DrawBits: MemoryDrawBits,
Clip: MemoryClip,
ClipRectangle: MemoryClipRectangle,
ClipRectangleI: MemoryClipRectangleI,
GetCP: MemoryGetCP,
GetBoundingRectangle: MemoryGetBoundingRectangle
]];