author | Claus Gittinger <cg@exept.de> |
Tue, 14 Nov 2017 23:00:36 +0100 | |
changeset 4528 | 844e085a7ac1 |
parent 4480 | 3149cd46d7d1 |
child 4619 | 7e627429f1c6 |
permissions | -rw-r--r-- |
2337
755696d72648
comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents:
2303
diff
changeset
|
1 |
"{ Package: 'stx:libbasic2' }"! |
1668 | 2 |
|
4381 | 3 |
!ArithmeticValue methodsFor:'converting'! |
4 |
||
5 |
asQDouble |
|
6 |
"return a QDouble with same value" |
|
7 |
||
4480 | 8 |
^ QDouble fromFloat:self asFloat |
4381 | 9 |
|
10 |
" |
|
11 |
123 asQDouble |
|
4480 | 12 |
(Fraction basicNew setNumerator:246 denominator:2) asQDouble |
13 |
123 asLongFloat asQDouble |
|
14 |
123 asLargeFloat asQDouble |
|
4381 | 15 |
" |
16 |
||
17 |
"Created: / 13-06-2017 / 16:48:24 / cg" |
|
4480 | 18 |
"Modified (comment): / 25-07-2017 / 16:06:19 / cg" |
4381 | 19 |
! ! |
20 |
||
4379
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
21 |
!ArithmeticValue methodsFor:'double dispatching'! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
22 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
23 |
differenceFromQDouble:aQDouble |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
24 |
"aQDouble does not know how to subtract the receiver - |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
25 |
retry the operation by coercing to higher generality" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
26 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
27 |
^ aQDouble retry:#- coercing:self |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
28 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
29 |
"Created: / 13-06-2017 / 08:55:38 / cg" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
30 |
! ! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
31 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
32 |
!ArithmeticValue methodsFor:'double dispatching'! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
33 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
34 |
equalFromQDouble:aQDouble |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
35 |
"aQDouble does not know how to compare to the receiver - |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
36 |
retry the operation by coercing to higher generality" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
37 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
38 |
^ aQDouble retry:#= coercing:self |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
39 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
40 |
"Created: / 13-06-2017 / 08:55:30 / cg" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
41 |
! ! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
42 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
43 |
!ArithmeticValue methodsFor:'double dispatching'! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
44 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
45 |
lessFromQDouble:aQDouble |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
46 |
"aQDouble does not know how to compare to the receiver - |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
47 |
Return true if aQDouble < self. |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
48 |
retry the operation by coercing to higher generality" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
49 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
50 |
^ aQDouble retry:#< coercing:self |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
51 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
52 |
"Created: / 13-06-2017 / 08:55:20 / cg" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
53 |
! ! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
54 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
55 |
!ArithmeticValue methodsFor:'double dispatching'! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
56 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
57 |
productFromQDouble:aQDouble |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
58 |
"aQDouble does not know how to multiply the receiver - |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
59 |
retry the operation by coercing to higher generality" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
60 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
61 |
^ aQDouble retry:#* coercing:self |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
62 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
63 |
"Created: / 13-06-2017 / 08:55:07 / cg" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
64 |
! ! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
65 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
66 |
!ArithmeticValue methodsFor:'double dispatching'! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
67 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
68 |
quotientFromQDouble:aQDouble |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
69 |
"aQDouble does not know how to divide by the receiver - |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
70 |
retry the operation by coercing to higher generality" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
71 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
72 |
^ aQDouble retry:#/ coercing:self |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
73 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
74 |
"Created: / 13-06-2017 / 08:54:55 / cg" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
75 |
! ! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
76 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
77 |
!ArithmeticValue methodsFor:'double dispatching'! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
78 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
79 |
remainderFromQDouble:aQDouble |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
80 |
"aQDouble does not know how to compute the remainder with the receiver - |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
81 |
retry the operation by coercing to higher generality" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
82 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
83 |
^ aQDouble retry:#rem: coercing:self |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
84 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
85 |
"Created: / 13-06-2017 / 08:54:47 / cg" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
86 |
! ! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
87 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
88 |
!ArithmeticValue methodsFor:'double dispatching'! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
89 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
90 |
sumFromQDouble:aQDouble |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
91 |
"aQDouble does not know how to add the receiver - |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
92 |
retry the operation by coercing to higher generality" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
93 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
94 |
^ aQDouble retry:#+ coercing:self |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
95 |
|
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
96 |
"Created: / 13-06-2017 / 08:54:27 / cg" |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
97 |
! ! |
e547154fa694
double dispatch for QDoubles
Claus Gittinger <cg@exept.de>
parents:
4365
diff
changeset
|
98 |
|
4448 | 99 |
!Block methodsFor:'Compatibility-Dolphin'! |
100 |
||
101 |
deferredValue |
|
102 |
"Dolphin compatibility method - do not use in new code. |
|
103 |
Dolphin's alias for futureValue" |
|
104 |
||
105 |
^ Future new block:self |
|
106 |
||
107 |
"Modified: / 04-10-2011 / 14:56:27 / cg" |
|
108 |
! ! |
|
109 |
||
110 |
!Block methodsFor:'Compatibility-Dolphin'! |
|
111 |
||
112 |
deferredValueAt:priority |
|
113 |
"Dolphin compatibility method - do not use in new code. |
|
114 |
Dolphin's alias for futureValue" |
|
115 |
||
116 |
^ Future new |
|
117 |
priority:priority block:self |
|
118 |
||
119 |
"Created: / 04-10-2011 / 14:55:56 / cg" |
|
120 |
! ! |
|
121 |
||
122 |
!Block methodsFor:'parallel evaluation'! |
|
123 |
||
124 |
futureValue |
|
125 |
"Fork a synchronised evaluation of myself. |
|
126 |
Starts the evaluation in parallel now, but synchronizes |
|
127 |
any access to wait until the result is computed." |
|
128 |
||
129 |
^ Future new block:self |
|
130 |
! ! |
|
131 |
||
132 |
!Block methodsFor:'parallel evaluation'! |
|
133 |
||
134 |
futureValue:aValue |
|
135 |
"Fork a synchronised evaluation of myself. |
|
136 |
Starts the evaluation in parallel now, but synchronizes |
|
137 |
any access to wait until the result is computed." |
|
138 |
||
139 |
^ Future new block:self value:aValue |
|
140 |
! ! |
|
141 |
||
142 |
!Block methodsFor:'parallel evaluation'! |
|
143 |
||
144 |
futureValue:aValue value:anotherValue |
|
145 |
"Fork a synchronised evaluation of myself. |
|
146 |
Starts the evaluation in parallel now, but synchronizes |
|
147 |
any access to wait until the result is computed." |
|
148 |
||
149 |
^ Future new |
|
150 |
block:self |
|
151 |
value:aValue |
|
152 |
value:anotherValue |
|
153 |
! ! |
|
154 |
||
155 |
!Block methodsFor:'parallel evaluation'! |
|
156 |
||
157 |
futureValue:aValue value:anotherValue value:bValue |
|
158 |
"Fork a synchronised evaluation of myself. |
|
159 |
Starts the evaluation in parallel now, but synchronizes |
|
160 |
any access to wait until the result is computed." |
|
161 |
||
162 |
^ Future new |
|
163 |
block:self |
|
164 |
value:aValue |
|
165 |
value:anotherValue |
|
166 |
value:bValue |
|
167 |
! ! |
|
168 |
||
169 |
!Block methodsFor:'parallel evaluation'! |
|
170 |
||
171 |
futureValueWithArguments:anArray |
|
172 |
"Fork a synchronised evaluation of myself. |
|
173 |
Starts the evaluation in parallel now, but synchronizes |
|
174 |
any access to wait until the result is computed." |
|
175 |
||
176 |
^ Future new |
|
177 |
block:self |
|
178 |
valueWithArguments:anArray |
|
179 |
||
180 |
"Modified (format): / 04-10-2011 / 14:55:40 / cg" |
|
181 |
! ! |
|
182 |
||
183 |
!Block methodsFor:'parallel evaluation'! |
|
184 |
||
185 |
lazyValue |
|
186 |
"Fork a synchronised evaluation of myself. Only starts |
|
187 |
the evaluation when the result is requested." |
|
188 |
||
189 |
^ Lazy new block:self |
|
190 |
! ! |
|
191 |
||
192 |
!Block methodsFor:'parallel evaluation'! |
|
193 |
||
194 |
lazyValue:aValue |
|
195 |
"Fork a synchronised evaluation of myself. Only starts |
|
196 |
the evaluation when the result is requested." |
|
197 |
||
198 |
^ Lazy new block:self value:aValue |
|
199 |
! ! |
|
200 |
||
201 |
!Block methodsFor:'parallel evaluation'! |
|
202 |
||
203 |
lazyValue:aValue value:anotherValue |
|
204 |
"Fork a synchronised evaluation of myself. Only starts |
|
205 |
the evaluation when the result is requested." |
|
206 |
||
207 |
^ Lazy new |
|
208 |
block:self |
|
209 |
value:aValue |
|
210 |
value:anotherValue |
|
211 |
! ! |
|
212 |
||
213 |
!Block methodsFor:'parallel evaluation'! |
|
214 |
||
215 |
lazyValue:aValue value:anotherValue value:bValue |
|
216 |
"Fork a synchronised evaluation of myself. Only starts |
|
217 |
the evaluation when the result is requested." |
|
218 |
||
219 |
^ Lazy new |
|
220 |
block:self |
|
221 |
value:aValue |
|
222 |
value:anotherValue |
|
223 |
value:bValue |
|
224 |
! ! |
|
225 |
||
226 |
!Block methodsFor:'parallel evaluation'! |
|
227 |
||
228 |
lazyValueWithArguments:anArray |
|
229 |
"Fork a synchronised evaluation of myself. Only starts |
|
230 |
the evaluation when the result is requested." |
|
231 |
||
232 |
^ Lazy new block:self valueWithArguments:anArray |
|
233 |
! ! |
|
234 |
||
235 |
!Block methodsFor:'process creation'! |
|
236 |
||
237 |
promise |
|
238 |
"create a promise on the receiver. The promise will evaluate the |
|
239 |
receiver and promise to return the value with the #value message. |
|
240 |
The evaluation will be performed as a separate process. |
|
241 |
Asking the promise for its value will either block the asking process |
|
242 |
(if the evaluation has not yet been finished) or return the value |
|
243 |
immediately." |
|
244 |
||
245 |
^ Promise value:self |
|
246 |
||
247 |
" |
|
248 |
|p| |
|
249 |
||
250 |
p := [1000 factorial] promise. |
|
251 |
'do something else ...'. |
|
252 |
p value |
|
253 |
" |
|
254 |
! ! |
|
255 |
||
256 |
!Block methodsFor:'process creation'! |
|
257 |
||
258 |
promiseAt:prio |
|
259 |
"create a promise on the receiver. The promise will evaluate the |
|
260 |
receiver and promise to return the value with the #value message. |
|
261 |
The evaluation will be performed as a separate process running at prio. |
|
262 |
Asking the promise for its value will either block the asking process |
|
263 |
(if the evaluation has not yet been finished) or return the value |
|
264 |
immediately." |
|
265 |
||
266 |
^ Promise value:self priority:prio |
|
267 |
! ! |
|
268 |
||
2288 | 269 |
!CharacterArray methodsFor:'matching - phonetic'! |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
270 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
271 |
asKoelnerPhoneticCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
272 |
"return a koelner phonetic code. |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
273 |
The koelnerPhonetic code is for the german language what the soundex code is for english; |
2303 | 274 |
it returns simular strings for similar sounding words. |
275 |
There are some differences to soundex, though: |
|
276 |
its length is not limited to 4, but depends on the length of the original string; |
|
277 |
it does not start with the first character of the input. |
|
2288 | 278 |
|
279 |
Caveat: this phonetic code is especially suited for german words. |
|
2303 | 280 |
Please have a look at the other phonetic comparison operators found |
281 |
in PhoneticStringUtilities." |
|
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
282 |
|
2303 | 283 |
^ PhoneticStringUtilities koelnerPhoneticCodeOf:self |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
284 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
285 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
286 |
#( |
3715 | 287 |
'Müller' |
2303 | 288 |
'Miller' |
289 |
'Mueller' |
|
3715 | 290 |
'Mühler' |
291 |
'Mühlherr' |
|
292 |
'Mülherr' |
|
2303 | 293 |
'Myler' |
294 |
'Millar' |
|
295 |
'Myller' |
|
3715 | 296 |
'Müllar' |
297 |
'Müler' |
|
2303 | 298 |
'Muehler' |
3715 | 299 |
'Mülller' |
300 |
'Müllerr' |
|
2303 | 301 |
'Muehlherr' |
302 |
'Muellar' |
|
303 |
'Mueler' |
|
3715 | 304 |
'Mülleer' |
2303 | 305 |
'Mueller' |
3715 | 306 |
'Nüller' |
2303 | 307 |
'Nyller' |
308 |
'Niler' |
|
309 |
'Czerny' |
|
310 |
'Tscherny' |
|
311 |
'Czernie' |
|
312 |
'Tschernie' |
|
313 |
'Schernie' |
|
314 |
'Scherny' |
|
315 |
'Scherno' |
|
316 |
'Czerne' |
|
317 |
'Zerny' |
|
318 |
'Tzernie' |
|
319 |
'Breschnew' |
|
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
320 |
) do:[:w | |
2303 | 321 |
Transcript show:w; show:'->'; showCR:(w asKoelnerPhoneticCode) |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
322 |
]. |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
323 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
324 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
325 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
326 |
'Breschnew' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
327 |
'Breschnew' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
328 |
'Breschneff' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
329 |
'Braeschneff' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
330 |
'Braessneff' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
331 |
'Pressneff' asKoelnerPhoneticCode -> '17863' |
3715 | 332 |
'Presznäph' asKoelnerPhoneticCode -> '17863' |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
333 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
334 |
! ! |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
335 |
|
2288 | 336 |
!CharacterArray methodsFor:'matching - phonetic'! |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
337 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
338 |
asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
339 |
"return a soundex phonetic code or nil. |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
340 |
Soundex returns similar codes for similar sounding words, making it a useful |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
341 |
tool when searching for words where the correct spelling is unknown. |
4190 | 342 |
(read Knuth or search the web if you don't know what a soundex code is). |
2288 | 343 |
|
2337
755696d72648
comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents:
2303
diff
changeset
|
344 |
Caveat: 'similar sounding words' means: 'similar sounding in ENGLISH' |
4190 | 345 |
Please have a look at the other phonetic comparison operators found |
346 |
in PhoneticStringUtilities." |
|
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
347 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
348 |
^ PhoneticStringUtilities soundexCodeOf:self |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
349 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
350 |
" |
2303 | 351 |
'claus' asSoundexCode |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
352 |
'clause' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
353 |
'close' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
354 |
'smalltalk' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
355 |
'smaltalk' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
356 |
'smaltak' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
357 |
'smaltok' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
358 |
'smoltok' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
359 |
'aa' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
360 |
'by' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
361 |
'bab' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
362 |
'bob' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
363 |
'bop' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
364 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
365 |
! ! |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
366 |
|
2241 | 367 |
!CharacterArray methodsFor:'printing & storing'! |
368 |
||
2303 | 369 |
printf:args |
370 |
"Format and print the receiver with <args> formatted in C style, |
|
2295 | 371 |
as specified in the Unix C-language manual page for printf(3). |
3114 | 372 |
Return the resulting string (i.e actually, this is more like an sprintf). |
4528 | 373 |
For smalltalk specific formats, see documentation in PrintfScanf. |
2241 | 374 |
For copyright information, see goodies/String-printf_scanf.chg" |
2303 | 375 |
|
2241 | 376 |
|aStream| |
377 |
||
3538 | 378 |
aStream := CharacterWriteStream on:(self species uninitializedNew:self size). |
2260 | 379 |
self printf:args on:aStream. |
2241 | 380 |
^ aStream contents |
381 |
||
382 |
" |
|
3796 | 383 |
('%05x %d %f %o' printf:{ 123. 234*5. 1.234. 8r377 } ) |
2303 | 384 |
Transcript showCR:('%05x %d %f %o' printf:{ 123. 234*5. 1.234. 8r377 } ) |
2256 | 385 |
" |
386 |
||
387 |
" |
|
2241 | 388 |
Transcript showCR: 'Some examples:'!! |
389 |
||
390 |
Transcript show:'''%#x %#X %03o%*.*s'' printf: #(16rABCD 16rEF 5 9 5 ''ghijklmn'') = .'. |
|
2303 | 391 |
Transcript show: ('%#x %#X %03o%*.*s' printf: #(16rABCD 16rEF 5 9 5 'ghijklmn')). |
2241 | 392 |
Transcript showCR: '.' |
393 |
||
394 |
Transcript show: '''%- 10.4s%.2e'' printf: (Array with: ''abcdefghijkl'' with: Float pi) = .'. |
|
2303 | 395 |
Transcript show: ('%- 10.4s%.2e' printf: (Array with: 'abcdefghijkl' with: Float pi)). |
2241 | 396 |
Transcript showCR: '.' |
397 |
||
398 |
Transcript show: '''%8.3f'' printf: (Array with: 200 sqrt negated) = .'. |
|
399 |
Transcript show: ('%8.3f' printf: (Array with: 200 sqrt negated)). |
|
400 |
Transcript showCR: '.' |
|
401 |
||
402 |
Transcript show: '''%c'' printf: #(16r41) = .'. |
|
403 |
Transcript show: ('%c' printf: #(16r41)). |
|
404 |
Transcript showCR: '.' |
|
405 |
||
406 |
Transcript show: '''%f%2s%s%s%s'' sscanf: ''237.0 this is a test'' = '. |
|
407 |
Transcript showCR: ('%f%2s%s%s%s' sscanf: '237.0 this is a test') printString. |
|
408 |
||
409 |
Transcript show: '''%d%f%s'' sscanf: ''25 54.32e-01 monday'' = '. |
|
410 |
Transcript showCR: ('%d%f%s' sscanf: '25 54.32e-01 monday') printString. |
|
411 |
||
412 |
Transcript show: '''%f%*f %8[A-F0-9]%c%d 0x%x%f'' sscanf: ''12.45 1048.73 AE40Z527 0x75BCD15 34'' = '. |
|
413 |
Transcript showCR: ('%f%*f %8[A-F0-9]%c%d 0x%x%f' sscanf: '12.45 1048.73 AE40Z527 0x75BCD15 34') printString. |
|
414 |
" |
|
4528 | 415 |
|
416 |
"Modified (comment): / 14-11-2017 / 22:58:01 / cg" |
|
2241 | 417 |
! ! |
418 |
||
419 |
!CharacterArray methodsFor:'printing & storing'! |
|
420 |
||
2260 | 421 |
printf:args on:outStream |
422 |
"Format and print the receiver on <outStream> with <args> |
|
423 |
formatted in C style, as specified in the Unix C-language manual page for printf(3). |
|
4528 | 424 |
For smalltalk specific formats, see documentation in PrintfScanf. |
2260 | 425 |
For copyright information, see goodies/String-printf_scanf.chg" |
2303 | 426 |
|
4418 | 427 |
PrintfScanf printf:self on:outStream arguments: args |
428 |
||
429 |
" |
|
430 |
'%e' printf:{ 1234.567 ] on:Transcript |
|
431 |
||
432 |
'%10s%3d\n' printf:{ 'hello' . 12 } on:Transcript |
|
433 |
'%10s%3d\n' printf:{ '1234567890' . 12 } on:Transcript |
|
2260 | 434 |
|
4418 | 435 |
like C's printf, a longer datum may be formatted wider than the formatspec says: |
436 |
||
437 |
'%10s%3d\n' printf:{ '12345678901234' . 12 } on:Transcript |
|
438 |
||
439 |
'%10s%3d\n' printf:{ 'hello' . 12 } on:Transcript |
|
440 |
'%10s%03d\n' printf:{ 'hello' . 12 } on:Transcript |
|
441 |
" |
|
442 |
||
4528 | 443 |
"Modified (comment): / 14-11-2017 / 22:57:58 / cg" |
2260 | 444 |
! ! |
445 |
||
446 |
!CharacterArray methodsFor:'printing & storing'! |
|
447 |
||
2303 | 448 |
printfWith:arg1 |
2295 | 449 |
"Format and print the receiver with <arg1> formatted in C style, |
450 |
as specified in the Unix C-language manual page for printf(3). |
|
4528 | 451 |
Return the resulting string (i.e actually, this is more like an sprintf). |
452 |
For smalltalk specific formats, see documentation in PrintfScanf." |
|
2303 | 453 |
|
2256 | 454 |
^ self printf:(Array with:arg1) |
455 |
||
456 |
" |
|
3796 | 457 |
('%05x' printfWith:123) |
2303 | 458 |
Transcript showCR:('%05x' printfWith:123) |
2256 | 459 |
" |
4528 | 460 |
|
461 |
"Modified (comment): / 14-11-2017 / 22:58:10 / cg" |
|
2256 | 462 |
! ! |
463 |
||
464 |
!CharacterArray methodsFor:'printing & storing'! |
|
465 |
||
2303 | 466 |
printfWith:arg1 with:arg2 |
467 |
"Format and print the receiver with <argI> formatted in C style, |
|
2295 | 468 |
as specified in the Unix C-language manual page for printf(3). |
4528 | 469 |
Return the resulting string (i.e actually, this is more like an sprintf). |
470 |
For smalltalk specific formats, see documentation in PrintfScanf." |
|
2303 | 471 |
|
2256 | 472 |
^ self printf:(Array with:arg1 with:arg2) |
473 |
||
474 |
" |
|
2303 | 475 |
Transcript showCR:('%d %05x' printfWith:123 with:234) |
2256 | 476 |
" |
4528 | 477 |
|
478 |
"Modified (comment): / 14-11-2017 / 22:58:16 / cg" |
|
2256 | 479 |
! ! |
480 |
||
481 |
!CharacterArray methodsFor:'printing & storing'! |
|
482 |
||
483 |
printfWith:arg1 with:arg2 with:arg3 |
|
2303 | 484 |
"Format and print the receiver with <argI> formatted in C style, |
2295 | 485 |
as specified in the Unix C-language manual page for printf(3). |
4528 | 486 |
Return the resulting string (i.e actually, this is more like an sprintf). |
487 |
For smalltalk specific formats, see documentation in PrintfScanf." |
|
2303 | 488 |
|
2256 | 489 |
^ self printf:(Array with:arg1 with:arg2 with:arg3) |
490 |
||
491 |
" |
|
2303 | 492 |
Transcript showCR:('%d %05x %08o' printfWith:123 with:234 with:345) |
2256 | 493 |
" |
4528 | 494 |
|
495 |
"Modified (comment): / 14-11-2017 / 22:58:20 / cg" |
|
2256 | 496 |
! ! |
497 |
||
498 |
!CharacterArray methodsFor:'printing & storing'! |
|
499 |
||
500 |
printfWith:arg1 with:arg2 with:arg3 with:arg4 |
|
2303 | 501 |
"Format and print the receiver with <argI> formatted in C style, |
2295 | 502 |
as specified in the Unix C-language manual page for printf(3). |
4528 | 503 |
Return the resulting string (i.e actually, this is more like an sprintf). |
504 |
For smalltalk specific formats, see documentation in PrintfScanf." |
|
2303 | 505 |
|
2256 | 506 |
^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
507 |
||
508 |
" |
|
2303 | 509 |
Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123) |
2256 | 510 |
" |
4528 | 511 |
|
512 |
"Modified (comment): / 14-11-2017 / 22:58:23 / cg" |
|
513 |
! ! |
|
514 |
||
515 |
!CharacterArray methodsFor:'printing & storing'! |
|
516 |
||
517 |
printfWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
518 |
"Format and print the receiver with <argI> formatted in C style, |
|
519 |
as specified in the Unix C-language manual page for printf(3). |
|
520 |
Return the resulting string (i.e actually, this is more like an sprintf). |
|
521 |
For smalltalk specific formats, see documentation in PrintfScanf." |
|
522 |
||
523 |
^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
|
524 |
||
525 |
" |
|
526 |
Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123) |
|
527 |
" |
|
528 |
||
529 |
"Modified (comment): / 14-11-2017 / 22:58:28 / cg" |
|
2256 | 530 |
! ! |
531 |
||
532 |
!CharacterArray methodsFor:'printing & storing'! |
|
533 |
||
2241 | 534 |
printf_formatArgCount |
535 |
"Return the number of arguments required/produced if the receiver is interpreted |
|
536 |
as a printf/scanf format control string. |
|
4528 | 537 |
For smalltalk specific formats, see documentation in PrintfScanf. |
2241 | 538 |
For copyright information, see goodies/String-printf_scanf.chg" |
2303 | 539 |
|
4418 | 540 |
^ PrintfScanf formatArgCountFor:self. |
2241 | 541 |
|
4418 | 542 |
"Modified: / 19-06-2017 / 16:54:10 / cg" |
4528 | 543 |
"Modified (comment): / 14-11-2017 / 22:58:34 / cg" |
2241 | 544 |
! ! |
545 |
||
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
546 |
!CharacterArray methodsFor:'private'! |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
547 |
|
4418 | 548 |
printf_printArgFrom:formatStream to:outStream withData:argStream |
549 |
<resource: #obsolete> |
|
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
550 |
"Interpret the required number of arguments from <argStream> |
4418 | 551 |
according to the formatting information in <formatStream>. |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
552 |
Place the interpretation on <outStream>. |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
553 |
The interpretation is C printf(3) style, as |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
554 |
specified in the Unix C-language manual page for printf(3). |
4418 | 555 |
<formatStream> is assumed to be positioned just past |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
556 |
$%, and a complete control string is assumed available. |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
557 |
|
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
558 |
Return when the conversion control string is consumed. |
4418 | 559 |
Leave <formatStream> pointing past the last character in the conversion control string. |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
560 |
|
4418 | 561 |
This code assumes that <formatStream> is formatted according to |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
562 |
specification, and error checking is minimal. Unexpected |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
563 |
results will be obtained by illegal control strings, or when |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
564 |
argument types do not match conversion codes, but it probably |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
565 |
won't dump core, like C does in such cases!! |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
566 |
|
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
567 |
For copyright information, see goodies/String-printf_scanf.chg" |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
568 |
|
4418 | 569 |
PrintfScanf printArgFrom:formatStream to:outStream arguments:argStream |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
570 |
|
4418 | 571 |
"Modified: / 19-06-2017 / 15:44:28 / cg" |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
572 |
! ! |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
573 |
|
2241 | 574 |
!CharacterArray methodsFor:'printing & storing'! |
575 |
||
2260 | 576 |
printf_printOn:outStream withData:args |
577 |
<resource: #obsolete> |
|
2303 | 578 |
|
2241 | 579 |
"Format and print the receiver on <outStream> with <args> |
580 |
formatted in C style, as specified in the Unix C-language manual page for printf(3). |
|
581 |
||
582 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
583 |
||
2260 | 584 |
self obsoleteMethodWarning:'use printf:on:'. |
585 |
self printf:args on:outStream |
|
2241 | 586 |
! ! |
587 |
||
588 |
!CharacterArray methodsFor:'converting'! |
|
589 |
||
4473 | 590 |
scanf:dataStreamOrString |
2241 | 591 |
"Return a Collection of objects found in the Character Stream |
2303 | 592 |
<dataStream> as interpreted according to the receiver. |
2241 | 593 |
The receiver is assumed to be a conversion control string as |
594 |
specified in the Unix C-language manual page for scanf(3). |
|
595 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 596 |
|
4473 | 597 |
|dataStream| |
2241 | 598 |
|
4473 | 599 |
dataStream := dataStreamOrString readStream. |
600 |
^ PrintfScanf scanf:self fromStream:dataStream |
|
601 |
||
602 |
"/ |results format char| |
|
603 |
"/ |
|
604 |
"/ results := OrderedCollection new. |
|
605 |
"/ format := ReadStream on:self. |
|
606 |
"/ [ format atEnd ] whileFalse:[ |
|
607 |
"/ char := format next. |
|
608 |
"/ (char == Character space or:[ char == Character tab ]) ifTrue:[ |
|
609 |
"/ dataStream skipSeparators. |
|
610 |
"/ format skipSeparators |
|
611 |
"/ ]. |
|
612 |
"/ char == $% ifTrue:[ |
|
613 |
"/ PrintfScanf scanArgFrom:dataStream to:results format:format. |
|
614 |
"/ ] ifFalse:[ |
|
615 |
"/ dataStream peekFor:char |
|
616 |
"/ ] |
|
617 |
"/ ]. |
|
618 |
"/ ^ results |
|
2241 | 619 |
|
620 |
" |
|
2303 | 621 |
'%d %x' scanf:(ReadStream on:'1234 ff00') |
4473 | 622 |
'%d %s' scanf:(ReadStream on:'1234 ff00') |
623 |
'%d %b' scanf:(ReadStream on:'1234 1111') |
|
624 |
'%d %f' scanf:(ReadStream on:'1234 1111') |
|
625 |
'%d %f' scanf:(ReadStream on:'1234 1111.2345') |
|
626 |
'%d %q' scanf:(ReadStream on:'1234 1111.2345') |
|
2241 | 627 |
" |
4473 | 628 |
|
629 |
"Modified: / 14-07-2017 / 11:11:49 / cg" |
|
2241 | 630 |
! ! |
631 |
||
632 |
!CharacterArray methodsFor:'private'! |
|
633 |
||
2303 | 634 |
scanf_scanArgFrom:dataStream to:collection format:format |
4418 | 635 |
<resource: #obsolete> |
2241 | 636 |
"Add to <collection> an object who's representation is found |
637 |
in <dataStream> interpreted according to the conversion |
|
2303 | 638 |
control string in the Stream <format>. |
639 |
<format> is assumed to be positioned just past a $%, and a complete control |
|
2241 | 640 |
string is assumed available. |
641 |
||
642 |
Return when the conversion control string is consumed. Leave |
|
643 |
<format> pointing past the last character in the conversion |
|
644 |
control string, leave <dataStream> pointing past any width |
|
645 |
specified in <format>, or at the first character that doesn't |
|
646 |
make sense for the <format>. |
|
647 |
||
648 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 649 |
|
4473 | 650 |
PrintfScanf scanArgFrom:dataStream to:collection format:format. |
2256 | 651 |
|
652 |
" |
|
2303 | 653 |
'%d %x' sscanf:'1234 ff00' |
654 |
'%d %x %b' sscanf:'1234 ff00 1001' |
|
2256 | 655 |
" |
2679
cfab54d30fcc
changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
656 |
|
4473 | 657 |
"Modified: / 14-07-2017 / 11:09:35 / cg" |
2241 | 658 |
! ! |
659 |
||
660 |
!CharacterArray methodsFor:'converting'! |
|
661 |
||
2303 | 662 |
sscanf:string |
2241 | 663 |
"Return a Collection of objects found in <string> as |
2303 | 664 |
interpreted according to the receiver. |
2241 | 665 |
The receiver is assumed to be a conversion control string as |
666 |
specified in the Unix C-language manual page for scanf(3). |
|
667 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 668 |
|
2241 | 669 |
^ self scanf:(ReadStream on:string) |
670 |
||
671 |
" |
|
2303 | 672 |
'%d %x' sscanf:'1234 ff00' |
673 |
'%d %x %b' sscanf:'1234 ff00 1001' |
|
2241 | 674 |
" |
675 |
! ! |
|
676 |
||
4365
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
677 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
678 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
679 |
asHalfFloatArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
680 |
"return a new HalfFloatArray with the collection's elements |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
681 |
(which must convert to 16bit half-floats)." |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
682 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
683 |
^ self asArrayOfType:HalfFloatArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
684 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
685 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
686 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
687 |
|
4400 | 688 |
asIdentitySkipList |
689 |
"Answer a IdentitySkipList whose elements are the elements of the |
|
690 |
receiver. The sort order is the default less than or equal." |
|
691 |
||
692 |
^ self as: IdentitySkipList |
|
693 |
! ! |
|
694 |
||
695 |
!Collection methodsFor:'converting'! |
|
696 |
||
4365
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
697 |
asList |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
698 |
"return a new List with the receiver collection's elements" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
699 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
700 |
^ self addAllTo:(List new:self size) |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
701 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
702 |
"Created: 14.2.1997 / 16:25:23 / cg" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
703 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
704 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
705 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
706 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
707 |
asRunArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
708 |
"return a new RunArray with the collection's elements" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
709 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
710 |
^ RunArray from:self. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
711 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
712 |
"/ |runs lastElement occurrences| |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
713 |
"/ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
714 |
"/ runs := RunArray new. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
715 |
"/ occurrences := 0. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
716 |
"/ self do:[:each | |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
717 |
"/ each == lastElement ifTrue:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
718 |
"/ occurrences := occurrences + 1 |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
719 |
"/ ] ifFalse:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
720 |
"/ runs add:lastElement withOccurrences:occurrences. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
721 |
"/ occurrences := 1. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
722 |
"/ lastElement := each |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
723 |
"/ ]. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
724 |
"/ ]. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
725 |
"/ occurrences ~~ 0 ifTrue:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
726 |
"/ runs add:lastElement withOccurrences:occurrences |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
727 |
"/ ]. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
728 |
"/ ^ runs |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
729 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
730 |
" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
731 |
#(1 2 3 3 3 4 4 4 4 5 6 7) asRunArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
732 |
" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
733 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
734 |
"Modified: / 7.4.1998 / 09:50:54 / cg" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
735 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
736 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
737 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
738 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
739 |
asSharedCollection |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
740 |
"return a shared collection on the receiver. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
741 |
This implements synchronized (i.e. mutually excluded) access to me. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
742 |
Use this for safe access when multiple processes access me concurrently. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
743 |
Notice that this is a general (possibly suboptimal) mechanism, which should |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
744 |
work with all collections. Look for specialized collections (SharedQueue), which are |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
745 |
tuned for this kind of operation." |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
746 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
747 |
^ SharedCollection for:self. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
748 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
749 |
|
4400 | 750 |
!Collection methodsFor:'converting'! |
751 |
||
752 |
asSkipList |
|
753 |
"Answer a SkipList whose elements are the elements of the |
|
754 |
receiver. The sort order is the default less than or equal." |
|
755 |
||
756 |
^ self as: SkipList |
|
757 |
! ! |
|
758 |
||
759 |
!Collection methodsFor:'converting'! |
|
760 |
||
761 |
asSkipList: aSortBlock |
|
762 |
"Answer a SkipList whose elements are the elements of the |
|
763 |
receiver. The sort order is defined by the argument, aSortBlock." |
|
764 |
||
765 |
| skipList | |
|
766 |
skipList := SkipList new: self size sortBlock: aSortBlock. |
|
767 |
skipList addAll: self. |
|
768 |
^ skipList |
|
769 |
||
770 |
"Modified (comment): / 18-06-2017 / 22:40:10 / cg" |
|
771 |
! ! |
|
772 |
||
2237 | 773 |
!Float methodsFor:'private'! |
774 |
||
2303 | 775 |
absDecimalPrintOn:aStream digits:digits |
2237 | 776 |
"Place a string representation of the receiver's abs value |
777 |
on <aStream> using <digits> significant digits, using decimal notation. |
|
778 |
This is a helper for printf." |
|
779 |
||
4429 | 780 |
<resource: #obsolete> |
781 |
PrintfScanf absDecimalPrintFloat:self on:aStream digits:digits. |
|
2237 | 782 |
|
4429 | 783 |
"Modified: / 20-06-2017 / 11:49:15 / cg" |
2237 | 784 |
! ! |
785 |
||
786 |
!Float methodsFor:'private'! |
|
787 |
||
2303 | 788 |
absPrintOn:aStream digits:digits |
789 |
"Place a string representation of the receiver's abs value on <aStream> using |
|
2237 | 790 |
<digits> significant digits. |
791 |
This is a helper for printf." |
|
2303 | 792 |
|
4429 | 793 |
<resource: #obsolete> |
4418 | 794 |
PrintfScanf absPrintFloat:self on:aStream digits:digits |
795 |
||
4429 | 796 |
"Modified: / 20-06-2017 / 11:49:11 / cg" |
2237 | 797 |
! ! |
798 |
||
799 |
!Float methodsFor:'private'! |
|
800 |
||
2303 | 801 |
absScientificPrintOn:aStream digits:digits |
2237 | 802 |
"Place a string representation of the receiver's abs value on <aStream> using <digits> significant |
803 |
digits, using scientific notation. |
|
804 |
This is a helper for printf." |
|
2303 | 805 |
|
4429 | 806 |
<resource: #obsolete> |
4418 | 807 |
PrintfScanf absScientificPrintFloat:self on:aStream digits:digits. |
2237 | 808 |
|
4418 | 809 |
"Modified: / 19-06-2017 / 14:59:56 / cg" |
4429 | 810 |
"Modified (format): / 20-06-2017 / 11:49:07 / cg" |
2237 | 811 |
! ! |
812 |
||
4381 | 813 |
!Float methodsFor:'coercing & converting'! |
814 |
||
815 |
asQDouble |
|
816 |
"return a QDouble with my value" |
|
817 |
||
818 |
^ QDouble fromFloat:self |
|
819 |
||
820 |
" |
|
821 |
1.0 asQDouble |
|
822 |
" |
|
823 |
||
824 |
"Created: / 13-06-2017 / 16:48:57 / cg" |
|
825 |
! ! |
|
826 |
||
4383 | 827 |
!Integer methodsFor:'coercing & converting'! |
828 |
||
829 |
asQDouble |
|
830 |
"return a QDouble with same value as myself." |
|
831 |
||
832 |
^ QDouble fromInteger:self |
|
833 |
||
834 |
" |
|
835 |
1234567890 asQDouble |
|
836 |
1234567890 asQDouble asInteger |
|
837 |
12345678901234567890 asQDouble |
|
838 |
12345678901234567890 asQDouble asInteger |
|
839 |
" |
|
840 |
||
841 |
"Created: / 12-06-2017 / 18:41:07 / cg" |
|
842 |
"Modified (comment): / 12-06-2017 / 20:55:24 / cg" |
|
843 |
! ! |
|
844 |
||
1759 | 845 |
!Object methodsFor:'dependents-interests'! |
846 |
||
847 |
addInterest:anInterest |
|
848 |
"install an interest forwarder. |
|
849 |
Here, we use the nonWeakDependencies." |
|
850 |
||
851 |
self addNonWeakDependent:anInterest |
|
852 |
||
853 |
"Created: 14.10.1996 / 22:27:34 / stefan" |
|
854 |
! ! |
|
855 |
||
3896 | 856 |
!Object methodsFor:'converting'! |
857 |
||
858 |
asDoubleLink |
|
859 |
"return a valueDoubleLink for the receiver. |
|
860 |
Used to make sure the receiver can be added to a double linked list" |
|
861 |
||
862 |
^ ValueDoubleLink value:self |
|
863 |
! ! |
|
864 |
||
1759 | 865 |
!Object methodsFor:'dependents-interests'! |
866 |
||
867 |
expressInterestIn:aspect for:anObject sendBack:aSelector |
|
868 |
"arrange for aSelector to be sent to anObject whenever the receiver |
|
869 |
changes aspect." |
|
870 |
||
871 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
|
872 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
873 |
||
2303 | 874 |
self addInterest:(InterestConverter |
875 |
destination:anObject |
|
876 |
selector:aSelector |
|
877 |
aspect:aspect) |
|
1759 | 878 |
|
879 |
" |
|
880 |
|p b| |
|
881 |
||
882 |
b := [Transcript showCR:' -> the point changed']. |
|
883 |
||
884 |
p := Point new. |
|
885 |
Transcript showCR:'interest in #foo:'. |
|
886 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
887 |
p x:1. |
|
888 |
Transcript showCR:'now changing #bar ... (expect no notification)'. |
|
889 |
p changed:#bar. |
|
890 |
Transcript cr. |
|
891 |
||
892 |
Delay waitForSeconds:1. |
|
893 |
Transcript showCR:'now changing #foo ... (expect notification)'. |
|
894 |
p changed:#foo. |
|
895 |
Transcript cr. |
|
896 |
||
897 |
Delay waitForSeconds:1. |
|
898 |
Transcript showCR:'no more interest in #foo:'. |
|
899 |
p retractInterestIn:#foo for:b. |
|
900 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
901 |
p changed:#foo. |
|
902 |
Transcript cr. |
|
903 |
||
904 |
Delay waitForSeconds:1. |
|
905 |
Transcript showCR:'interest in #bar now:'. |
|
906 |
p expressInterestIn:#bar for:b sendBack:#value. |
|
907 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
908 |
p changed:#foo. |
|
909 |
Transcript showCR:'now changing #bar ... (expect notification)'. |
|
910 |
p changed:#bar. |
|
911 |
Transcript cr. |
|
912 |
||
913 |
Delay waitForSeconds:1. |
|
914 |
Transcript showCR:'interest in #foo now:'. |
|
915 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
916 |
Transcript showCR:'now changing #foo ... (expect notification)'. |
|
917 |
p changed:#foo. |
|
918 |
Transcript showCR:'now changing #bar ... (expect notification)'. |
|
919 |
p changed:#bar. |
|
920 |
Transcript cr. |
|
921 |
||
922 |
Delay waitForSeconds:1. |
|
923 |
Transcript showCR:'no more interests:'. |
|
924 |
p retractInterestsFor:b. |
|
925 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
926 |
p changed:#foo. |
|
927 |
Transcript showCR:'now changing #bar... (expect no notification)'. |
|
928 |
p changed:#bar. |
|
929 |
Transcript cr. |
|
930 |
||
931 |
p release. |
|
932 |
" |
|
1668 | 933 |
|
1759 | 934 |
"Created: 19.4.1996 / 10:26:22 / cg" |
935 |
"Modified: 19.4.1996 / 12:34:08 / cg" |
|
936 |
"Modified: 14.10.1996 / 22:28:20 / stefan" |
|
937 |
! ! |
|
938 |
||
939 |
!Object methodsFor:'dependents-interests'! |
|
940 |
||
941 |
interests |
|
942 |
"return a Collection of interests - empty if there is none. |
|
943 |
Here, we use the nonWeakDependents for interests." |
|
944 |
||
945 |
^ self nonWeakDependents |
|
946 |
||
947 |
"Created: / 14.10.1996 / 22:20:51 / stefan" |
|
948 |
"Modified: / 30.1.1998 / 14:07:35 / cg" |
|
949 |
! ! |
|
950 |
||
951 |
!Object methodsFor:'dependents-interests'! |
|
952 |
||
953 |
interestsFor:someOne |
|
954 |
"return a collection of interests of someOne - empty if there is none." |
|
955 |
||
956 |
|coll deps| |
|
957 |
||
958 |
deps := self interests. |
|
959 |
deps size == 0 ifTrue:[^ #()]. |
|
960 |
||
961 |
coll := IdentitySet new. |
|
962 |
||
963 |
deps do:[:dep | |
|
2303 | 964 |
(dep isInterestConverter) ifTrue:[ |
965 |
dep destination == someOne ifTrue:[ |
|
966 |
coll add:dep. |
|
967 |
] |
|
968 |
] |
|
1759 | 969 |
]. |
970 |
^ coll |
|
971 |
||
972 |
"Created: / 30.1.1998 / 14:02:26 / cg" |
|
973 |
"Modified: / 30.1.1998 / 14:08:24 / cg" |
|
974 |
! ! |
|
1668 | 975 |
|
1759 | 976 |
!Object methodsFor:'dependents-interests'! |
977 |
||
978 |
onChangeEvaluate:aBlock |
|
979 |
"arrange for aBlock to be evaluated whenever the receiver changes." |
|
980 |
||
2149
329461c02e84
allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents:
1759
diff
changeset
|
981 |
|na selector| |
329461c02e84
allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents:
1759
diff
changeset
|
982 |
|
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
983 |
na := aBlock argumentCount. |
2149
329461c02e84
allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents:
1759
diff
changeset
|
984 |
na == 0 ifTrue:[ |
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
985 |
selector := #value |
2149
329461c02e84
allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents:
1759
diff
changeset
|
986 |
] ifFalse:[ |
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
987 |
selector := #( #'value:' #'value:value:' #'value:value:value:') at:na |
2149
329461c02e84
allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents:
1759
diff
changeset
|
988 |
]. |
329461c02e84
allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents:
1759
diff
changeset
|
989 |
^ self onChangeSend:selector to:aBlock |
1759 | 990 |
|
991 |
" |
|
992 |
|p b| |
|
993 |
||
994 |
b := [Transcript showCR:' -> the point changed']. |
|
995 |
||
996 |
p := Point new. |
|
997 |
Transcript showCR:'interest in #foo:'. |
|
998 |
p onChangeEvaluate:b. |
|
999 |
p x:1. |
|
1000 |
Transcript showCR:'now changing #bar ... (expect no notification)'. |
|
1001 |
p changed:#bar. |
|
1002 |
||
1003 |
p retractInterests. |
|
1004 |
p changed:#bar. |
|
1005 |
" |
|
1006 |
! ! |
|
1007 |
||
1008 |
!Object methodsFor:'dependents-interests'! |
|
1009 |
||
1010 |
onChangeSend:aSelector to:anObject |
|
1011 |
"arrange for aSelector to be sent to anObject whenever the receiver |
|
4030 | 1012 |
changes. |
1013 |
Use retractInterestsFor: in case you are no longer interested" |
|
1759 | 1014 |
|
1015 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
|
1016 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1017 |
||
1018 |
((self interests ? #()) |
|
4030 | 1019 |
contains:[:anInterest | |
1020 |
(anInterest isInterestConverter) |
|
1021 |
and:[ anInterest destination == anObject |
|
1022 |
and:[ anInterest selector == aSelector]] |
|
1023 |
]) |
|
1024 |
ifTrue:[^ self]. |
|
1759 | 1025 |
|
2303 | 1026 |
self addInterest:(InterestConverter |
4030 | 1027 |
destination:anObject |
1028 |
selector:aSelector) |
|
1668 | 1029 |
|
1030 |
" |
|
1759 | 1031 |
|p b| |
1032 |
||
1033 |
b := [Transcript showCR:'the point changed']. |
|
1034 |
||
1035 |
p := Point new. |
|
1036 |
p onChangeSend:#value to:b. |
|
1037 |
p x:1. |
|
1038 |
Transcript showCR:'now changing'. |
|
1039 |
p changed. |
|
1040 |
Transcript cr. |
|
1041 |
||
1042 |
Delay waitForSeconds:1. |
|
1043 |
Transcript showCR:'now changing'. |
|
1044 |
p changed. |
|
1045 |
Transcript cr. |
|
1046 |
||
1047 |
Delay waitForSeconds:1. |
|
1048 |
Transcript showCR:'no more interest'. |
|
1049 |
p retractInterestsFor:b. |
|
1050 |
Transcript showCR:'now changing again'. |
|
1051 |
p changed. |
|
1052 |
Transcript cr. |
|
1053 |
||
1054 |
Delay waitForSeconds:1. |
|
1055 |
Transcript showCR:'interest again'. |
|
1056 |
p onChangeSend:#value to:b. |
|
1057 |
Transcript showCR:'now changing again'. |
|
1058 |
p changed. |
|
1059 |
Transcript cr. |
|
1060 |
" |
|
1061 |
||
1062 |
"Created: 19.4.1996 / 10:26:38 / cg" |
|
1063 |
"Modified: 19.4.1996 / 12:34:26 / cg" |
|
1064 |
"Modified: 14.10.1996 / 22:28:27 / stefan" |
|
1065 |
! ! |
|
1066 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1067 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1068 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1069 |
removeActionsForEvent:eventSymbol |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1070 |
"remove ST/V-style event triggers." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1071 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1072 |
self retractInterestsIn:eventSymbol |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1073 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1074 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1075 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1076 |
|
2903 | 1077 |
removeActionsWithReceiver:aReceiver |
1078 |
"remove ST/V-style event triggers." |
|
1079 |
||
1080 |
self retractInterestsFor:aReceiver |
|
1081 |
! ! |
|
1082 |
||
1083 |
!Object methodsFor:'dependents-st/v event simulation'! |
|
1084 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1085 |
removeAllActionsWithReceiver:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1086 |
"remove ST/V-style event triggers." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1087 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1088 |
self retractInterestsFor:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1089 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1090 |
|
1759 | 1091 |
!Object methodsFor:'dependents-interests'! |
1092 |
||
1093 |
removeInterest:anInterest |
|
1094 |
"remove an interest forwarder. |
|
1095 |
Here, we use the nonWeakDependencies." |
|
1096 |
||
1097 |
self removeNonWeakDependent:anInterest |
|
1098 |
||
1099 |
"Created: 14.10.1996 / 22:21:59 / stefan" |
|
1100 |
! ! |
|
1101 |
||
1102 |
!Object methodsFor:'dependents-interests'! |
|
1103 |
||
1104 |
retractInterestIn:aspect for:someOne |
|
1105 |
"remove the interest of someOne in the receiver changing aspect |
|
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1106 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1107 |
Answer the retracted interests." |
1759 | 1108 |
|
1109 |
"/ for now, remove the interestConverter. |
|
1110 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1111 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1112 |
^ self retractInterestsForWhich:[:i | |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1113 |
(i aspect == aspect) and:[i destination == someOne] |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1114 |
] |
1759 | 1115 |
|
1668 | 1116 |
" |
1759 | 1117 |
|p b| |
1118 |
||
1119 |
b := [Transcript showCR:'the point changed']. |
|
1120 |
||
1121 |
p := Point new. |
|
1122 |
Transcript showCR:'interest in #foo'. |
|
1123 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
1124 |
p x:1. |
|
1125 |
Transcript showCR:'now changing #bar'. |
|
1126 |
p changed:#bar. |
|
1127 |
Transcript cr. |
|
1128 |
||
1129 |
Delay waitForSeconds:1. |
|
1130 |
Transcript showCR:'now changing #foo'. |
|
1131 |
p changed:#foo. |
|
1132 |
Transcript cr. |
|
1133 |
||
1134 |
Delay waitForSeconds:1. |
|
1135 |
Transcript showCR:'no more interest in #foo'. |
|
1136 |
p retractInterestIn:#foo for:b. |
|
1137 |
Transcript showCR:'now changing #foo'. |
|
1138 |
p changed:#foo. |
|
1139 |
Transcript cr. |
|
1140 |
||
1141 |
Delay waitForSeconds:1. |
|
1142 |
Transcript showCR:'interest in #bar now'. |
|
1143 |
p expressInterestIn:#bar for:b sendBack:#value. |
|
1144 |
Transcript showCR:'now changing #foo'. |
|
1145 |
p changed:#foo. |
|
1146 |
Transcript showCR:'now changing #bar'. |
|
1147 |
p changed:#bar. |
|
1148 |
Transcript cr. |
|
1149 |
||
1150 |
Delay waitForSeconds:1. |
|
1151 |
Transcript showCR:'interest in #foo now'. |
|
1152 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
1153 |
Transcript showCR:'now changing #foo'. |
|
1154 |
p changed:#foo. |
|
1155 |
Transcript showCR:'now changing #bar'. |
|
1156 |
p changed:#bar. |
|
1157 |
Transcript cr. |
|
1158 |
||
1159 |
Delay waitForSeconds:1. |
|
1160 |
Transcript showCR:'no more interests'. |
|
1161 |
p retractInterestsFor:b. |
|
1162 |
Transcript showCR:'now changing #foo'. |
|
1163 |
p changed:#foo. |
|
1164 |
Transcript showCR:'now changing #bar'. |
|
1165 |
p changed:#bar. |
|
1166 |
Transcript cr. |
|
1167 |
" |
|
1168 |
||
1169 |
"Created: / 19.4.1996 / 10:27:11 / cg" |
|
1170 |
"Modified: / 14.10.1996 / 22:21:19 / stefan" |
|
1171 |
"Modified: / 30.1.1998 / 14:05:34 / cg" |
|
1172 |
! ! |
|
1173 |
||
1174 |
!Object methodsFor:'dependents-interests'! |
|
1175 |
||
1176 |
retractInterests |
|
1177 |
"remove all interests in the receiver changing aspect |
|
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1178 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1179 |
Answer the retraced interests." |
1759 | 1180 |
|
1181 |
"/ for now, remove the interestConverter. |
|
1182 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1183 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1184 |
^ self retractInterestsForWhich:[:i | true ] |
1759 | 1185 |
! ! |
1186 |
||
1187 |
!Object methodsFor:'dependents-interests'! |
|
1188 |
||
1189 |
retractInterestsFor:someOne |
|
2303 | 1190 |
"remove the interest of someOne in the receiver |
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1191 |
(as installed with #onChangeSend:to:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1192 |
Answer the retracted interests." |
1759 | 1193 |
|
1194 |
"/ for now, remove the interestConverter. |
|
1195 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1196 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1197 |
^ self retractInterestsForWhich:[:i | i destination == someOne ] |
1759 | 1198 |
|
1199 |
" |
|
1200 |
|p b| |
|
1201 |
||
1202 |
b := [Transcript showCR:'the point changed']. |
|
1203 |
||
1204 |
p := Point new. |
|
1205 |
p onChangeSend:#value to:b. |
|
1206 |
p x:1. |
|
1207 |
Transcript showCR:'now changing'. |
|
1208 |
p changed. |
|
1209 |
Transcript cr. |
|
1210 |
||
1211 |
Delay waitForSeconds:1. |
|
1212 |
Transcript showCR:'now changing'. |
|
1213 |
p changed. |
|
1214 |
Transcript cr. |
|
1215 |
||
1216 |
Delay waitForSeconds:1. |
|
1217 |
Transcript showCR:'no more interest'. |
|
1218 |
p retractInterestsFor:b. |
|
1219 |
Transcript showCR:'now changing again'. |
|
1220 |
p changed. |
|
1221 |
Transcript cr. |
|
1222 |
||
1223 |
Delay waitForSeconds:1. |
|
1224 |
Transcript showCR:'interest again'. |
|
1225 |
p onChangeSend:#value to:b. |
|
1226 |
Transcript showCR:'now changing again'. |
|
1227 |
p changed. |
|
1228 |
Transcript cr. |
|
1229 |
" |
|
1230 |
||
1231 |
"Created: / 19.4.1996 / 10:23:46 / cg" |
|
1232 |
"Modified: / 14.10.1996 / 22:21:25 / stefan" |
|
1233 |
"Modified: / 30.1.1998 / 14:04:52 / cg" |
|
1234 |
! ! |
|
1235 |
||
1236 |
!Object methodsFor:'dependents-interests'! |
|
1237 |
||
1238 |
retractInterestsForWhich:aBlock |
|
1239 |
"remove all interests in the receiver changing aspect |
|
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1240 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1241 |
Answer the retracted interests." |
1759 | 1242 |
|
1243 |
"/ for now, remove the interestConverter. |
|
1244 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1245 |
||
1246 |
|deps coll| |
|
1247 |
||
1248 |
deps := self interests. |
|
1249 |
deps size ~~ 0 ifTrue:[ |
|
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1250 |
"/ cannot removeDependent within the loop - the interests collection rehashes |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1251 |
coll := IdentitySet new. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1252 |
deps do:[:dep | |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1253 |
dep isInterestConverter ifTrue:[ |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1254 |
(aBlock value:dep) ifTrue:[coll add:dep]. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1255 |
] |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1256 |
]. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1257 |
coll do:[:dep | |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1258 |
self removeInterest:dep. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1259 |
]. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1260 |
^ coll. |
1759 | 1261 |
]. |
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1262 |
^ #() |
1759 | 1263 |
! ! |
1264 |
||
1265 |
!Object methodsFor:'dependents-interests'! |
|
1266 |
||
1267 |
retractInterestsIn:aspect |
|
1268 |
"remove all interests in the receiver changing aspect |
|
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1269 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1270 |
Answer the retracted interests." |
1759 | 1271 |
|
1272 |
"/ for now, remove the interestConverter. |
|
1273 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1274 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1275 |
^ self retractInterestsForWhich:[:i | i aspect == aspect ] |
1668 | 1276 |
! ! |
1277 |
||
2901 | 1278 |
!Object methodsFor:'Compatibility-Dolphin'! |
1279 |
||
1280 |
trigger:anAspect |
|
1281 |
self changed:anAspect |
|
1282 |
! ! |
|
1283 |
||
1284 |
!Object methodsFor:'Compatibility-Dolphin'! |
|
1285 |
||
1286 |
trigger:anAspect with:anArgument |
|
1287 |
self changed:anAspect with:anArgument |
|
1288 |
! ! |
|
1289 |
||
1290 |
!Object methodsFor:'dependents-st/v event simulation'! |
|
1291 |
||
1292 |
triggerEvent:aSymbol |
|
1293 |
self changed:aSymbol |
|
1294 |
! ! |
|
1295 |
||
1668 | 1296 |
!Object methodsFor:'dependents-st/v event simulation'! |
1297 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1298 |
triggerEvent:eventSymbol with:aParameter |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1299 |
"perform ST/V-style event triggering." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1300 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1301 |
self changed:eventSymbol with:(Array with:aParameter). |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1302 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1303 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1304 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1305 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1306 |
triggerEvent:eventSymbol withArguments:parameters |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1307 |
"perform ST/V-style event triggering." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1308 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1309 |
self changed:eventSymbol with:parameters. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1310 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1311 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1312 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1313 |
|
1668 | 1314 |
when:eventSymbol send:selector to:anObject |
1315 |
"install an ST/V-style interest forwarder. |
|
1316 |
Here, we use the nonWeakDependencies." |
|
1317 |
||
1318 |
self addInterest:(InterestConverterWithParameters |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1319 |
destination:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1320 |
selector:selector |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1321 |
aspect:eventSymbol). |
1668 | 1322 |
|
1323 |
" |
|
1324 |
|p b| |
|
1325 |
||
1326 |
b := [Transcript showCR:'the point changed']. |
|
1327 |
||
1328 |
p := Point new. |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1329 |
p when:#foo:bar: send:#value:value: to:[:a :b | Transcript show:'foo: '; show:a; show:' bar: '; showCR:b]. |
1668 | 1330 |
Transcript showCR:'now changing'. |
1331 |
p triggerEvent:#foo:bar: withArguments:#('fooArg' 'barArg'). |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1332 |
p removeActionsForEvent:#foo:bar:. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1333 |
" |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1334 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1335 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1336 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1337 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1338 |
when:eventSymbol send:selector to:anObject with:aParameter |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1339 |
"install an ST/V-style interest forwarder. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1340 |
Here, we use the nonWeakDependencies." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1341 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1342 |
self addInterest:((InterestConverterWithParameters |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1343 |
destination:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1344 |
selector:selector |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1345 |
aspect:eventSymbol) |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1346 |
defaultParameters:(Array with:aParameter)). |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1347 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1348 |
" |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1349 |
|p b| |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1350 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1351 |
b := [Transcript showCR:'the point changed']. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1352 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1353 |
p := Point new. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1354 |
p |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1355 |
when:#foo: |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1356 |
send:#value: |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1357 |
to:[:a | Transcript show:'foo: '; showCR:a] |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1358 |
with:123. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1359 |
Transcript showCR:'now changing'. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1360 |
p triggerEvent:#foo:. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1361 |
p triggerEvent:#foo: with:987. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1362 |
p removeActionsForEvent:#foo:. |
1668 | 1363 |
" |
1364 |
! ! |
|
1365 |
||
2901 | 1366 |
!Object methodsFor:'Compatibility-Dolphin'! |
1367 |
||
1368 |
when:anAspect sendTo:anObject |
|
1369 |
self expressInterestIn:anAspect for:anObject sendBack:anAspect |
|
1370 |
! ! |
|
1371 |
||
2364 | 1372 |
!Stream methodsFor:'stacked computing streams'! |
1373 |
||
1374 |
collecting:aBlock |
|
1375 |
"return a stacked computing stream, which reads elements from the receiver, |
|
1376 |
applies aBlock to each read element, and provides the results as elements to its reader." |
|
1377 |
||
1378 |
^ CollectingReadStream on:self collecting:aBlock |
|
3094 | 1379 |
|
1380 |
" |
|
1381 |
|s s2| |
|
1382 |
||
1383 |
s := 'hello world' readStream. |
|
1384 |
s2 := s collecting:[:ch | ch asUppercase]. |
|
1385 |
s2 upToEnd. |
|
1386 |
" |
|
2364 | 1387 |
! ! |
1388 |
||
1389 |
!Stream methodsFor:'stacked computing streams'! |
|
1390 |
||
1391 |
selecting:aBlock |
|
1392 |
"return a stacked computing stream, which reads elements from the receiver, |
|
1393 |
but only provides elements for which aBlock returns true to its reader." |
|
1394 |
||
1395 |
^ SelectingReadStream on:self selecting:aBlock |
|
3094 | 1396 |
|
1397 |
" |
|
1398 |
|s s2| |
|
1399 |
||
1400 |
s := 'hello world' readStream. |
|
1401 |
s2 := s selecting:[:ch | ch isVowel]. |
|
1402 |
s2 upToEnd. |
|
1403 |
" |
|
2364 | 1404 |
! ! |
1405 |
||
2303 | 1406 |
!stx_libbasic2 class methodsFor:'documentation'! |
1407 |
||
1408 |
extensionsVersion_CVS |
|
3715 | 1409 |
^ '$Header$' |
3005 | 1410 |
! ! |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
1411 |