author | Claus Gittinger <cg@exept.de> |
Tue, 28 Mar 2006 16:34:56 +0200 | |
changeset 9305 | 6836bc44f3c3 |
parent 8987 | b0d7be646112 |
child 9351 | 8f21c31ac0c2 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
202 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
5810 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
1 | 15 |
PositionableStream subclass:#ReadStream |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
16 |
instanceVariableNames:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
17 |
classVariableNames:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
18 |
poolDictionaries:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
829
diff
changeset
|
19 |
category:'Streams' |
1 | 20 |
! |
21 |
||
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
22 |
!ReadStream class methodsFor:'documentation'! |
88 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
202 | 27 |
All Rights Reserved |
1 | 28 |
|
88 | 29 |
This software is furnished under a license and may be used |
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
1 | 37 |
|
88 | 38 |
documentation |
39 |
" |
|
40 |
ReadStream defines protocol for reading streamwise over collections. |
|
1295 | 41 |
|
42 |
[author:] |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
43 |
Claus Gittinger |
1295 | 44 |
|
88 | 45 |
" |
46 |
! ! |
|
1 | 47 |
|
9305
6836bc44f3c3
warn when ReadStream with: is used.
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
48 |
!ReadStream class methodsFor:'blocked instance creation'! |
6836bc44f3c3
warn when ReadStream with: is used.
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
49 |
|
6836bc44f3c3
warn when ReadStream with: is used.
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
50 |
with:aCollection |
6836bc44f3c3
warn when ReadStream with: is used.
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
51 |
self halt:'WARNING: with: should not be used for ReadStreams - use #on:'. |
6836bc44f3c3
warn when ReadStream with: is used.
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
52 |
^ super with:aCollection |
6836bc44f3c3
warn when ReadStream with: is used.
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
53 |
! ! |
8987
b0d7be646112
#nextBytes:into:startingAt: now works, when fetching into a bit array.
Stefan Vogel <sv@exept.de>
parents:
8914
diff
changeset
|
54 |
|
202 | 55 |
!ReadStream methodsFor:'converting'! |
56 |
||
57 |
readStream |
|
58 |
"return a readStream from the receiver. Since this is already |
|
59 |
a readStream, return self." |
|
60 |
||
61 |
^ self |
|
8140
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
62 |
! |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
63 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
64 |
readStreamOrNil |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
65 |
"return a readStream from the receiver. Since this is already |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
66 |
a readStream, return self. |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
67 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
68 |
This method has been defined for protocol copmatibility with Filename" |
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
69 |
|
7cc7ac5f29ca
Define #xxxStreamOrNil methods.
Stefan Vogel <sv@exept.de>
parents:
8098
diff
changeset
|
70 |
^ self |
202 | 71 |
! ! |
72 |
||
1400 | 73 |
!ReadStream methodsFor:'emphasis'! |
74 |
||
75 |
emphasis |
|
76 |
"return the emphasis of the current (i.e. next returned by #next) |
|
77 |
element. Streams on a string will return nil for all elements. |
|
78 |
Streams on collections which nothing at all about emphasises, |
|
79 |
will report an error." |
|
80 |
||
7114 | 81 |
^ collection emphasisAt:(position - ZeroPosition + 1). |
1400 | 82 |
|
83 |
" |
|
84 |
|t s| |
|
85 |
||
86 |
t := 'hello world' asText |
|
7114 | 87 |
emphasizeFrom:1 to:5 with:#bold; |
88 |
emphasizeFrom:7 to:11 with:#italic. |
|
1400 | 89 |
|
90 |
s := t readStream. |
|
91 |
[s atEnd] whileFalse:[ |
|
7114 | 92 |
Transcript show:(s emphasis); show:' '. |
93 |
Transcript show:''''; show:(s next); showCR:''''. |
|
1400 | 94 |
]. |
95 |
" |
|
96 |
||
97 |
"Modified: 15.5.1996 / 17:30:33 / cg" |
|
98 |
! ! |
|
99 |
||
345 | 100 |
!ReadStream methodsFor:'queries'! |
101 |
||
5310 | 102 |
copyFrom:beginning to:end |
103 |
^ collection copyFrom:beginning to:end |
|
104 |
! |
|
105 |
||
345 | 106 |
isReadable |
2997 | 107 |
"return true, if reading is supported by the recevier. |
108 |
Here, true is always returned." |
|
109 |
||
345 | 110 |
^ true |
2997 | 111 |
|
112 |
"Modified: 4.10.1997 / 17:59:21 / cg" |
|
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
113 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
114 |
|
6315 | 115 |
isWritable |
116 |
"return true, if writing is supported by the recevier. |
|
117 |
This has to be redefined in concrete subclasses." |
|
118 |
||
119 |
^ false |
|
120 |
! |
|
121 |
||
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
122 |
size |
2997 | 123 |
"return the number of elements in the streamed collection." |
124 |
||
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
125 |
^ collection size |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
126 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
127 |
"Created: 13.9.1996 / 18:14:35 / cg" |
2997 | 128 |
"Modified: 4.10.1997 / 17:59:45 / cg" |
345 | 129 |
! ! |
130 |
||
59 | 131 |
!ReadStream methodsFor:'reading'! |
1 | 132 |
|
133 |
next |
|
134 |
"return the next element; advance read pointer. |
|
2 | 135 |
return nil, if there is no next element. |
345 | 136 |
- tuned for a bit more speed on String/ByteArray/Array-Streams" |
1 | 137 |
|
138 |
|ret| |
|
139 |
||
140 |
%{ /* NOCONTEXT */ |
|
141 |
||
142 |
REGISTER int pos; |
|
143 |
unsigned ch; |
|
252 | 144 |
OBJ coll, p, l; |
1 | 145 |
|
1133 | 146 |
coll = __INST(collection); |
147 |
p = __INST(position); |
|
148 |
l = __INST(readLimit); |
|
1 | 149 |
|
252 | 150 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
151 |
||
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
152 |
pos = __intVal(p); |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
153 |
/* make 1-based */ |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
154 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
155 |
if (pos > 0 && pos <= __intVal(l)) { |
8614 | 156 |
OBJ cls, ret; |
59 | 157 |
|
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
158 |
cls = __qClass(coll); |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
159 |
if (cls == @global(String)) { |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
160 |
if (pos <= __stringSize(coll)) { |
8614 | 161 |
ch = __stringVal(coll)[pos-1]; |
162 |
ret = __MKCHARACTER(ch); |
|
8913 | 163 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
8614 | 164 |
RETURN ( ret ); |
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
165 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
166 |
} else if (cls == @global(ByteArray)) { |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
167 |
if (pos <= __byteArraySize(coll)) { |
8614 | 168 |
ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
8913 | 169 |
ret = __mkSmallInteger(ch); |
170 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
|
8614 | 171 |
RETURN ( ret ); |
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
172 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
173 |
} else if (cls == @global(Unicode16String)) { |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
174 |
if (pos <= __unicode16StringSize(coll)) { |
8614 | 175 |
ch = __Unicode16StringInstPtr(coll)->s_element[pos-1]; |
176 |
ret = __MKUCHARACTER(ch); |
|
8913 | 177 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
8614 | 178 |
RETURN ( ret ); |
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
179 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
180 |
} else if (cls == @global(Array)) { |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
181 |
if (pos <= __arraySize(coll)) { |
8614 | 182 |
ret = __ArrayInstPtr(coll)->a_element[pos-1]; |
8913 | 183 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
8614 | 184 |
RETURN ( ret ); |
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
185 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
186 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
187 |
} |
1 | 188 |
} |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
189 |
%}. |
8614 | 190 |
((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead]. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
191 |
ret := collection at:(position + 1 - ZeroPosition). |
1 | 192 |
position := position + 1. |
193 |
^ ret |
|
194 |
! |
|
195 |
||
252 | 196 |
nextAlphaNumericWord |
1 | 197 |
"read the next word (i.e. up to non letter-or-digit). |
198 |
return a string containing those characters. |
|
3112
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
199 |
Skips any non-alphanumeric chars first. |
59 | 200 |
- tuned for speed on String-Streams for faster scanning" |
1 | 201 |
%{ |
202 |
/* speedup, if collection is a string */ |
|
203 |
||
204 |
int pos, limit, sz; |
|
205 |
int len; |
|
13 | 206 |
char buffer[256]; |
207 |
REGISTER unsigned char *cp; |
|
208 |
REGISTER unsigned ch; |
|
252 | 209 |
OBJ coll, p, l; |
1 | 210 |
|
1133 | 211 |
coll = __INST(collection); |
212 |
p = __INST(position); |
|
213 |
l = __INST(readLimit); |
|
252 | 214 |
|
215 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
216 |
||
1133 | 217 |
pos = __intVal(p); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
218 |
/* make 1-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
219 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
220 |
|
1133 | 221 |
limit = __intVal(l); |
329 | 222 |
sz = __qSize(coll) - OHDR_SIZE; |
202 | 223 |
if (sz < limit) |
224 |
limit = sz; |
|
1133 | 225 |
cp = __stringVal(coll) + pos - 1; |
1 | 226 |
|
202 | 227 |
for (;;) { |
228 |
if (pos > limit) break; |
|
229 |
ch = *cp; |
|
1 | 230 |
|
3112
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
231 |
if (((ch >= 'a') && (ch <= 'z')) || |
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
232 |
((ch >= 'A') && (ch <= 'Z')) || |
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
233 |
((ch >= '0') && (ch <= '9'))) |
ccf7121ddae8
nextAlphaNumericWord changed
Claus Gittinger <cg@exept.de>
parents:
2997
diff
changeset
|
234 |
break; |
202 | 235 |
cp++; |
236 |
pos++; |
|
237 |
} |
|
1 | 238 |
|
202 | 239 |
len = 0; |
240 |
for (;;) { |
|
241 |
if (pos > limit) break; |
|
242 |
ch = *cp & 0xFF; |
|
1 | 243 |
|
202 | 244 |
if (! (((ch >= 'a') && (ch <= 'z')) || |
245 |
((ch >= 'A') && (ch <= 'Z')) || |
|
246 |
((ch >= '0') && (ch <= '9')))) |
|
247 |
break; |
|
248 |
buffer[len++] = ch; |
|
249 |
if (len >= (sizeof(buffer)-1)) { |
|
250 |
/* emergency */ |
|
251 |
break; |
|
252 |
} |
|
253 |
pos++; |
|
254 |
cp++; |
|
255 |
} |
|
1 | 256 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
257 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
258 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 259 |
__INST(position) = __mkSmallInteger(pos); |
202 | 260 |
buffer[len] = '\0'; |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1665
diff
changeset
|
261 |
RETURN ( (len != 0) ? __MKSTRING_L(buffer, len) : nil ); |
1 | 262 |
} |
263 |
%} |
|
264 |
. |
|
252 | 265 |
^ super nextAlphaNumericWord |
1 | 266 |
! |
267 |
||
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
268 |
nextByte |
4826
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
269 |
"return the next element; advance read pointer. |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
270 |
return nil, if there is no next element. |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
271 |
- tuned for a bit more speed on String/ByteArray/Array-Streams" |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
272 |
|
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
273 |
|ret| |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
274 |
|
4826
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
275 |
%{ /* NOCONTEXT */ |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
276 |
|
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
277 |
REGISTER int pos; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
278 |
unsigned ch; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
279 |
OBJ coll, p, l; |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
280 |
|
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
281 |
coll = __INST(collection); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
282 |
p = __INST(position); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
283 |
l = __INST(readLimit); |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
284 |
|
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
285 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
286 |
|
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
287 |
pos = __intVal(p); |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
288 |
/* make 1-based */ |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
289 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
290 |
if (pos > 0 && pos <= __intVal(l)) { |
8614 | 291 |
OBJ cls, ret; |
4826
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
292 |
|
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
293 |
cls = __qClass(coll); |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
294 |
if (cls == @global(String)) { |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
295 |
if (pos <= __stringSize(coll)) { |
8614 | 296 |
ch = __stringVal(coll)[pos-1]; |
8913 | 297 |
ret = __mkSmallInteger(ch); |
298 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
|
8614 | 299 |
RETURN ( ret ); |
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
300 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
301 |
} else if (cls == @global(ByteArray)) { |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
302 |
if (pos <= __byteArraySize(coll)) { |
8614 | 303 |
ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
8913 | 304 |
ret = __mkSmallInteger(ch); |
305 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
|
8614 | 306 |
RETURN ( ret ); |
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
307 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
308 |
} else if (cls == @global(Array)) { |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
309 |
if (pos <= __arraySize(coll)) { |
8614 | 310 |
ret = __ArrayInstPtr(coll)->a_element[pos-1]; |
8913 | 311 |
__INST(position) = __mkSmallInteger(__intVal(__INST(position)) + 1); |
8614 | 312 |
RETURN ( ret ); |
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
313 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
314 |
} |
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
315 |
} |
4826
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
316 |
} |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
317 |
%}. |
8614 | 318 |
((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead]. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
319 |
ret := collection at:(position + 1 -ZeroPosition). |
4826
ff30434f0feb
#nextByte does return an integer, even when operating on a
Claus Gittinger <cg@exept.de>
parents:
4522
diff
changeset
|
320 |
position := position + 1. |
8098
8d1d5cd8529b
nextByte should (at least) return integer when reading from a string-stream
Claus Gittinger <cg@exept.de>
parents:
7483
diff
changeset
|
321 |
^ ret asInteger |
1665
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
322 |
! |
928e9a308cea
added ExternalStream compatibility protocol
Claus Gittinger <cg@exept.de>
parents:
1488
diff
changeset
|
323 |
|
8530
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
324 |
nextBytes:numBytes into:aCollection startingAt:initialIndex |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
325 |
"return the next numBytes from the stream. If the end is |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
326 |
reached before, only that many bytes are copyied into the |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
327 |
collection. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
328 |
Returns the number of bytes that have been actually read. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
329 |
The receiver must support reading of binary bytes. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
330 |
|
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
331 |
Notice: this method is provided here for protocol completeness |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
332 |
with externalStreams - it is normally not used with other |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
333 |
streams." |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
334 |
|
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
335 |
(initialIndex + numBytes - 1) <= aCollection size ifTrue:[ |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
336 |
(position + numBytes - 1) <= readLimit ifTrue:[ |
8987
b0d7be646112
#nextBytes:into:startingAt: now works, when fetching into a bit array.
Stefan Vogel <sv@exept.de>
parents:
8914
diff
changeset
|
337 |
(collection isByteCollection and:[aCollection isByteCollection]) ifTrue:[ |
b0d7be646112
#nextBytes:into:startingAt: now works, when fetching into a bit array.
Stefan Vogel <sv@exept.de>
parents:
8914
diff
changeset
|
338 |
aCollection |
b0d7be646112
#nextBytes:into:startingAt: now works, when fetching into a bit array.
Stefan Vogel <sv@exept.de>
parents:
8914
diff
changeset
|
339 |
replaceBytesFrom:initialIndex to:(initialIndex + numBytes - 1) |
b0d7be646112
#nextBytes:into:startingAt: now works, when fetching into a bit array.
Stefan Vogel <sv@exept.de>
parents:
8914
diff
changeset
|
340 |
with:collection startingAt:position+1. |
b0d7be646112
#nextBytes:into:startingAt: now works, when fetching into a bit array.
Stefan Vogel <sv@exept.de>
parents:
8914
diff
changeset
|
341 |
position := position + numBytes. |
b0d7be646112
#nextBytes:into:startingAt: now works, when fetching into a bit array.
Stefan Vogel <sv@exept.de>
parents:
8914
diff
changeset
|
342 |
^ numBytes |
8530
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
343 |
]. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
344 |
]. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
345 |
]. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
346 |
^ super nextBytes:numBytes into:aCollection startingAt:initialIndex |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
347 |
|
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
348 |
" |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
349 |
|s n buffer| |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
350 |
|
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
351 |
buffer := ByteArray new:10. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
352 |
|
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
353 |
s := ReadStream on:#[1 2 3 4 5 6 7 8 9]. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
354 |
s next:3. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
355 |
n := s nextBytes:9 into:buffer startingAt:1. |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
356 |
Transcript showCR:('n = %1; buffer = <%2>' bindWith:n with:buffer) |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
357 |
" |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
358 |
! |
edcadeea17a1
tuned reading long strings & byteArrays from byteArray streams.
Claus Gittinger <cg@exept.de>
parents:
8140
diff
changeset
|
359 |
|
611 | 360 |
nextDecimalInteger |
361 |
"read the next integer in radix 10. dont skip whitespace. |
|
362 |
- tuned for speed on String-Streams for faster scanning" |
|
363 |
||
364 |
|value nextOne| |
|
365 |
%{ |
|
366 |
int pos, limit, sz; |
|
367 |
REGISTER unsigned char *cp; |
|
368 |
REGISTER unsigned ch; |
|
8914 | 369 |
INT val = 0; |
611 | 370 |
OBJ coll, p, l; |
371 |
||
1133 | 372 |
coll = __INST(collection); |
373 |
p = __INST(position); |
|
374 |
l = __INST(readLimit); |
|
611 | 375 |
|
376 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
377 |
||
1133 | 378 |
pos = __intVal(p); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
379 |
/* make 1-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
380 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
1133 | 381 |
limit = __intVal(l); |
611 | 382 |
sz = __qSize(coll) - OHDR_SIZE; |
383 |
if (sz < limit) |
|
384 |
limit = sz; |
|
1133 | 385 |
cp = __stringVal(coll) + pos - 1; |
611 | 386 |
|
387 |
for (;;) { |
|
388 |
if (pos > limit) break; |
|
389 |
ch = *cp; |
|
390 |
||
391 |
if ((ch < '0') || (ch > '9')) break; |
|
392 |
val = val * 10 + (ch - '0'); |
|
393 |
pos++; |
|
394 |
if (val > (_MAX_INT / 10)) goto oops; |
|
395 |
cp++; |
|
396 |
} |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
397 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
398 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 399 |
__INST(position) = __mkSmallInteger(pos); |
400 |
RETURN (__mkSmallInteger(val)); |
|
611 | 401 |
} |
402 |
oops: |
|
8913 | 403 |
value = __mkSmallInteger(val); |
611 | 404 |
%} |
405 |
. |
|
406 |
"fall-back for non-string streams - we have to continue where |
|
407 |
above primitive left off, in case of a large integer ... |
|
408 |
(instead of doing a super nextDecimalInteger)" |
|
409 |
||
410 |
nextOne := self peek. |
|
411 |
[nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[ |
|
412 |
value = (value * 10) + nextOne digitValue. |
|
413 |
nextOne := self nextPeek |
|
414 |
]. |
|
415 |
^ value |
|
416 |
! |
|
417 |
||
418 |
nextPeek |
|
419 |
"advance read pointer return the peek element. |
|
420 |
this is equivalent to (self next; peek). |
|
421 |
- tuned for speed on String-Streams for faster scanning" |
|
422 |
||
423 |
%{ /* NOCONTEXT */ |
|
424 |
OBJ coll, l, p; |
|
425 |
||
1133 | 426 |
coll = __INST(collection); |
427 |
p = __INST(position); |
|
428 |
l = __INST(readLimit); |
|
611 | 429 |
|
430 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
8614 | 431 |
REGISTER int pos; |
432 |
unsigned ch; |
|
611 | 433 |
|
8614 | 434 |
pos = __intVal(p); |
435 |
/* make 1-based */ |
|
436 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
|
437 |
if ((pos > 0) && (pos < __intVal(l)) && (pos < __stringSize(coll))) { |
|
438 |
pos = pos + 1; |
|
439 |
ch = __stringVal(coll)[pos-1]; |
|
440 |
/* make ZeroPosition-based */ |
|
441 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
|
8913 | 442 |
__INST(position) = __mkSmallInteger(pos); |
8614 | 443 |
RETURN ( __MKCHARACTER(ch) ); |
444 |
} |
|
611 | 445 |
} |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
446 |
%}. |
8614 | 447 |
((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead]. |
611 | 448 |
position := position + 1. |
8614 | 449 |
((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead]. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
450 |
^ collection at:(position + 1 - ZeroPosition) |
611 | 451 |
! |
452 |
||
1 | 453 |
nextSymbol |
454 |
"read the next selector-symbol (i.e. up to non letter-or-digit). |
|
455 |
return a string containing those characters. |
|
59 | 456 |
- tuned for speed on String-Streams for faster scanning" |
1 | 457 |
%{ |
458 |
int pos, limit, sz; |
|
459 |
int len; |
|
13 | 460 |
char buffer[256]; |
461 |
REGISTER unsigned char *cp; |
|
462 |
REGISTER unsigned ch; |
|
252 | 463 |
OBJ coll, p, l; |
1 | 464 |
|
1133 | 465 |
coll = __INST(collection); |
466 |
p = __INST(position); |
|
467 |
l = __INST(readLimit); |
|
252 | 468 |
|
469 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
470 |
||
1133 | 471 |
pos = __intVal(p); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
472 |
/* make 1-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
473 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
1133 | 474 |
limit = __intVal(l); |
329 | 475 |
sz = __qSize(coll) - OHDR_SIZE; |
202 | 476 |
if (sz < limit) |
477 |
limit = sz; |
|
1133 | 478 |
cp = __stringVal(coll) + pos - 1; |
1 | 479 |
|
202 | 480 |
len = 0; |
481 |
for (;;) { |
|
482 |
if (pos > limit) break; |
|
483 |
ch = *cp; |
|
1 | 484 |
|
202 | 485 |
if (! (((ch >= 'a') && (ch <= 'z')) || |
486 |
((ch >= 'A') && (ch <= 'Z')) || |
|
487 |
((ch >= '0') && (ch <= '9')) || |
|
488 |
(ch == ':'))) |
|
489 |
break; |
|
490 |
buffer[len++] = ch; |
|
491 |
if (len >= (sizeof(buffer)-1)) { |
|
492 |
/* emergency */ |
|
493 |
break; |
|
494 |
} |
|
495 |
pos++; |
|
496 |
cp++; |
|
497 |
} |
|
1 | 498 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
499 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
500 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 501 |
__INST(position) = __mkSmallInteger(pos); |
202 | 502 |
buffer[len] = '\0'; |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1665
diff
changeset
|
503 |
RETURN ( (len != 0) ? __MKSTRING_L(buffer, len) : nil ); |
1 | 504 |
} |
505 |
%} |
|
506 |
. |
|
507 |
^ super nextSymbol |
|
508 |
! |
|
509 |
||
611 | 510 |
peek |
511 |
"return the next element; do NOT advance read pointer. |
|
512 |
return nil, if there is no next element. |
|
513 |
- tuned for a bit more speed on String/ByteArray/Array-Streams" |
|
1 | 514 |
|
515 |
%{ /* NOCONTEXT */ |
|
611 | 516 |
|
517 |
REGISTER int pos; |
|
518 |
unsigned ch; |
|
519 |
OBJ coll; |
|
520 |
OBJ cls, p, l; |
|
1 | 521 |
|
1133 | 522 |
coll = __INST(collection); |
523 |
p = __INST(position); |
|
524 |
l = __INST(readLimit); |
|
252 | 525 |
|
611 | 526 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
1 | 527 |
|
8614 | 528 |
pos = __intVal(p); |
529 |
/* make 1-based */ |
|
530 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
|
531 |
if (pos <= __intVal(l) && pos > 0) { |
|
532 |
cls = __qClass(coll); |
|
533 |
if (cls == @global(String)) { |
|
534 |
if (pos <= __stringSize(coll)) { |
|
535 |
ch = __stringVal(coll)[pos-1]; |
|
536 |
RETURN ( __MKCHARACTER(ch) ); |
|
537 |
} |
|
538 |
} else if (cls == @global(ByteArray)) { |
|
539 |
if (pos <= __byteArraySize(coll)) { |
|
540 |
ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
|
8913 | 541 |
RETURN ( __mkSmallInteger(ch) ); |
8614 | 542 |
} |
543 |
} else if (cls == @global(Array)) { |
|
544 |
if (pos <= __arraySize(coll)) { |
|
545 |
RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
|
546 |
} |
|
547 |
} |
|
548 |
} |
|
1 | 549 |
} |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
550 |
%}. |
8614 | 551 |
((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ self pastEndRead]. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
552 |
^ collection at:(position + 1 - ZeroPosition) |
1 | 553 |
! |
554 |
||
3316 | 555 |
peekOrNil |
556 |
"return the next element; do NOT advance read pointer. |
|
557 |
return nil, if there is no next element. |
|
558 |
This is much like #peek - |
|
559 |
However, unlike #peek, this does not raise an atEnd-query signal - even |
|
560 |
if handled. Instead, nil is returned immediately." |
|
561 |
||
562 |
%{ /* NOCONTEXT */ |
|
563 |
||
564 |
REGISTER int pos; |
|
565 |
unsigned ch; |
|
566 |
OBJ coll; |
|
567 |
OBJ cls, p, l; |
|
568 |
||
569 |
coll = __INST(collection); |
|
570 |
p = __INST(position); |
|
571 |
l = __INST(readLimit); |
|
572 |
||
573 |
if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) { |
|
574 |
||
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
575 |
pos = __intVal(p); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
576 |
/* make 1-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
577 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
578 |
if (pos <= __intVal(l) && pos > 0) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
579 |
cls = __qClass(coll); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
580 |
if (cls == @global(String)) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
581 |
if (pos <= __stringSize(coll)) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
582 |
ch = __stringVal(coll)[pos-1]; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
583 |
RETURN ( __MKCHARACTER(ch) ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
584 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
585 |
RETURN ( nil ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
586 |
} else if (cls == @global(ByteArray)) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
587 |
if (pos <= __byteArraySize(coll)) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
588 |
ch = __ByteArrayInstPtr(coll)->ba_element[pos-1]; |
8913 | 589 |
RETURN ( __mkSmallInteger(ch) ); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
590 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
591 |
RETURN ( nil ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
592 |
} else if (cls == @global(Array)) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
593 |
if (pos <= __arraySize(coll)) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
594 |
RETURN ( __ArrayInstPtr(coll)->a_element[pos-1]); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
595 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
596 |
RETURN ( nil ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
597 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
598 |
} |
3316 | 599 |
} |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
600 |
%}. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
601 |
((position + 1 - ZeroPosition) > readLimit) ifTrue:[^ nil]. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
602 |
^ collection at:(position + 1 - ZeroPosition) |
3316 | 603 |
! |
604 |
||
1 | 605 |
skipSeparators |
606 |
"skip all whitespace; next will return next non-white-space element. |
|
59 | 607 |
Return the peeked character or nil, if the end-of-stream was reached. |
2 | 608 |
- reimplemented for speed on String-Streams for faster scanning" |
1 | 609 |
|
610 |
%{ /* NOCONTEXT */ |
|
252 | 611 |
OBJ coll, p, l; |
1 | 612 |
|
1133 | 613 |
coll = __INST(collection); |
614 |
p = __INST(position); |
|
615 |
l = __INST(readLimit); |
|
252 | 616 |
|
617 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
618 |
REGISTER unsigned char *chars; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
619 |
REGISTER unsigned ch; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
620 |
REGISTER int pos; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
621 |
int limit; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
622 |
int sz; |
1 | 623 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
624 |
pos = __intVal(p); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
625 |
/* make 1-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
626 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
627 |
if (pos <= 0) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
628 |
RETURN ( nil ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
629 |
} |
1 | 630 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
631 |
limit = __intVal(l); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
632 |
sz = __qSize(coll) - OHDR_SIZE; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
633 |
if (limit > sz) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
634 |
limit = sz; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
635 |
} |
1 | 636 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
637 |
chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
638 |
while (pos <= limit) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
639 |
pos++; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
640 |
ch = *chars++; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
641 |
if ((ch > 0x20) |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
642 |
|| ((ch != ' ') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
643 |
&& (ch != '\t') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
644 |
&& (ch != '\r') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
645 |
&& (ch != '\n') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
646 |
&& (ch != '\f') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
647 |
&& (ch != 0x0B))) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
648 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
649 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 650 |
__INST(position) = __mkSmallInteger(pos-1); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
651 |
RETURN ( __MKCHARACTER(ch) ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
652 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
653 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
654 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
655 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 656 |
__INST(position) = __mkSmallInteger(pos); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
657 |
RETURN ( nil ); |
1 | 658 |
} |
1406 | 659 |
%}. |
1 | 660 |
^ super skipSeparators |
1406 | 661 |
|
662 |
" |
|
663 |
|s| |
|
664 |
||
665 |
s := ' hello world ' readStream. |
|
666 |
s skipSeparators. |
|
667 |
s next. |
|
668 |
" |
|
1 | 669 |
! |
670 |
||
13 | 671 |
skipSeparatorsExceptCR |
672 |
"skip all whitespace except newlines; |
|
202 | 673 |
next will return next non-white-space element. |
674 |
- reimplemented for speed on String-Streams for faster scanning" |
|
675 |
||
13 | 676 |
%{ /* NOCONTEXT */ |
677 |
||
252 | 678 |
OBJ coll, p, l; |
679 |
||
1133 | 680 |
coll = __INST(collection); |
681 |
p = __INST(position); |
|
682 |
l = __INST(readLimit); |
|
252 | 683 |
|
684 |
if (__isString(coll) && __bothSmallInteger(p, l)) { |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
685 |
REGISTER unsigned char *chars; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
686 |
REGISTER unsigned ch; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
687 |
REGISTER int pos; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
688 |
int limit; |
13 | 689 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
690 |
pos = __intVal(p); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
691 |
/* make 1-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
692 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
693 |
if (pos <= 0) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
694 |
RETURN ( nil ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
695 |
} |
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
696 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
697 |
limit = __intVal(l); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
698 |
if (limit > (__qSize(coll) - OHDR_SIZE)) |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
699 |
limit = __qSize(coll) - OHDR_SIZE; |
13 | 700 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
701 |
chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
702 |
while (pos <= limit) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
703 |
ch = *chars++; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
704 |
if (((int)ch > 0x20) |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
705 |
|| ( |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
706 |
(ch != ' ') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
707 |
&& (ch != '\t') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
708 |
&& (ch != '\f') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
709 |
&& (ch != '\b') |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
710 |
&& (ch != 0x0B))) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
711 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
712 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 713 |
__INST(position) = __mkSmallInteger(pos); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
714 |
RETURN ( __MKCHARACTER(ch) ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
715 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
716 |
pos++; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
717 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
718 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
719 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 720 |
__INST(position) = __mkSmallInteger(pos); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
721 |
RETURN ( nil ); |
13 | 722 |
} |
723 |
%} |
|
724 |
. |
|
725 |
^ super skipSeparatorsExceptCR |
|
726 |
! |
|
727 |
||
611 | 728 |
skipThrough:anObject |
6011
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
729 |
"skip all objects up-to and including anObject. |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
730 |
Return the receiver if skip was successful, |
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
731 |
otherwise (i.e. if not found) return nil and leave the stream positioned at the end. |
611 | 732 |
On success, the next read operation will return the element after anObject. |
733 |
- reimplemented for speed on String-Streams for faster scanning" |
|
734 |
||
735 |
%{ /* NOCONTEXT */ |
|
736 |
OBJ coll, p, l; |
|
737 |
||
1133 | 738 |
coll = __INST(collection); |
739 |
p = __INST(position); |
|
740 |
l = __INST(readLimit); |
|
611 | 741 |
|
742 |
if (__isString(coll) |
|
743 |
&& __isCharacter(anObject) |
|
744 |
&& __bothSmallInteger(p, l)) { |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
745 |
REGISTER unsigned char *chars; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
746 |
REGISTER int pos, limit; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
747 |
unsigned ch; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
748 |
int sz; |
611 | 749 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
750 |
pos = __intVal(p); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
751 |
/* make 1-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
752 |
pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
753 |
if (pos <= 0) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
754 |
RETURN ( nil ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
755 |
} |
611 | 756 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
757 |
limit = __intVal(l); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
758 |
sz = __stringSize(coll); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
759 |
if (limit > sz) limit = sz; |
611 | 760 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
761 |
chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
762 |
ch = __intVal(_characterVal(anObject)) & 0xFF; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
763 |
while (pos < limit) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
764 |
if (*chars == ch) { |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
765 |
ch = *++chars; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
766 |
pos++; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
767 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
768 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 769 |
__INST(position) = __mkSmallInteger(pos); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
770 |
RETURN ( self ); |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
771 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
772 |
chars++; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
773 |
pos++; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
774 |
} |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
775 |
/* make ZeroPosition-based */ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
776 |
pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
8913 | 777 |
__INST(position) = __mkSmallInteger(pos+1); |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6814
diff
changeset
|
778 |
RETURN ( nil ); |
611 | 779 |
} |
6011
3b91d7834ca5
fixed: skipThrough dod not position atEnd if the element was not found.
Claus Gittinger <cg@exept.de>
parents:
5810
diff
changeset
|
780 |
%}. |
611 | 781 |
^ super skipThrough:anObject |
1 | 782 |
! ! |
783 |
||
59 | 784 |
!ReadStream methodsFor:'writing'! |
1 | 785 |
|
786 |
nextPut:anElement |
|
10 | 787 |
"catch write access to readstreams - report an error" |
788 |
||
789 |
self shouldNotImplement |
|
1 | 790 |
! ! |
611 | 791 |
|
2162
7e1601f633b6
ff is a separator too (in #skipSeparators*)
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
792 |
!ReadStream class methodsFor:'documentation'! |
701 | 793 |
|
794 |
version |
|
9305
6836bc44f3c3
warn when ReadStream with: is used.
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
795 |
^ '$Header: /cvs/stx/stx/libbasic/ReadStream.st,v 1.56 2006-03-28 14:34:56 cg Exp $' |
701 | 796 |
! ! |