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