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