DIRECTORY Basics USING [UnsafeBlock], IO USING [STREAM], Rope USING [ROPE]; RopeFile: CEDAR DEFINITIONS = BEGIN OPEN Rope; ByteSequenceObject: TYPE ~ REF ByteSequenceObjectRep; ByteSequenceObjectRep: TYPE ~ MONITORED RECORD [ length: [0..LAST[INT]], data: REF ANY, equal: PROC [self: ByteSequenceObject, other: ByteSequenceObject] RETURNS [BOOL], deactivate: PROC [self: ByteSequenceObject, final: BOOL] RETURNS [DeactivateResult], describe: PROC [self: ByteSequenceObject] RETURNS [fileName: ROPE, created: ROPE, open: BOOL], move: UNSAFE PROC [self: ByteSequenceObject, block: Basics.UnsafeBlock, start: INT] RETURNS [charsMoved: INT ¬ 0] ]; DeactivateResult: TYPE ~ { ok, cant, alreadyInactive }; CreateByteSequenceObject: PROC [ length: [0..LAST[INT]], data: REF ANY, equal: PROC [self: ByteSequenceObject, other: ByteSequenceObject] RETURNS [BOOL], deactivate: PROC [self: ByteSequenceObject, final: BOOL] RETURNS [DeactivateResult], describe: PROC [self: ByteSequenceObject] RETURNS [fileName: ROPE, created: ROPE, open: BOOL], move: UNSAFE PROC [self: ByteSequenceObject, block: Basics.UnsafeBlock, start: INT] RETURNS [charsMoved: INT ¬ 0]] RETURNS [ByteSequenceObject]; Error: ERROR [ec: ATOM, explanation: ROPE]; FromByteSequenceObject: PROC [byteSequenceObject: ByteSequenceObject, flatten: BOOL ¬ FALSE] RETURNS [ROPE]; FromStream: PROC [stream: IO.STREAM, start: INT ¬ 0, len: INT ¬ LAST[INT], flatten: BOOL ¬ FALSE] RETURNS [rope: ROPE]; ByteSequenceObjectFromStream: PROC [stream: IO.STREAM] RETURNS [ByteSequenceObject]; Deactivate: PROC [rope: ROPE]; LimitActive: PROC [activeLimit: INT]; END. Create: PROC [name: ROPE, start: INT ¬ 0, len: INT ¬ LAST[INT], bufSize: INT ¬ 512, buffers: NAT ¬ 4, raw: BOOL ¬ TRUE] RETURNS [rope: ROPE]; SubstrCreate: PROC [name: ROPE, start: INT ¬ 0, len: INT ¬ LAST[INT]] RETURNS [rope: ROPE]; SimpleCreate: PROC [name: ROPE] RETURNS [rope: ROPE]; ^ RopeFile.mesa Copyright Σ 1985, 1986, 1991, 1992 by Xerox Corporation. All rights reserved. Russ Atkinson, February 5, 1985 2:15:26 pm PST Carl Hauser, July 12, 1988 8:35:12 pm PDT Michael Plass, October 15, 1991 5:20 pm PDT The ByteSequenceObject implements the abstraction of an immutable, ordered sequence of bytes. It differs from a ROPE in several ways. First, there is an explicit request to "deactivate" it, which may involve closing a file or otherwise giving up resources; it should be willing to come out of an inactive state when necessary unless final~TRUE. Second, its performance characteristics differ - it is not expected to service small requests particularly fast. Finally, there are provisions for providing status information. The implementor of a ByteSequenceObject is responsible for synchronization. Only called when self.equal and other.equal are the same procedure describe is useful for status display, not needed for correct operation Raised when an illegal condition is detected, such as $BadStream, use of a stream that does not support IO.GetLength, IO.GetIndex, IO.SetIndex $Closed, use of a closed stream, either in FromStream or a Rope operation $MultipleUse, use of a stream for more than one rope Creates a new rope based on the open stream for characters. If flatten, then the stream contents are copied into a rope and the stream is closed. Otherwise, the open stream is retained as a source of the rope contents. The start parameter is used as an index into the stream using IO.SetIndex[...]. If the length is less than the remaining number of characters in the stream, then the lesser of the length and the remainder is used as a length. If the resulting length is less than some implementation-determined length, the result is as if flatten = TRUE. Asserts that the client does not expect to be touching the rope (or its constituent parts) in the near future; however, the rope remains valid. Closes files until the activeLimit is satisfied; will reopen on demand, so ropes don't become invalid unless the source file goes away. Russ Atkinson (RRA) January 29, 1985 6:31:15 pm PST Removed AppendChars (use Rope.AppendChars instead) Michael Plass, October 14, 1991 Cedar10.0 port. Removed file-system assumptions; merged with RopeTrick. See PFS.RopeOpen. Added: ByteSequenceObject, Error, FromByteSequenceObject, Deactivate, Removed: Κ”–(cedarcode) style•NewlineDelimiter ™codešœ ™ Kšœ ΟeœC™NKšœ.™.K™)K™+—K˜šΟk ˜ Kšœžœ˜Kšžœžœžœ˜Kšœžœžœ˜K˜—Kš Οnœžœž œžœžœ˜.˜Kšœžœžœ˜5šœžœž œžœ˜0KšœΪ™ΪKšœ žœžœ˜Kšœžœžœ˜šœžœ7žœžœ˜QKšœB™B—Kšœ žœ#žœžœ˜Tš œ žœžœ žœ žœžœ˜^KšœG™G—Kš œžœžœ>žœžœžœ˜qKšœ˜K˜—šœžœ!˜7K˜—š.Ÿœžœžœžœ žœžœ žœ7žœžœžœ#žœžœžœžœ žœ žœžœ žœžœ>žœžœžœžœ˜ίK˜—šŸœžœžœžœ˜+™5K™XKšœI™IK™4—K˜—š Ÿœžœ3žœžœžœžœ˜lK˜—šŸ œžœ žœžœ žœ žœžœžœ žœžœžœžœ˜wKšœ±™±—K˜š Ÿœžœ žœžœžœ˜TK˜—šŸ œžœžœ˜Kšœ™K˜—šŸ œžœžœ˜%Kšœ‡™‡K˜——šžœ˜K˜—K˜™3K™2—™K™[KšœŸœŸœŸ œ™F™KšŸœžœžœ žœ žœžœžœ žœžœ žœžœžœžœ˜KšŸ œžœžœ žœ žœžœžœžœžœ˜[Kš Ÿ œžœžœžœžœ˜5K™—K™—K™—…—zl