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