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