DIRECTORY Basics, Rope, Xl, XlEndianPrivate; XlPrivate: CEDAR DEFINITIONS SHARES Xl ~ BEGIN OPEN Xl, XlEndianPrivate; BadImplError: PROC [c: Connection]; PaddingBytes: PROC [n: INT] RETURNS [INT]; DoWithLocks: PROC [c: Connection, action: PROC [c: Connection], details: Xl.Details]; RequestHeader: TYPE = MACHINE DEPENDENT RECORD [ opCode: BYTE, minor: BYTE, length: CARD16 --in 32 bit word units ]; AssertBuffer: PROC [c: Connection, bytes: CARD] = INLINE { IF (c.bufLimit-c.bufNext)> PROC [c: Connection, drawable: Drawable, gc: GContext, partialDetails: Details] RETURNS [id: ID]; InternalRoundTrip: PROC [c: Connection]; Reply: TYPE = REF ReplyRec; ReplyRec: TYPE = MACHINE DEPENDENT RECORD [ cheat: PACKED ARRAY [0..0) OF BYTE, fix: PACKED ARRAY [0..32) OF BYTE ¬ ALL[0], varPart: REF Basics.RawBytes ¬ NIL, varLength: CARD ¬ 0, --length of allocated varPart (maybe longer then necessary) next: INT ¬ 0 --position for reading next field ]; RopeFromRaw: UNSAFE PROC [p: LONG POINTER TO Basics.RawBytes, start: CARD, len: INT] RETURNS [Rope.ROPE]; FinishWithReply: --INTERNAL-- PROC [c: Connection] RETURNS [reply: Reply]; FinishWithMultipleReplies: --INTERNAL-- PROC [c: Connection, callback: ReplyGotProc, data: REF ¬ NIL]; ReplyGotProc: TYPE = PROC [c: Connection, reply: Reply, data: REF] RETURNS [more: BOOL ¬ FALSE]; FinishWithDetails: --INTERNAL-- PROC [c: Connection, details: Details ¬ NIL]; FinishWithDetailsNoErrors: --INTERNAL-- PROC [c: Connection, details: Details ¬ NIL] RETURNS [errors: REF Xl.EventRep.errorNotify ¬ NIL]; FinishWithPartialDetailsNoErrors: --INTERNAL-- PROC [c: Connection, details: Details] RETURNS [errors: REF Xl.EventRep.errorNotify ¬ NIL]; DisposeReply: PROC [c: Connection, r: Reply]; CheckReply: PROC [r: Reply]; SetPos: PROC [r: Reply, startByte: INT ¬ 0] = INLINE {r.next ¬ startByte}; Skip: PROC [r: Reply, bytes: INT ¬ 1] = INLINE {r.next ¬ r.next+bytes}; Read8: PROC [r: Reply] RETURNS [b: BYTE] = TRUSTED INLINE { b ¬ r.cheat[r.next]; r.next ¬ r.next+1; }; Read16: PROC [r: Reply] RETURNS [c: CARD16] = TRUSTED INLINE { c ¬ r.cheat[r.next+highOff]*256+r.cheat[r.next+lowOff]; r.next ¬ r.next+2; }; Read32: PROC [r: Reply] RETURNS [CARD32] = TRUSTED INLINE { four: FourBytes = [ hh: r.cheat[r.next+hhOff], hl: r.cheat[r.next+hlOff], lh: r.cheat[r.next+lHOff], ll: r.cheat[r.next+llOff] ]; r.next ¬ r.next+4; RETURN [LOOPHOLE[four]]; }; Get8: PROC [r: Reply, pos: INT] RETURNS [BYTE] = TRUSTED INLINE { RETURN [r.cheat[pos]] --avoid the bounds check... }; Get16: PROC [r: Reply, pos: INT] RETURNS [CARD16] = TRUSTED INLINE { RETURN [ r.cheat[pos+highOff]*256+r.cheat[pos+lowOff] ]; }; Get32: PROC [r: Reply, pos: INT] RETURNS [CARD32] = TRUSTED INLINE { RETURN [LOOPHOLE[ FourBytes[ hh: r.cheat[pos+hhOff], hl: r.cheat[pos+hlOff], lh: r.cheat[pos+lHOff], ll: r.cheat[pos+llOff] ]]]; }; ERead8: PROC [r: Reply] RETURNS [BYTE]; ERead16: PROC [r: Reply] RETURNS [CARD16]; ERead32: PROC [r: Reply] RETURNS [CARD32]; EReadRope: PROC [r: Reply] RETURNS [ROPE]; debugX: BOOL = FALSE; --used for conditional compiling debug stuff END. PXlPrivate.mesa Copyright Σ 1988, 1990, 1991, 1992, 1993 by Xerox Corporation. All rights reserved. Christian Jacobi, April 13, 1988 12:24:42 pm PDT Christian Jacobi, September 14, 1993 4:23 pm PDT Private interface to split implementation of Xl and to make extensions for it. All features are private against Xl clients. Features explicitely called PRIVATE are private for the base implementation of Xl and should probably not be used by implementors of extensions of Xl. This module is DANGEROUS in the following sense: Its ""internal"" procedures might wait with object monitors; If the caller wasn't monitored using the same object monitors this would probably produce chaos. Handy For certain self-checks; wedges connection. Computes padding necesary to get multiple of 4. Executes action within monitor locks and all required UNWIND's. Buffer allocation and flushing [all INTERNAL] --Guarantees bytes free space in buffer; callable at beginning of request only --Might cause a flush of completed requests to make space --Does NOT raise errors (errors are accumulated hiddenly) --Buffer is allocated even in error case for memory safety reason --Guarantees bytes free space in buffer; callable with partial request but aligned buffer only. --Might cause a flush of completed and un-completed requests to make space --Does NOT raise errors (errors are accumulated hiddenly) --Guarantees buffer "empty" ()c.bufReady=0 by flushing all completed requests into real communication buffer --Does NOT raise errors (errors are accumulated hiddenly) --Warning: Flush on real wire only with non-empty buffer contents --Like SoftFlushBuffer but also flushes the communication buffer --Does NOT raise errors (errors are accumulated hiddenly) Buffer output operations [all INTERNAL] All buffer operations are aligned properly or crash... --length: length of request in 32 bit words. Asserts full buffer size. --length: length of request in 32 bit words. Asserts assertBytes bytes in buffer. --assertBytes may be more, or, less. --Short ropes only --NOT padded --Short ropes only --Returns pointer to next blockBytes bytes. Buffer must be aligned. --No tests; The blockBytes are NOT asserted --Optional tests whether previous command is finished properly and asserts a block of "blockBytes" bytes in buffer, and, establishes self check for next command. opCode is NOT assigned but used for checking. Assuming len bytes written, adds padding to next multiple of 4 --... (used by extensions) Direct output Procedures; [all INTERNAL] Flushes buffer and makes it ready for continueing as direct request Flushes buffer and starts a direct request Assuming len bytes written, puts padding to next multiple of 4 Utilities, unmonitored scanning events procedures mapping from X name space to Cedar types procedures mapping from Cedar types to C type Utilities, [INTERNAL] Does not raise immediate errors but returns a zero id on failure Always returns id, such that a NIL gc might fail command but won't wedge connection. Reply stuff --Avoid bounds checking hack for fix --Use this since LOOPHOLE to [0..32) has size ambiguity on PrincOps --Replies are requested by exactly one client process; this is the only process allowed to fool with next Waits for reply with current sequence number Also initializes "next" field of reply to 1 Asumes all bytes already written but monitor lock never released since starting request. I found a single request which returns multiple replies. Waits for replies with current sequence number. callback is called within monitor locks and must be well behaved. Called to return a reply; must return whether more replies are following. Does not automatically dispose reply. Finishes up request. Asumes monitor lock never released since starting request. Very essential because stuff catching event needs to be prepared before event can arrive. Like FinishWithDetails but does not raise any errors directly. In case of errors returns an event. Like FinishWithDetailsNoErrors but uses only errorMatch and synchronous of details. This is useful to implement multi-request commands. Allows reusing of reply without memory allocation. Disaster if r still used afterwards. May be used inside and outside monitors. Checks whether r really is an X reply and not an error Raises the XError if not Also does SetPos[1] Set position for next reply reading Skip bytes for next read operation on reply "Reads" next byte [from fixed part only] "Reads" next two bytes [from fixed part only] "Reads" next four bytes [from fixed part only] "Reads" byte at fixed position [from fixed part only] "Reads" two bytes at fixed position [from fixed part only] "Reads" four bytes at fixed position [from fixed part only] The following routines can "read" stuff from either fix or varpart but may crash if used on positions not used by the X protocol And removes trailing null chars Debugging Κ •NewlineDelimiter –(cedarcode) style˜codešœ™Kšœ ΟeœI™TKšœ-Οk™0K™1K™—šž œ#˜,K˜—šΟn œžœž ˜Kšžœ˜ —Kšœžœžœ˜!K™K™OK™™ΖK™—šœ1™1Kšœ™—headšœ™K˜šŸ œžœ˜#K™+—K˜š Ÿ œžœžœžœžœ˜*J™/—K™šŸ œžœžœ'˜UK™?K™—š œžœžœž œžœ˜0Kšœžœ˜ Kšœžœ˜ KšœžœΟc˜%K˜——šœ-™-K˜šŸ œžœžœžœ˜:Jšœ)Οb%œ™OJšœ:™:Jšœ‘œ0™:JšœB™BKšžœžœ˜?K˜KšŸœžœžœžœ˜<—K˜šŸœžœžœžœ˜>JšœK‘œ™`Jšœ#‘œ™KJšœ‘œ0™:Kšžœžœ˜CK˜KšŸœžœžœžœ˜@K˜—š ŸŸ œžœžœžœžœ˜EJ™oJšœ‘œ0™:JšœA™AKšžœžœ˜.K˜—š Ÿœžœžœžœžœ˜EJ™AJšœ‘œ0™:Kšžœžœžœ˜@K˜Kš Ÿœžœžœžœžœ˜CK˜——šœ'™'K˜KšŸ6™6K˜Kšœ žœžœžœžœž œžœžœ˜>Kšœ žœžœžœžœž œžœžœ˜>K˜š Ÿœžœžœžœžœ˜8Kšœžœ ˜Kšœ˜Kšœ˜K˜K˜—š Ÿœžœžœžœžœ˜;Kšœžœ ˜Kšœ žœ˜Kšœ ˜ Kšœ˜K˜K˜—š Ÿœžœžœžœžœ˜;Kšœ žœ˜Kšœžœ ˜Kšœ ˜ Kšœ˜K˜—K˜š Ÿœžœžœ žœžœ˜HKšœG™GK™—š Ÿ œžœžœ žœžœžœ˜fKšœR™RKšœ$™$K™—KšŸœžœžœ˜%KšŸœžœžœ˜(KšŸœžœžœ˜(Kš Ÿœžœžœžœžœ˜UK˜KšŸœžœžœ˜'KšŸœžœžœ˜(KšŸ œžœžœ˜*KšŸ œžœžœ˜.KšŸ œžœ˜0KšŸ œžœ˜*KšŸœžœ˜(KšŸœžœ$˜2KšŸ œžœ˜,KšŸ œžœ˜0KšŸœžœ˜-KšŸ œžœ˜,KšŸ œžœ!˜1K˜KšŸœžœ ˜4K˜šŸœžœžœ žœ žœžœžœ˜WKšœ™K™—šŸœžœžœ žœ žœžœžœ˜QKšœ ™ Kšœ™K™—š Ÿœžœžœžœžœžœ˜RJšœD™DJšœ,™,J™—šŸœžœžœžœžœžœžœžœ˜zJ™ΠJ™—šŸœžœžœžœ˜2Kšœ?™?Kšœ˜K˜K˜—šŸœžœ7žœœ˜PJ™——™(šŸœžœ˜,KšœE™EK™—š Ÿœžœžœ žœžœ˜XKšœ*™*—K˜KšŸœžœžœ˜+KšŸ œžœžœ˜.Kš Ÿ œžœžœžœžœ˜PKšŸ œžœžœ˜.KšŸ œžœ˜,KšŸœžœ!žœ˜KKšŸœžœžœ žœ žœžœžœ˜WšŸœžœžœ˜(Kšœ?™?——™L™KšŸ œžœžœžœ žœžœžœ˜EKšŸ œžœžœžœ žœžœžœ˜EK˜L™3š Ÿœžœžœžœžœ˜EKšžœ ˜Kšœ˜—K˜š Ÿœžœžœžœžœ˜EKšžœ ˜Kšœ˜K˜—š Ÿœžœžœžœžœ˜EKšžœ˜ Kšœ˜—K™L™-š Ÿœžœžœžœžœžœ˜1Kšžœžœ˜K˜——šœ ž ™K˜š Ÿ œ  œžœLžœžœ˜{Kš @™@Kš T™T—K™šŸœžœ˜(K˜—K™—šœ ™ Kšœžœžœ  ˜š œ žœžœž œžœ˜+š œžœžœžœžœ˜%Jšœ$™$JšœC™C—Kš œžœžœ žœžœžœ˜-Kšœ žœžœ˜#Kšœ žœ ;˜PKšœžœ !˜/K˜Jšœi™iK˜—KšŸ œžœžœž œžœžœžœžœžœ˜iK˜š Ÿœ Πci œžœžœ˜JJšœ,™,Jšœ  œ  œ ™+JšœX™XJ™š Ÿœ ’ œžœ/žœžœ˜fK™8Kšœ/™/Kšœ‘œ*™Cš œžœžœ%žœžœžœžœ˜`K™IKšœ%™%—K™——š Ÿœ ’ œžœ$žœ˜MJšœ™Jšœ•™•J™—šŸœ ’ œžœ$žœžœ žœžœ˜‰Jšœc™cJ™—šŸ œ ’ œžœ#žœ žœžœ˜ŠJšœS™SJ™3J™—šŸ œžœ˜-Jšœ2™2J™$J™(—K˜šŸ œžœ ˜Jšœ6™6J™Jšœ Ÿœ™K˜—šŸœžœžœžœ˜JJ™#—K˜šŸœžœžœžœ˜GJ™+—J™K˜š Ÿœžœ žœžœžœ˜;J™(Kšœ'˜'K˜K˜—š Ÿœžœ žœžœžœ˜>J™-Kšœ7˜7Kšœ˜Kšœ˜K˜—š Ÿœžœ žœžœžœ˜;Jšœ.™.šœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜—Kšœ˜Kšžœžœ˜K˜—J™šŸœžœžœžœžœžœžœ˜AJšœ5™5Kšžœ ˜1K˜—K˜š Ÿœžœžœžœžœžœ˜DJšœ:™:Kšžœ2˜8K˜—K˜š Ÿœžœžœžœžœžœ˜DJšœ;™;šžœžœ ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜—K˜—J™Jšœ€™€K˜KšŸœžœ žœžœ˜'KšŸœžœ žœžœ˜*KšŸœžœ žœžœ˜*šŸ œžœ žœžœ˜*Jšœ™——K˜™ Kšœžœžœ -˜C—K˜Kšžœ˜K˜K˜—…—;