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