2 "Various utilities, should probably be moved elsewhere."
4 s@(Sequence traits) splitPreservingEmptys: obj &count: count
5 "Divides the Sequence up into subsequences as delimited by the given element."
6 [| subSeqs keyStart keyEnd |
7 keyEnd := s indexOf: obj startingAt: 0 ifAbsent: [s size].
8 subSeqs := ExtensibleArray new*, (s copyFrom: 0 to: keyEnd - 1).
9 [keyEnd < s size] whileTrue:
10 [count isNotNil /\ [subSeqs size >= count] ifTrue:
11 [subSeqs add: (s copyFrom: keyEnd to: s size - 1).
13 keyStart := (s indexOf: obj startingAt: keyEnd ifAbsent: [keyEnd]) + 1.
14 keyEnd := s indexOf: obj startingAt: keyStart ifAbsent: [s size].
15 keyStart <= keyEnd ifTrue:
16 [subSeqs add: (s copyFrom: keyStart to: keyEnd - 1)]].
22 prototypes define: #Int16ReadStream &parents: {StreamProcessor}.
23 Int16ReadStream define: #LittleEndian &parents: {Int16ReadStream}.
24 Int16ReadStream define: #BigEndian &parents: {Int16ReadStream}.
26 "FIXME: when reading from streams check that they aren't shorter than
29 s@(Int16ReadStream LittleEndian traits) next
31 byte1 := (s source next as: Integer).
32 byte2 := (s source next as: Integer).
33 (byte2 bitShift: 8) bitOr: byte1
36 s@(Int16ReadStream BigEndian traits) next
38 byte1 := (s source next as: Integer).
39 byte2 := (s source next as: Integer).
40 (byte1 bitShift: 8) bitOr: byte2
43 prototypes define: #Int16WriteStream &parents: {WriteStream}.
45 s@(Int16WriteStream traits) on: target
51 Int16WriteStream define: #LittleEndian &parents: {Int16WriteStream}.
52 Int16WriteStream define: #BigEndian &parents: {Int16WriteStream}.
54 Int16ReadStream LittleEndian traitsWindow
55 atSlotNamed: #printName
56 put: 'Int16ReadStream LittleEndian'.
57 Int16ReadStream BigEndian traitsWindow
58 atSlotNamed: #printName
59 put:'Int16ReadStream BigEndian'.
60 Int16WriteStream LittleEndian traitsWindow
61 atSlotNamed: #printName
62 put: 'Int16WriteStream LittleEndian'.
63 Int16WriteStream BigEndian traitsWindow
64 atSlotNamed: #printName
65 put: 'Int16WriteStream BigEndian'.
67 Int16WriteStream LittleEndian addSlot: #target.
68 Int16WriteStream BigEndian addSlot: #target.
70 s@(Int16WriteStream LittleEndian traits) nextPut: char
72 s target nextPut: ((char bitAnd: 16r00FF) as: ASCIIString Character).
73 s target nextPut: ((char bitShift: -8) as: ASCIIString Character).
76 s@(Int16WriteStream BigEndian traits) nextPut: char
78 s target nextPut: ((char bitShift: -8) as: ASCIIString Character).
79 s target nextPut: ((char bitAnd: 16r00FF) as: ASCIIString Character).