author | Claus Gittinger <cg@exept.de> |
Tue, 25 Jun 2019 11:09:04 +0200 | |
changeset 5048 | 63f42cfbaf59 |
parent 4969 | 9acd20c528a3 |
child 5088 | 72f0347803b6 |
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 |
|
4797 | 186 |
"Return a lazy value object, evaluating myself. |
187 |
Only computes when the result is requested." |
|
4448 | 188 |
|
189 |
^ Lazy new block:self |
|
4797 | 190 |
|
191 |
"Modified (comment): / 09-02-2019 / 15:59:29 / Claus Gittinger" |
|
4448 | 192 |
! ! |
193 |
||
194 |
!Block methodsFor:'parallel evaluation'! |
|
195 |
||
196 |
lazyValue:aValue |
|
4797 | 197 |
"Return a lazy value object, evaluating myself. |
198 |
Only computes when the result is requested." |
|
4448 | 199 |
|
200 |
^ Lazy new block:self value:aValue |
|
4797 | 201 |
|
202 |
"Modified (comment): / 09-02-2019 / 16:00:02 / Claus Gittinger" |
|
4448 | 203 |
! ! |
204 |
||
205 |
!Block methodsFor:'parallel evaluation'! |
|
206 |
||
207 |
lazyValue:aValue value:anotherValue |
|
4797 | 208 |
"Return a lazy value object, evaluating myself. |
209 |
Only computes when the result is requested." |
|
4448 | 210 |
|
211 |
^ Lazy new |
|
4797 | 212 |
block:self |
213 |
value:aValue |
|
214 |
value:anotherValue |
|
215 |
||
216 |
"Modified (comment): / 09-02-2019 / 16:00:05 / Claus Gittinger" |
|
4448 | 217 |
! ! |
218 |
||
219 |
!Block methodsFor:'parallel evaluation'! |
|
220 |
||
221 |
lazyValue:aValue value:anotherValue value:bValue |
|
4797 | 222 |
"Return a lazy value object, evaluating myself. |
223 |
Only computes when the result is requested." |
|
4448 | 224 |
|
225 |
^ Lazy new |
|
4797 | 226 |
block:self |
227 |
value:aValue |
|
228 |
value:anotherValue |
|
229 |
value:bValue |
|
230 |
||
231 |
"Modified (comment): / 09-02-2019 / 16:00:08 / Claus Gittinger" |
|
4448 | 232 |
! ! |
233 |
||
234 |
!Block methodsFor:'parallel evaluation'! |
|
235 |
||
236 |
lazyValueWithArguments:anArray |
|
4797 | 237 |
"Return a lazy value object, evaluating myself. |
238 |
Only computes when the result is requested." |
|
4448 | 239 |
|
240 |
^ Lazy new block:self valueWithArguments:anArray |
|
4797 | 241 |
|
242 |
"Modified (comment): / 09-02-2019 / 16:00:12 / Claus Gittinger" |
|
4448 | 243 |
! ! |
244 |
||
245 |
!Block methodsFor:'process creation'! |
|
246 |
||
247 |
promise |
|
248 |
"create a promise on the receiver. The promise will evaluate the |
|
249 |
receiver and promise to return the value with the #value message. |
|
250 |
The evaluation will be performed as a separate process. |
|
251 |
Asking the promise for its value will either block the asking process |
|
252 |
(if the evaluation has not yet been finished) or return the value |
|
253 |
immediately." |
|
254 |
||
255 |
^ Promise value:self |
|
256 |
||
257 |
" |
|
258 |
|p| |
|
259 |
||
260 |
p := [1000 factorial] promise. |
|
261 |
'do something else ...'. |
|
262 |
p value |
|
263 |
" |
|
264 |
! ! |
|
265 |
||
266 |
!Block methodsFor:'process creation'! |
|
267 |
||
268 |
promiseAt:prio |
|
269 |
"create a promise on the receiver. The promise will evaluate the |
|
270 |
receiver and promise to return the value with the #value message. |
|
271 |
The evaluation will be performed as a separate process running at prio. |
|
272 |
Asking the promise for its value will either block the asking process |
|
273 |
(if the evaluation has not yet been finished) or return the value |
|
274 |
immediately." |
|
275 |
||
276 |
^ Promise value:self priority:prio |
|
277 |
! ! |
|
278 |
||
2288 | 279 |
!CharacterArray methodsFor:'matching - phonetic'! |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
280 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
281 |
asKoelnerPhoneticCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
282 |
"return a koelner phonetic code. |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
283 |
The koelnerPhonetic code is for the german language what the soundex code is for english; |
2303 | 284 |
it returns simular strings for similar sounding words. |
285 |
There are some differences to soundex, though: |
|
286 |
its length is not limited to 4, but depends on the length of the original string; |
|
287 |
it does not start with the first character of the input. |
|
2288 | 288 |
|
289 |
Caveat: this phonetic code is especially suited for german words. |
|
2303 | 290 |
Please have a look at the other phonetic comparison operators found |
291 |
in PhoneticStringUtilities." |
|
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
292 |
|
2303 | 293 |
^ PhoneticStringUtilities koelnerPhoneticCodeOf:self |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
294 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
295 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
296 |
#( |
3715 | 297 |
'Müller' |
2303 | 298 |
'Miller' |
299 |
'Mueller' |
|
3715 | 300 |
'Mühler' |
301 |
'Mühlherr' |
|
302 |
'Mülherr' |
|
2303 | 303 |
'Myler' |
304 |
'Millar' |
|
305 |
'Myller' |
|
3715 | 306 |
'Müllar' |
307 |
'Müler' |
|
2303 | 308 |
'Muehler' |
3715 | 309 |
'Mülller' |
310 |
'Müllerr' |
|
2303 | 311 |
'Muehlherr' |
312 |
'Muellar' |
|
313 |
'Mueler' |
|
3715 | 314 |
'Mülleer' |
2303 | 315 |
'Mueller' |
3715 | 316 |
'Nüller' |
2303 | 317 |
'Nyller' |
318 |
'Niler' |
|
319 |
'Czerny' |
|
320 |
'Tscherny' |
|
321 |
'Czernie' |
|
322 |
'Tschernie' |
|
323 |
'Schernie' |
|
324 |
'Scherny' |
|
325 |
'Scherno' |
|
326 |
'Czerne' |
|
327 |
'Zerny' |
|
328 |
'Tzernie' |
|
329 |
'Breschnew' |
|
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
330 |
) do:[:w | |
2303 | 331 |
Transcript show:w; show:'->'; showCR:(w asKoelnerPhoneticCode) |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
332 |
]. |
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 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
336 |
'Breschnew' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
337 |
'Breschnew' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
338 |
'Breschneff' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
339 |
'Braeschneff' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
340 |
'Braessneff' asKoelnerPhoneticCode -> '17863' |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
341 |
'Pressneff' asKoelnerPhoneticCode -> '17863' |
3715 | 342 |
'Presznäph' asKoelnerPhoneticCode -> '17863' |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
343 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
344 |
! ! |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
345 |
|
2288 | 346 |
!CharacterArray methodsFor:'matching - phonetic'! |
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 |
asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
349 |
"return a soundex phonetic code or nil. |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
350 |
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
|
351 |
tool when searching for words where the correct spelling is unknown. |
4190 | 352 |
(read Knuth or search the web if you don't know what a soundex code is). |
2288 | 353 |
|
2337
755696d72648
comment/format in: #asSoundexCode
Claus Gittinger <cg@exept.de>
parents:
2303
diff
changeset
|
354 |
Caveat: 'similar sounding words' means: 'similar sounding in ENGLISH' |
4190 | 355 |
Please have a look at the other phonetic comparison operators found |
356 |
in PhoneticStringUtilities." |
|
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
357 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
358 |
^ PhoneticStringUtilities soundexCodeOf:self |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
359 |
|
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
360 |
" |
2303 | 361 |
'claus' asSoundexCode |
2199
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
362 |
'clause' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
363 |
'close' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
364 |
'smalltalk' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
365 |
'smaltalk' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
366 |
'smaltak' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
367 |
'smaltok' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
368 |
'smoltok' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
369 |
'aa' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
370 |
'by' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
371 |
'bab' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
372 |
'bob' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
373 |
'bop' asSoundexCode |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
374 |
" |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
375 |
! ! |
a9d3b1aa9f03
phonetic stuff extraced into libbasic2
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
376 |
|
2241 | 377 |
!CharacterArray methodsFor:'printing & storing'! |
378 |
||
2303 | 379 |
printf:args |
380 |
"Format and print the receiver with <args> formatted in C style, |
|
2295 | 381 |
as specified in the Unix C-language manual page for printf(3). |
3114 | 382 |
Return the resulting string (i.e actually, this is more like an sprintf). |
4619 | 383 |
For smalltalk specific formats, |
384 |
see documentation in PrintfScanf >> format_printf. |
|
2241 | 385 |
For copyright information, see goodies/String-printf_scanf.chg" |
2303 | 386 |
|
2241 | 387 |
|aStream| |
388 |
||
3538 | 389 |
aStream := CharacterWriteStream on:(self species uninitializedNew:self size). |
2260 | 390 |
self printf:args on:aStream. |
2241 | 391 |
^ aStream contents |
392 |
||
393 |
" |
|
3796 | 394 |
('%05x %d %f %o' printf:{ 123. 234*5. 1.234. 8r377 } ) |
2303 | 395 |
Transcript showCR:('%05x %d %f %o' printf:{ 123. 234*5. 1.234. 8r377 } ) |
2256 | 396 |
" |
397 |
||
398 |
" |
|
2241 | 399 |
Transcript showCR: 'Some examples:'!! |
400 |
||
401 |
Transcript show:'''%#x %#X %03o%*.*s'' printf: #(16rABCD 16rEF 5 9 5 ''ghijklmn'') = .'. |
|
2303 | 402 |
Transcript show: ('%#x %#X %03o%*.*s' printf: #(16rABCD 16rEF 5 9 5 'ghijklmn')). |
2241 | 403 |
Transcript showCR: '.' |
404 |
||
405 |
Transcript show: '''%- 10.4s%.2e'' printf: (Array with: ''abcdefghijkl'' with: Float pi) = .'. |
|
2303 | 406 |
Transcript show: ('%- 10.4s%.2e' printf: (Array with: 'abcdefghijkl' with: Float pi)). |
2241 | 407 |
Transcript showCR: '.' |
408 |
||
409 |
Transcript show: '''%8.3f'' printf: (Array with: 200 sqrt negated) = .'. |
|
410 |
Transcript show: ('%8.3f' printf: (Array with: 200 sqrt negated)). |
|
411 |
Transcript showCR: '.' |
|
412 |
||
413 |
Transcript show: '''%c'' printf: #(16r41) = .'. |
|
414 |
Transcript show: ('%c' printf: #(16r41)). |
|
415 |
Transcript showCR: '.' |
|
416 |
||
417 |
Transcript show: '''%f%2s%s%s%s'' sscanf: ''237.0 this is a test'' = '. |
|
418 |
Transcript showCR: ('%f%2s%s%s%s' sscanf: '237.0 this is a test') printString. |
|
419 |
||
420 |
Transcript show: '''%d%f%s'' sscanf: ''25 54.32e-01 monday'' = '. |
|
421 |
Transcript showCR: ('%d%f%s' sscanf: '25 54.32e-01 monday') printString. |
|
422 |
||
423 |
Transcript show: '''%f%*f %8[A-F0-9]%c%d 0x%x%f'' sscanf: ''12.45 1048.73 AE40Z527 0x75BCD15 34'' = '. |
|
424 |
Transcript showCR: ('%f%*f %8[A-F0-9]%c%d 0x%x%f' sscanf: '12.45 1048.73 AE40Z527 0x75BCD15 34') printString. |
|
425 |
" |
|
4528 | 426 |
|
427 |
"Modified (comment): / 14-11-2017 / 22:58:01 / cg" |
|
2241 | 428 |
! ! |
429 |
||
430 |
!CharacterArray methodsFor:'printing & storing'! |
|
431 |
||
2260 | 432 |
printf:args on:outStream |
433 |
"Format and print the receiver on <outStream> with <args> |
|
434 |
formatted in C style, as specified in the Unix C-language manual page for printf(3). |
|
4619 | 435 |
For smalltalk specific formats, |
436 |
see documentation in PrintfScanf >> format_printf. |
|
2260 | 437 |
For copyright information, see goodies/String-printf_scanf.chg" |
2303 | 438 |
|
4418 | 439 |
PrintfScanf printf:self on:outStream arguments: args |
440 |
||
441 |
" |
|
442 |
'%e' printf:{ 1234.567 ] on:Transcript |
|
443 |
||
444 |
'%10s%3d\n' printf:{ 'hello' . 12 } on:Transcript |
|
445 |
'%10s%3d\n' printf:{ '1234567890' . 12 } on:Transcript |
|
2260 | 446 |
|
4418 | 447 |
like C's printf, a longer datum may be formatted wider than the formatspec says: |
448 |
||
449 |
'%10s%3d\n' printf:{ '12345678901234' . 12 } on:Transcript |
|
450 |
||
451 |
'%10s%3d\n' printf:{ 'hello' . 12 } on:Transcript |
|
452 |
'%10s%03d\n' printf:{ 'hello' . 12 } on:Transcript |
|
453 |
" |
|
454 |
||
4528 | 455 |
"Modified (comment): / 14-11-2017 / 22:57:58 / cg" |
2260 | 456 |
! ! |
457 |
||
458 |
!CharacterArray methodsFor:'printing & storing'! |
|
459 |
||
2303 | 460 |
printfWith:arg1 |
2295 | 461 |
"Format and print the receiver with <arg1> formatted in C style, |
462 |
as specified in the Unix C-language manual page for printf(3). |
|
4528 | 463 |
Return the resulting string (i.e actually, this is more like an sprintf). |
4619 | 464 |
For smalltalk specific formats, |
465 |
see documentation in PrintfScanf >> format_printf" |
|
2303 | 466 |
|
2256 | 467 |
^ self printf:(Array with:arg1) |
468 |
||
469 |
" |
|
3796 | 470 |
('%05x' printfWith:123) |
2303 | 471 |
Transcript showCR:('%05x' printfWith:123) |
2256 | 472 |
" |
4528 | 473 |
|
474 |
"Modified (comment): / 14-11-2017 / 22:58:10 / cg" |
|
2256 | 475 |
! ! |
476 |
||
477 |
!CharacterArray methodsFor:'printing & storing'! |
|
478 |
||
2303 | 479 |
printfWith:arg1 with:arg2 |
480 |
"Format and print the receiver with <argI> formatted in C style, |
|
2295 | 481 |
as specified in the Unix C-language manual page for printf(3). |
4528 | 482 |
Return the resulting string (i.e actually, this is more like an sprintf). |
4619 | 483 |
For smalltalk specific formats, see documentation in PrintfScanf >> format_printf." |
2303 | 484 |
|
2256 | 485 |
^ self printf:(Array with:arg1 with:arg2) |
486 |
||
487 |
" |
|
2303 | 488 |
Transcript showCR:('%d %05x' printfWith:123 with:234) |
2256 | 489 |
" |
4528 | 490 |
|
491 |
"Modified (comment): / 14-11-2017 / 22:58:16 / cg" |
|
2256 | 492 |
! ! |
493 |
||
494 |
!CharacterArray methodsFor:'printing & storing'! |
|
495 |
||
496 |
printfWith:arg1 with:arg2 with:arg3 |
|
2303 | 497 |
"Format and print the receiver with <argI> formatted in C style, |
2295 | 498 |
as specified in the Unix C-language manual page for printf(3). |
4528 | 499 |
Return the resulting string (i.e actually, this is more like an sprintf). |
4619 | 500 |
For smalltalk specific formats, see documentation in PrintfScanf >> format_printf." |
2303 | 501 |
|
2256 | 502 |
^ self printf:(Array with:arg1 with:arg2 with:arg3) |
503 |
||
504 |
" |
|
2303 | 505 |
Transcript showCR:('%d %05x %08o' printfWith:123 with:234 with:345) |
2256 | 506 |
" |
4528 | 507 |
|
508 |
"Modified (comment): / 14-11-2017 / 22:58:20 / cg" |
|
2256 | 509 |
! ! |
510 |
||
511 |
!CharacterArray methodsFor:'printing & storing'! |
|
512 |
||
513 |
printfWith:arg1 with:arg2 with:arg3 with:arg4 |
|
2303 | 514 |
"Format and print the receiver with <argI> formatted in C style, |
2295 | 515 |
as specified in the Unix C-language manual page for printf(3). |
4528 | 516 |
Return the resulting string (i.e actually, this is more like an sprintf). |
4619 | 517 |
For smalltalk specific formats, see documentation in PrintfScanf >> format_printf." |
2303 | 518 |
|
2256 | 519 |
^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
520 |
||
521 |
" |
|
2303 | 522 |
Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123) |
2256 | 523 |
" |
4528 | 524 |
|
525 |
"Modified (comment): / 14-11-2017 / 22:58:23 / cg" |
|
526 |
! ! |
|
527 |
||
528 |
!CharacterArray methodsFor:'printing & storing'! |
|
529 |
||
530 |
printfWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
531 |
"Format and print the receiver with <argI> formatted in C style, |
|
532 |
as specified in the Unix C-language manual page for printf(3). |
|
533 |
Return the resulting string (i.e actually, this is more like an sprintf). |
|
4619 | 534 |
For smalltalk specific formats, see documentation in PrintfScanf >> format_printf." |
4528 | 535 |
|
536 |
^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
|
537 |
||
538 |
" |
|
539 |
Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123) |
|
540 |
" |
|
541 |
||
542 |
"Modified (comment): / 14-11-2017 / 22:58:28 / cg" |
|
2256 | 543 |
! ! |
544 |
||
545 |
!CharacterArray methodsFor:'printing & storing'! |
|
546 |
||
2241 | 547 |
printf_formatArgCount |
548 |
"Return the number of arguments required/produced if the receiver is interpreted |
|
549 |
as a printf/scanf format control string. |
|
4528 | 550 |
For smalltalk specific formats, see documentation in PrintfScanf. |
2241 | 551 |
For copyright information, see goodies/String-printf_scanf.chg" |
2303 | 552 |
|
4418 | 553 |
^ PrintfScanf formatArgCountFor:self. |
2241 | 554 |
|
4418 | 555 |
"Modified: / 19-06-2017 / 16:54:10 / cg" |
4528 | 556 |
"Modified (comment): / 14-11-2017 / 22:58:34 / cg" |
2241 | 557 |
! ! |
558 |
||
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
559 |
!CharacterArray methodsFor:'private'! |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
560 |
|
4418 | 561 |
printf_printArgFrom:formatStream to:outStream withData:argStream |
562 |
<resource: #obsolete> |
|
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
563 |
"Interpret the required number of arguments from <argStream> |
4418 | 564 |
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
|
565 |
Place the interpretation on <outStream>. |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
566 |
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
|
567 |
specified in the Unix C-language manual page for printf(3). |
4418 | 568 |
<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
|
569 |
$%, 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
|
570 |
|
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
571 |
Return when the conversion control string is consumed. |
4418 | 572 |
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
|
573 |
|
4418 | 574 |
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
|
575 |
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
|
576 |
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
|
577 |
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
|
578 |
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
|
579 |
|
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
580 |
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
|
581 |
|
4418 | 582 |
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
|
583 |
|
4418 | 584 |
"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
|
585 |
! ! |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
586 |
|
2241 | 587 |
!CharacterArray methodsFor:'printing & storing'! |
588 |
||
2260 | 589 |
printf_printOn:outStream withData:args |
590 |
<resource: #obsolete> |
|
2303 | 591 |
|
2241 | 592 |
"Format and print the receiver on <outStream> with <args> |
593 |
formatted in C style, as specified in the Unix C-language manual page for printf(3). |
|
594 |
||
595 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
596 |
||
2260 | 597 |
self obsoleteMethodWarning:'use printf:on:'. |
598 |
self printf:args on:outStream |
|
2241 | 599 |
! ! |
600 |
||
601 |
!CharacterArray methodsFor:'converting'! |
|
602 |
||
4473 | 603 |
scanf:dataStreamOrString |
2241 | 604 |
"Return a Collection of objects found in the Character Stream |
2303 | 605 |
<dataStream> as interpreted according to the receiver. |
2241 | 606 |
The receiver is assumed to be a conversion control string as |
607 |
specified in the Unix C-language manual page for scanf(3). |
|
608 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 609 |
|
4473 | 610 |
|dataStream| |
2241 | 611 |
|
4473 | 612 |
dataStream := dataStreamOrString readStream. |
613 |
^ PrintfScanf scanf:self fromStream:dataStream |
|
614 |
||
615 |
"/ |results format char| |
|
616 |
"/ |
|
617 |
"/ results := OrderedCollection new. |
|
618 |
"/ format := ReadStream on:self. |
|
619 |
"/ [ format atEnd ] whileFalse:[ |
|
620 |
"/ char := format next. |
|
621 |
"/ (char == Character space or:[ char == Character tab ]) ifTrue:[ |
|
622 |
"/ dataStream skipSeparators. |
|
623 |
"/ format skipSeparators |
|
624 |
"/ ]. |
|
625 |
"/ char == $% ifTrue:[ |
|
626 |
"/ PrintfScanf scanArgFrom:dataStream to:results format:format. |
|
627 |
"/ ] ifFalse:[ |
|
628 |
"/ dataStream peekFor:char |
|
629 |
"/ ] |
|
630 |
"/ ]. |
|
631 |
"/ ^ results |
|
2241 | 632 |
|
633 |
" |
|
2303 | 634 |
'%d %x' scanf:(ReadStream on:'1234 ff00') |
4473 | 635 |
'%d %s' scanf:(ReadStream on:'1234 ff00') |
636 |
'%d %b' scanf:(ReadStream on:'1234 1111') |
|
637 |
'%d %f' scanf:(ReadStream on:'1234 1111') |
|
638 |
'%d %f' scanf:(ReadStream on:'1234 1111.2345') |
|
639 |
'%d %q' scanf:(ReadStream on:'1234 1111.2345') |
|
2241 | 640 |
" |
4473 | 641 |
|
642 |
"Modified: / 14-07-2017 / 11:11:49 / cg" |
|
2241 | 643 |
! ! |
644 |
||
645 |
!CharacterArray methodsFor:'private'! |
|
646 |
||
2303 | 647 |
scanf_scanArgFrom:dataStream to:collection format:format |
4418 | 648 |
<resource: #obsolete> |
2241 | 649 |
"Add to <collection> an object who's representation is found |
650 |
in <dataStream> interpreted according to the conversion |
|
2303 | 651 |
control string in the Stream <format>. |
652 |
<format> is assumed to be positioned just past a $%, and a complete control |
|
2241 | 653 |
string is assumed available. |
654 |
||
655 |
Return when the conversion control string is consumed. Leave |
|
656 |
<format> pointing past the last character in the conversion |
|
657 |
control string, leave <dataStream> pointing past any width |
|
658 |
specified in <format>, or at the first character that doesn't |
|
659 |
make sense for the <format>. |
|
660 |
||
661 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 662 |
|
4473 | 663 |
PrintfScanf scanArgFrom:dataStream to:collection format:format. |
2256 | 664 |
|
665 |
" |
|
2303 | 666 |
'%d %x' sscanf:'1234 ff00' |
667 |
'%d %x %b' sscanf:'1234 ff00 1001' |
|
2256 | 668 |
" |
2679
cfab54d30fcc
changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
669 |
|
4473 | 670 |
"Modified: / 14-07-2017 / 11:09:35 / cg" |
2241 | 671 |
! ! |
672 |
||
673 |
!CharacterArray methodsFor:'converting'! |
|
674 |
||
2303 | 675 |
sscanf:string |
2241 | 676 |
"Return a Collection of objects found in <string> as |
2303 | 677 |
interpreted according to the receiver. |
2241 | 678 |
The receiver is assumed to be a conversion control string as |
679 |
specified in the Unix C-language manual page for scanf(3). |
|
680 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 681 |
|
2241 | 682 |
^ self scanf:(ReadStream on:string) |
683 |
||
684 |
" |
|
2303 | 685 |
'%d %x' sscanf:'1234 ff00' |
686 |
'%d %x %b' sscanf:'1234 ff00 1001' |
|
2241 | 687 |
" |
688 |
! ! |
|
689 |
||
4714 | 690 |
!CharacterArray methodsFor:'Compatibility-Squeak'! |
691 |
||
692 |
urlDecoded |
|
693 |
"decode %xx form. This is the opposite of #urlEncoded" |
|
694 |
||
695 |
^ HTMLUtilities urlDecoded:self |
|
696 |
||
697 |
" |
|
698 |
'abc%61def' unescapePercents |
|
699 |
'abc%61def' urlDecoded |
|
700 |
||
701 |
(HTMLUtilities urlEncoded:'_-.*Frankfurt(Main) Hbf') unescapePercents |
|
702 |
(HTMLUtilities urlEncoded:'_-.*Frankfurt(Main) Hbf') urlDecoded |
|
703 |
||
704 |
(HTMLUtilities urlEncoded:'-_.*%exept ex+pecco;') unescapePercents |
|
705 |
(HTMLUtilities urlEncoded:'-_.*%exept+ex+pecco;') urlDecoded |
|
706 |
" |
|
707 |
||
708 |
"Created: / 26-08-2018 / 12:41:49 / Claus Gittinger" |
|
709 |
! ! |
|
710 |
||
711 |
!CharacterArray methodsFor:'Compatibility-Squeak'! |
|
712 |
||
713 |
urlEncoded |
|
714 |
"encode into %xx form. This is the opposite of #urlDecoded" |
|
715 |
||
716 |
^ HTMLUtilities urlEncoded:self |
|
717 |
||
718 |
" |
|
719 |
'abcäöüdef' urlEncoded urlDecoded |
|
720 |
'abc%def' urlEncoded urlDecoded |
|
721 |
||
722 |
('_-.*Frankfurt(Main) Hbf' urlEncoded) unescapePercents |
|
723 |
('_-.*Frankfurt(Main) Hbf' urlEncoded) urlDecoded |
|
724 |
||
725 |
('-_.*%exept ex+pecco;' urlEncoded) unescapePercents |
|
726 |
('-_.*%exept+ex+pecco;' urlEncoded) urlDecoded |
|
727 |
" |
|
728 |
||
729 |
"Created: / 26-08-2018 / 13:03:03 / Claus Gittinger" |
|
730 |
! ! |
|
731 |
||
4365
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
732 |
!Collection methodsFor:'converting'! |
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 |
asHalfFloatArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
735 |
"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
|
736 |
(which must convert to 16bit half-floats)." |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
737 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
738 |
^ self asArrayOfType:HalfFloatArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
739 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
740 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
741 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
742 |
|
4400 | 743 |
asIdentitySkipList |
744 |
"Answer a IdentitySkipList whose elements are the elements of the |
|
745 |
receiver. The sort order is the default less than or equal." |
|
746 |
||
747 |
^ self as: IdentitySkipList |
|
748 |
! ! |
|
749 |
||
750 |
!Collection methodsFor:'converting'! |
|
751 |
||
4365
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
752 |
asList |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
753 |
"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
|
754 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
755 |
^ self addAllTo:(List new:self size) |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
756 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
757 |
"Created: 14.2.1997 / 16:25:23 / cg" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
758 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
759 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
760 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
761 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
762 |
asRunArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
763 |
"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
|
764 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
765 |
^ RunArray from:self. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
766 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
767 |
"/ |runs lastElement occurrences| |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
768 |
"/ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
769 |
"/ runs := RunArray new. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
770 |
"/ occurrences := 0. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
771 |
"/ self do:[:each | |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
772 |
"/ each == lastElement ifTrue:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
773 |
"/ occurrences := occurrences + 1 |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
774 |
"/ ] ifFalse:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
775 |
"/ runs add:lastElement withOccurrences:occurrences. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
776 |
"/ occurrences := 1. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
777 |
"/ lastElement := each |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
778 |
"/ ]. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
779 |
"/ ]. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
780 |
"/ occurrences ~~ 0 ifTrue:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
781 |
"/ runs add:lastElement withOccurrences:occurrences |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
782 |
"/ ]. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
783 |
"/ ^ runs |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
784 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
785 |
" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
786 |
#(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
|
787 |
" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
788 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
789 |
"Modified: / 7.4.1998 / 09:50:54 / cg" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
790 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
791 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
792 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
793 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
794 |
asSharedCollection |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
795 |
"return a shared collection on the receiver. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
796 |
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
|
797 |
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
|
798 |
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
|
799 |
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
|
800 |
tuned for this kind of operation." |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
801 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
802 |
^ SharedCollection for:self. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
803 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
804 |
|
4400 | 805 |
!Collection methodsFor:'converting'! |
806 |
||
807 |
asSkipList |
|
808 |
"Answer a SkipList whose elements are the elements of the |
|
809 |
receiver. The sort order is the default less than or equal." |
|
810 |
||
811 |
^ self as: SkipList |
|
812 |
! ! |
|
813 |
||
814 |
!Collection methodsFor:'converting'! |
|
815 |
||
816 |
asSkipList: aSortBlock |
|
817 |
"Answer a SkipList whose elements are the elements of the |
|
818 |
receiver. The sort order is defined by the argument, aSortBlock." |
|
819 |
||
820 |
| skipList | |
|
821 |
skipList := SkipList new: self size sortBlock: aSortBlock. |
|
822 |
skipList addAll: self. |
|
823 |
^ skipList |
|
824 |
||
825 |
"Modified (comment): / 18-06-2017 / 22:40:10 / cg" |
|
826 |
! ! |
|
827 |
||
2237 | 828 |
!Float methodsFor:'private'! |
829 |
||
2303 | 830 |
absDecimalPrintOn:aStream digits:digits |
2237 | 831 |
"Place a string representation of the receiver's abs value |
832 |
on <aStream> using <digits> significant digits, using decimal notation. |
|
833 |
This is a helper for printf." |
|
834 |
||
4429 | 835 |
<resource: #obsolete> |
836 |
PrintfScanf absDecimalPrintFloat:self on:aStream digits:digits. |
|
2237 | 837 |
|
4429 | 838 |
"Modified: / 20-06-2017 / 11:49:15 / cg" |
2237 | 839 |
! ! |
840 |
||
841 |
!Float methodsFor:'private'! |
|
842 |
||
2303 | 843 |
absPrintOn:aStream digits:digits |
844 |
"Place a string representation of the receiver's abs value on <aStream> using |
|
2237 | 845 |
<digits> significant digits. |
846 |
This is a helper for printf." |
|
2303 | 847 |
|
4429 | 848 |
<resource: #obsolete> |
4418 | 849 |
PrintfScanf absPrintFloat:self on:aStream digits:digits |
850 |
||
4429 | 851 |
"Modified: / 20-06-2017 / 11:49:11 / cg" |
2237 | 852 |
! ! |
853 |
||
854 |
!Float methodsFor:'private'! |
|
855 |
||
2303 | 856 |
absScientificPrintOn:aStream digits:digits |
2237 | 857 |
"Place a string representation of the receiver's abs value on <aStream> using <digits> significant |
858 |
digits, using scientific notation. |
|
859 |
This is a helper for printf." |
|
2303 | 860 |
|
4429 | 861 |
<resource: #obsolete> |
4418 | 862 |
PrintfScanf absScientificPrintFloat:self on:aStream digits:digits. |
2237 | 863 |
|
4418 | 864 |
"Modified: / 19-06-2017 / 14:59:56 / cg" |
4429 | 865 |
"Modified (format): / 20-06-2017 / 11:49:07 / cg" |
2237 | 866 |
! ! |
867 |
||
4381 | 868 |
!Float methodsFor:'coercing & converting'! |
869 |
||
870 |
asQDouble |
|
871 |
"return a QDouble with my value" |
|
872 |
||
873 |
^ QDouble fromFloat:self |
|
874 |
||
875 |
" |
|
876 |
1.0 asQDouble |
|
877 |
" |
|
878 |
||
879 |
"Created: / 13-06-2017 / 16:48:57 / cg" |
|
880 |
! ! |
|
881 |
||
4383 | 882 |
!Integer methodsFor:'coercing & converting'! |
883 |
||
884 |
asQDouble |
|
885 |
"return a QDouble with same value as myself." |
|
886 |
||
887 |
^ QDouble fromInteger:self |
|
888 |
||
889 |
" |
|
890 |
1234567890 asQDouble |
|
891 |
1234567890 asQDouble asInteger |
|
892 |
12345678901234567890 asQDouble |
|
893 |
12345678901234567890 asQDouble asInteger |
|
894 |
" |
|
895 |
||
896 |
"Created: / 12-06-2017 / 18:41:07 / cg" |
|
897 |
"Modified (comment): / 12-06-2017 / 20:55:24 / cg" |
|
898 |
! ! |
|
899 |
||
1759 | 900 |
!Object methodsFor:'dependents-interests'! |
901 |
||
902 |
addInterest:anInterest |
|
903 |
"install an interest forwarder. |
|
904 |
Here, we use the nonWeakDependencies." |
|
905 |
||
906 |
self addNonWeakDependent:anInterest |
|
907 |
||
908 |
"Created: 14.10.1996 / 22:27:34 / stefan" |
|
909 |
! ! |
|
910 |
||
3896 | 911 |
!Object methodsFor:'converting'! |
912 |
||
913 |
asDoubleLink |
|
914 |
"return a valueDoubleLink for the receiver. |
|
915 |
Used to make sure the receiver can be added to a double linked list" |
|
916 |
||
917 |
^ ValueDoubleLink value:self |
|
918 |
! ! |
|
919 |
||
1759 | 920 |
!Object methodsFor:'dependents-interests'! |
921 |
||
922 |
expressInterestIn:aspect for:anObject sendBack:aSelector |
|
923 |
"arrange for aSelector to be sent to anObject whenever the receiver |
|
924 |
changes aspect." |
|
925 |
||
926 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
|
927 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
928 |
||
2303 | 929 |
self addInterest:(InterestConverter |
930 |
destination:anObject |
|
931 |
selector:aSelector |
|
932 |
aspect:aspect) |
|
1759 | 933 |
|
934 |
" |
|
935 |
|p b| |
|
936 |
||
937 |
b := [Transcript showCR:' -> the point changed']. |
|
938 |
||
939 |
p := Point new. |
|
940 |
Transcript showCR:'interest in #foo:'. |
|
941 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
942 |
p x:1. |
|
943 |
Transcript showCR:'now changing #bar ... (expect no notification)'. |
|
944 |
p changed:#bar. |
|
945 |
Transcript cr. |
|
946 |
||
947 |
Delay waitForSeconds:1. |
|
948 |
Transcript showCR:'now changing #foo ... (expect notification)'. |
|
949 |
p changed:#foo. |
|
950 |
Transcript cr. |
|
951 |
||
952 |
Delay waitForSeconds:1. |
|
953 |
Transcript showCR:'no more interest in #foo:'. |
|
954 |
p retractInterestIn:#foo for:b. |
|
955 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
956 |
p changed:#foo. |
|
957 |
Transcript cr. |
|
958 |
||
959 |
Delay waitForSeconds:1. |
|
960 |
Transcript showCR:'interest in #bar now:'. |
|
961 |
p expressInterestIn:#bar for:b sendBack:#value. |
|
962 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
963 |
p changed:#foo. |
|
964 |
Transcript showCR:'now changing #bar ... (expect notification)'. |
|
965 |
p changed:#bar. |
|
966 |
Transcript cr. |
|
967 |
||
968 |
Delay waitForSeconds:1. |
|
969 |
Transcript showCR:'interest in #foo now:'. |
|
970 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
971 |
Transcript showCR:'now changing #foo ... (expect notification)'. |
|
972 |
p changed:#foo. |
|
973 |
Transcript showCR:'now changing #bar ... (expect notification)'. |
|
974 |
p changed:#bar. |
|
975 |
Transcript cr. |
|
976 |
||
977 |
Delay waitForSeconds:1. |
|
978 |
Transcript showCR:'no more interests:'. |
|
979 |
p retractInterestsFor:b. |
|
980 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
981 |
p changed:#foo. |
|
982 |
Transcript showCR:'now changing #bar... (expect no notification)'. |
|
983 |
p changed:#bar. |
|
984 |
Transcript cr. |
|
985 |
||
986 |
p release. |
|
987 |
" |
|
1668 | 988 |
|
1759 | 989 |
"Created: 19.4.1996 / 10:26:22 / cg" |
990 |
"Modified: 19.4.1996 / 12:34:08 / cg" |
|
991 |
"Modified: 14.10.1996 / 22:28:20 / stefan" |
|
992 |
! ! |
|
993 |
||
994 |
!Object methodsFor:'dependents-interests'! |
|
995 |
||
996 |
interests |
|
997 |
"return a Collection of interests - empty if there is none. |
|
998 |
Here, we use the nonWeakDependents for interests." |
|
999 |
||
1000 |
^ self nonWeakDependents |
|
1001 |
||
1002 |
"Created: / 14.10.1996 / 22:20:51 / stefan" |
|
1003 |
"Modified: / 30.1.1998 / 14:07:35 / cg" |
|
1004 |
! ! |
|
1005 |
||
1006 |
!Object methodsFor:'dependents-interests'! |
|
1007 |
||
1008 |
interestsFor:someOne |
|
1009 |
"return a collection of interests of someOne - empty if there is none." |
|
1010 |
||
1011 |
|coll deps| |
|
1012 |
||
1013 |
deps := self interests. |
|
1014 |
deps size == 0 ifTrue:[^ #()]. |
|
1015 |
||
1016 |
coll := IdentitySet new. |
|
1017 |
||
1018 |
deps do:[:dep | |
|
2303 | 1019 |
(dep isInterestConverter) ifTrue:[ |
1020 |
dep destination == someOne ifTrue:[ |
|
1021 |
coll add:dep. |
|
1022 |
] |
|
1023 |
] |
|
1759 | 1024 |
]. |
1025 |
^ coll |
|
1026 |
||
1027 |
"Created: / 30.1.1998 / 14:02:26 / cg" |
|
1028 |
"Modified: / 30.1.1998 / 14:08:24 / cg" |
|
1029 |
! ! |
|
1668 | 1030 |
|
1759 | 1031 |
!Object methodsFor:'dependents-interests'! |
1032 |
||
1033 |
onChangeEvaluate:aBlock |
|
1034 |
"arrange for aBlock to be evaluated whenever the receiver changes." |
|
1035 |
||
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
|
1036 |
|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
|
1037 |
|
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
1038 |
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
|
1039 |
na == 0 ifTrue:[ |
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
1040 |
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
|
1041 |
] ifFalse:[ |
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
1042 |
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
|
1043 |
]. |
329461c02e84
allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents:
1759
diff
changeset
|
1044 |
^ self onChangeSend:selector to:aBlock |
1759 | 1045 |
|
1046 |
" |
|
1047 |
|p b| |
|
1048 |
||
1049 |
b := [Transcript showCR:' -> the point changed']. |
|
1050 |
||
1051 |
p := Point new. |
|
1052 |
Transcript showCR:'interest in #foo:'. |
|
1053 |
p onChangeEvaluate:b. |
|
1054 |
p x:1. |
|
1055 |
Transcript showCR:'now changing #bar ... (expect no notification)'. |
|
1056 |
p changed:#bar. |
|
1057 |
||
1058 |
p retractInterests. |
|
1059 |
p changed:#bar. |
|
1060 |
" |
|
1061 |
! ! |
|
1062 |
||
1063 |
!Object methodsFor:'dependents-interests'! |
|
1064 |
||
1065 |
onChangeSend:aSelector to:anObject |
|
1066 |
"arrange for aSelector to be sent to anObject whenever the receiver |
|
4030 | 1067 |
changes. |
1068 |
Use retractInterestsFor: in case you are no longer interested" |
|
1759 | 1069 |
|
1070 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
|
1071 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1072 |
||
4773 | 1073 |
(self interests contains:[:anInterest | |
1074 |
anInterest isInterestConverter |
|
1075 |
and:[anInterest destination == anObject |
|
1076 |
and:[anInterest selector == aSelector]] |
|
1077 |
] |
|
1078 |
) ifFalse:[ |
|
1079 |
self addInterest:(InterestConverter |
|
1080 |
destination:anObject |
|
1081 |
selector:aSelector) |
|
1082 |
]. |
|
1759 | 1083 |
|
1668 | 1084 |
|
1085 |
" |
|
1759 | 1086 |
|p b| |
1087 |
||
1088 |
b := [Transcript showCR:'the point changed']. |
|
1089 |
||
1090 |
p := Point new. |
|
1091 |
p onChangeSend:#value to:b. |
|
1092 |
p x:1. |
|
1093 |
Transcript showCR:'now changing'. |
|
1094 |
p changed. |
|
1095 |
Transcript cr. |
|
1096 |
||
1097 |
Delay waitForSeconds:1. |
|
1098 |
Transcript showCR:'now changing'. |
|
1099 |
p changed. |
|
1100 |
Transcript cr. |
|
1101 |
||
1102 |
Delay waitForSeconds:1. |
|
1103 |
Transcript showCR:'no more interest'. |
|
1104 |
p retractInterestsFor:b. |
|
1105 |
Transcript showCR:'now changing again'. |
|
1106 |
p changed. |
|
1107 |
Transcript cr. |
|
1108 |
||
1109 |
Delay waitForSeconds:1. |
|
1110 |
Transcript showCR:'interest again'. |
|
1111 |
p onChangeSend:#value to:b. |
|
1112 |
Transcript showCR:'now changing again'. |
|
1113 |
p changed. |
|
1114 |
Transcript cr. |
|
1115 |
" |
|
1116 |
||
4773 | 1117 |
"Created: / 19-04-1996 / 10:26:38 / cg" |
1118 |
"Modified: / 19-04-1996 / 12:34:26 / cg" |
|
1119 |
"Modified: / 14-10-1996 / 22:28:27 / stefan" |
|
1120 |
"Modified: / 30-11-2018 / 18:01:47 / Stefan Vogel" |
|
1759 | 1121 |
! ! |
1122 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1123 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1124 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1125 |
removeActionsForEvent:eventSymbol |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1126 |
"remove ST/V-style event triggers." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1127 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1128 |
self retractInterestsIn:eventSymbol |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1129 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1130 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1131 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1132 |
|
2903 | 1133 |
removeActionsWithReceiver:aReceiver |
1134 |
"remove ST/V-style event triggers." |
|
1135 |
||
1136 |
self retractInterestsFor:aReceiver |
|
1137 |
! ! |
|
1138 |
||
1139 |
!Object methodsFor:'dependents-st/v event simulation'! |
|
1140 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1141 |
removeAllActionsWithReceiver:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1142 |
"remove ST/V-style event triggers." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1143 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1144 |
self retractInterestsFor:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1145 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1146 |
|
1759 | 1147 |
!Object methodsFor:'dependents-interests'! |
1148 |
||
4969
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1149 |
removeDependentAndRetractInterestsFor:someOne |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1150 |
"remove any dependency and interest of someOne in the receiver. |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1151 |
Answer the receiver" |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1152 |
|
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1153 |
self retractInterestsFor:someOne. |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1154 |
self removeDependent:someOne. |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1155 |
|
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1156 |
"Created: / 30-05-2019 / 11:11:19 / Claus Gittinger" |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1157 |
! ! |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1158 |
|
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1159 |
!Object methodsFor:'dependents-interests'! |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1160 |
|
1759 | 1161 |
removeInterest:anInterest |
1162 |
"remove an interest forwarder. |
|
1163 |
Here, we use the nonWeakDependencies." |
|
1164 |
||
1165 |
self removeNonWeakDependent:anInterest |
|
1166 |
||
1167 |
"Created: 14.10.1996 / 22:21:59 / stefan" |
|
1168 |
! ! |
|
1169 |
||
1170 |
!Object methodsFor:'dependents-interests'! |
|
1171 |
||
1172 |
retractInterestIn:aspect for:someOne |
|
1173 |
"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
|
1174 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1175 |
Answer the retracted interests." |
1759 | 1176 |
|
1177 |
"/ for now, remove the interestConverter. |
|
1178 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1179 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1180 |
^ self retractInterestsForWhich:[:i | |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1181 |
(i aspect == aspect) and:[i destination == someOne] |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1182 |
] |
1759 | 1183 |
|
1668 | 1184 |
" |
1759 | 1185 |
|p b| |
1186 |
||
1187 |
b := [Transcript showCR:'the point changed']. |
|
1188 |
||
1189 |
p := Point new. |
|
1190 |
Transcript showCR:'interest in #foo'. |
|
1191 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
1192 |
p x:1. |
|
1193 |
Transcript showCR:'now changing #bar'. |
|
1194 |
p changed:#bar. |
|
1195 |
Transcript cr. |
|
1196 |
||
1197 |
Delay waitForSeconds:1. |
|
1198 |
Transcript showCR:'now changing #foo'. |
|
1199 |
p changed:#foo. |
|
1200 |
Transcript cr. |
|
1201 |
||
1202 |
Delay waitForSeconds:1. |
|
1203 |
Transcript showCR:'no more interest in #foo'. |
|
1204 |
p retractInterestIn:#foo for:b. |
|
1205 |
Transcript showCR:'now changing #foo'. |
|
1206 |
p changed:#foo. |
|
1207 |
Transcript cr. |
|
1208 |
||
1209 |
Delay waitForSeconds:1. |
|
1210 |
Transcript showCR:'interest in #bar now'. |
|
1211 |
p expressInterestIn:#bar for:b sendBack:#value. |
|
1212 |
Transcript showCR:'now changing #foo'. |
|
1213 |
p changed:#foo. |
|
1214 |
Transcript showCR:'now changing #bar'. |
|
1215 |
p changed:#bar. |
|
1216 |
Transcript cr. |
|
1217 |
||
1218 |
Delay waitForSeconds:1. |
|
1219 |
Transcript showCR:'interest in #foo now'. |
|
1220 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
1221 |
Transcript showCR:'now changing #foo'. |
|
1222 |
p changed:#foo. |
|
1223 |
Transcript showCR:'now changing #bar'. |
|
1224 |
p changed:#bar. |
|
1225 |
Transcript cr. |
|
1226 |
||
1227 |
Delay waitForSeconds:1. |
|
1228 |
Transcript showCR:'no more interests'. |
|
1229 |
p retractInterestsFor:b. |
|
1230 |
Transcript showCR:'now changing #foo'. |
|
1231 |
p changed:#foo. |
|
1232 |
Transcript showCR:'now changing #bar'. |
|
1233 |
p changed:#bar. |
|
1234 |
Transcript cr. |
|
1235 |
" |
|
1236 |
||
1237 |
"Created: / 19.4.1996 / 10:27:11 / cg" |
|
1238 |
"Modified: / 14.10.1996 / 22:21:19 / stefan" |
|
1239 |
"Modified: / 30.1.1998 / 14:05:34 / cg" |
|
1240 |
! ! |
|
1241 |
||
1242 |
!Object methodsFor:'dependents-interests'! |
|
1243 |
||
1244 |
retractInterests |
|
1245 |
"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
|
1246 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1247 |
Answer the retraced interests." |
1759 | 1248 |
|
1249 |
"/ for now, remove the interestConverter. |
|
1250 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1251 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1252 |
^ self retractInterestsForWhich:[:i | true ] |
1759 | 1253 |
! ! |
1254 |
||
1255 |
!Object methodsFor:'dependents-interests'! |
|
1256 |
||
1257 |
retractInterestsFor:someOne |
|
2303 | 1258 |
"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
|
1259 |
(as installed with #onChangeSend:to:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1260 |
Answer the retracted interests." |
1759 | 1261 |
|
1262 |
"/ for now, remove the interestConverter. |
|
1263 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1264 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1265 |
^ self retractInterestsForWhich:[:i | i destination == someOne ] |
1759 | 1266 |
|
1267 |
" |
|
1268 |
|p b| |
|
1269 |
||
1270 |
b := [Transcript showCR:'the point changed']. |
|
1271 |
||
1272 |
p := Point new. |
|
1273 |
p onChangeSend:#value to:b. |
|
1274 |
p x:1. |
|
1275 |
Transcript showCR:'now changing'. |
|
1276 |
p changed. |
|
1277 |
Transcript cr. |
|
1278 |
||
1279 |
Delay waitForSeconds:1. |
|
1280 |
Transcript showCR:'now changing'. |
|
1281 |
p changed. |
|
1282 |
Transcript cr. |
|
1283 |
||
1284 |
Delay waitForSeconds:1. |
|
1285 |
Transcript showCR:'no more interest'. |
|
1286 |
p retractInterestsFor:b. |
|
1287 |
Transcript showCR:'now changing again'. |
|
1288 |
p changed. |
|
1289 |
Transcript cr. |
|
1290 |
||
1291 |
Delay waitForSeconds:1. |
|
1292 |
Transcript showCR:'interest again'. |
|
1293 |
p onChangeSend:#value to:b. |
|
1294 |
Transcript showCR:'now changing again'. |
|
1295 |
p changed. |
|
1296 |
Transcript cr. |
|
1297 |
" |
|
1298 |
||
1299 |
"Created: / 19.4.1996 / 10:23:46 / cg" |
|
1300 |
"Modified: / 14.10.1996 / 22:21:25 / stefan" |
|
1301 |
"Modified: / 30.1.1998 / 14:04:52 / cg" |
|
1302 |
! ! |
|
1303 |
||
1304 |
!Object methodsFor:'dependents-interests'! |
|
1305 |
||
1306 |
retractInterestsForWhich:aBlock |
|
1307 |
"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
|
1308 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1309 |
Answer the retracted interests." |
1759 | 1310 |
|
1311 |
"/ for now, remove the interestConverter. |
|
1312 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1313 |
||
1314 |
|deps coll| |
|
1315 |
||
1316 |
deps := self interests. |
|
1317 |
deps size ~~ 0 ifTrue:[ |
|
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1318 |
"/ 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
|
1319 |
coll := IdentitySet new. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1320 |
deps do:[:dep | |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1321 |
dep isInterestConverter ifTrue:[ |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1322 |
(aBlock value:dep) ifTrue:[coll add:dep]. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1323 |
] |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1324 |
]. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1325 |
coll do:[:dep | |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1326 |
self removeInterest:dep. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1327 |
]. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1328 |
^ coll. |
1759 | 1329 |
]. |
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1330 |
^ #() |
1759 | 1331 |
! ! |
1332 |
||
1333 |
!Object methodsFor:'dependents-interests'! |
|
1334 |
||
1335 |
retractInterestsIn:aspect |
|
1336 |
"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
|
1337 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1338 |
Answer the retracted interests." |
1759 | 1339 |
|
1340 |
"/ for now, remove the interestConverter. |
|
1341 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1342 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1343 |
^ self retractInterestsForWhich:[:i | i aspect == aspect ] |
1668 | 1344 |
! ! |
1345 |
||
2901 | 1346 |
!Object methodsFor:'Compatibility-Dolphin'! |
1347 |
||
1348 |
trigger:anAspect |
|
1349 |
self changed:anAspect |
|
1350 |
! ! |
|
1351 |
||
1352 |
!Object methodsFor:'Compatibility-Dolphin'! |
|
1353 |
||
1354 |
trigger:anAspect with:anArgument |
|
1355 |
self changed:anAspect with:anArgument |
|
1356 |
! ! |
|
1357 |
||
1358 |
!Object methodsFor:'dependents-st/v event simulation'! |
|
1359 |
||
1360 |
triggerEvent:aSymbol |
|
1361 |
self changed:aSymbol |
|
1362 |
! ! |
|
1363 |
||
1668 | 1364 |
!Object methodsFor:'dependents-st/v event simulation'! |
1365 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1366 |
triggerEvent:eventSymbol with:aParameter |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1367 |
"perform ST/V-style event triggering." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1368 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1369 |
self changed:eventSymbol with:(Array with:aParameter). |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1370 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1371 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1372 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1373 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1374 |
triggerEvent:eventSymbol withArguments:parameters |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1375 |
"perform ST/V-style event triggering." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1376 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1377 |
self changed:eventSymbol with:parameters. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1378 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1379 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1380 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1381 |
|
1668 | 1382 |
when:eventSymbol send:selector to:anObject |
1383 |
"install an ST/V-style interest forwarder. |
|
1384 |
Here, we use the nonWeakDependencies." |
|
1385 |
||
1386 |
self addInterest:(InterestConverterWithParameters |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1387 |
destination:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1388 |
selector:selector |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1389 |
aspect:eventSymbol). |
1668 | 1390 |
|
1391 |
" |
|
1392 |
|p b| |
|
1393 |
||
1394 |
b := [Transcript showCR:'the point changed']. |
|
1395 |
||
1396 |
p := Point new. |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1397 |
p when:#foo:bar: send:#value:value: to:[:a :b | Transcript show:'foo: '; show:a; show:' bar: '; showCR:b]. |
1668 | 1398 |
Transcript showCR:'now changing'. |
1399 |
p triggerEvent:#foo:bar: withArguments:#('fooArg' 'barArg'). |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1400 |
p removeActionsForEvent:#foo:bar:. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1401 |
" |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1402 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1403 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1404 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1405 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1406 |
when:eventSymbol send:selector to:anObject with:aParameter |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1407 |
"install an ST/V-style interest forwarder. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1408 |
Here, we use the nonWeakDependencies." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1409 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1410 |
self addInterest:((InterestConverterWithParameters |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1411 |
destination:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1412 |
selector:selector |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1413 |
aspect:eventSymbol) |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1414 |
defaultParameters:(Array with:aParameter)). |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1415 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1416 |
" |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1417 |
|p b| |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1418 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1419 |
b := [Transcript showCR:'the point changed']. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1420 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1421 |
p := Point new. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1422 |
p |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1423 |
when:#foo: |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1424 |
send:#value: |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1425 |
to:[:a | Transcript show:'foo: '; showCR:a] |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1426 |
with:123. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1427 |
Transcript showCR:'now changing'. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1428 |
p triggerEvent:#foo:. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1429 |
p triggerEvent:#foo: with:987. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1430 |
p removeActionsForEvent:#foo:. |
1668 | 1431 |
" |
1432 |
! ! |
|
1433 |
||
2901 | 1434 |
!Object methodsFor:'Compatibility-Dolphin'! |
1435 |
||
1436 |
when:anAspect sendTo:anObject |
|
1437 |
self expressInterestIn:anAspect for:anObject sendBack:anAspect |
|
1438 |
! ! |
|
1439 |
||
2364 | 1440 |
!Stream methodsFor:'stacked computing streams'! |
1441 |
||
1442 |
collecting:aBlock |
|
1443 |
"return a stacked computing stream, which reads elements from the receiver, |
|
1444 |
applies aBlock to each read element, and provides the results as elements to its reader." |
|
1445 |
||
1446 |
^ CollectingReadStream on:self collecting:aBlock |
|
3094 | 1447 |
|
1448 |
" |
|
1449 |
|s s2| |
|
1450 |
||
1451 |
s := 'hello world' readStream. |
|
1452 |
s2 := s collecting:[:ch | ch asUppercase]. |
|
1453 |
s2 upToEnd. |
|
1454 |
" |
|
2364 | 1455 |
! ! |
1456 |
||
4620 | 1457 |
!Stream methodsFor:'writing'! |
1458 |
||
1459 |
printf:format |
|
1460 |
"C-style printing into a stream. |
|
1461 |
For smalltalk specific formats, |
|
1462 |
see documentation in PrintfScanf >> format_printf" |
|
1463 |
||
1464 |
format printf:#() on:self. |
|
1465 |
||
1466 |
" |
|
1467 |
Transcript printf:'Hello World\n' |
|
4866 | 1468 |
Transcript printf:'Hello World %d\n' with:123 |
4620 | 1469 |
" |
4866 | 1470 |
|
1471 |
"Modified (comment): / 17-03-2019 / 15:05:29 / Claus Gittinger" |
|
4620 | 1472 |
! ! |
1473 |
||
1474 |
!Stream methodsFor:'writing'! |
|
1475 |
||
1476 |
printf:format arguments:arguments |
|
1477 |
"C-style printing into a stream. |
|
1478 |
Same as printf:withAll:, for protocol completeness. |
|
1479 |
For smalltalk specific formats, |
|
1480 |
see documentation in PrintfScanf >> format_printf" |
|
1481 |
||
1482 |
format printf:arguments on:self. |
|
1483 |
||
1484 |
" |
|
1485 |
Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 } |
|
1486 |
Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 } |
|
1487 |
" |
|
1488 |
||
1489 |
"Created: / 23-02-2017 / 16:43:39 / cg" |
|
1490 |
! ! |
|
1491 |
||
1492 |
!Stream methodsFor:'writing'! |
|
1493 |
||
1494 |
printf:format with:argument |
|
1495 |
"C-style printing into a stream. |
|
1496 |
For smalltalk specific formats, |
|
1497 |
see documentation in PrintfScanf >> format_printf" |
|
1498 |
||
1499 |
format printf:{argument} on:self. |
|
1500 |
||
1501 |
" |
|
1502 |
Transcript printf:'%05x\n' with:12345 |
|
1503 |
" |
|
1504 |
! ! |
|
1505 |
||
1506 |
!Stream methodsFor:'writing'! |
|
1507 |
||
1508 |
printf:format with:argument1 with:argument2 |
|
1509 |
"C-style printing into a stream. |
|
1510 |
For smalltalk specific formats, |
|
1511 |
see documentation in PrintfScanf >> format_printf" |
|
1512 |
||
1513 |
format printf:{argument1 . argument2} on:self. |
|
1514 |
||
1515 |
" |
|
1516 |
Transcript printf:'%05x %3s\n' with:12345 with:'abc' |
|
1517 |
" |
|
1518 |
! ! |
|
1519 |
||
1520 |
!Stream methodsFor:'writing'! |
|
1521 |
||
1522 |
printf:format with:argument1 with:argument2 with:argument3 |
|
1523 |
"C-style printing into a stream. |
|
1524 |
For smalltalk specific formats, |
|
1525 |
see documentation in PrintfScanf >> format_printf" |
|
1526 |
||
1527 |
format printf:{argument1 . argument2 . argument3} on:self. |
|
1528 |
||
1529 |
" |
|
1530 |
Transcript printf:'%05x %3s %09s\n' with:12345 with:'abc' with:'abc' |
|
1531 |
Transcript printf:'%05x %3s %9s\n' with:12345 with:'abc' with:'abc' |
|
1532 |
" |
|
1533 |
! ! |
|
1534 |
||
1535 |
!Stream methodsFor:'writing'! |
|
1536 |
||
1537 |
printf:format with:argument1 with:argument2 with:argument3 with:argument4 |
|
1538 |
"C-style printing into a stream. |
|
1539 |
For smalltalk specific formats, |
|
1540 |
see documentation in PrintfScanf >> format_printf" |
|
1541 |
||
1542 |
format printf:{argument1 . argument2 . argument3 . argument4} on:self. |
|
1543 |
||
1544 |
" |
|
1545 |
Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4 |
|
1546 |
Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4 |
|
1547 |
Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4 |
|
1548 |
" |
|
1549 |
! ! |
|
1550 |
||
1551 |
!Stream methodsFor:'writing'! |
|
1552 |
||
1553 |
printf:format with:argument1 with:argument2 with:argument3 with:argument4 with:argument5 |
|
1554 |
"C-style printing into a stream. |
|
1555 |
For smalltalk specific formats, |
|
1556 |
see documentation in PrintfScanf >> format_printf" |
|
1557 |
||
1558 |
format printf:{argument1 . argument2 . argument3 . argument4 . argument5} on:self. |
|
1559 |
||
1560 |
" |
|
1561 |
Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4 |
|
1562 |
Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4 |
|
1563 |
Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4 |
|
1564 |
" |
|
1565 |
! ! |
|
1566 |
||
1567 |
!Stream methodsFor:'writing'! |
|
1568 |
||
1569 |
printf:format withAll:arguments |
|
1570 |
"C-style printing into a stream. |
|
1571 |
For smalltalk specific formats, |
|
1572 |
see documentation in PrintfScanf >> format_printf" |
|
1573 |
||
1574 |
format printf:arguments on:self. |
|
1575 |
||
1576 |
" |
|
1577 |
Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 } |
|
1578 |
Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 } |
|
1579 |
" |
|
1580 |
! ! |
|
1581 |
||
2364 | 1582 |
!Stream methodsFor:'stacked computing streams'! |
1583 |
||
1584 |
selecting:aBlock |
|
1585 |
"return a stacked computing stream, which reads elements from the receiver, |
|
1586 |
but only provides elements for which aBlock returns true to its reader." |
|
1587 |
||
1588 |
^ SelectingReadStream on:self selecting:aBlock |
|
3094 | 1589 |
|
1590 |
" |
|
1591 |
|s s2| |
|
1592 |
||
1593 |
s := 'hello world' readStream. |
|
1594 |
s2 := s selecting:[:ch | ch isVowel]. |
|
1595 |
s2 upToEnd. |
|
1596 |
" |
|
2364 | 1597 |
! ! |
1598 |
||
2303 | 1599 |
!stx_libbasic2 class methodsFor:'documentation'! |
1600 |
||
1601 |
extensionsVersion_CVS |
|
3715 | 1602 |
^ '$Header$' |
3005 | 1603 |
! ! |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
1604 |