author | Claus Gittinger <cg@exept.de> |
Mon, 25 Nov 2019 15:22:11 +0100 | |
changeset 5292 | 975a4c7373cb |
parent 5234 | d2fc4924e6eb |
child 5293 | db346a540bf9 |
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) |
5234 | 489 |
('%d %05x' printfWith:123 with:234) |
490 |
('%d%02d' printfWith:2004 with:9) |
|
2256 | 491 |
" |
4528 | 492 |
|
493 |
"Modified (comment): / 14-11-2017 / 22:58:16 / cg" |
|
2256 | 494 |
! ! |
495 |
||
496 |
!CharacterArray methodsFor:'printing & storing'! |
|
497 |
||
498 |
printfWith:arg1 with:arg2 with:arg3 |
|
2303 | 499 |
"Format and print the receiver with <argI> formatted in C style, |
2295 | 500 |
as specified in the Unix C-language manual page for printf(3). |
4528 | 501 |
Return the resulting string (i.e actually, this is more like an sprintf). |
4619 | 502 |
For smalltalk specific formats, see documentation in PrintfScanf >> format_printf." |
2303 | 503 |
|
2256 | 504 |
^ self printf:(Array with:arg1 with:arg2 with:arg3) |
505 |
||
506 |
" |
|
2303 | 507 |
Transcript showCR:('%d %05x %08o' printfWith:123 with:234 with:345) |
2256 | 508 |
" |
4528 | 509 |
|
510 |
"Modified (comment): / 14-11-2017 / 22:58:20 / cg" |
|
2256 | 511 |
! ! |
512 |
||
513 |
!CharacterArray methodsFor:'printing & storing'! |
|
514 |
||
515 |
printfWith:arg1 with:arg2 with:arg3 with:arg4 |
|
2303 | 516 |
"Format and print the receiver with <argI> formatted in C style, |
2295 | 517 |
as specified in the Unix C-language manual page for printf(3). |
4528 | 518 |
Return the resulting string (i.e actually, this is more like an sprintf). |
4619 | 519 |
For smalltalk specific formats, see documentation in PrintfScanf >> format_printf." |
2303 | 520 |
|
2256 | 521 |
^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
522 |
||
523 |
" |
|
2303 | 524 |
Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123) |
2256 | 525 |
" |
4528 | 526 |
|
527 |
"Modified (comment): / 14-11-2017 / 22:58:23 / cg" |
|
528 |
! ! |
|
529 |
||
530 |
!CharacterArray methodsFor:'printing & storing'! |
|
531 |
||
532 |
printfWith:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
533 |
"Format and print the receiver with <argI> formatted in C style, |
|
534 |
as specified in the Unix C-language manual page for printf(3). |
|
535 |
Return the resulting string (i.e actually, this is more like an sprintf). |
|
4619 | 536 |
For smalltalk specific formats, see documentation in PrintfScanf >> format_printf." |
4528 | 537 |
|
538 |
^ self printf:(Array with:arg1 with:arg2 with:arg3 with:arg4 with:arg5) |
|
539 |
||
540 |
" |
|
541 |
Transcript showCR:('%d %05x %08o %b' printfWith:123 with:234 with:345 with:123) |
|
542 |
" |
|
543 |
||
544 |
"Modified (comment): / 14-11-2017 / 22:58:28 / cg" |
|
2256 | 545 |
! ! |
546 |
||
547 |
!CharacterArray methodsFor:'printing & storing'! |
|
548 |
||
2241 | 549 |
printf_formatArgCount |
550 |
"Return the number of arguments required/produced if the receiver is interpreted |
|
551 |
as a printf/scanf format control string. |
|
4528 | 552 |
For smalltalk specific formats, see documentation in PrintfScanf. |
2241 | 553 |
For copyright information, see goodies/String-printf_scanf.chg" |
2303 | 554 |
|
4418 | 555 |
^ PrintfScanf formatArgCountFor:self. |
2241 | 556 |
|
4418 | 557 |
"Modified: / 19-06-2017 / 16:54:10 / cg" |
4528 | 558 |
"Modified (comment): / 14-11-2017 / 22:58:34 / cg" |
2241 | 559 |
! ! |
560 |
||
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
561 |
!CharacterArray methodsFor:'private'! |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
562 |
|
4418 | 563 |
printf_printArgFrom:formatStream to:outStream withData:argStream |
564 |
<resource: #obsolete> |
|
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
565 |
"Interpret the required number of arguments from <argStream> |
4418 | 566 |
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
|
567 |
Place the interpretation on <outStream>. |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
568 |
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
|
569 |
specified in the Unix C-language manual page for printf(3). |
4418 | 570 |
<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
|
571 |
$%, 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
|
572 |
|
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
573 |
Return when the conversion control string is consumed. |
4418 | 574 |
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
|
575 |
|
4418 | 576 |
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
|
577 |
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
|
578 |
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
|
579 |
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
|
580 |
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
|
581 |
|
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
582 |
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
|
583 |
|
4418 | 584 |
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
|
585 |
|
4418 | 586 |
"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
|
587 |
! ! |
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
588 |
|
2241 | 589 |
!CharacterArray methodsFor:'printing & storing'! |
590 |
||
2260 | 591 |
printf_printOn:outStream withData:args |
592 |
<resource: #obsolete> |
|
2303 | 593 |
|
2241 | 594 |
"Format and print the receiver on <outStream> with <args> |
595 |
formatted in C style, as specified in the Unix C-language manual page for printf(3). |
|
596 |
||
597 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
598 |
||
2260 | 599 |
self obsoleteMethodWarning:'use printf:on:'. |
600 |
self printf:args on:outStream |
|
2241 | 601 |
! ! |
602 |
||
603 |
!CharacterArray methodsFor:'converting'! |
|
604 |
||
4473 | 605 |
scanf:dataStreamOrString |
2241 | 606 |
"Return a Collection of objects found in the Character Stream |
2303 | 607 |
<dataStream> as interpreted according to the receiver. |
2241 | 608 |
The receiver is assumed to be a conversion control string as |
609 |
specified in the Unix C-language manual page for scanf(3). |
|
610 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 611 |
|
4473 | 612 |
|dataStream| |
2241 | 613 |
|
4473 | 614 |
dataStream := dataStreamOrString readStream. |
615 |
^ PrintfScanf scanf:self fromStream:dataStream |
|
616 |
||
617 |
"/ |results format char| |
|
618 |
"/ |
|
619 |
"/ results := OrderedCollection new. |
|
620 |
"/ format := ReadStream on:self. |
|
621 |
"/ [ format atEnd ] whileFalse:[ |
|
622 |
"/ char := format next. |
|
623 |
"/ (char == Character space or:[ char == Character tab ]) ifTrue:[ |
|
624 |
"/ dataStream skipSeparators. |
|
625 |
"/ format skipSeparators |
|
626 |
"/ ]. |
|
627 |
"/ char == $% ifTrue:[ |
|
628 |
"/ PrintfScanf scanArgFrom:dataStream to:results format:format. |
|
629 |
"/ ] ifFalse:[ |
|
630 |
"/ dataStream peekFor:char |
|
631 |
"/ ] |
|
632 |
"/ ]. |
|
633 |
"/ ^ results |
|
2241 | 634 |
|
635 |
" |
|
2303 | 636 |
'%d %x' scanf:(ReadStream on:'1234 ff00') |
4473 | 637 |
'%d %s' scanf:(ReadStream on:'1234 ff00') |
638 |
'%d %b' scanf:(ReadStream on:'1234 1111') |
|
639 |
'%d %f' scanf:(ReadStream on:'1234 1111') |
|
640 |
'%d %f' scanf:(ReadStream on:'1234 1111.2345') |
|
641 |
'%d %q' scanf:(ReadStream on:'1234 1111.2345') |
|
2241 | 642 |
" |
4473 | 643 |
|
644 |
"Modified: / 14-07-2017 / 11:11:49 / cg" |
|
2241 | 645 |
! ! |
646 |
||
647 |
!CharacterArray methodsFor:'private'! |
|
648 |
||
2303 | 649 |
scanf_scanArgFrom:dataStream to:collection format:format |
4418 | 650 |
<resource: #obsolete> |
2241 | 651 |
"Add to <collection> an object who's representation is found |
652 |
in <dataStream> interpreted according to the conversion |
|
2303 | 653 |
control string in the Stream <format>. |
654 |
<format> is assumed to be positioned just past a $%, and a complete control |
|
2241 | 655 |
string is assumed available. |
656 |
||
657 |
Return when the conversion control string is consumed. Leave |
|
658 |
<format> pointing past the last character in the conversion |
|
659 |
control string, leave <dataStream> pointing past any width |
|
660 |
specified in <format>, or at the first character that doesn't |
|
661 |
make sense for the <format>. |
|
662 |
||
663 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 664 |
|
4473 | 665 |
PrintfScanf scanArgFrom:dataStream to:collection format:format. |
2256 | 666 |
|
667 |
" |
|
2303 | 668 |
'%d %x' sscanf:'1234 ff00' |
669 |
'%d %x %b' sscanf:'1234 ff00 1001' |
|
2256 | 670 |
" |
2679
cfab54d30fcc
changed: #scanArgFrom:to:format:
Claus Gittinger <cg@exept.de>
parents:
2582
diff
changeset
|
671 |
|
4473 | 672 |
"Modified: / 14-07-2017 / 11:09:35 / cg" |
2241 | 673 |
! ! |
674 |
||
675 |
!CharacterArray methodsFor:'converting'! |
|
676 |
||
2303 | 677 |
sscanf:string |
2241 | 678 |
"Return a Collection of objects found in <string> as |
2303 | 679 |
interpreted according to the receiver. |
2241 | 680 |
The receiver is assumed to be a conversion control string as |
681 |
specified in the Unix C-language manual page for scanf(3). |
|
682 |
For copyright information, see goodies/String-printf_scanf.chg" |
|
2303 | 683 |
|
2241 | 684 |
^ self scanf:(ReadStream on:string) |
685 |
||
686 |
" |
|
2303 | 687 |
'%d %x' sscanf:'1234 ff00' |
688 |
'%d %x %b' sscanf:'1234 ff00 1001' |
|
2241 | 689 |
" |
690 |
! ! |
|
691 |
||
4714 | 692 |
!CharacterArray methodsFor:'Compatibility-Squeak'! |
693 |
||
694 |
urlDecoded |
|
695 |
"decode %xx form. This is the opposite of #urlEncoded" |
|
696 |
||
697 |
^ HTMLUtilities urlDecoded:self |
|
698 |
||
699 |
" |
|
700 |
'abc%61def' unescapePercents |
|
701 |
'abc%61def' urlDecoded |
|
702 |
||
703 |
(HTMLUtilities urlEncoded:'_-.*Frankfurt(Main) Hbf') unescapePercents |
|
704 |
(HTMLUtilities urlEncoded:'_-.*Frankfurt(Main) Hbf') urlDecoded |
|
705 |
||
706 |
(HTMLUtilities urlEncoded:'-_.*%exept ex+pecco;') unescapePercents |
|
707 |
(HTMLUtilities urlEncoded:'-_.*%exept+ex+pecco;') urlDecoded |
|
708 |
" |
|
709 |
||
710 |
"Created: / 26-08-2018 / 12:41:49 / Claus Gittinger" |
|
711 |
! ! |
|
712 |
||
713 |
!CharacterArray methodsFor:'Compatibility-Squeak'! |
|
714 |
||
715 |
urlEncoded |
|
716 |
"encode into %xx form. This is the opposite of #urlDecoded" |
|
717 |
||
718 |
^ HTMLUtilities urlEncoded:self |
|
719 |
||
720 |
" |
|
721 |
'abcäöüdef' urlEncoded urlDecoded |
|
722 |
'abc%def' urlEncoded urlDecoded |
|
723 |
||
724 |
('_-.*Frankfurt(Main) Hbf' urlEncoded) unescapePercents |
|
725 |
('_-.*Frankfurt(Main) Hbf' urlEncoded) urlDecoded |
|
726 |
||
727 |
('-_.*%exept ex+pecco;' urlEncoded) unescapePercents |
|
728 |
('-_.*%exept+ex+pecco;' urlEncoded) urlDecoded |
|
729 |
" |
|
730 |
||
731 |
"Created: / 26-08-2018 / 13:03:03 / Claus Gittinger" |
|
732 |
! ! |
|
733 |
||
4365
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
734 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
735 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
736 |
asHalfFloatArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
737 |
"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
|
738 |
(which must convert to 16bit half-floats)." |
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 |
^ self asArrayOfType:HalfFloatArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
741 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
742 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
743 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
744 |
|
4400 | 745 |
asIdentitySkipList |
746 |
"Answer a IdentitySkipList whose elements are the elements of the |
|
747 |
receiver. The sort order is the default less than or equal." |
|
748 |
||
749 |
^ self as: IdentitySkipList |
|
750 |
! ! |
|
751 |
||
752 |
!Collection methodsFor:'converting'! |
|
753 |
||
4365
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
754 |
asList |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
755 |
"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
|
756 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
757 |
^ self addAllTo:(List new:self size) |
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 |
"Created: 14.2.1997 / 16:25:23 / cg" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
760 |
! ! |
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 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
763 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
764 |
asRunArray |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
765 |
"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
|
766 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
767 |
^ RunArray from:self. |
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 lastElement occurrences| |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
770 |
"/ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
771 |
"/ runs := RunArray new. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
772 |
"/ occurrences := 0. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
773 |
"/ self do:[:each | |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
774 |
"/ each == lastElement ifTrue:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
775 |
"/ occurrences := occurrences + 1 |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
776 |
"/ ] ifFalse:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
777 |
"/ runs add:lastElement withOccurrences:occurrences. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
778 |
"/ occurrences := 1. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
779 |
"/ lastElement := each |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
780 |
"/ ]. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
781 |
"/ ]. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
782 |
"/ occurrences ~~ 0 ifTrue:[ |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
783 |
"/ runs add:lastElement withOccurrences:occurrences |
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 |
"/ ^ runs |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
786 |
|
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 |
#(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
|
789 |
" |
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 |
"Modified: / 7.4.1998 / 09:50:54 / cg" |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
792 |
! ! |
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 |
!Collection methodsFor:'converting'! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
795 |
|
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
796 |
asSharedCollection |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
797 |
"return a shared collection on the receiver. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
798 |
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
|
799 |
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
|
800 |
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
|
801 |
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
|
802 |
tuned for this kind of operation." |
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 |
^ SharedCollection for:self. |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
805 |
! ! |
c166b1f7825c
Move methods from Collection to libbasic2
Stefan Vogel <sv@exept.de>
parents:
4202
diff
changeset
|
806 |
|
4400 | 807 |
!Collection methodsFor:'converting'! |
808 |
||
809 |
asSkipList |
|
810 |
"Answer a SkipList whose elements are the elements of the |
|
811 |
receiver. The sort order is the default less than or equal." |
|
812 |
||
813 |
^ self as: SkipList |
|
814 |
! ! |
|
815 |
||
816 |
!Collection methodsFor:'converting'! |
|
817 |
||
818 |
asSkipList: aSortBlock |
|
819 |
"Answer a SkipList whose elements are the elements of the |
|
820 |
receiver. The sort order is defined by the argument, aSortBlock." |
|
821 |
||
822 |
| skipList | |
|
823 |
skipList := SkipList new: self size sortBlock: aSortBlock. |
|
824 |
skipList addAll: self. |
|
825 |
^ skipList |
|
826 |
||
827 |
"Modified (comment): / 18-06-2017 / 22:40:10 / cg" |
|
828 |
! ! |
|
829 |
||
2237 | 830 |
!Float methodsFor:'private'! |
831 |
||
2303 | 832 |
absDecimalPrintOn:aStream digits:digits |
2237 | 833 |
"Place a string representation of the receiver's abs value |
834 |
on <aStream> using <digits> significant digits, using decimal notation. |
|
835 |
This is a helper for printf." |
|
836 |
||
4429 | 837 |
<resource: #obsolete> |
838 |
PrintfScanf absDecimalPrintFloat:self on:aStream digits:digits. |
|
2237 | 839 |
|
4429 | 840 |
"Modified: / 20-06-2017 / 11:49:15 / cg" |
2237 | 841 |
! ! |
842 |
||
843 |
!Float methodsFor:'private'! |
|
844 |
||
2303 | 845 |
absPrintOn:aStream digits:digits |
846 |
"Place a string representation of the receiver's abs value on <aStream> using |
|
2237 | 847 |
<digits> significant digits. |
848 |
This is a helper for printf." |
|
2303 | 849 |
|
4429 | 850 |
<resource: #obsolete> |
4418 | 851 |
PrintfScanf absPrintFloat:self on:aStream digits:digits |
852 |
||
4429 | 853 |
"Modified: / 20-06-2017 / 11:49:11 / cg" |
2237 | 854 |
! ! |
855 |
||
856 |
!Float methodsFor:'private'! |
|
857 |
||
2303 | 858 |
absScientificPrintOn:aStream digits:digits |
2237 | 859 |
"Place a string representation of the receiver's abs value on <aStream> using <digits> significant |
860 |
digits, using scientific notation. |
|
861 |
This is a helper for printf." |
|
2303 | 862 |
|
4429 | 863 |
<resource: #obsolete> |
4418 | 864 |
PrintfScanf absScientificPrintFloat:self on:aStream digits:digits. |
2237 | 865 |
|
4418 | 866 |
"Modified: / 19-06-2017 / 14:59:56 / cg" |
4429 | 867 |
"Modified (format): / 20-06-2017 / 11:49:07 / cg" |
2237 | 868 |
! ! |
869 |
||
4381 | 870 |
!Float methodsFor:'coercing & converting'! |
871 |
||
872 |
asQDouble |
|
873 |
"return a QDouble with my value" |
|
874 |
||
875 |
^ QDouble fromFloat:self |
|
876 |
||
877 |
" |
|
878 |
1.0 asQDouble |
|
879 |
" |
|
880 |
||
881 |
"Created: / 13-06-2017 / 16:48:57 / cg" |
|
882 |
! ! |
|
883 |
||
4383 | 884 |
!Integer methodsFor:'coercing & converting'! |
885 |
||
5292
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
886 |
asOctaFloat |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
887 |
"return a OctaFloat with same value as myself. |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
888 |
Since octaFloats have a limited precision, you may loose bits when |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
889 |
doing this." |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
890 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
891 |
^ OctaFloat fromInteger:self |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
892 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
893 |
" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
894 |
1234567890 asOctaFloat |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
895 |
1234567890 asOctaFloat asInteger |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
896 |
12345678901234567890 asOctaFloat |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
897 |
12345678901234567890 asOctaFloat asInteger |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
898 |
" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
899 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
900 |
"Created: / 07-06-2019 / 02:30:38 / Claus Gittinger" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
901 |
! ! |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
902 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
903 |
!Integer methodsFor:'coercing & converting'! |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
904 |
|
4383 | 905 |
asQDouble |
906 |
"return a QDouble with same value as myself." |
|
907 |
||
908 |
^ QDouble fromInteger:self |
|
909 |
||
910 |
" |
|
911 |
1234567890 asQDouble |
|
912 |
1234567890 asQDouble asInteger |
|
913 |
12345678901234567890 asQDouble |
|
914 |
12345678901234567890 asQDouble asInteger |
|
915 |
" |
|
916 |
||
917 |
"Created: / 12-06-2017 / 18:41:07 / cg" |
|
918 |
"Modified (comment): / 12-06-2017 / 20:55:24 / cg" |
|
919 |
! ! |
|
920 |
||
5292
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
921 |
!Integer methodsFor:'coercing & converting'! |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
922 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
923 |
asQuadFloat |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
924 |
"return a QuadFloat with same value as myself. |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
925 |
Since quadFloats have a limited precision, you may loose bits when |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
926 |
doing this." |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
927 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
928 |
^ QuadFloat fromInteger:self |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
929 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
930 |
" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
931 |
1234567890 asQuadFloat |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
932 |
1234567890 asQuadFloat asInteger |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
933 |
12345678901234567890 asQuadFloat |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
934 |
12345678901234567890 asQuadFloat asInteger |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
935 |
" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
936 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
937 |
"Created: / 07-06-2019 / 02:30:38 / Claus Gittinger" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
938 |
! ! |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
939 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
940 |
!Integer methodsFor:'Compatibility-Squeak'! |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
941 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
942 |
atRandom |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
943 |
"return a random number between 1 and myself" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
944 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
945 |
^ self atRandom:Random. |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
946 |
|
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
947 |
" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
948 |
100 atRandom |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
949 |
1000 atRandom |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
950 |
" |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
951 |
! ! |
975a4c7373cb
methods shuffled to their package
Claus Gittinger <cg@exept.de>
parents:
5234
diff
changeset
|
952 |
|
1759 | 953 |
!Object methodsFor:'dependents-interests'! |
954 |
||
955 |
addInterest:anInterest |
|
956 |
"install an interest forwarder. |
|
957 |
Here, we use the nonWeakDependencies." |
|
958 |
||
959 |
self addNonWeakDependent:anInterest |
|
960 |
||
961 |
"Created: 14.10.1996 / 22:27:34 / stefan" |
|
962 |
! ! |
|
963 |
||
3896 | 964 |
!Object methodsFor:'converting'! |
965 |
||
966 |
asDoubleLink |
|
967 |
"return a valueDoubleLink for the receiver. |
|
968 |
Used to make sure the receiver can be added to a double linked list" |
|
969 |
||
970 |
^ ValueDoubleLink value:self |
|
971 |
! ! |
|
972 |
||
1759 | 973 |
!Object methodsFor:'dependents-interests'! |
974 |
||
975 |
expressInterestIn:aspect for:anObject sendBack:aSelector |
|
976 |
"arrange for aSelector to be sent to anObject whenever the receiver |
|
977 |
changes aspect." |
|
978 |
||
979 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
|
980 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
981 |
||
2303 | 982 |
self addInterest:(InterestConverter |
983 |
destination:anObject |
|
984 |
selector:aSelector |
|
985 |
aspect:aspect) |
|
1759 | 986 |
|
987 |
" |
|
988 |
|p b| |
|
989 |
||
990 |
b := [Transcript showCR:' -> the point changed']. |
|
991 |
||
992 |
p := Point new. |
|
993 |
Transcript showCR:'interest in #foo:'. |
|
994 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
995 |
p x:1. |
|
996 |
Transcript showCR:'now changing #bar ... (expect no notification)'. |
|
997 |
p changed:#bar. |
|
998 |
Transcript cr. |
|
999 |
||
1000 |
Delay waitForSeconds:1. |
|
1001 |
Transcript showCR:'now changing #foo ... (expect notification)'. |
|
1002 |
p changed:#foo. |
|
1003 |
Transcript cr. |
|
1004 |
||
1005 |
Delay waitForSeconds:1. |
|
1006 |
Transcript showCR:'no more interest in #foo:'. |
|
1007 |
p retractInterestIn:#foo for:b. |
|
1008 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
1009 |
p changed:#foo. |
|
1010 |
Transcript cr. |
|
1011 |
||
1012 |
Delay waitForSeconds:1. |
|
1013 |
Transcript showCR:'interest in #bar now:'. |
|
1014 |
p expressInterestIn:#bar for:b sendBack:#value. |
|
1015 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
1016 |
p changed:#foo. |
|
1017 |
Transcript showCR:'now changing #bar ... (expect notification)'. |
|
1018 |
p changed:#bar. |
|
1019 |
Transcript cr. |
|
1020 |
||
1021 |
Delay waitForSeconds:1. |
|
1022 |
Transcript showCR:'interest in #foo now:'. |
|
1023 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
1024 |
Transcript showCR:'now changing #foo ... (expect notification)'. |
|
1025 |
p changed:#foo. |
|
1026 |
Transcript showCR:'now changing #bar ... (expect notification)'. |
|
1027 |
p changed:#bar. |
|
1028 |
Transcript cr. |
|
1029 |
||
1030 |
Delay waitForSeconds:1. |
|
1031 |
Transcript showCR:'no more interests:'. |
|
1032 |
p retractInterestsFor:b. |
|
1033 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
|
1034 |
p changed:#foo. |
|
1035 |
Transcript showCR:'now changing #bar... (expect no notification)'. |
|
1036 |
p changed:#bar. |
|
1037 |
Transcript cr. |
|
1038 |
||
1039 |
p release. |
|
1040 |
" |
|
1668 | 1041 |
|
1759 | 1042 |
"Created: 19.4.1996 / 10:26:22 / cg" |
1043 |
"Modified: 19.4.1996 / 12:34:08 / cg" |
|
1044 |
"Modified: 14.10.1996 / 22:28:20 / stefan" |
|
1045 |
! ! |
|
1046 |
||
1047 |
!Object methodsFor:'dependents-interests'! |
|
1048 |
||
1049 |
interests |
|
1050 |
"return a Collection of interests - empty if there is none. |
|
1051 |
Here, we use the nonWeakDependents for interests." |
|
1052 |
||
1053 |
^ self nonWeakDependents |
|
1054 |
||
1055 |
"Created: / 14.10.1996 / 22:20:51 / stefan" |
|
1056 |
"Modified: / 30.1.1998 / 14:07:35 / cg" |
|
1057 |
! ! |
|
1058 |
||
1059 |
!Object methodsFor:'dependents-interests'! |
|
1060 |
||
1061 |
interestsFor:someOne |
|
1062 |
"return a collection of interests of someOne - empty if there is none." |
|
1063 |
||
1064 |
|coll deps| |
|
1065 |
||
1066 |
deps := self interests. |
|
1067 |
deps size == 0 ifTrue:[^ #()]. |
|
1068 |
||
1069 |
coll := IdentitySet new. |
|
1070 |
||
1071 |
deps do:[:dep | |
|
2303 | 1072 |
(dep isInterestConverter) ifTrue:[ |
1073 |
dep destination == someOne ifTrue:[ |
|
1074 |
coll add:dep. |
|
1075 |
] |
|
1076 |
] |
|
1759 | 1077 |
]. |
1078 |
^ coll |
|
1079 |
||
1080 |
"Created: / 30.1.1998 / 14:02:26 / cg" |
|
1081 |
"Modified: / 30.1.1998 / 14:08:24 / cg" |
|
1082 |
! ! |
|
1668 | 1083 |
|
1759 | 1084 |
!Object methodsFor:'dependents-interests'! |
1085 |
||
5139 | 1086 |
onChange:aspect evaluate:aBlock |
1087 |
"arrange for aBlock to be evaluated whenever the receiver changes the given aspect." |
|
1088 |
||
1089 |
|na selector| |
|
1090 |
||
1091 |
na := aBlock argumentCount. |
|
1092 |
na == 0 ifTrue:[ |
|
1093 |
selector := #value |
|
1094 |
] ifFalse:[ |
|
1095 |
selector := #( #'value:' #'value:value:' #'value:value:value:') at:na |
|
1096 |
]. |
|
1097 |
^ self onChange:aspect send:selector to:aBlock |
|
1098 |
||
1099 |
" |
|
1100 |
|p b| |
|
1101 |
||
1102 |
b := [Transcript showCR:' -> the point changed X']. |
|
1103 |
||
1104 |
p := Point new. |
|
1105 |
Transcript showCR:'interest in #x, #y'. |
|
1106 |
p onChange:#x evaluate:b. |
|
1107 |
p onChange:#y evaluate:[Transcript showCR:' -> the point changed Y']. |
|
1108 |
Transcript showCR:'now changing ...'. |
|
1109 |
p changed. |
|
1110 |
Transcript showCR:'now changing #bar ...'. |
|
1111 |
p changed:#bar. |
|
1112 |
Transcript showCR:'now changing #x ...'. |
|
1113 |
p x:1. |
|
1114 |
p changed:#x. |
|
1115 |
Transcript showCR:'now changing #y ...'. |
|
1116 |
p y:1. |
|
1117 |
p changed:#y. |
|
1118 |
||
1119 |
Transcript showCR:'no more interests'. |
|
1120 |
p retractInterests. |
|
1121 |
p changed:#bar. |
|
1122 |
p changed:#y. |
|
1123 |
p changed:#x. |
|
1124 |
" |
|
1125 |
! ! |
|
1126 |
||
1127 |
!Object methodsFor:'dependents-interests'! |
|
1128 |
||
1129 |
onChange:aspect send:aSelector to:anObject |
|
1130 |
"arrange for aSelector to be sent to anObject whenever the receiver |
|
1131 |
changed the given aspect. |
|
1132 |
Use retractInterestsFor: in case you are no longer interested" |
|
1133 |
||
1134 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
|
1135 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1136 |
||
1137 |
(self interests contains:[:anInterest | |
|
1138 |
anInterest isInterestConverter |
|
1139 |
and:[anInterest destination == anObject |
|
1140 |
and:[anInterest selector == aSelector |
|
1141 |
and:[anInterest aspect == aspect]]] |
|
1142 |
] |
|
1143 |
) ifFalse:[ |
|
1144 |
self addInterest:(InterestConverter |
|
1145 |
destination:anObject |
|
1146 |
selector:aSelector |
|
1147 |
aspect:aspect) |
|
1148 |
]. |
|
1149 |
||
1150 |
||
1151 |
" |
|
1152 |
|p b| |
|
1153 |
||
1154 |
b := [Transcript showCR:'the point changed X']. |
|
1155 |
||
1156 |
p := Point new. |
|
1157 |
p onChange:#x send:#value to:b. |
|
1158 |
p onChange:#y send:#value to:[Transcript showCR:'the point changed Y']. |
|
1159 |
Transcript showCR:'now changing x'. |
|
1160 |
p x:1. |
|
1161 |
p changed:#x. |
|
1162 |
Transcript cr. |
|
1163 |
||
1164 |
Transcript showCR:'now changing y'. |
|
1165 |
p y:2. |
|
1166 |
p changed:#y. |
|
1167 |
Transcript cr. |
|
1168 |
||
1169 |
Delay waitForSeconds:1. |
|
1170 |
Transcript showCR:'now changing (any)'. |
|
1171 |
p changed. |
|
1172 |
Transcript cr. |
|
1173 |
||
1174 |
Delay waitForSeconds:1. |
|
1175 |
Transcript showCR:'no more interest in x'. |
|
1176 |
p retractInterestsFor:b. |
|
1177 |
Transcript showCR:'now changing again'. |
|
1178 |
p changed:#y. |
|
1179 |
p changed:#x. |
|
1180 |
p changed. |
|
1181 |
Transcript cr. |
|
1182 |
||
1183 |
Delay waitForSeconds:1. |
|
1184 |
Transcript showCR:'interest in x again'. |
|
1185 |
p onChange:#x send:#value to:b. |
|
1186 |
Transcript showCR:'now changing again'. |
|
1187 |
p changed:#y. |
|
1188 |
p changed:#x. |
|
1189 |
p changed. |
|
1190 |
Transcript cr. |
|
1191 |
||
1192 |
Transcript showCR:'no more interest at all'. |
|
1193 |
p retractInterests. |
|
1194 |
p changed:#y. |
|
1195 |
p changed:#x. |
|
1196 |
p changed. |
|
1197 |
Transcript cr. |
|
1198 |
" |
|
1199 |
||
1200 |
"Created: / 19-04-1996 / 10:26:38 / cg" |
|
1201 |
"Modified: / 19-04-1996 / 12:34:26 / cg" |
|
1202 |
"Modified: / 14-10-1996 / 22:28:27 / stefan" |
|
1203 |
"Modified: / 30-11-2018 / 18:01:47 / Stefan Vogel" |
|
1204 |
! ! |
|
1205 |
||
1206 |
!Object methodsFor:'dependents-interests'! |
|
1207 |
||
1759 | 1208 |
onChangeEvaluate:aBlock |
1209 |
"arrange for aBlock to be evaluated whenever the receiver changes." |
|
1210 |
||
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
|
1211 |
|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
|
1212 |
|
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
1213 |
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
|
1214 |
na == 0 ifTrue:[ |
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
1215 |
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
|
1216 |
] ifFalse:[ |
3559
fa3443d808a1
Changed Object>>#onChangeEvaluate: (send #argumentCount instead of #numArgs)
Stefan Vogel <sv@exept.de>
parents:
3538
diff
changeset
|
1217 |
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
|
1218 |
]. |
329461c02e84
allow for 0,1,2 arguments (update params) to be passed to interest blocks.
Claus Gittinger <cg@exept.de>
parents:
1759
diff
changeset
|
1219 |
^ self onChangeSend:selector to:aBlock |
1759 | 1220 |
|
1221 |
" |
|
1222 |
|p b| |
|
1223 |
||
1224 |
b := [Transcript showCR:' -> the point changed']. |
|
1225 |
||
1226 |
p := Point new. |
|
1227 |
Transcript showCR:'interest in #foo:'. |
|
1228 |
p onChangeEvaluate:b. |
|
1229 |
p x:1. |
|
1230 |
Transcript showCR:'now changing #bar ... (expect no notification)'. |
|
1231 |
p changed:#bar. |
|
1232 |
||
1233 |
p retractInterests. |
|
1234 |
p changed:#bar. |
|
1235 |
" |
|
1236 |
! ! |
|
1237 |
||
1238 |
!Object methodsFor:'dependents-interests'! |
|
1239 |
||
1240 |
onChangeSend:aSelector to:anObject |
|
1241 |
"arrange for aSelector to be sent to anObject whenever the receiver |
|
4030 | 1242 |
changes. |
1243 |
Use retractInterestsFor: in case you are no longer interested" |
|
1759 | 1244 |
|
1245 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
|
1246 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1247 |
||
4773 | 1248 |
(self interests contains:[:anInterest | |
1249 |
anInterest isInterestConverter |
|
1250 |
and:[anInterest destination == anObject |
|
1251 |
and:[anInterest selector == aSelector]] |
|
1252 |
] |
|
1253 |
) ifFalse:[ |
|
1254 |
self addInterest:(InterestConverter |
|
1255 |
destination:anObject |
|
1256 |
selector:aSelector) |
|
1257 |
]. |
|
1759 | 1258 |
|
1668 | 1259 |
|
1260 |
" |
|
1759 | 1261 |
|p b| |
1262 |
||
1263 |
b := [Transcript showCR:'the point changed']. |
|
1264 |
||
1265 |
p := Point new. |
|
1266 |
p onChangeSend:#value to:b. |
|
1267 |
p x:1. |
|
1268 |
Transcript showCR:'now changing'. |
|
1269 |
p changed. |
|
1270 |
Transcript cr. |
|
1271 |
||
1272 |
Delay waitForSeconds:1. |
|
1273 |
Transcript showCR:'now changing'. |
|
1274 |
p changed. |
|
1275 |
Transcript cr. |
|
1276 |
||
1277 |
Delay waitForSeconds:1. |
|
1278 |
Transcript showCR:'no more interest'. |
|
1279 |
p retractInterestsFor:b. |
|
1280 |
Transcript showCR:'now changing again'. |
|
1281 |
p changed. |
|
1282 |
Transcript cr. |
|
1283 |
||
1284 |
Delay waitForSeconds:1. |
|
1285 |
Transcript showCR:'interest again'. |
|
1286 |
p onChangeSend:#value to:b. |
|
1287 |
Transcript showCR:'now changing again'. |
|
1288 |
p changed. |
|
1289 |
Transcript cr. |
|
1290 |
" |
|
1291 |
||
4773 | 1292 |
"Created: / 19-04-1996 / 10:26:38 / cg" |
1293 |
"Modified: / 19-04-1996 / 12:34:26 / cg" |
|
1294 |
"Modified: / 14-10-1996 / 22:28:27 / stefan" |
|
1295 |
"Modified: / 30-11-2018 / 18:01:47 / Stefan Vogel" |
|
1759 | 1296 |
! ! |
1297 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1298 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1299 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1300 |
removeActionsForEvent:eventSymbol |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1301 |
"remove ST/V-style event triggers." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1302 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1303 |
self retractInterestsIn:eventSymbol |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1304 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1305 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1306 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1307 |
|
2903 | 1308 |
removeActionsWithReceiver:aReceiver |
1309 |
"remove ST/V-style event triggers." |
|
1310 |
||
1311 |
self retractInterestsFor:aReceiver |
|
1312 |
! ! |
|
1313 |
||
1314 |
!Object methodsFor:'dependents-st/v event simulation'! |
|
1315 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1316 |
removeAllActionsWithReceiver:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1317 |
"remove ST/V-style event triggers." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1318 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1319 |
self retractInterestsFor:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1320 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1321 |
|
1759 | 1322 |
!Object methodsFor:'dependents-interests'! |
1323 |
||
4969
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1324 |
removeDependentAndRetractInterestsFor:someOne |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1325 |
"remove any dependency and interest of someOne in the receiver. |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1326 |
Answer the receiver" |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1327 |
|
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1328 |
self retractInterestsFor:someOne. |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1329 |
self removeDependent:someOne. |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1330 |
|
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1331 |
"Created: / 30-05-2019 / 11:11:19 / Claus Gittinger" |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1332 |
! ! |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1333 |
|
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1334 |
!Object methodsFor:'dependents-interests'! |
9acd20c528a3
combination retract+removeDependent
Claus Gittinger <cg@exept.de>
parents:
4866
diff
changeset
|
1335 |
|
1759 | 1336 |
removeInterest:anInterest |
1337 |
"remove an interest forwarder. |
|
1338 |
Here, we use the nonWeakDependencies." |
|
1339 |
||
1340 |
self removeNonWeakDependent:anInterest |
|
1341 |
||
1342 |
"Created: 14.10.1996 / 22:21:59 / stefan" |
|
1343 |
! ! |
|
1344 |
||
1345 |
!Object methodsFor:'dependents-interests'! |
|
1346 |
||
1347 |
retractInterestIn:aspect for:someOne |
|
1348 |
"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
|
1349 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1350 |
Answer the retracted interests." |
1759 | 1351 |
|
1352 |
"/ for now, remove the interestConverter. |
|
1353 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1354 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1355 |
^ self retractInterestsForWhich:[:i | |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1356 |
(i aspect == aspect) and:[i destination == someOne] |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1357 |
] |
1759 | 1358 |
|
1668 | 1359 |
" |
1759 | 1360 |
|p b| |
1361 |
||
1362 |
b := [Transcript showCR:'the point changed']. |
|
1363 |
||
1364 |
p := Point new. |
|
1365 |
Transcript showCR:'interest in #foo'. |
|
1366 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
1367 |
p x:1. |
|
1368 |
Transcript showCR:'now changing #bar'. |
|
1369 |
p changed:#bar. |
|
1370 |
Transcript cr. |
|
1371 |
||
1372 |
Delay waitForSeconds:1. |
|
1373 |
Transcript showCR:'now changing #foo'. |
|
1374 |
p changed:#foo. |
|
1375 |
Transcript cr. |
|
1376 |
||
1377 |
Delay waitForSeconds:1. |
|
1378 |
Transcript showCR:'no more interest in #foo'. |
|
1379 |
p retractInterestIn:#foo for:b. |
|
1380 |
Transcript showCR:'now changing #foo'. |
|
1381 |
p changed:#foo. |
|
1382 |
Transcript cr. |
|
1383 |
||
1384 |
Delay waitForSeconds:1. |
|
1385 |
Transcript showCR:'interest in #bar now'. |
|
1386 |
p expressInterestIn:#bar for:b sendBack:#value. |
|
1387 |
Transcript showCR:'now changing #foo'. |
|
1388 |
p changed:#foo. |
|
1389 |
Transcript showCR:'now changing #bar'. |
|
1390 |
p changed:#bar. |
|
1391 |
Transcript cr. |
|
1392 |
||
1393 |
Delay waitForSeconds:1. |
|
1394 |
Transcript showCR:'interest in #foo now'. |
|
1395 |
p expressInterestIn:#foo for:b sendBack:#value. |
|
1396 |
Transcript showCR:'now changing #foo'. |
|
1397 |
p changed:#foo. |
|
1398 |
Transcript showCR:'now changing #bar'. |
|
1399 |
p changed:#bar. |
|
1400 |
Transcript cr. |
|
1401 |
||
1402 |
Delay waitForSeconds:1. |
|
1403 |
Transcript showCR:'no more interests'. |
|
1404 |
p retractInterestsFor:b. |
|
1405 |
Transcript showCR:'now changing #foo'. |
|
1406 |
p changed:#foo. |
|
1407 |
Transcript showCR:'now changing #bar'. |
|
1408 |
p changed:#bar. |
|
1409 |
Transcript cr. |
|
1410 |
" |
|
1411 |
||
1412 |
"Created: / 19.4.1996 / 10:27:11 / cg" |
|
1413 |
"Modified: / 14.10.1996 / 22:21:19 / stefan" |
|
1414 |
"Modified: / 30.1.1998 / 14:05:34 / cg" |
|
1415 |
! ! |
|
1416 |
||
1417 |
!Object methodsFor:'dependents-interests'! |
|
1418 |
||
1419 |
retractInterests |
|
1420 |
"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
|
1421 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1422 |
Answer the retraced interests." |
1759 | 1423 |
|
1424 |
"/ for now, remove the interestConverter. |
|
1425 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1426 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1427 |
^ self retractInterestsForWhich:[:i | true ] |
1759 | 1428 |
! ! |
1429 |
||
1430 |
!Object methodsFor:'dependents-interests'! |
|
1431 |
||
1432 |
retractInterestsFor:someOne |
|
2303 | 1433 |
"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
|
1434 |
(as installed with #onChangeSend:to:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1435 |
Answer the retracted interests." |
1759 | 1436 |
|
1437 |
"/ for now, remove the interestConverter. |
|
1438 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1439 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1440 |
^ self retractInterestsForWhich:[:i | i destination == someOne ] |
1759 | 1441 |
|
1442 |
" |
|
1443 |
|p b| |
|
1444 |
||
1445 |
b := [Transcript showCR:'the point changed']. |
|
1446 |
||
1447 |
p := Point new. |
|
1448 |
p onChangeSend:#value to:b. |
|
1449 |
p x:1. |
|
1450 |
Transcript showCR:'now changing'. |
|
1451 |
p changed. |
|
1452 |
Transcript cr. |
|
1453 |
||
1454 |
Delay waitForSeconds:1. |
|
1455 |
Transcript showCR:'now changing'. |
|
1456 |
p changed. |
|
1457 |
Transcript cr. |
|
1458 |
||
1459 |
Delay waitForSeconds:1. |
|
1460 |
Transcript showCR:'no more interest'. |
|
1461 |
p retractInterestsFor:b. |
|
1462 |
Transcript showCR:'now changing again'. |
|
1463 |
p changed. |
|
1464 |
Transcript cr. |
|
1465 |
||
1466 |
Delay waitForSeconds:1. |
|
1467 |
Transcript showCR:'interest again'. |
|
1468 |
p onChangeSend:#value to:b. |
|
1469 |
Transcript showCR:'now changing again'. |
|
1470 |
p changed. |
|
1471 |
Transcript cr. |
|
1472 |
" |
|
1473 |
||
1474 |
"Created: / 19.4.1996 / 10:23:46 / cg" |
|
1475 |
"Modified: / 14.10.1996 / 22:21:25 / stefan" |
|
1476 |
"Modified: / 30.1.1998 / 14:04:52 / cg" |
|
1477 |
! ! |
|
1478 |
||
1479 |
!Object methodsFor:'dependents-interests'! |
|
1480 |
||
1481 |
retractInterestsForWhich:aBlock |
|
1482 |
"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
|
1483 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1484 |
Answer the retracted interests." |
1759 | 1485 |
|
1486 |
"/ for now, remove the interestConverter. |
|
1487 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1488 |
||
5139 | 1489 |
|deps toRemove| |
1759 | 1490 |
|
1491 |
deps := self interests. |
|
1492 |
deps size ~~ 0 ifTrue:[ |
|
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1493 |
"/ cannot removeDependent within the loop - the interests collection rehashes |
5139 | 1494 |
toRemove := IdentitySet new. |
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1495 |
deps do:[:dep | |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1496 |
dep isInterestConverter ifTrue:[ |
5139 | 1497 |
(aBlock value:dep) ifTrue:[toRemove add:dep]. |
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1498 |
] |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1499 |
]. |
5139 | 1500 |
toRemove do:[:dep | |
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1501 |
self removeInterest:dep. |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1502 |
]. |
5139 | 1503 |
^ toRemove. |
1759 | 1504 |
]. |
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1505 |
^ #() |
1759 | 1506 |
! ! |
1507 |
||
1508 |
!Object methodsFor:'dependents-interests'! |
|
1509 |
||
1510 |
retractInterestsIn:aspect |
|
1511 |
"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
|
1512 |
(as installed with #expressInterestIn:for:sendBack:). |
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1513 |
Answer the retracted interests." |
1759 | 1514 |
|
1515 |
"/ for now, remove the interestConverter. |
|
1516 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
|
1517 |
||
4202
88ea818849fa
change #retractInterest* to return the retracted interests
Stefan Vogel <sv@exept.de>
parents:
4190
diff
changeset
|
1518 |
^ self retractInterestsForWhich:[:i | i aspect == aspect ] |
1668 | 1519 |
! ! |
1520 |
||
2901 | 1521 |
!Object methodsFor:'Compatibility-Dolphin'! |
1522 |
||
1523 |
trigger:anAspect |
|
1524 |
self changed:anAspect |
|
1525 |
! ! |
|
1526 |
||
1527 |
!Object methodsFor:'Compatibility-Dolphin'! |
|
1528 |
||
1529 |
trigger:anAspect with:anArgument |
|
1530 |
self changed:anAspect with:anArgument |
|
1531 |
! ! |
|
1532 |
||
1533 |
!Object methodsFor:'dependents-st/v event simulation'! |
|
1534 |
||
1535 |
triggerEvent:aSymbol |
|
1536 |
self changed:aSymbol |
|
1537 |
! ! |
|
1538 |
||
1668 | 1539 |
!Object methodsFor:'dependents-st/v event simulation'! |
1540 |
||
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1541 |
triggerEvent:eventSymbol with:aParameter |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1542 |
"perform ST/V-style event triggering." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1543 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1544 |
self changed:eventSymbol with:(Array with:aParameter). |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1545 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1546 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1547 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1548 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1549 |
triggerEvent:eventSymbol withArguments:parameters |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1550 |
"perform ST/V-style event triggering." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1551 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1552 |
self changed:eventSymbol with:parameters. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1553 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1554 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1555 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1556 |
|
1668 | 1557 |
when:eventSymbol send:selector to:anObject |
1558 |
"install an ST/V-style interest forwarder. |
|
1559 |
Here, we use the nonWeakDependencies." |
|
1560 |
||
1561 |
self addInterest:(InterestConverterWithParameters |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1562 |
destination:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1563 |
selector:selector |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1564 |
aspect:eventSymbol). |
1668 | 1565 |
|
1566 |
" |
|
1567 |
|p b| |
|
1568 |
||
1569 |
b := [Transcript showCR:'the point changed']. |
|
1570 |
||
1571 |
p := Point new. |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1572 |
p when:#foo:bar: send:#value:value: to:[:a :b | Transcript show:'foo: '; show:a; show:' bar: '; showCR:b]. |
1668 | 1573 |
Transcript showCR:'now changing'. |
1574 |
p triggerEvent:#foo:bar: withArguments:#('fooArg' 'barArg'). |
|
2897
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1575 |
p removeActionsForEvent:#foo:bar:. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1576 |
" |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1577 |
! ! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1578 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1579 |
!Object methodsFor:'dependents-st/v event simulation'! |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1580 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1581 |
when:eventSymbol send:selector to:anObject with:aParameter |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1582 |
"install an ST/V-style interest forwarder. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1583 |
Here, we use the nonWeakDependencies." |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1584 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1585 |
self addInterest:((InterestConverterWithParameters |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1586 |
destination:anObject |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1587 |
selector:selector |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1588 |
aspect:eventSymbol) |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1589 |
defaultParameters:(Array with:aParameter)). |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1590 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1591 |
" |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1592 |
|p b| |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1593 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1594 |
b := [Transcript showCR:'the point changed']. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1595 |
|
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1596 |
p := Point new. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1597 |
p |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1598 |
when:#foo: |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1599 |
send:#value: |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1600 |
to:[:a | Transcript show:'foo: '; showCR:a] |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1601 |
with:123. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1602 |
Transcript showCR:'now changing'. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1603 |
p triggerEvent:#foo:. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1604 |
p triggerEvent:#foo: with:987. |
3060cf059978
more trigger event simulation stuff
Claus Gittinger <cg@exept.de>
parents:
2679
diff
changeset
|
1605 |
p removeActionsForEvent:#foo:. |
1668 | 1606 |
" |
1607 |
! ! |
|
1608 |
||
2901 | 1609 |
!Object methodsFor:'Compatibility-Dolphin'! |
1610 |
||
1611 |
when:anAspect sendTo:anObject |
|
1612 |
self expressInterestIn:anAspect for:anObject sendBack:anAspect |
|
1613 |
! ! |
|
1614 |
||
2364 | 1615 |
!Stream methodsFor:'stacked computing streams'! |
1616 |
||
1617 |
collecting:aBlock |
|
1618 |
"return a stacked computing stream, which reads elements from the receiver, |
|
1619 |
applies aBlock to each read element, and provides the results as elements to its reader." |
|
1620 |
||
1621 |
^ CollectingReadStream on:self collecting:aBlock |
|
3094 | 1622 |
|
1623 |
" |
|
1624 |
|s s2| |
|
1625 |
||
1626 |
s := 'hello world' readStream. |
|
1627 |
s2 := s collecting:[:ch | ch asUppercase]. |
|
1628 |
s2 upToEnd. |
|
1629 |
" |
|
2364 | 1630 |
! ! |
1631 |
||
4620 | 1632 |
!Stream methodsFor:'writing'! |
1633 |
||
1634 |
printf:format |
|
1635 |
"C-style printing into a stream. |
|
1636 |
For smalltalk specific formats, |
|
1637 |
see documentation in PrintfScanf >> format_printf" |
|
1638 |
||
1639 |
format printf:#() on:self. |
|
1640 |
||
1641 |
" |
|
1642 |
Transcript printf:'Hello World\n' |
|
4866 | 1643 |
Transcript printf:'Hello World %d\n' with:123 |
4620 | 1644 |
" |
4866 | 1645 |
|
1646 |
"Modified (comment): / 17-03-2019 / 15:05:29 / Claus Gittinger" |
|
4620 | 1647 |
! ! |
1648 |
||
1649 |
!Stream methodsFor:'writing'! |
|
1650 |
||
1651 |
printf:format arguments:arguments |
|
1652 |
"C-style printing into a stream. |
|
1653 |
Same as printf:withAll:, for protocol completeness. |
|
1654 |
For smalltalk specific formats, |
|
1655 |
see documentation in PrintfScanf >> format_printf" |
|
1656 |
||
1657 |
format printf:arguments on:self. |
|
1658 |
||
1659 |
" |
|
1660 |
Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 } |
|
1661 |
Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 } |
|
1662 |
" |
|
1663 |
||
1664 |
"Created: / 23-02-2017 / 16:43:39 / cg" |
|
1665 |
! ! |
|
1666 |
||
1667 |
!Stream methodsFor:'writing'! |
|
1668 |
||
1669 |
printf:format with:argument |
|
1670 |
"C-style printing into a stream. |
|
1671 |
For smalltalk specific formats, |
|
1672 |
see documentation in PrintfScanf >> format_printf" |
|
1673 |
||
1674 |
format printf:{argument} on:self. |
|
1675 |
||
1676 |
" |
|
1677 |
Transcript printf:'%05x\n' with:12345 |
|
1678 |
" |
|
1679 |
! ! |
|
1680 |
||
1681 |
!Stream methodsFor:'writing'! |
|
1682 |
||
1683 |
printf:format with:argument1 with:argument2 |
|
1684 |
"C-style printing into a stream. |
|
1685 |
For smalltalk specific formats, |
|
1686 |
see documentation in PrintfScanf >> format_printf" |
|
1687 |
||
1688 |
format printf:{argument1 . argument2} on:self. |
|
1689 |
||
1690 |
" |
|
1691 |
Transcript printf:'%05x %3s\n' with:12345 with:'abc' |
|
1692 |
" |
|
1693 |
! ! |
|
1694 |
||
1695 |
!Stream methodsFor:'writing'! |
|
1696 |
||
1697 |
printf:format with:argument1 with:argument2 with:argument3 |
|
1698 |
"C-style printing into a stream. |
|
1699 |
For smalltalk specific formats, |
|
1700 |
see documentation in PrintfScanf >> format_printf" |
|
1701 |
||
1702 |
format printf:{argument1 . argument2 . argument3} on:self. |
|
1703 |
||
1704 |
" |
|
1705 |
Transcript printf:'%05x %3s %09s\n' with:12345 with:'abc' with:'abc' |
|
1706 |
Transcript printf:'%05x %3s %9s\n' with:12345 with:'abc' with:'abc' |
|
1707 |
" |
|
1708 |
! ! |
|
1709 |
||
1710 |
!Stream methodsFor:'writing'! |
|
1711 |
||
1712 |
printf:format with:argument1 with:argument2 with:argument3 with:argument4 |
|
1713 |
"C-style printing into a stream. |
|
1714 |
For smalltalk specific formats, |
|
1715 |
see documentation in PrintfScanf >> format_printf" |
|
1716 |
||
1717 |
format printf:{argument1 . argument2 . argument3 . argument4} on:self. |
|
1718 |
||
1719 |
" |
|
1720 |
Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4 |
|
1721 |
Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4 |
|
1722 |
Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4 |
|
1723 |
" |
|
1724 |
! ! |
|
1725 |
||
1726 |
!Stream methodsFor:'writing'! |
|
1727 |
||
1728 |
printf:format with:argument1 with:argument2 with:argument3 with:argument4 with:argument5 |
|
1729 |
"C-style printing into a stream. |
|
1730 |
For smalltalk specific formats, |
|
1731 |
see documentation in PrintfScanf >> format_printf" |
|
1732 |
||
1733 |
format printf:{argument1 . argument2 . argument3 . argument4 . argument5} on:self. |
|
1734 |
||
1735 |
" |
|
1736 |
Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4 |
|
1737 |
Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4 |
|
1738 |
Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4 |
|
1739 |
" |
|
1740 |
! ! |
|
1741 |
||
1742 |
!Stream methodsFor:'writing'! |
|
1743 |
||
1744 |
printf:format withAll:arguments |
|
1745 |
"C-style printing into a stream. |
|
1746 |
For smalltalk specific formats, |
|
1747 |
see documentation in PrintfScanf >> format_printf" |
|
1748 |
||
1749 |
format printf:arguments on:self. |
|
1750 |
||
1751 |
" |
|
1752 |
Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 } |
|
1753 |
Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 } |
|
1754 |
" |
|
1755 |
! ! |
|
1756 |
||
2364 | 1757 |
!Stream methodsFor:'stacked computing streams'! |
1758 |
||
1759 |
selecting:aBlock |
|
1760 |
"return a stacked computing stream, which reads elements from the receiver, |
|
1761 |
but only provides elements for which aBlock returns true to its reader." |
|
1762 |
||
1763 |
^ SelectingReadStream on:self selecting:aBlock |
|
3094 | 1764 |
|
1765 |
" |
|
1766 |
|s s2| |
|
1767 |
||
1768 |
s := 'hello world' readStream. |
|
1769 |
s2 := s selecting:[:ch | ch isVowel]. |
|
1770 |
s2 upToEnd. |
|
1771 |
" |
|
2364 | 1772 |
! ! |
1773 |
||
2303 | 1774 |
!stx_libbasic2 class methodsFor:'documentation'! |
1775 |
||
1776 |
extensionsVersion_CVS |
|
3715 | 1777 |
^ '$Header$' |
3005 | 1778 |
! ! |
3006
1847bcaf8018
Added lost method #printf_printOn:withData:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3005
diff
changeset
|
1779 |