DIRECTORY Basics USING [BYTE], IPVector USING [Vector], IO USING [STREAM], Rope USING [MaxLen, ROPE]; IPMaster: CEDAR DEFINITIONS ~ BEGIN BYTE: TYPE ~ Basics.BYTE; STREAM: TYPE ~ IO.STREAM; ROPE: TYPE ~ Rope.ROPE; Vector: TYPE ~ IPVector.Vector; MaxLen: INT ~ Rope.MaxLen; MaxTextLen: NAT ~ NAT.LAST; Version: TYPE ~ RECORD [major, minor: CARDINAL]; -- Interpress version number currentVersion: Version ~ [3, 0]; -- latest version supported by this interface Op: TYPE ~ { nil, get, makeveclu, makevec, shape, getprop, getp, mergeprop, fget, fset, makesimpleco, do, dosave, dosaveall, dosavesimplebody, findoperator, pop, copy, dup, roll, exch, mark, unmark, unmark0, count, nop, error, if, ifelse, ifcopy, eq, gt, ge, and, or, not, type, add, sub, neg, abs, floor, ceiling, trunc, round, mul, div, mod, rem, iget, iset, maket, translate, rotate, scale, scale2, concat, concatt, move, trans, setxy, setxyrel, setxrel, setyrel, getcp, makepixelarray, extractpixelarray, finddecompressor, makegray, findcolor, findcoloroperator, findcolormodeloperator, makesampledcolor, makesampledblack, setgray, setsampledcolor, setsampledblack, moveto, lineto, linetox, linetoy, curveto, conicto, arcto, makeoutline, makeoutlineodd, maskfill, maskfillparity, maskrectangle, startunderline, maskunderline, masktrapezoidx, masktrapezoidy, maskstroke, maskstrokeclosed, maskvector, maskdashedstroke, maskpixel, clipoutline, cliprectangle, maskchar, makefont, findfont, modifyfont, setfont, show, showandxrel, showandfixedxrel, correctmask, correctspace, space, setcorrectmeasure, setcorrecttolerance, correct, beginBody, endBody, beginBlock, endBlock, contentInstructions }; ImagerVariable: TYPE ~ MACHINE DEPENDENT { DCScpx(0), DCScpy(1), correctMX(2), correctMY(3), T(4), priorityImportant(5), mediumXSize(6), mediumYSize(7), fieldXMin(8), fieldYMin(9), fieldXMax(10), fieldYMax(11), font(12), color(13), noImage(14), strokeWidth(15), strokeEnd(16), underlineStart(17), amplifySpace(18), correctPass(19), correctShrink(20), correctTX(21), correctTY(22), strokeJoint(23), clipper(24) }; StrokeEnd: TYPE ~ MACHINE DEPENDENT {square(0), butt(1), round(2)}; StrokeJoint: TYPE ~ MACHINE DEPENDENT {miter(0), bevel(1), round(2)}; shortNumberBias: INTEGER ~ 4000; ShortNumber: TYPE ~ [0-shortNumberBias .. 77777B-shortNumberBias]; -- 15 bits EncodingValue: TYPE ~ MACHINE DEPENDENT { -- 13 bits nil(0), nop(1), setxy(10), setxyrel(11), setxrel(12), setyrel(13), linetox(14), linetoy(15), space(16), get(17), iget(18), iset(19), fget(20), fset(21), show(22), lineto(23), maskstroke(24), moveto(25), metricMaster(100), -- nonstandard environmentMaster(101), -- nonstandard beginBlock(102), endBlock(103), contentInstructions(105), beginBody(106), endBody(107), correct(110), disablecorrection(111), -- nonstandard makesimpleco(114), makeco(115), -- nonstandard findoperator(116), dosavesimplebody(120), dobody(121), -- nonstandard dosavebody(122), -- nonstandard dosaveallbody(123), -- nonstandard maskchar(140), showandfixedxrel(145), showandxrel(146), findfont(147), modifyfont(148), finddecompressor(149), makefont(150), setfont(151), setcorrectmeasure(154), setcorrecttolerance(155), correctmask(156), correctspace(157), getcp(159), maket(160), opent(161), -- nonstandard translate(162), rotate(163), scale(164), concat(165), scale2(166), invert(167), -- nonstandard concatt(168), move(169), trans(170), transform(174), -- nonstandard transformvec(175), -- nonstandard roundxy(176), -- nonstandard roundxyvec(177), -- nonstandard pop(180), dup(181), copy(183), roll(184), exch(185), mark(186), unmark(187), count(188), unmark0(192), abs(200), add(201), and(202), ceiling(203), div(204), eq(205), floor(206), ge(207), gt(208), mod(209), mul(210), neg(211), not(212), or(213), sub(214), trunc(215), rem(216), round(217), eqname(218), -- nonstandard type(220), atan(221), -- nonstandard cos(222), -- nonstandard exp(223), -- nonstandard log(224), -- nonstandard sin(225), -- nonstandard sqrt(226), -- nonstandard max(227), -- nonstandard min(228), -- nonstandard do(231), dosave(232), dosaveall(233), if(239), ifcopy(240), ifelse(241), loop(242), -- nonstandard frame(250), -- nonstandard env(260), -- nonstandard makeveclu(282), makevec(283), openvec(284), -- nonstandard shape(285), getp(286), getprop(287), mergeprop(288), dround(300), -- nonstandard getcprounded(301), -- nonstandard curveto(402), arcto(403), conicto(404), maskfillparity(408), -- nonstandard (for compatibility) maskfill(409), maskrectangle(410), masktrapezoidx(411), masktrapezoidy(412), startunderline(413), maskunderline(414), makeoutlineodd(416), makeoutline(417), clipoutline(418), cliprectangle(419), findcoloroperator(421), findcolormodeloperator(422), findcolor(423), setgray(424), makegray(425), makesampledblack(426), makesampledcolor(427), setsampledblack(428), setsampledcolor(429), excludeoutline(430), -- nonstandard excluderectangle(431), -- nonstandard maskstrokeclosed(440), maskvector(441), maskdashedstroke(442), makepixelarray(450), extractpixelarray(451), maskpixel(452), joinpixelarrays(453), -- nonstandard error(600), (17777B) }; ShortEncodingValue: TYPE ~ EncodingValue[VAL[0]..VAL[37B]]; -- 5 bits SequenceType: TYPE ~ MACHINE DEPENDENT { -- 5 bits nil(0), sequenceString(1), sequenceInteger(2), sequenceInsertMaster(3), sequenceRational(4), sequenceIdentifier(5), sequenceComment(6), sequenceContinued(7), sequenceLargeVector(8), sequencePackedPixelVector(9), sequenceCompressedPixelVector(10), sequenceInsertFile(11), sequenceAdaptivePixelVector(12), sequenceCCITT4PixelVector(13), (37B) }; ShortSequenceLength: TYPE ~ INT[0..377B]; -- 8 bits LongSequenceLength: TYPE ~ INT--[0..77777777B]--; -- 24 bits ErrorDesc: TYPE ~ RECORD[code: ATOM, explanation: ROPE, index: INT _ 0]; Error: ERROR[error: ErrorDesc]; EncodingValueFromOp: PROC [Op] RETURNS [EncodingValue]; OpFromEncodingValue: PROC [EncodingValue] RETURNS [Op]; OpFromRope: PROC [ROPE] RETURNS [Op]; RopeFromOp: PROC [Op] RETURNS [ROPE]; RopeFromImagerVariable: PROC [ImagerVariable] RETURNS [ROPE]; PartActionType: TYPE ~ PROC [base: ROPE, start, len: INT] RETURNS [quit: BOOL _ FALSE]; MapParts: PROC [base: ROPE, start: INT _ 0, len: INT _ MaxLen, delimiter: CHAR, action: PartActionType] RETURNS [BOOL]; ValidateIdentifier: PROC [rope: ROPE, start: INT _ 0, len: INT _ MaxLen]; ValidateName: PROC [rope: ROPE, start: INT _ 0, len: INT _ MaxLen]; ValidateString: PROC [rope: ROPE, start: INT _ 0, len: INT _ MaxLen]; ValidateVersion: PROC [rope: ROPE, start: INT _ 0, len: INT _ MaxLen]; VersionFromRope: PROC [rope: ROPE, start: INT _ 0, len: INT _ MaxLen] RETURNS [Version]; PutShortNumber: PROC [stream: STREAM, n: ShortNumber]; PutShortOp: PROC [stream: STREAM, op: ShortEncodingValue]; PutLongOp: PROC [stream: STREAM, op: EncodingValue]; PutShortSequence: PROC [stream: STREAM, seq: SequenceType, len: ShortSequenceLength]; PutLongSequence: PROC [stream: STREAM, seq: SequenceType, len: LongSequenceLength]; ByteCount: TYPE ~ NAT[0..4]; BytesInInt: PROC [val: INT] RETURNS [ByteCount]; PutIntBytes: PROC [stream: STREAM, val: INT, len: ByteCount]; PutByte: PROC [stream: STREAM, byte: BYTE]; PutOp: PROC [stream: STREAM, op: Op]; PutInt: PROC [stream: STREAM, n: INT]; PutRational: PROC [stream: STREAM, n, d: INT]; PutReal: PROC [stream: STREAM, val: REAL]; PutIdentifier: PROC [stream: STREAM, rope: ROPE, start: INT _ 0, len: INT _ MaxLen]; PutString: PROC [stream: STREAM, rope: ROPE, start: INT _ 0, len: INT _ MaxLen]; PutName: PROC [stream: STREAM, rope: ROPE, start: INT _ 0, len: INT _ MaxLen]; PutSequence: PROC [stream: STREAM, seq: SequenceType, len: INT]; PutSequenceRope: PROC [stream: STREAM, seq: SequenceType, rope: ROPE, start: INT _ 0, len: INT _ MaxLen]; PutSequenceText: PROC [stream: STREAM, seq: SequenceType, text: REF READONLY TEXT, start: NAT _ 0, len: NAT _ MaxTextLen]; TokenType: TYPE ~ {nil, num, op, seq}; Token: TYPE ~ RECORD [ type: TokenType _ nil, -- token type num: INTEGER _ 0, -- number value, if type=num (0 otherwise) op: EncodingValue _ nil, -- op value, if type=op (nil otherwise) seq: SequenceType _ nil, -- sequence type, if type=seq (nil otherwise) len: INT _ 0 -- sequence data length, if type=seq (0 otherwise) ]; Body: TYPE ~ ROPE; Node: TYPE ~ REF NodeRep; NodeRep: TYPE ~ RECORD[ contentInstructions: Instructions _ NIL, content: SELECT tag: * FROM body => [body: Body], block => [block: Block], ENDCASE]; Instructions: TYPE = REF InstructionsRecord; InstructionsRecord: TYPE = RECORD [ source: Body _ NIL, instructions: Vector _ NIL, frame, environment: Vector _ NIL]; Preamble: TYPE = REF PreambleRecord; PreambleRecord: TYPE = RECORD [ source: Body _ NIL, initialFrame, environment: Vector _ NIL]; Block: TYPE ~ REF BlockRep; BlockRep: TYPE ~ RECORD[ startingPlateNumber, totalPlates: NAT _ 0, -- 0 origin for startingPlateNumber preamble: Preamble _ NIL, nodes: SEQUENCE size: NAT OF Node]; Skeleton: TYPE = REF SkeletonRecord; SkeletonRecord: TYPE = RECORD [ instructions: Instructions _ NIL, topBlock: Block _ NIL, z: UNCOUNTED ZONE _ NIL]; -- For use in the NS world where all storage for this Skeleton will come from. GetSkeleton: PROC [master: ROPE, start: INT] RETURNS [SkeletonRecord]; GetToken: PROC [encoding: ROPE, start: INT] RETURNS [token: Token, next: INT]; GetSequenceRope: PROC [encoding: ROPE, start, len: INT] RETURNS [rope: ROPE, next: INT]; SkipBytes: PROC [encoding: ROPE, start, len: INT] RETURNS [next: INT] = INLINE {next _ start+len}; SkipToEndOfBody: PROC [encoding: ROPE, start: INT] RETURNS [next: INT]; CopyBytes: PROC [to: STREAM, from: STREAM, count: INT] RETURNS [copied: INT]; CopySegment: PROC [to: STREAM, from: STREAM, start, length: INT]; IntFromSequenceData: PROC [text: REF READONLY TEXT, start: NAT _ 0, len: NAT _ MaxTextLen] RETURNS [INT]; RealFromSequenceData: PROC [text: REF READONLY TEXT, start: NAT _ 0, len: NAT _ MaxTextLen] RETURNS [REAL]; END. rIPMaster.mesa Copyright c 1984, 1985, 1986 by Xerox Corporation. All rights reserved. Doug Wyatt, May 30, 1986 2:44:21 pm PDT Allan H. Wax December 5, 1986 8:47:29 am PST Allan Wax: January 21, 1987 10:42:34 am PST Operations for reading and writing Interpress masters at the token level. Basic types BASE primitives IMAGE primitives Symbols Xerox Encoding Errors, Utilities Converts an Op to a Xerox encoding value. Converts a Xerox encoding value to an Op. Returns nil if undefined. Converts a ROPE to an Op. Ignores case. Returns nil if undefined. Converts an Op to a ROPE. Returns NIL if given nil. Converts an ImagerVariable to a ROPE. Applies action to each part of a subrope; delimiter separates parts. Returns TRUE when some action returns TRUE. For example, delimiter='/ parses a structured name, delimiter='. parses a version number. Verifies that the specified subrope is a valid Identifier. See the Interpress Standard, section 2.2.2. ! $invalidIdentifier if the identifier is empty or contains an illegal character. Verifies that the specified subrope is a valid structured name. See the Interpress Standard, section 3.2.1. ! $invalidIdentifier if the name contains an invalid identifier. ! $invalidName if the name is empty. Verifies that the specified subrope is a valid Xerox string. See the Character Code Standard, chapter 6, and the Interpress Standard, section 2.5.3. ! $invalidString if the string contains an invalid code or ends within an escape sequence. Verifies that the specified subrope is a valid Interpress version number. ! $invalidVersion if the version number is malformed. Parses a Version number of the form "m.n". Writing a master Appends a ShortNumber token (2 bytes). Appends a ShortOp token (1 byte). Appends a LongOp token (2 bytes). Appends a ShortSequence token (2 bytes). Appends a LongSequence token (4 bytes). Returns the minimum number of bytes needed to represent val in two's complement. Appends the low order len bytes of val. Appends a single byte. Appends a primitive operator or symbol literal; chooses the shortest encoding. Appends an integer Number literal; chooses the shortest encoding. Appends a rational Number literal, n/d. ! $invalidRational if d is zero. Appends a Number literal. Chooses a rational approximation if necessary. Appends an Identifier literal. See the Interpress Standard, section 2.2.2. ! $invalidIdentifier if the identifier is malformed. Appends the encoding notation for a string. Treats '\377 as an escape code. ! $invalidString if the string is malformed. Parses a structured name and appends tokens to build a Vector of Identifiers. For example, "a/b/c" produces < a b c 3 MAKEVEC >; "id" produces < id 1 MAKEVEC >. See the Interpress Standard, section 3.2.1. ! $invalidName or $invalidIdentifier if the name is malformed. Appends a sequence descriptor; chooses the shortest encoding. Must be followed immediately by len data bytes. Appends a sequence with data obtained from Rope.Map[rope, start, len]. Appends a sequence with data obtained from RefText.Map[text, start, len]. Reading a master Parses the skeleton structure of the master, starting at "start". ! $invalidSkeleton, $malformedInsertFile/Master if the skeleton is malformed. ! various $unavailable otehr messages if inserted files cannot be found/opened. Reads from the encoding a token in the Xerox encoding. See Interpress, section 2.5.1. If token.type=seq, caller must read token.len data bytes from the rope to reach the next token. Skips len bytes in the rope; equivalent to next _ start+len. Skips to the end of the enclosing body. Returns the position of the token following the body. Copies bytes to an output stream from an input stream. Returns the actual number of bytes copied. Does SetIndex[from, start], then copies length bytes. ! IO.EndOfStream[from] if too few bytes were copied. These interpret text[start..start+len) as a two's complement binary integer. Κ0˜codešœ ™ Kšœ Οmœ=™HKšœ$Οk™'Kšœ,™,K™+—K™K™IK™šž ˜ Kšœžœžœ˜Kšœ žœ ˜Kšžœžœžœ˜Kšœžœ žœ˜—K˜KšΡblnœžœž ˜šœž˜K˜Kšžœžœ žœ˜Kšžœžœžœžœ˜Kšžœžœžœ˜Kšœžœ˜KšΟnœžœ˜Kš  œžœžœžœ˜—head™ Kšœ žœžœžœΟc˜MKšœ"‘-˜OK˜šœžœ˜ Kšœ˜KšΡbksœ ™KšœF˜FKšœE˜EKšœF˜FKšœ4˜4KšœF˜FKš’œ ™Kšœ=˜=Kšœ@˜@Kšœ5˜5Kšœ@˜@KšœO˜OKšœ;˜;KšœF˜FKšœ?˜?KšœG˜GKšœ˜Kšœ3˜3Kšœ%˜%KšœS˜SKšœ™Kšœ=˜=Kšœ˜K˜—šœžœžœž œ˜*Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜K˜—šœ žœžœž œ ˜CK˜—šœ žœžœž œ ˜EK˜——™šœžœ˜ J˜—šœ žœ2‘ ˜MJ˜—šœžœžœž œ‘ ˜4J˜Jšœ˜J˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ ˜ J˜Jšœ‘˜!Jšœ‘˜&Jšœ˜Jšœ˜J˜Jšœ˜Jšœ˜Jšœ ˜ J˜Jšœ ˜ Jšœ‘˜&J˜Jšœ˜Jšœ ‘˜Jšœ˜J˜Jšœ˜Jšœ ‘˜Jšœ‘˜Jšœ‘˜"J˜Jšœ˜J˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ ˜ J˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜J˜Jšœ ˜ Jšœ ˜ Jšœ ‘˜Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ‘˜Jšœ ˜ Jšœ ˜ Jšœ ˜ J˜Jšœ‘˜Jšœ‘˜!Jšœ‘˜Jšœ‘˜J˜Jšœ ˜ Jšœ ˜ J˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ J˜Jšœ ˜ J˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ ˜ Jšœ˜Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ‘˜J˜Jšœ ˜ Jšœ ‘˜Jšœ ‘˜Jšœ ‘˜Jšœ ‘˜Jšœ ‘˜Jšœ ‘˜Jšœ ‘˜Jšœ ‘˜J˜Jšœ˜Jšœ ˜ Jšœ˜J˜Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ ‘˜J˜Jšœ ‘˜J˜Jšœ ‘˜J˜Jšœ˜Jšœ ˜ Jšœ‘˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ˜J˜Jšœ ‘˜Jšœ‘˜!J˜Jšœ ˜ Jšœ ˜ Jšœ ˜ J˜Jšœ‘"˜7Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜J˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜J˜Jšœ˜Jšœ˜Jšœ˜Jšœ ˜ Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ‘˜#Jšœ‘˜%J˜Jšœ˜Jšœ˜Jšœ˜J˜Jšœ˜Jšœ˜Jšœ˜Jšœ‘˜$J˜Jšœ ˜ J˜J˜J˜J˜—šœžœžœžœ‘ ˜EJ˜—šœžœžœž œ‘ ˜2J˜J˜J˜Jšœ˜J˜J˜J˜J˜J˜J˜J˜"J˜Jšœ ˜ Jšœ˜J˜J˜J˜J˜—šœžœžœ ‘ ˜3J˜—šœžœž‘œ‘ ˜K˜—š  œžœ žœžœ˜@K™=K™/K™—š  œžœ žœžœ žœ žœ ˜jK™FK™—š œžœ žœžœžœžœ žœ žœ˜{K™IK™——™Kšœ žœ˜&šœžœžœ˜Kšœ‘ ˜$Kšœžœ‘*˜