author | Claus Gittinger <cg@exept.de> |
Sat, 23 Aug 2003 14:09:21 +0200 | |
changeset 7573 | 5c0f8cd19b66 |
parent 7503 | ddabde2900d2 |
child 7578 | 9ac1e4ee012a |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
159 | 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 |
||
5393
7e2230bd4bad
moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
5308
diff
changeset
|
13 |
"{ Package: 'stx:libbasic' }" |
7e2230bd4bad
moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
5308
diff
changeset
|
14 |
|
57 | 15 |
PeekableStream subclass:#PositionableStream |
973 | 16 |
instanceVariableNames:'collection position readLimit writeLimit' |
4405 | 17 |
classVariableNames:'ZeroPosition InvalidPositionErrorSignal ErrorDuringFileInSignal |
5393
7e2230bd4bad
moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
5308
diff
changeset
|
18 |
CurrentFileInDirectoryQuerySignal ChunkSeparator' |
973 | 19 |
poolDictionaries:'' |
20 |
category:'Streams' |
|
1 | 21 |
! |
22 |
||
1897 | 23 |
!PositionableStream class methodsFor:'documentation'! |
88 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
159 | 28 |
All Rights Reserved |
1 | 29 |
|
88 | 30 |
This software is furnished under a license and may be used |
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
10 | 38 |
|
88 | 39 |
documentation |
40 |
" |
|
41 |
Instances of PositionableStream allow positioning the read pointer. |
|
42 |
The PositionableStream class also adds methods for source-chunk reading |
|
43 |
and writing, and for filing-in/out of source code. |
|
3249
8401c3e42165
checkin to force re-checkout.
Claus Gittinger <cg@exept.de>
parents:
3184
diff
changeset
|
44 |
|
88 | 45 |
This is an abstract class. |
1295 | 46 |
|
4405 | 47 |
Compatibility Notice: |
48 |
For historical reasons, ST/X starts with a 1-position (i.e. as in collections), |
|
49 |
while ST-80 uses 0-based postions for streams and 1-based positions for collections. |
|
50 |
||
51 |
THIS CERTAINLY IS BAD. |
|
52 |
To allow for portable code, this method can be asked to return the initial position. |
|
53 |
(for code, which ought to execute under other systems, use: |
|
54 |
posZero := (PositionableStream class respondsTo:#zeroPosition) |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
55 |
ifTrue:[PositionableStream zeroPosition] |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
56 |
ifFalse:[0] |
5228 | 57 |
Please use this query for ST/X programs - we will eventually switch to a 0-based |
58 |
indexing scheme, and your programs should be prepared for that. |
|
4405 | 59 |
|
1295 | 60 |
[author:] |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
61 |
Claus Gittinger |
88 | 62 |
" |
63 |
! ! |
|
1 | 64 |
|
1897 | 65 |
!PositionableStream class methodsFor:'initialization'! |
1 | 66 |
|
10 | 67 |
initialize |
44 | 68 |
"setup the signal used to handle errors during fileIn" |
69 |
||
7363 | 70 |
ZeroPosition := 0. "/ changed with stx rel5.1 |
71 |
||
10 | 72 |
ErrorDuringFileInSignal isNil ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
73 |
ErrorDuringFileInSignal := Error newSignalMayProceed:true. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
74 |
ErrorDuringFileInSignal nameClass:self message:#errorDuringFileInSignal. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
75 |
ErrorDuringFileInSignal notifierString:'error during fileIn'. |
276 | 76 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
77 |
InvalidPositionErrorSignal := PositionOutOfBoundsError. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
78 |
InvalidPositionErrorSignal notifierString:'position out of bounds: '. |
2966 | 79 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
80 |
CurrentFileInDirectoryQuerySignal := QuerySignal new. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
81 |
CurrentFileInDirectoryQuerySignal nameClass:self message:#currentFileInDirectoryQuerySignal. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
82 |
CurrentFileInDirectoryQuerySignal notifierString:'query for current directory when filing in'. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
83 |
CurrentFileInDirectoryQuerySignal handlerBlock:[:ex | ex proceedWith:Filename currentDirectory]. |
10 | 84 |
] |
85 |
! ! |
|
1 | 86 |
|
1897 | 87 |
!PositionableStream class methodsFor:'instance creation'! |
1 | 88 |
|
89 |
on:aCollection |
|
90 |
"return a new PositionableStream streaming on aCollection" |
|
91 |
||
92 |
^ (self basicNew) on:aCollection |
|
93 |
! |
|
94 |
||
95 |
on:aCollection from:first to:last |
|
96 |
"return a new PositionableStream streaming on aCollection |
|
97 |
from first to last" |
|
98 |
||
369 | 99 |
^ (self basicNew) on:aCollection from:first to:last |
57 | 100 |
! |
101 |
||
102 |
with:aCollection |
|
103 |
"return a new PositionableStream streaming on aCollection, |
|
104 |
the stream is positioned to the end of the collection." |
|
105 |
||
362 | 106 |
^ (self basicNew) with:aCollection |
1 | 107 |
! ! |
108 |
||
3032
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
109 |
!PositionableStream class methodsFor:'Signal constants'! |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
110 |
|
5223 | 111 |
currentFileInDirectoryQuerySignal |
112 |
"return the querySignal, which can be used to ask for the current directory |
|
5228 | 113 |
during a fileIn (that is the directory where the filed-in file resides), |
114 |
and in a fileBrowsers doIt. |
|
115 |
Using this, allows for the loaded code or doIts to ask for the fileBrowsers |
|
116 |
current directory, by asking this querySignal (which is nice sometimes)." |
|
5223 | 117 |
|
118 |
^ CurrentFileInDirectoryQuerySignal |
|
119 |
! |
|
120 |
||
3032
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
121 |
invalidPositionErrorSignal |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
122 |
"return the signal raised if positioning is attempted to an |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
123 |
invalid position (i.e. before the begin of the stream or after |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
124 |
the end)" |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
125 |
|
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
126 |
^ InvalidPositionErrorSignal |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
127 |
! ! |
d267a0b1b48d
handle empty chunks when filing in
Claus Gittinger <cg@exept.de>
parents:
2966
diff
changeset
|
128 |
|
1897 | 129 |
!PositionableStream class methodsFor:'constants'! |
1 | 130 |
|
4405 | 131 |
zeroPosition |
132 |
"return the number, which marks the initial position. |
|
133 |
Compatibility Notice: |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
134 |
For historical reasons, ST/X starts with a 1-position (i.e. as in collections), |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
135 |
while ST-80 uses 0-based postions for streams and 1-based positions for collections. |
4405 | 136 |
|
137 |
THIS CERTAINLY IS BAD. |
|
138 |
To allow for portable code, this method can be asked to return the initial position. |
|
139 |
(for code, which ought to execute under other systems, use: |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
140 |
posZero := (PositionableStream class respondsTo:#zeroPosition) |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
141 |
ifTrue:[PositionableStream zeroPosition] |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
142 |
ifFalse:[0] |
4405 | 143 |
|
144 |
Be prepared for this to be changed to return 0 as other ST's do. |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
145 |
" |
4405 | 146 |
|
147 |
^ ZeroPosition |
|
360 | 148 |
! ! |
149 |
||
6777
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
150 |
!PositionableStream class methodsFor:'queries'! |
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
151 |
|
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
152 |
currentFileInDirectory |
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
153 |
"during a fileIn (if a script), the script can ask for the current directory" |
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
154 |
|
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
155 |
^ CurrentFileInDirectoryQuerySignal query |
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
156 |
! ! |
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
157 |
|
7261 | 158 |
!PositionableStream methodsFor:'Compatibility-Dolphin'! |
6413 | 159 |
|
160 |
endChunk |
|
161 |
self nextPutChunkSeparator |
|
162 |
! ! |
|
163 |
||
1 | 164 |
!PositionableStream methodsFor:'accessing'! |
165 |
||
166 |
contents |
|
167 |
"return the entire contents of the stream" |
|
168 |
||
169 |
^ collection |
|
170 |
! |
|
171 |
||
172 |
peek |
|
173 |
"look ahead for and return the next element" |
|
174 |
||
175 |
|peekObject| |
|
176 |
||
177 |
peekObject := self next. |
|
10 | 178 |
self backStep. |
1 | 179 |
^ peekObject |
180 |
! |
|
181 |
||
2432 | 182 |
peekForAll:aCollection |
183 |
"return true and advance if the next elements are the same |
|
184 |
as aCollection. |
|
185 |
otherwise stay and let the position unchanged" |
|
186 |
||
187 |
|oldPos| |
|
188 |
||
189 |
oldPos := self position. |
|
190 |
(self next:(aCollection size)) = aCollection ifTrue:[ |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
191 |
^ true |
2432 | 192 |
]. |
193 |
self position:oldPos. |
|
194 |
^ false |
|
195 |
||
196 |
"Created: 1.3.1997 / 15:11:25 / cg" |
|
197 |
! |
|
198 |
||
3905
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
199 |
readLimit |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
200 |
"return the read-limit; thats the position at which EOF is returned" |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
201 |
|
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
202 |
^ readLimit |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
203 |
|
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
204 |
"Created: / 30.10.1998 / 16:47:04 / cg" |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
205 |
! |
682fc38fd339
added read-access to readLimit.
Claus Gittinger <cg@exept.de>
parents:
3604
diff
changeset
|
206 |
|
1 | 207 |
readLimit:aNumber |
369 | 208 |
"set the read-limit; thats the position at which EOF is returned" |
1 | 209 |
|
210 |
readLimit := aNumber |
|
369 | 211 |
! |
212 |
||
213 |
writeLimit:aNumber |
|
214 |
"set the writeLimit; thats the position after which writing is prohibited" |
|
215 |
||
216 |
writeLimit := aNumber |
|
1 | 217 |
! ! |
218 |
||
44 | 219 |
!PositionableStream methodsFor:'chunk input/output'! |
1 | 220 |
|
221 |
nextChunkPut:aString |
|
222 |
"put aString as a chunk onto the receiver; |
|
217 | 223 |
double all exclamation marks except within primitives and append a |
276 | 224 |
single delimiting exclamation mark at the end. |
718
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
225 |
This modification of the chunk format (not doubling exclas in primitive code) |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
226 |
was done to have primitive code more readable and easier be edited in the fileBrowser |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
227 |
or other editors. |
276 | 228 |
Its no incompatibility, since inline primitives are an ST/X special |
718
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
229 |
and code containing ST/X primitives cannot be loaded into other smalltalks anyway." |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
230 |
|
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
231 |
self nextPutAllAsChunk:aString. |
5393
7e2230bd4bad
moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
5308
diff
changeset
|
232 |
self nextPut:(self class chunkSeparator) |
718
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
233 |
|
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
234 |
"Modified: 9.12.1995 / 15:56:54 / cg" |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
235 |
! |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
236 |
|
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
237 |
nextPutAllAsChunk:aString |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
238 |
"put aString as a chunk onto the receiver; |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
239 |
double all exclamation marks except within primitives. |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
240 |
This modification of the chunk format (not doubling exclas in primitive code) |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
241 |
was done to have primitive code more readable and easier be edited in the fileBrowser |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
242 |
or other editors. |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
243 |
Its no incompatibility, since inline primitives are an ST/X special |
6f8222ff2ff0
extra entry to store a chunk without appending a chunk-separator
Claus Gittinger <cg@exept.de>
parents:
701
diff
changeset
|
244 |
and code containing ST/X primitives cannot be loaded into other smalltalks anyway." |
1 | 245 |
|
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
246 |
|sep stopChars inPrimitive character |
1 | 247 |
index "{ Class:SmallInteger }" |
248 |
endIndex "{ Class:SmallInteger }" |
|
217 | 249 |
stop "{ Class:SmallInteger }" |
253 | 250 |
next "{ Class:SmallInteger }"| |
1 | 251 |
|
3386 | 252 |
endIndex := aString size. |
253 |
endIndex == 0 ifTrue:[^ self]. |
|
254 |
||
5393
7e2230bd4bad
moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
5308
diff
changeset
|
255 |
sep := self class chunkSeparator. |
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
256 |
stopChars := '{}' copyWith:sep. |
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
257 |
|
1 | 258 |
inPrimitive := false. |
259 |
index := 1. |
|
217 | 260 |
stop := endIndex + 1. |
1 | 261 |
|
262 |
[index <= endIndex] whileTrue:[ |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
263 |
" |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
264 |
find position of next interesting character; |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
265 |
output stuff up to that one in one piece |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
266 |
" |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
267 |
next := aString indexOfAny:stopChars startingAt:index ifAbsent:stop. |
1 | 268 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
269 |
((index == 1) and:[next == stop]) ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
270 |
self nextPutAll:aString |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
271 |
] ifFalse:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
272 |
self nextPutAll:aString startingAt:index to:(next - 1) |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
273 |
]. |
1 | 274 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
275 |
index := next. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
276 |
(index <= endIndex) ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
277 |
character := aString at:index. |
276 | 278 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
279 |
(character == ${ ) ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
280 |
"/ starts a primitive |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
281 |
((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
282 |
inPrimitive := true |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
283 |
] |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
284 |
] ifFalse:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
285 |
"/ ends a primitive |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
286 |
(character == $} ) ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
287 |
((index > 1) and:[(aString at:index-1) == $%]) ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
288 |
inPrimitive := false |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
289 |
] |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
290 |
] ifFalse:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
291 |
"/ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
292 |
"/ exclas have to be doubled - except if within a primitive |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
293 |
"/ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
294 |
inPrimitive ifFalse:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
295 |
(character == sep) ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
296 |
self nextPut:sep |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
297 |
] |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
298 |
] |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
299 |
] |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
300 |
]. |
276 | 301 |
|
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
302 |
self nextPut:character. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
303 |
index := index + 1. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
304 |
]. |
5694
20ccdf123aab
add a cr, if the source does not end in a carriage return.
Claus Gittinger <cg@exept.de>
parents:
5441
diff
changeset
|
305 |
]. |
5695 | 306 |
(aString endsWith:Character cr) ifFalse:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
307 |
self cr. |
1 | 308 |
]. |
517
c8fae50c2cc5
fixed nextChunkPut: which sometimes doubled exclas within primitives
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
309 |
|
3386 | 310 |
"Modified: / 21.4.1998 / 17:22:47 / cg" |
5694
20ccdf123aab
add a cr, if the source does not end in a carriage return.
Claus Gittinger <cg@exept.de>
parents:
5441
diff
changeset
|
311 |
"/ foo |
611 | 312 |
! |
313 |
||
314 |
nextPutChunkSeparator |
|
315 |
"append a chunk separator character" |
|
316 |
||
5393
7e2230bd4bad
moved some stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
5308
diff
changeset
|
317 |
self nextPut:(self class chunkSeparator) |
611 | 318 |
|
319 |
"Created: 13.9.1995 / 17:39:26 / claus" |
|
44 | 320 |
! ! |
321 |
||
322 |
!PositionableStream methodsFor:'fileIn'! |
|
323 |
||
611 | 324 |
askForDebug:message |
325 |
"launch a box asking if a debugger is wanted - used when an error |
|
326 |
occurs while filing in" |
|
327 |
||
4416 | 328 |
^ self askForDebug:message canContinueForAll:false |
329 |
! |
|
330 |
||
331 |
askForDebug:message canContinueForAll:canContinueForAll |
|
332 |
"launch a box asking if a debugger is wanted - used when an error |
|
333 |
occurs while filing in" |
|
334 |
||
335 |
|labels values| |
|
336 |
||
611 | 337 |
Smalltalk isInitialized ifFalse:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
338 |
'PositionableStream [warning]: fileIn error during startup: ' errorPrint. message errorPrintCR. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
339 |
^ #debug |
611 | 340 |
]. |
875
2bb6fea4cb55
dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
341 |
"/ |
2bb6fea4cb55
dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
342 |
"/ are we in the startup sequence of an image restart ? |
2bb6fea4cb55
dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
343 |
"/ |
2bb6fea4cb55
dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
344 |
Processor activeProcessIsSystemProcess ifTrue:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
345 |
'PositionableStream [warning]: fileIn error during startup: ' errorPrint. message errorPrintCR. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
346 |
^ #continue |
875
2bb6fea4cb55
dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
347 |
]. |
2bb6fea4cb55
dont launch box when fileIn errors occur during startup
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
348 |
|
4416 | 349 |
canContinueForAll ifTrue:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
350 |
labels := #('Cancel' 'Skip' 'Debug' 'Dont ask again' 'Continue'). |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
351 |
values := #(#abort #skip #debug #continueForAll #continue). |
4416 | 352 |
] ifFalse:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
353 |
labels := #('Cancel' 'Skip' 'Debug' 'Continue'). |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
354 |
values := #(#abort #skip #debug #continue). |
4416 | 355 |
]. |
6699
3a8b14a9c51a
offer cancelAll in fileIn (if AbortAllSignal is handled)
Claus Gittinger <cg@exept.de>
parents:
6626
diff
changeset
|
356 |
AbortAllSignal isHandled ifTrue:[ |
3a8b14a9c51a
offer cancelAll in fileIn (if AbortAllSignal is handled)
Claus Gittinger <cg@exept.de>
parents:
6626
diff
changeset
|
357 |
labels := #('Cancel All') , labels. |
3a8b14a9c51a
offer cancelAll in fileIn (if AbortAllSignal is handled)
Claus Gittinger <cg@exept.de>
parents:
6626
diff
changeset
|
358 |
values := #(#cancelAll) , values. |
3a8b14a9c51a
offer cancelAll in fileIn (if AbortAllSignal is handled)
Claus Gittinger <cg@exept.de>
parents:
6626
diff
changeset
|
359 |
]. |
4416 | 360 |
|
611 | 361 |
^ OptionBox |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
362 |
request:message |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
363 |
label:'Error in fileIn' |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
364 |
form:(WarningBox iconBitmap) |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
365 |
buttonLabels:labels |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
366 |
values:values |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
367 |
default:#continue |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
368 |
onCancel:#abort. |
975 | 369 |
|
2130
b9e7e1cf98bd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2005
diff
changeset
|
370 |
"Modified: 10.1.1997 / 18:00:56 / cg" |
611 | 371 |
! |
372 |
||
7573 | 373 |
basicFileInNotifying:someone passChunk:passChunk |
5302 | 374 |
"central method to file in from the receiver, i.e. read chunks and evaluate them - |
611 | 375 |
return the value of the last chunk. |
376 |
Someone (which is usually some codeView) is notified of errors." |
|
377 |
||
2893 | 378 |
|lastValue pkg spc spaces |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
379 |
packageQuerySignal nameSpaceQuerySignal usedNameSpaceQuerySignal |
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
380 |
changeDefaultApplicationNotificationSignal |
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
381 |
defaultApplicationQuerySignal defaultApplication |
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
382 |
confirmationQuerySignal handledSignals passedSignals |
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
383 |
dontAskSignals askSomeoneForPackage redef outerContext| |
611 | 384 |
|
5302 | 385 |
self skipSeparators. |
6538
1828dcb8f067
Allow #! as begin of filein chunk
Stefan Vogel <sv@exept.de>
parents:
6494
diff
changeset
|
386 |
lastValue := self peek. |
1828dcb8f067
Allow #! as begin of filein chunk
Stefan Vogel <sv@exept.de>
parents:
6494
diff
changeset
|
387 |
lastValue == $< ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
388 |
"/ assume, its an xml file |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
389 |
^ self fileInXMLNotifying:someone passChunk:passChunk. |
5302 | 390 |
]. |
6538
1828dcb8f067
Allow #! as begin of filein chunk
Stefan Vogel <sv@exept.de>
parents:
6494
diff
changeset
|
391 |
lastValue == $# ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
392 |
"assume unix interpreter name: |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
393 |
'#!!stx -e' or something like this" |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
394 |
self nextPeek == $!! ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
395 |
"skip the unix command line" |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
396 |
self nextLine |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
397 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
398 |
self error:'Invalid chunk start' |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
399 |
] |
6538
1828dcb8f067
Allow #! as begin of filein chunk
Stefan Vogel <sv@exept.de>
parents:
6494
diff
changeset
|
400 |
]. |
5302 | 401 |
|
6924 | 402 |
Smalltalk::Compiler isNil ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
403 |
self isFileStream ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
404 |
Transcript show:('[' , self pathName , '] '). |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
405 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
406 |
Transcript showCR:'cannot fileIn (no compiler).'. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
407 |
^ nil. |
6924 | 408 |
]. |
409 |
||
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
410 |
"/ support for V'Age applications |
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
411 |
defaultApplicationQuerySignal := Class defaultApplicationQuerySignal. |
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
412 |
changeDefaultApplicationNotificationSignal := Class changeDefaultApplicationNotificationSignal. |
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
413 |
|
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
414 |
"/ support for ST/X's namespaces & packages |
2343 | 415 |
packageQuerySignal := Class packageQuerySignal. |
416 |
nameSpaceQuerySignal := Class nameSpaceQuerySignal. |
|
417 |
usedNameSpaceQuerySignal := Class usedNameSpaceQuerySignal. |
|
418 |
||
2893 | 419 |
(someone respondsTo:#packageToInstall) ifFalse:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
420 |
pkg := packageQuerySignal query. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
421 |
askSomeoneForPackage := false. |
2893 | 422 |
] ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
423 |
pkg := someone packageToInstall. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
424 |
askSomeoneForPackage := true. |
2893 | 425 |
]. |
426 |
(someone respondsTo:#currentNameSpace) ifFalse:[ |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
427 |
spc := nameSpaceQuerySignal query. |
2893 | 428 |
] ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
429 |
spc := someone currentNameSpace |
2893 | 430 |
]. |
431 |
(someone respondsTo:#usedNameSpaces) ifFalse:[ |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
432 |
spaces := usedNameSpaceQuerySignal query. |
2893 | 433 |
] ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
434 |
spaces := someone usedNameSpaces |
2893 | 435 |
]. |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
436 |
(someone respondsTo:#defaultApplication) ifFalse:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
437 |
defaultApplication := defaultApplicationQuerySignal query. |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
438 |
] ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
439 |
defaultApplication := someone defaultApplication |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
440 |
]. |
2893 | 441 |
|
3966
1013f1476687
suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents:
3905
diff
changeset
|
442 |
confirmationQuerySignal := Metaclass confirmationQuerySignal. |
1013f1476687
suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents:
3905
diff
changeset
|
443 |
|
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
444 |
passedSignals := IdentitySet new. |
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
445 |
|
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
446 |
handledSignals := SignalSet new. |
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
447 |
handledSignals add:changeDefaultApplicationNotificationSignal. |
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
448 |
passedSignals add:changeDefaultApplicationNotificationSignal. |
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
449 |
handledSignals add:defaultApplicationQuerySignal. |
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
450 |
passedSignals add:defaultApplicationQuerySignal. |
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
451 |
|
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
452 |
handledSignals add:packageQuerySignal. |
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
453 |
handledSignals add:usedNameSpaceQuerySignal. |
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
454 |
handledSignals add:nameSpaceQuerySignal. |
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
455 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
456 |
handledSignals add:Error. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
457 |
passedSignals add:Error. |
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
458 |
|
3592 | 459 |
handledSignals add:(Class methodRedefinitionSignal). |
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
460 |
passedSignals add:(Class methodRedefinitionSignal). |
3597
98bd336b3c3f
also care for class redefinitions.
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
461 |
handledSignals add:(Class classRedefinitionSignal). |
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
462 |
passedSignals add:(Class classRedefinitionSignal). |
3966
1013f1476687
suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents:
3905
diff
changeset
|
463 |
handledSignals add:confirmationQuerySignal. |
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
464 |
passedSignals add:confirmationQuerySignal. |
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
465 |
|
4772 | 466 |
outerContext := thisContext. |
467 |
||
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
468 |
handledSignals handle:[:ex | |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
469 |
|sig action what sender msg param oldPackage newPackage proceedValue |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
470 |
canContinueForAll| |
1902 | 471 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
472 |
sig := ex signal. |
5250
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
473 |
"/sig == packageQuerySignal ifTrue:[ |
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
474 |
"/self halt. |
991f068f9a80
not all query signals are passed (packageQuery)
Claus Gittinger <cg@exept.de>
parents:
5228
diff
changeset
|
475 |
"/]. |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
476 |
(passedSignals includes:sig) ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
477 |
(sig isHandledIn:outerContext) ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
478 |
ex reject |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
479 |
] |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
480 |
]. |
4772 | 481 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
482 |
sig == changeDefaultApplicationNotificationSignal ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
483 |
"/ invoked via #becomeDefault to set the defaultApp and the package. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
484 |
"/ (only when filing in V'Age code) |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
485 |
defaultApplication := ex parameter. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
486 |
pkg := defaultApplication name asSymbol. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
487 |
ex proceedWith:nil |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
488 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
489 |
sig == defaultApplicationQuerySignal ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
490 |
"/ query for the application to add classes & methods into |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
491 |
"/ (only when filing in V'Age code) |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
492 |
ex proceedWith:defaultApplication |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
493 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
494 |
sig == packageQuerySignal ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
495 |
"/ query for the package to use for classes & methods |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
496 |
askSomeoneForPackage ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
497 |
ex proceedWith:someone packageToInstall |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
498 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
499 |
ex proceedWith:pkg |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
500 |
] |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
501 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
502 |
sig == usedNameSpaceQuerySignal ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
503 |
"/ query for the namespaces searched when encountering globals |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
504 |
ex proceedWith:spaces |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
505 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
506 |
sig == nameSpaceQuerySignal ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
507 |
"/ query for the namespace to install new classes in |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
508 |
ex proceedWith:spc |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
509 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
510 |
sig == confirmationQuerySignal ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
511 |
ex proceedWith:false "/ no dialogs popping up |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
512 |
]. |
3966
1013f1476687
suppress confirmation dialogs when classes violate conventions
Claus Gittinger <cg@exept.de>
parents:
3905
diff
changeset
|
513 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
514 |
sig == Stream endOfStreamSignal ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
515 |
ex reject |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
516 |
]. |
3580
47534257f9e5
avoid two queries for rejected signals.
Claus Gittinger <cg@exept.de>
parents:
3386
diff
changeset
|
517 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
518 |
sig == Signal noHandlerSignal ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
519 |
ex parameter rejected ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
520 |
ex reject |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
521 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
522 |
]. |
2893 | 523 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
524 |
(dontAskSignals notNil and:[dontAskSignals includesKey:sig]) ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
525 |
ex proceedWith:(dontAskSignals at:sig) |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
526 |
]. |
4639
a139399c5f4f
package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents:
4559
diff
changeset
|
527 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
528 |
canContinueForAll := false. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
529 |
redef := false. |
4416 | 530 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
531 |
"/ for your convenience ... |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
532 |
(sig == Class methodRedefinitionSignal) ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
533 |
param := ex parameter. "/ an association: oldMethod -> newMethod |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
534 |
oldPackage := param key package. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
535 |
newPackage := param value package. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
536 |
msg := 'trying to overwrite method:\\ ' , param key whoString , '\\in package ''' |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
537 |
, oldPackage , ''' with method from package ''' , newPackage , ''''. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
538 |
canContinueForAll := true. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
539 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
540 |
(sig == Class classRedefinitionSignal) ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
541 |
param := ex parameter. "/ an association: oldClass -> newClass |
4639
a139399c5f4f
package redefinition handling fixed
Claus Gittinger <cg@exept.de>
parents:
4559
diff
changeset
|
542 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
543 |
oldPackage := param key package. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
544 |
newPackage := param value package. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
545 |
msg := 'trying to redefine class: ' , param key name allBold , '\\in package ''' |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
546 |
, oldPackage , ''' with new definition from package ''' , newPackage , ''''. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
547 |
canContinueForAll := true. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
548 |
redef := true. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
549 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
550 |
msg := 'error in fileIn: %1' |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
551 |
] |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
552 |
]. |
2893 | 553 |
|
7205 | 554 |
what := ex description. |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
555 |
what isNil ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
556 |
what := ex signal notifierString. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
557 |
]. |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
558 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
559 |
"/ handle the case where no GUI has been built in, |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
560 |
"/ just abort the fileIn with a notification |
2893 | 561 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
562 |
Display isNil ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
563 |
sender := ex suspendedContext sender. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
564 |
self notify:(what , |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
565 |
' in ' , sender receiver class name , |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
566 |
'>>>' , sender selector). |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
567 |
ex return |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
568 |
]. |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
569 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
570 |
msg := msg bindWith:what. |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
571 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
572 |
sig == HaltInterrupt ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
573 |
sender := ex suspendedContext. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
574 |
msg := msg , ('\\in ' , sender receiver class name , '>>>' , sender selector) withCRs |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
575 |
]. |
2893 | 576 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
577 |
"/ otherwise ask what should be done now and either |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
578 |
"/ continue or abort the fileIn |
7573 | 579 |
Transcript showCR:Screen current. |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
580 |
redef ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
581 |
action := OptionBox |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
582 |
request:(msg withCRs) |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
583 |
label:'Class redefinition in fileIn' |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
584 |
form:(WarningBox iconBitmap) |
5098
4cb82101e94a
always preserve the packageID, when redefining a class
Claus Gittinger <cg@exept.de>
parents:
4912
diff
changeset
|
585 |
"/ cg: now always keep the old packageID |
4cb82101e94a
always preserve the packageID, when redefining a class
Claus Gittinger <cg@exept.de>
parents:
4912
diff
changeset
|
586 |
"/ buttonLabels:#('cancel' 'skip' 'debug' 'keep' 'keep all' 'continue' 'continue all') |
4cb82101e94a
always preserve the packageID, when redefining a class
Claus Gittinger <cg@exept.de>
parents:
4912
diff
changeset
|
587 |
"/ values:#(#abort #skip #debug #keep #keepAll #continue #continueForAll) |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
588 |
buttonLabels:#('Cancel' 'Skip' 'Debug' 'Continue' 'Continue All') |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
589 |
values:#(#abort #skip #debug #keep #keepAll) |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
590 |
default:#continue |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
591 |
onCancel:#abort. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
592 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
593 |
action := self askForDebug:msg withCRs canContinueForAll:canContinueForAll. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
594 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
595 |
action == #continueForAll ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
596 |
dontAskSignals isNil ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
597 |
dontAskSignals := IdentityDictionary new. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
598 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
599 |
dontAskSignals at:sig put:#continue. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
600 |
action := proceedValue := #continue. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
601 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
602 |
action == #keepForAll ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
603 |
dontAskSignals isNil ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
604 |
dontAskSignals := IdentityDictionary new. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
605 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
606 |
dontAskSignals at:sig put:#keep. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
607 |
action := #continue. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
608 |
proceedValue := #keep. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
609 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
610 |
action == #keep ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
611 |
action := #continue. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
612 |
proceedValue := #keep. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
613 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
614 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
615 |
]. |
4416 | 616 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
617 |
action == #continue ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
618 |
ex proceedWith:(proceedValue ? #continue) |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
619 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
620 |
action == #abort ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
621 |
AbortSignal raise. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
622 |
ex return |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
623 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
624 |
action == #cancelAll ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
625 |
AbortAllSignal raise. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
626 |
ex return |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
627 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
628 |
action == #skip ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
629 |
ex proceedWith:nil |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
630 |
]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
631 |
action == #debug ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
632 |
Debugger enter:ex suspendedContext |
7205 | 633 |
withMessage:ex description |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
634 |
mayProceed:true. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
635 |
ex proceedWith:proceedValue |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
636 |
]. |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
637 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
638 |
"/ (ex signal) enterDebuggerWith:ex message:what. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
639 |
ex reject |
3584
099a64bc9b63
support for V'Age fileIn (application stuff)
Claus Gittinger <cg@exept.de>
parents:
3580
diff
changeset
|
640 |
] do:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
641 |
[self atEnd] whileFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
642 |
lastValue := self fileInNextChunkNotifying:someone passChunk:passChunk |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7054
diff
changeset
|
643 |
] |
180 | 644 |
]. |
611 | 645 |
^ lastValue |
973 | 646 |
|
4717 | 647 |
"Modified: / 10.9.1999 / 16:54:01 / stefan" |
6201
389dc86fdb80
class based exceptions - no longer need to send #haltSÃgnal
Claus Gittinger <cg@exept.de>
parents:
6180
diff
changeset
|
648 |
"Modified: / 16.11.2001 / 16:21:28 / cg" |
5302 | 649 |
! |
650 |
||
7573 | 651 |
fileIn |
652 |
"file in from the receiver, i.e. read chunks and evaluate them - |
|
653 |
return the value of the last chunk." |
|
654 |
||
655 |
|notifiedLoader| |
|
656 |
||
657 |
SourceFileLoader notNil ifTrue:[ |
|
658 |
notifiedLoader := SourceFileLoader on:self. |
|
659 |
]. |
|
660 |
||
661 |
^ self fileInNotifying:notifiedLoader passChunk:true. |
|
662 |
! |
|
663 |
||
664 |
fileInBinary |
|
665 |
"file in from the receiver, i.e. read binary stored classes and/or objects. |
|
666 |
Return the last object." |
|
667 |
||
668 |
|bos obj| |
|
669 |
||
670 |
bos := BinaryObjectStorage onOld:self. |
|
671 |
Class nameSpaceQuerySignal |
|
672 |
answer:Smalltalk |
|
673 |
do:[ |
|
674 |
[self atEnd] whileFalse:[ |
|
675 |
obj := bos next. |
|
676 |
] |
|
677 |
]. |
|
678 |
bos close. |
|
679 |
^ obj |
|
680 |
||
681 |
"Created: / 13.11.2001 / 10:12:30 / cg" |
|
682 |
"Modified: / 13.11.2001 / 10:14:04 / cg" |
|
683 |
! |
|
684 |
||
685 |
fileInNextChunkNotifying:someone |
|
686 |
"read next chunk, evaluate it and return the result; |
|
687 |
someone (which is usually some codeView) is notified of errors. |
|
688 |
Filein is done as follows: |
|
689 |
read a chunk |
|
690 |
if it started with an excla, evaluate it, and let the resulting object |
|
691 |
fileIn more chunks. |
|
692 |
This is a nice trick, since the methodsFor: expression evaluates to |
|
693 |
a ClassCategoryReader which reads and compiles chunks for its class. |
|
694 |
However, other than methodsFor expressions are possible - you can |
|
695 |
(in theory) create readers for any syntax. |
|
696 |
" |
|
697 |
||
698 |
^ self fileInNextChunkNotifying:someone passChunk:false |
|
699 |
! |
|
700 |
||
701 |
fileInNextChunkNotifying:someone passChunk:passChunk |
|
702 |
"read next chunk, evaluate it and return the result; |
|
703 |
someone (which is usually some codeView) is notified of errors. |
|
704 |
Filein is done as follows: |
|
705 |
read a chunk |
|
706 |
if it started with an excla, evaluate it, and let the resulting object |
|
707 |
fileIn more chunks. |
|
708 |
This is a nice trick, since the methodsFor: expression evaluates to |
|
709 |
a ClassCategoryReader which reads and compiles chunks for its class. |
|
710 |
However, other than methodsFor expressions are possible - you can |
|
711 |
(in theory) create readers for any syntax. |
|
712 |
" |
|
713 |
||
714 |
^ self fileInNextChunkNotifying:someone passChunk:passChunk silent:nil |
|
715 |
! |
|
716 |
||
717 |
fileInNextChunkNotifying:someone passChunk:passChunk silent:beSilent |
|
718 |
"read next chunk, evaluate it and return the result; |
|
719 |
someone (which is usually some codeView) is notified of errors. |
|
720 |
Filein is done as follows: |
|
721 |
read a chunk |
|
722 |
if it started with an excla, evaluate it, and let the resulting object |
|
723 |
fileIn more chunks. |
|
724 |
This is a nice trick, since the methodsFor: expression evaluates to |
|
725 |
a ClassCategoryReader which reads and compiles chunks for its class. |
|
726 |
However, other than methodsFor expressions are possible - you can |
|
727 |
(in theory) create readers for any syntax. |
|
728 |
" |
|
729 |
||
730 |
|aString sawExcla rslt done| |
|
731 |
||
732 |
self skipSeparators. |
|
733 |
self atEnd ifFalse:[ |
|
734 |
sawExcla := self peekFor:(self class chunkSeparator). |
|
735 |
aString := self nextChunk. |
|
736 |
"/ |
|
737 |
"/ handle empty chunks; |
|
738 |
"/ this allows for Squeak code to be filedIn |
|
739 |
"/ |
|
740 |
[aString size == 0 |
|
741 |
and:[self atEnd not]] whileTrue:[ |
|
742 |
aString := self nextChunk. |
|
743 |
]. |
|
744 |
aString size ~~ 0 ifTrue:[ |
|
745 |
passChunk ifTrue:[ |
|
746 |
someone notNil ifTrue:[someone source:aString] |
|
747 |
]. |
|
748 |
sawExcla ifFalse:[ |
|
749 |
rslt := Smalltalk::Compiler evaluate:aString notifying:someone. |
|
750 |
] ifTrue:[ |
|
751 |
Smalltalk::Compiler emptySourceNotificationSignal handle:[:ex | |
|
752 |
^ nil |
|
753 |
] do:[ |
|
754 |
rslt := Smalltalk::Compiler evaluate:aString notifying:someone compile:false. |
|
755 |
]. |
|
756 |
||
757 |
" |
|
758 |
usually, the above chunk consists of some methodsFor:-expression |
|
759 |
in this case, the returned value is a ClassCategoryReader, |
|
760 |
which is used to load & compile the methods ... |
|
761 |
" |
|
762 |
rslt isNil ifTrue:[ |
|
763 |
" |
|
764 |
however, if that was nil (i.e. some error), we skip chunks |
|
765 |
up to the next empty chunk. |
|
766 |
" |
|
767 |
Transcript showCR:'skipping chunks ...'. |
|
768 |
done := false. |
|
769 |
[done] whileFalse:[ |
|
770 |
aString := self nextChunk. |
|
771 |
done := (aString size == 0). |
|
772 |
] |
|
773 |
] ifFalse:[ |
|
774 |
rslt := rslt |
|
775 |
fileInFrom:self |
|
776 |
notifying:someone |
|
777 |
passChunk:passChunk |
|
778 |
single:false |
|
779 |
silent:beSilent |
|
780 |
] |
|
781 |
] |
|
782 |
] |
|
783 |
]. |
|
784 |
^ rslt |
|
785 |
||
786 |
"Modified: 14.10.1997 / 17:10:35 / cg" |
|
787 |
! |
|
788 |
||
789 |
fileInNotifying:notifiedLoader passChunk:passChunk |
|
790 |
"central method to file in from the receiver, i.e. read chunks and evaluate them - |
|
791 |
return the value of the last chunk. |
|
792 |
Someone (which is usually some codeView) is notified of errors." |
|
793 |
||
794 |
self isFileStream ifFalse:[ |
|
795 |
^ self basicFileInNotifying:notifiedLoader passChunk:passChunk. |
|
796 |
]. |
|
797 |
||
798 |
^ self fileInNotifying:notifiedLoader passChunk:passChunk inDirectory:(self pathName asFilename directory). |
|
799 |
! |
|
800 |
||
801 |
fileInNotifying:notifiedLoader passChunk:passChunk inDirectory:aDirectory |
|
802 |
"central method to file in from the receiver, i.e. read chunks and evaluate them - |
|
803 |
return the value of the last chunk. |
|
804 |
Someone (which is usually some codeView) is notified of errors." |
|
805 |
||
806 |
|oldPath val| |
|
807 |
||
808 |
[ |
|
809 |
|thisDirectory| |
|
810 |
||
811 |
thisDirectory := aDirectory asFilename. |
|
812 |
||
813 |
oldPath := Smalltalk systemPath. |
|
814 |
Smalltalk systemPath:(oldPath copy addFirst:thisDirectory pathName; yourself). |
|
815 |
CurrentFileInDirectoryQuerySignal answer:thisDirectory do:[ |
|
816 |
val := self basicFileInNotifying:notifiedLoader passChunk:passChunk. |
|
817 |
] |
|
818 |
] ensure:[ |
|
819 |
Smalltalk systemPath:oldPath. |
|
820 |
]. |
|
821 |
^ val |
|
822 |
! |
|
823 |
||
5302 | 824 |
fileInXMLNotifying:someone passChunk:passChunk |
825 |
"filein an XML source file (format as in campSmalltalk DTD)" |
|
826 |
||
827 |
| builder parser| |
|
828 |
||
6093 | 829 |
(XML isNil or:[XML::SourceNodeBuilder isNil or:[XML::XMLParser isNil]]) ifTrue:[ |
7226 | 830 |
Smalltalk loadPackage:'stx:goodies/xml/vw'. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
831 |
(XML isNil or:[XML::SourceNodeBuilder isNil or:[XML::XMLParser isNil]]) ifTrue:[ |
7226 | 832 |
self error:'Could not load XML package(s) from ''stx:goodies/xml/vw'''. |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
833 |
] |
6003 | 834 |
]. |
835 |
||
6093 | 836 |
builder := XML::SourceNodeBuilder new. |
837 |
parser := XML::XMLParser on:self. |
|
5302 | 838 |
parser builder:builder. |
839 |
parser validate:false. |
|
840 |
parser scanDocument. |
|
6093 | 841 |
"/ self halt. |
611 | 842 |
! ! |
843 |
||
844 |
!PositionableStream methodsFor:'positioning'! |
|
845 |
||
846 |
backStep |
|
847 |
"move backward read position by one" |
|
848 |
||
4405 | 849 |
self position:(self position - 1) |
611 | 850 |
! |
851 |
||
852 |
position |
|
853 |
"return the read position" |
|
854 |
||
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
855 |
ZeroPosition == 0 ifTrue:[ |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
856 |
^ self position0Based |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
857 |
] ifFalse:[ |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
858 |
^ self position1Based |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
859 |
]. |
611 | 860 |
! |
861 |
||
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
862 |
position0Based |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
863 |
"return the read position 0-based" |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
864 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
865 |
^ position - ZeroPosition |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
866 |
! |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
867 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
868 |
position0Based:index0Based |
4405 | 869 |
"set the read (or write) position" |
611 | 870 |
|
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
871 |
((index0Based > readLimit) or:[index0Based < 0]) ifTrue: [^ self positionError:index0Based]. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
872 |
position := index0Based + ZeroPosition |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
873 |
! |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
874 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
875 |
position1Based |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
876 |
"return the read position 1-based" |
611 | 877 |
|
7053
13e04c48e23c
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7052
diff
changeset
|
878 |
^ self position0Based + 1 |
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
879 |
! |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
880 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
881 |
position1Based:index1Based |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
882 |
"set the read (or write) position" |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
883 |
|
7053
13e04c48e23c
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7052
diff
changeset
|
884 |
self position0Based:(index1Based - 1) |
4405 | 885 |
|
886 |
" |
|
887 |
|s| |
|
888 |
||
889 |
s := '1234567890' readStream. |
|
890 |
s next:5. |
|
891 |
s position:1. |
|
892 |
s next:7. |
|
893 |
" |
|
894 |
||
895 |
" |
|
896 |
|s| |
|
897 |
||
898 |
s := '' writeStream. |
|
899 |
s nextPutAll:'1234567890'. |
|
900 |
s position:5. |
|
901 |
s nextPutAll:'abcdefg'. |
|
902 |
s contents |
|
903 |
" |
|
904 |
||
905 |
" |
|
906 |
|s| |
|
907 |
||
908 |
s := '' writeStream. |
|
909 |
s nextPutAll:'1234567890'. |
|
910 |
s position:0. |
|
911 |
s nextPutAll:'abcdefg'. |
|
912 |
s contents |
|
913 |
" |
|
611 | 914 |
! |
915 |
||
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
916 |
position:newPos |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
917 |
"set the read (or write) position" |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
918 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
919 |
ZeroPosition == 0 ifTrue:[ |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
920 |
^ self position0Based:newPos |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
921 |
] ifFalse:[ |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
922 |
^ self position1Based:newPos |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
923 |
]. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
924 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
925 |
" |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
926 |
|s| |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
927 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
928 |
s := '1234567890' readStream. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
929 |
s next:5. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
930 |
s position:1. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
931 |
s next:7. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
932 |
" |
6626
f7b08d6bee3f
#positionStartingAt0 and #positionStartingAt1
Stefan Vogel <sv@exept.de>
parents:
6538
diff
changeset
|
933 |
|
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
934 |
" |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
935 |
|s| |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
936 |
|
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
937 |
s := '' writeStream. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
938 |
s nextPutAll:'1234567890'. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
939 |
s position:5. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
940 |
s nextPutAll:'abcdefg'. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
941 |
s contents |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
942 |
" |
6626
f7b08d6bee3f
#positionStartingAt0 and #positionStartingAt1
Stefan Vogel <sv@exept.de>
parents:
6538
diff
changeset
|
943 |
|
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
944 |
" |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
945 |
|s| |
6626
f7b08d6bee3f
#positionStartingAt0 and #positionStartingAt1
Stefan Vogel <sv@exept.de>
parents:
6538
diff
changeset
|
946 |
|
7052
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
947 |
s := '' writeStream. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
948 |
s nextPutAll:'1234567890'. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
949 |
s position:0. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
950 |
s nextPutAll:'abcdefg'. |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
951 |
s contents |
207cc9c62982
prep for 0-based stream position
Claus Gittinger <cg@exept.de>
parents:
7051
diff
changeset
|
952 |
" |
6626
f7b08d6bee3f
#positionStartingAt0 and #positionStartingAt1
Stefan Vogel <sv@exept.de>
parents:
6538
diff
changeset
|
953 |
! |
f7b08d6bee3f
#positionStartingAt0 and #positionStartingAt1
Stefan Vogel <sv@exept.de>
parents:
6538
diff
changeset
|
954 |
|
611 | 955 |
reset |
956 |
"set the read position to the beginning of the collection" |
|
957 |
||
5308 | 958 |
self resetPosition |
959 |
||
960 |
" |
|
961 |
|s| |
|
962 |
||
963 |
s := 'hello world' readStream. |
|
964 |
Transcript showCR:(s next:5). |
|
965 |
s reset. |
|
966 |
Transcript showCR:(s next:10). |
|
967 |
" |
|
968 |
! |
|
969 |
||
970 |
resetPosition |
|
971 |
"set the read position to the beginning of the collection" |
|
972 |
||
7114 | 973 |
position := ZeroPosition |
4405 | 974 |
|
975 |
" |
|
976 |
|s| |
|
977 |
||
978 |
s := 'hello world' readStream. |
|
979 |
Transcript showCR:(s next:5). |
|
980 |
s reset. |
|
981 |
Transcript showCR:(s next:10). |
|
982 |
" |
|
611 | 983 |
! |
984 |
||
985 |
setToEnd |
|
986 |
"set the read position to the end of the collection" |
|
987 |
||
7114 | 988 |
position := readLimit - 1 + ZeroPosition |
611 | 989 |
! |
990 |
||
991 |
skip:numberToSkip |
|
992 |
"skip the next numberToSkip elements" |
|
993 |
||
5774 | 994 |
numberToSkip ~~ 0 ifTrue:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
995 |
self position:(self position + numberToSkip) |
5774 | 996 |
] |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
997 |
! |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
998 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
999 |
skipThroughAll:aCollection |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1000 |
"skip for and through the sequence given by the argument, aCollection; |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1001 |
return nil if not found, self otherwise. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1002 |
On a successful match, the next read will return elements after aCollection; |
2153
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1003 |
if no match was found, the receiver will be positioned at the end. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1004 |
This is redefined here, to make use of positioning." |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1005 |
|
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1006 |
|buffer len first idx| |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1007 |
|
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1008 |
len := aCollection size. |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1009 |
first := aCollection at:1. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1010 |
[self atEnd] whileFalse:[ |
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1011 |
buffer := self nextAvailable:len. |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1012 |
buffer = aCollection ifTrue:[ |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1013 |
^ self |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1014 |
]. |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1015 |
idx := buffer indexOf:first startingAt:2. |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1016 |
idx == 0 ifFalse:[ |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1017 |
self position:(self position - len + idx - 1) |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1018 |
] |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1019 |
]. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1020 |
^ nil |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1021 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1022 |
" |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1023 |
|s| |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1024 |
s := ReadStream on:'12345678901234567890'. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1025 |
s skipThroughAll:'901'. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1026 |
s upToEnd |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1027 |
" |
2153
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1028 |
" |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1029 |
|s| |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1030 |
s := ReadStream on:'12345678901234567890'. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1031 |
s skipThroughAll:'1234'. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1032 |
s upToEnd |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1033 |
" |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1034 |
" |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1035 |
|s| |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1036 |
s := ReadStream on:'12345678901234567890'. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1037 |
s skipThroughAll:'999'. |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1038 |
s atEnd |
244e36cbbd9b
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2130
diff
changeset
|
1039 |
" |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1040 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1041 |
"Created: 26.6.1996 / 09:35:35 / cg" |
2154
89e96599e1e2
skipThroughAll: does not need the old position
Claus Gittinger <cg@exept.de>
parents:
2153
diff
changeset
|
1042 |
"Modified: 11.1.1997 / 19:16:38 / cg" |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1043 |
! |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1044 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1045 |
skipToAll:aCollection |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1046 |
"skip for the sequence given by the argument, aCollection; |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1047 |
return nil if not found, self otherwise. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1048 |
On a successful match, the next read will return elements of aCollection." |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1049 |
|
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1050 |
|oldPos buffer len first idx| |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1051 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1052 |
oldPos := self position. |
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1053 |
len := aCollection size. |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1054 |
first := aCollection at:1. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1055 |
[self atEnd] whileFalse:[ |
7054
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1056 |
buffer := self next:len. |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1057 |
buffer = aCollection ifTrue:[ |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1058 |
self position:(self position - len). |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1059 |
^ self |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1060 |
]. |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1061 |
idx := buffer indexOf:first startingAt:2. |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1062 |
idx == 0 ifFalse:[ |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1063 |
self position:(self position - len + idx - 1) |
685d359f9847
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
7053
diff
changeset
|
1064 |
] |
1489
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1065 |
]. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1066 |
self position:oldPos. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1067 |
^ nil |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1068 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1069 |
" |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1070 |
|s| |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1071 |
s := ReadStream on:'12345678901234567890'. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1072 |
s skipToAll:'901'. |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1073 |
s upToEnd |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1074 |
" |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1075 |
|
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1076 |
"Modified: 26.6.1996 / 09:28:27 / cg" |
9e3b166483fb
moved some skip methods from readStream;
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
1077 |
"Created: 26.6.1996 / 09:35:06 / cg" |
44 | 1078 |
! ! |
611 | 1079 |
|
1080 |
!PositionableStream methodsFor:'private'! |
|
1081 |
||
1082 |
contentsSpecies |
|
1083 |
"return a class of which instances will be returned, when |
|
1084 |
parts of the collection are asked for. |
|
1085 |
(see upTo-kind of methods in subclasses)" |
|
1086 |
||
1087 |
^ collection species |
|
1088 |
! |
|
1089 |
||
1090 |
on:aCollection |
|
1091 |
"setup for streaming on aCollection" |
|
1092 |
||
1093 |
collection := aCollection. |
|
1094 |
readLimit := aCollection size. |
|
7114 | 1095 |
position := ZeroPosition |
611 | 1096 |
! |
1097 |
||
1098 |
on:aCollection from:first to:last |
|
1099 |
"setup for streaming on aCollection from first to last" |
|
1100 |
||
1101 |
collection := aCollection. |
|
7114 | 1102 |
position := first - 1 + ZeroPosition. |
611 | 1103 |
readLimit := last |
1104 |
! |
|
1105 |
||
1106 |
positionError |
|
1998 | 1107 |
"{ Pragma: +optSpace }" |
1108 |
||
2966 | 1109 |
"report an error when positioning past the end |
1110 |
or before the beginning." |
|
611 | 1111 |
|
4559 | 1112 |
^ InvalidPositionErrorSignal raiseRequestWith:nil |
4452
3d050f505a0a
Raise proceedable signals proceedable.
Stefan Vogel <sv@exept.de>
parents:
4416
diff
changeset
|
1113 |
|
3d050f505a0a
Raise proceedable signals proceedable.
Stefan Vogel <sv@exept.de>
parents:
4416
diff
changeset
|
1114 |
"Modified: / 26.7.1999 / 10:59:13 / stefan" |
611 | 1115 |
! |
1116 |
||
6314 | 1117 |
positionError:badPostition |
1118 |
"{ Pragma: +optSpace }" |
|
1119 |
||
1120 |
"report an error when positioning past the end |
|
1121 |
or before the beginning." |
|
1122 |
||
1123 |
^ InvalidPositionErrorSignal raiseRequestWith:badPostition |
|
1124 |
! |
|
1125 |
||
611 | 1126 |
with:aCollection |
1127 |
"setup for streaming to the end of aCollection" |
|
1128 |
||
1129 |
collection := aCollection. |
|
6230 | 1130 |
readLimit := aCollection size + 1. |
611 | 1131 |
self setToEnd |
1132 |
! ! |
|
1133 |
||
1134 |
!PositionableStream methodsFor:'queries'! |
|
1135 |
||
1136 |
isPositionable |
|
1137 |
"return true, if the stream supports positioning (this one is)" |
|
1138 |
||
1139 |
^ true |
|
1140 |
! ! |
|
1141 |
||
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1142 |
!PositionableStream methodsFor:'reading'! |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1143 |
|
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1144 |
upToAll:aCollection |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1145 |
"read until a subcollection consisisting of the elements in aCollection |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1146 |
is encountered. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1147 |
Return everything read excluding the elements in aCollection. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1148 |
The position is left before the collection; i.e. the next |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1149 |
read operations will return those elements. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1150 |
If no such subcollection is encountered, all elements up to the end |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1151 |
are read and returned. |
6494 | 1152 |
See also #throughAll: which also reads up to some objects |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1153 |
but positions behind it and DOES include it in the returned |
3184
d99302322139
Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents:
3170
diff
changeset
|
1154 |
collection. |
6494 | 1155 |
See also #upToAllExcluding:, which returns the same, but leaves the |
1156 |
read pointer after the matched subcollection. |
|
3184
d99302322139
Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents:
3170
diff
changeset
|
1157 |
|
d99302322139
Ok, #upToAll: positions after the collection.
Stefan Vogel <sv@exept.de>
parents:
3170
diff
changeset
|
1158 |
Note: this behavior is inconsistent with the other upTo.. methods, |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1159 |
which position after the found item. We implement the method |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1160 |
this way for the sake of ST80-compatibility." |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1161 |
|
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1162 |
|answerStream element last rslt| |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1163 |
|
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1164 |
last := aCollection last. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1165 |
answerStream := WriteStream on:(self contentsSpecies new). |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1166 |
[self atEnd] whileFalse:[ |
7051
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1167 |
element := self next. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1168 |
answerStream nextPut:element. |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1169 |
element == last ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1170 |
((rslt := answerStream contents) endsWith:aCollection) ifTrue:[ |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1171 |
self position:(self position - aCollection size). |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1172 |
^ rslt copyWithoutLast:aCollection size |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1173 |
] |
984d8271d06b
preps for 0-based stream positions
Claus Gittinger <cg@exept.de>
parents:
6924
diff
changeset
|
1174 |
]. |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1175 |
]. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1176 |
^ answerStream contents |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1177 |
|
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1178 |
" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1179 |
|s| |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1180 |
s := ReadStream on:'hello world'. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1181 |
Transcript show:'<'; show:(s upToAll:'wo'); showCR:'>'. |
6494 | 1182 |
Transcript showCR:s atEnd. |
3170
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1183 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1184 |
" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1185 |
" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1186 |
|s| |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1187 |
s := ReadStream on:'hello world'. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1188 |
Transcript show:'<'; show:(s upToAll:'xx'); showCR:'>'. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1189 |
Transcript showCR:s atEnd. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1190 |
Transcript show:'<'; show:(s upToEnd); showCR:'>'. |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1191 |
" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1192 |
|
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1193 |
"Modified: / 12.1.1998 / 22:06:42 / cg" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1194 |
"Created: / 12.1.1998 / 22:07:01 / cg" |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1195 |
! ! |
7b299d83c45a
moved upToAll: to positionableStream.
Claus Gittinger <cg@exept.de>
parents:
3032
diff
changeset
|
1196 |
|
611 | 1197 |
!PositionableStream methodsFor:'testing'! |
1198 |
||
1199 |
atEnd |
|
1200 |
"return true, if the read-position is at the end" |
|
1201 |
||
7114 | 1202 |
^ (position - ZeroPosition + 1) > readLimit |
611 | 1203 |
! |
1204 |
||
1205 |
isEmpty |
|
1206 |
"return true, if the contents of the stream is empty" |
|
1207 |
||
1208 |
^ readLimit == 0 |
|
1209 |
! ! |
|
1210 |
||
1897 | 1211 |
!PositionableStream class methodsFor:'documentation'! |
701 | 1212 |
|
1213 |
version |
|
7573 | 1214 |
^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.132 2003-08-23 12:09:21 cg Exp $' |
701 | 1215 |
! ! |
6777
5efddf5358b2
currentFileInDirectory query
Claus Gittinger <cg@exept.de>
parents:
6707
diff
changeset
|
1216 |
|
611 | 1217 |
PositionableStream initialize! |