ImagerNullImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Michael Plass, December 10, 1985 3:02:02 pm PST
DIRECTORY
Imager USING [ClassRep, Context, ContextRep, Error, PixelArray],
ImagerBackdoor USING [Clipper, IntKey, RealKey],
ImagerColorDefs USING [Color, ColorOperator, ConstantColor, ConstantColorImplRep, SampledColor],
ImagerColorOperatorPrivate USING [ColorOperatorImpl, ColorOperatorImplRep],
ImagerColorPrivate USING [ConstantColorImpl, ConstantColorImplRep],
ImagerFont USING [Font, XChar, XStringProc],
ImagerPath USING [ArcToProc, ConicToProc, CurveToProc, LineToProc, MoveToProc, PathProc],
ImagerPixelArray USING [PixelArray],
ImagerPrivate USING [Class, ClassRep],
ImagerTransformation USING [Rectangle, Scale, Transformation],
Rope USING [ROPE],
Vector2 USING [VEC];
ImagerNullImpl: CEDAR PROGRAM
IMPORTS Imager, ImagerTransformation
EXPORTS Imager, ImagerColorDefs
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
VEC: TYPE ~ Vector2.VEC;
Rectangle: TYPE ~ ImagerTransformation.Rectangle;
Transformation: TYPE ~ ImagerTransformation.Transformation;
PathProc: TYPE ~ ImagerPath.PathProc;
Color: TYPE ~ ImagerColorDefs.Color;
ConstantColor: TYPE ~ ImagerColorDefs.ConstantColor;
SampledColor: TYPE ~ ImagerColorDefs.SampledColor;
ConstantColorImpl: TYPE ~ ImagerColorPrivate.ConstantColorImpl;
ConstantColorImplRep: PUBLIC TYPE ~ ImagerColorPrivate.ConstantColorImplRep;
PixelArray: TYPE ~ ImagerPixelArray.PixelArray;
ColorOperator: TYPE ~ ImagerColorDefs.ColorOperator;
ColorOperatorImpl: TYPE ~ ImagerColorOperatorPrivate.ColorOperatorImpl;
ColorOperatorImplRep: PUBLIC TYPE ~ ImagerColorOperatorPrivate.ColorOperatorImplRep; -- export to ImagerColorDefs
Font: TYPE ~ ImagerFont.Font;
XChar: TYPE ~ ImagerFont.XChar;
XStringProc: TYPE ~ ImagerFont.XStringProc;
IntKey: TYPE ~ ImagerBackdoor.IntKey;
RealKey: TYPE ~ ImagerBackdoor.RealKey;
Clipper: TYPE ~ ImagerBackdoor.Clipper;
Context: TYPE ~ Imager.Context;
Class: TYPE ~ ImagerPrivate.Class;
ClassRep:
PUBLIC
TYPE ~ ImagerPrivate.ClassRep;
-- export to Imager
Data: TYPE ~ REF DataRep;
DataRep:
TYPE ~
RECORD [
doSave: INT ← 0,
nest: INT ← 0,
setInt: ARRAY IntKey OF INT ← ALL[0],
setReal: ARRAY RealKey OF INT ← ALL[0],
setFont: INT ← 0,
setColorGray: INT ← 0,
setColorRGB: INT ← 0,
setColorOther: INT ← 0,
setColorSampled: INT ← 0,
concatT: INT ← 0,
scale2T: INT ← 0,
rotateT: INT ← 0,
translateT: INT ← 0,
getT: INT ← 0,
move: INT ← 0,
setXY: INT ← 0,
setXYRel: INT ← 0,
show: INT ← 0,
showChars: INT ← 0,
showText: INT ← 0,
showBytes: INT ← 0,
startUnderline: INT ← 0,
maskUnderline: INT ← 0,
correctMask: INT ← 0,
correctSpace: INT ← 0,
space: INT ← 0,
setCorrectMeasure: INT ← 0,
setCorrectTolerance: INT ← 0,
correct: INT ← 0,
dontCorrect: INT ← 0,
setGray: INT ← 0,
setSampledColor: INT ← 0,
setSampledBlack: INT ← 0,
maskFill: INT ← 0,
maskFillPath: PathStats ← NIL,
maskRectangle: INT ← 0,
maskRectangleI: INT ← 0,
maskStroke: INT ← 0,
maskStrokePath: PathStats ← NIL,
maskStrokeClosed: INT ← 0,
maskStrokeClosedPath: PathStats ← NIL,
maskDashedStroke: INT ← 0,
maskDashedStrokePath: PathStats ← NIL,
maskVector: INT ← 0,
maskPixel: INT ← 0,
maskBits: INT ← 0,
clip: INT ← 0,
clipRectangle: INT ← 0,
clipRectangleI: INT ← 0
];
PathStats: TYPE ~ REF PathStatsRep;
PathStatsRep:
TYPE ~
RECORD [
move: INT ← 0,
line: INT ← 0,
curve: INT ← 0,
conic: INT ← 0,
arc: INT ← 0
];
CountPath:
PROC [path: PathProc, pathStats: PathStats] ~ {
MoveTo: ImagerPath.MoveToProc ~ {pathStats.move ← pathStats.move + 1};
LineTo: ImagerPath.LineToProc ~ {pathStats.line ← pathStats.line + 1};
CurveTo: ImagerPath.CurveToProc ~ {pathStats.curve ← pathStats.curve + 1};
ConicTo: ImagerPath.ConicToProc ~ {pathStats.conic ← pathStats.conic + 1};
ArcTo: ImagerPath.ArcToProc ~ {pathStats.arc ← pathStats.arc + 1};
path[MoveTo, LineTo, CurveTo, ConicTo, ArcTo];
};
Create:
PUBLIC
PROC
RETURNS [Context] ~ {
data: Data ← NEW[DataRep ← [maskFillPath: NEW[PathStatsRep], maskStrokePath: NEW[PathStatsRep], maskStrokeClosedPath: NEW[PathStatsRep], maskDashedStrokePath: NEW[PathStatsRep]]];
context: Context ← NEW[Imager.ContextRep ← [class: nullClass, data: data]];
RETURN [context]
};
break: BOOL ← FALSE;
NullDoSave:
PROC [context: Context, action:
PROC, all:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.doSave ← data.doSave + 1;
IF data.nest = 0 THEN break ← TRUE;
data.nest ← data.nest + 1;
action[];
data.nest ← data.nest - 1;
IF data.nest = 0 THEN break ← FALSE;
};
NullSetInt:
PROC [context: Context, key: IntKey, val:
INT] ~ {
data: Data ~ NARROW[context.data];
data.setInt[key] ← data.setInt[key] + 1;
};
NullSetReal:
PROC [context: Context, key: RealKey, val:
REAL] ~ {
data: Data ~ NARROW[context.data];
data.setReal[key] ← data.setReal[key] + 1;
};
NullSetFont:
PROC [context: Context, font: Font] ~ {
data: Data ~ NARROW[context.data];
data.setFont ← data.setFont + 1;
};
NullSetColor:
PROC [context: Context, color: Color] ~ {
data: Data ~ NARROW[context.data];
WITH color
SELECT
FROM
color: ConstantColor => {
impl: ConstantColorImpl ~ color.impl;
WITH impl: impl
SELECT
FROM
gray => {data.setColorGray ← data.setColorGray + 1};
rgb => {data.setColorRGB ← data.setColorRGB + 1};
ENDCASE => {data.setColorOther ← data.setColorOther + 1};
};
color: SampledColor => {
data.setColorSampled ← data.setColorSampled + 1;
};
ENDCASE => ERROR;
};
NullSetT:
PROC [context: Context, m: Transformation] ~ {
Imager.Error[[$unimplemented, "SetT not implemented"]];
};
NullSetClipper:
PROC [context: Context, clipper: Clipper] ~ {
Imager.Error[[$unimplemented, "SetClipper not implemented"]];
};
NullGetInt:
PROC [context: Context, key: IntKey]
RETURNS[
INT] ~ {
Imager.Error[[$unimplemented, "Not implemented"]];
};
NullGetReal:
PROC [context: Context, key: RealKey]
RETURNS[
REAL] ~ {
Imager.Error[[$unimplemented, "Not implemented"]];
};
NullGetT:
PROC [context: Context]
RETURNS[Transformation] ~ {
data: Data ~ NARROW[context.data];
m: Transformation ← ImagerTransformation.Scale[1.0];
data.getT ← data.getT + 1;
RETURN [m];
};
NullGetClipper:
PROC [context: Context]
RETURNS[Clipper] ~ {
Imager.Error[[$unimplemented, "Not implemented"]];
};
NullGetFont:
PROC [context: Context]
RETURNS[Font] ~ {
Imager.Error[[$unimplemented, "Not implemented"]];
};
NullGetColor:
PROC [context: Context]
RETURNS[Color] ~ {
Imager.Error[[$unimplemented, "Not implemented"]];
};
NullConcatT:
PROC [context: Context, m: Transformation] ~ {
data: Data ~ NARROW[context.data];
data.concatT ← data.concatT + 1;
};
NullScale2T:
PROC [context: Context, s:
VEC] ~ {
data: Data ~ NARROW[context.data];
data.scale2T ← data.scale2T + 1;
};
NullRotateT:
PROC [context: Context, a:
REAL] ~ {
data: Data ~ NARROW[context.data];
data.rotateT ← data.rotateT + 1;
};
NullTranslateT:
PROC [context: Context, t:
VEC] ~ {
data: Data ~ NARROW[context.data];
data.translateT ← data.translateT + 1;
};
NullMove:
PROC [context: Context, rounded:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.move ← data.move + 1;
};
NullSetXY:
PROC [context: Context, p:
VEC] ~ {
data: Data ~ NARROW[context.data];
data.setXY ← data.setXY + 1;
};
NullSetXYRel:
PROC [context: Context, v:
VEC] ~ {
data: Data ~ NARROW[context.data];
data.setXYRel ← data.setXYRel + 1;
};
NullShow:
PROC [context: Context, string: XStringProc, xrel:
BOOL] ~ {
data: Data ~ NARROW[context.data];
action: PROC [char: XChar] ~ {data.showChars ← data.showChars + 1};
data.show ← data.show + 1;
string[action];
};
NullShowText:
PROC [context: Context, text:
REF
READONLY
TEXT, start, len:
NAT, xrel:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.showBytes ← data.showBytes + text.length;
data.showText ← data.showText + 1;
};
NullStartUnderline:
PROC [context: Context] ~ {
data: Data ~ NARROW[context.data];
data.startUnderline ← data.startUnderline + 1;
};
NullMaskUnderline:
PROC [context: Context, dy, h:
REAL] ~ {
data: Data ~ NARROW[context.data];
data.maskUnderline ← data.maskUnderline + 1;
};
NullCorrectMask:
PROC [context: Context] ~ {
data: Data ~ NARROW[context.data];
data.correctMask ← data.correctMask + 1;
};
NullCorrectSpace:
PROC [context: Context, v:
VEC] ~ {
data: Data ~ NARROW[context.data];
data.correctSpace ← data.correctSpace + 1;
};
NullSpace:
PROC [context: Context, x:
REAL] ~ {
data: Data ~ NARROW[context.data];
data.space ← data.space + 1;
};
NullSetCorrectMeasure:
PROC [context: Context, v:
VEC] ~ {
data: Data ~ NARROW[context.data];
data.setCorrectMeasure ← data.setCorrectMeasure + 1;
};
NullSetCorrectTolerance:
PROC [context: Context, v:
VEC] ~ {
data: Data ~ NARROW[context.data];
data.setCorrectTolerance ← data.setCorrectTolerance + 1;
};
NullCorrect:
PROC [context: Context, action:
PROC] ~ {
data: Data ~ NARROW[context.data];
data.correct ← data.correct + 1;
action[];
};
NullDontCorrect:
PROC [context: Context, action:
PROC, saveCP:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.dontCorrect ← data.dontCorrect + 1;
action[];
};
NullSetGray:
PROC [context: Context, f:
REAL] ~ {
data: Data ~ NARROW[context.data];
data.setGray ← data.setGray + 1;
};
NullSetSampledColor:
PROC [context: Context,
pa: PixelArray, m: Transformation, colorOperator: ColorOperator] ~ {
data: Data ~ NARROW[context.data];
data.setSampledColor ← data.setSampledColor + 1;
};
NullSetSampledBlack:
PROC [context: Context,
pa: PixelArray, m: Transformation, clear:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.setSampledBlack ← data.setSampledBlack + 1;
};
NullMaskFill:
PROC [context: Context, path: PathProc, oddWrap:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.maskFill ← data.maskFill + 1;
CountPath[path, data.maskFillPath];
};
NullMaskRectangle:
PROC [context: Context, r: Rectangle] ~ {
data: Data ~ NARROW[context.data];
data.maskRectangle ← data.maskRectangle + 1;
};
NullMaskRectangleI:
PROC [context: Context, x, y, w, h:
INTEGER] ~ {
data: Data ~ NARROW[context.data];
data.maskRectangleI ← data.maskRectangleI + 1;
};
NullMaskStroke:
PROC [context: Context, path: PathProc, closed:
BOOL] ~ {
data: Data ~ NARROW[context.data];
IF closed
THEN {
CountPath[path, data.maskStrokeClosedPath];
data.maskStrokeClosed ← data.maskStrokeClosed + 1;
}
ELSE {
CountPath[path, data.maskStrokePath];
data.maskStroke ← data.maskStroke + 1;
};
};
NullMaskDashedStroke:
PROC [context: Context, path: PathProc, patternLen:
NAT, pattern:
PROC [
NAT]
RETURNS [
REAL], offset, length:
REAL] ~ {
data: Data ~ NARROW[context.data];
data.maskDashedStroke ← data.maskDashedStroke + 1;
CountPath[path, data.maskDashedStrokePath];
};
NullMaskVector:
PROC [context: Context, p1, p2:
VEC] ~ {
data: Data ~ NARROW[context.data];
data.maskVector ← data.maskVector + 1;
};
NullMaskPixel:
PROC [context: Context, pa: PixelArray] ~ {
data: Data ~ NARROW[context.data];
data.maskPixel ← data.maskPixel + 1;
};
NullMaskBits:
PROC [context: Context, base:
LONG
POINTER, wordsPerLine:
NAT,
sMin, fMin, sSize, fSize:
NAT, tx, ty:
INTEGER] ~
TRUSTED {
data: Data ~ NARROW[context.data];
data.maskBits ← data.maskBits + 1;
};
NullClip:
PROC [context: Context, path: PathProc, oddWrap:
BOOL, exclude:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.clip ← data.clip + 1;
};
NullClipRectangle:
PROC [context: Context, r: Rectangle, exclude:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.clipRectangle ← data.clipRectangle + 1;
};
NullClipRectangleI:
PROC [context: Context, x, y, w, h:
INTEGER, exclude:
BOOL] ~ {
data: Data ~ NARROW[context.data];
data.clipRectangleI ← data.clipRectangleI + 1;
};
NullGetCP:
PROC [context: Context, rounded:
BOOL]
RETURNS [
VEC] ~ {
Imager.Error[[$unimplemented, "GetCP not implemented"]];
};
NullGetBoundingRectangle:
PROC [context: Context]
RETURNS [Rectangle] ~ {
Imager.Error[[$unimplemented, "GetBoundingRectangle not implemented"]];
};
nullClass: Class ~
NEW[ClassRep ← [
type: $Interpress,
DoSave: NullDoSave,
SetInt: NullSetInt,
SetReal: NullSetReal,
SetT: NullSetT,
SetFont: NullSetFont,
SetColor: NullSetColor,
SetClipper: NullSetClipper,
GetInt: NullGetInt,
GetReal: NullGetReal,
GetT: NullGetT,
GetFont: NullGetFont,
GetColor: NullGetColor,
GetClipper: NullGetClipper,
ConcatT: NullConcatT,
Scale2T: NullScale2T,
RotateT: NullRotateT,
TranslateT: NullTranslateT,
Move: NullMove,
SetXY: NullSetXY,
SetXYRel: NullSetXYRel,
Show: NullShow,
ShowText: NullShowText,
StartUnderline: NullStartUnderline,
MaskUnderline: NullMaskUnderline,
CorrectMask: NullCorrectMask,
CorrectSpace: NullCorrectSpace,
Space: NullSpace,
SetCorrectMeasure: NullSetCorrectMeasure,
SetCorrectTolerance: NullSetCorrectTolerance,
Correct: NullCorrect,
DontCorrect: NullDontCorrect,
SetGray: NullSetGray,
SetSampledColor: NullSetSampledColor,
SetSampledBlack: NullSetSampledBlack,
MaskFill: NullMaskFill,
MaskRectangle: NullMaskRectangle,
MaskRectangleI: NullMaskRectangleI,
MaskStroke: NullMaskStroke,
MaskDashedStroke: NullMaskDashedStroke,
MaskVector: NullMaskVector,
MaskPixel: NullMaskPixel,
MaskBits: NullMaskBits,
Clip: NullClip,
ClipRectangle: NullClipRectangle,
ClipRectangleI: NullClipRectangleI,
GetCP: NullGetCP,
GetBoundingRectangle: NIL
]];
END.