author | Stefan Vogel <sv@exept.de> |
Mon, 02 Mar 1998 13:01:14 +0100 | |
changeset 3307 | 08ad28464911 |
parent 2900 | 2153bcddc299 |
child 3581 | 24a4c149bafb |
permissions | -rw-r--r-- |
420 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Signal subclass:#QuerySignal |
|
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
14 |
instanceVariableNames:'defaultAnswer hasDefault' |
1248 | 15 |
classVariableNames:'' |
16 |
poolDictionaries:'' |
|
17 |
category:'Kernel-Exceptions' |
|
420 | 18 |
! |
19 |
||
1954 | 20 |
!QuerySignal class methodsFor:'documentation'! |
420 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
QuerySignals are like signals, except that they are not accepted |
|
39 |
by handlers for ordinary signals. |
|
40 |
I.e. a signal handler for a normal signal will not handle a query |
|
580 | 41 |
signal. Thus, these bypass anySignal handlers. |
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
42 |
|
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
43 |
However, if unhandled, no error is raised, instead they are simply ignored |
1954 | 44 |
and nil is returned from the raise |
1248 | 45 |
(as opposed to normal signals, which raise an unhandled signal exception). |
1363 | 46 |
QuerySignals are also ignored, if a handler exists, but rejects. |
1248 | 47 |
|
1954 | 48 |
Their main use is to implement upQueries via signals, that work even |
1363 | 49 |
if intermediate errorSignal handlers are present |
50 |
(which is not possible with ordinary signals, since errorSignal handlers |
|
51 |
would catch those signals). |
|
52 |
||
1248 | 53 |
Code deep down in the calling hierarchy can post such an up-Query to ask |
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
54 |
for some information or to pass some information upward. |
580 | 55 |
|
1248 | 56 |
For example, the activityNotification mechanism is built on top of this: |
57 |
everyone can send such a notification which is either handled by someone |
|
58 |
up in the hierarchy (to show it in the windows info area) or simply |
|
59 |
ignored. |
|
60 |
||
61 |
Using QuerySignals for this (instead of regular Signals) helps in documenting |
|
62 |
the intended usage of those signals. |
|
1275 | 63 |
|
1954 | 64 |
Another use of querySignals is to provide additional information to |
65 |
deeply nested methods, which is only required in the uncommon case; |
|
66 |
or if another parameter is required by some method, which was not planned |
|
67 |
for in the beginning, and you do not want to hand this value (via an |
|
68 |
additional argument) through all intermediate levels. |
|
69 |
A highly elegant solution to this problem is to provide a handler somewhere |
|
70 |
at the top of the calling hierarchy, and raise an upQuery from whereever |
|
71 |
that value is required. |
|
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
72 |
A concrete application can be found in the windowGroup-lastEvent |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
73 |
queries. If anyone is interested in the windowEvent which was responible for |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
74 |
being invoked, all he needs to do is to raise the lastEventQuerySignal, |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
75 |
which returns that event. |
1954 | 76 |
No intermediate methods are required to know anything about that. |
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
77 |
Another example is found in the way Metaclass asks for the nameSpace |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
78 |
when new classes are to be installed. A Browser may simply answer such |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
79 |
a query and provide a namespace (no need to pass that information down |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
80 |
the calling chain). |
1954 | 81 |
|
82 |
A final note (to C++ and Java fans): |
|
83 |
such upQueries are only possible, if the exception handling mechanism |
|
84 |
does not automatically unwind the stack for the handler invokation. |
|
85 |
Since the handler must be able to proceed the execution and return |
|
86 |
a value to the raiser .... |
|
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
87 |
... another demonstration of why ST's exception mechanisms are superior. |
1954 | 88 |
|
1275 | 89 |
[see also:] |
90 |
Signal SignalSet Exception |
|
91 |
Object |
|
1363 | 92 |
(``Exception handling and signals'': programming/exceptions.html) |
1292 | 93 |
|
94 |
[author:] |
|
95 |
Claus Gittinger |
|
580 | 96 |
" |
97 |
! |
|
98 |
||
99 |
examples |
|
100 |
" |
|
1379 | 101 |
an up-query from a deeply nested operation to a higher level: |
1316 | 102 |
[exBegin] |
1379 | 103 |
|querySignal zero| |
580 | 104 |
|
1379 | 105 |
zero := 0. |
106 |
querySignal := QuerySignal new. |
|
107 |
querySignal handle:[:ex | |
|
1422 | 108 |
Transcript showCR:'query'. |
1379 | 109 |
ex proceedWith:true |
110 |
] do:[ |
|
111 |
'nesting'. |
|
112 |
[ |
|
113 |
[ |
|
114 |
Object errorSignal handle:[:ex | |
|
1422 | 115 |
Transcript showCR:'some error: ' , ex errorString. |
1379 | 116 |
ex proceed |
117 |
] do:[ |
|
118 |
[ |
|
2689 | 119 |
1 // zero. 'an error which is caught in the handler'. |
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
120 |
(querySignal query) == true ifTrue:[ |
1422 | 121 |
Transcript showCR:'query says: ok'. |
1379 | 122 |
] ifFalse:[ |
1422 | 123 |
Transcript showCR:'query says: no' |
1379 | 124 |
] |
125 |
] value |
|
126 |
] |
|
127 |
] value |
|
128 |
] value |
|
129 |
] |
|
130 |
[exEnd] |
|
1534
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
131 |
for lazy typists, a more compact interface is also provided |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
132 |
(which is also easier to read): |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
133 |
[exBegin] |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
134 |
|querySignal| |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
135 |
|
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
136 |
querySignal := QuerySignal new. |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
137 |
querySignal answer:true do:[ |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
138 |
'nesting'. |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
139 |
[ |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
140 |
[ |
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
141 |
(querySignal query) == true ifTrue:[ |
1534
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
142 |
Transcript showCR:'query says: ok'. |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
143 |
] ifFalse:[ |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
144 |
Transcript showCR:'query says: no' |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
145 |
] |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
146 |
] value |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
147 |
] value |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
148 |
] |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
149 |
[exEnd] |
1379 | 150 |
an up-query from a deeply nested operation, for which there |
151 |
is no handler: |
|
152 |
(notice, this would not work with normal signals, which would raise |
|
153 |
another unhandled exception-exception; |
|
154 |
also notice the == check #raise's return value being true, |
|
155 |
instead of a simple ifTrue; this handles a nil-value from |
|
156 |
the unhandled query) |
|
157 |
[exBegin] |
|
158 |
|querySignal zero| |
|
159 |
||
160 |
zero := 0. |
|
161 |
querySignal := QuerySignal new. |
|
162 |
||
163 |
[ |
|
164 |
'nesting'. |
|
165 |
[ |
|
166 |
[ |
|
167 |
Object errorSignal handle:[:ex | |
|
1422 | 168 |
Transcript showCR:'some error: ' , ex errorString. |
1379 | 169 |
ex proceed |
170 |
] do:[ |
|
171 |
[ |
|
2689 | 172 |
1 // zero. 'an error which is caught in the handler'. |
1379 | 173 |
(querySignal raise) == true ifTrue:[ |
1422 | 174 |
Transcript showCR:'query says: ok'. |
1379 | 175 |
] ifFalse:[ |
1422 | 176 |
Transcript showCR:'query says: no' |
1379 | 177 |
] |
178 |
] value |
|
179 |
] |
|
180 |
] value |
|
181 |
] value |
|
182 |
] value |
|
183 |
[exEnd] |
|
184 |
counter-example, just to show that things would not work this way |
|
185 |
with regular signals: |
|
186 |
[exBegin] |
|
187 |
|signal| |
|
188 |
||
189 |
signal := Signal new. |
|
190 |
'nesting deeply'. |
|
191 |
[ |
|
192 |
[ |
|
1316 | 193 |
[ |
194 |
[ |
|
1379 | 195 |
[ |
196 |
(signal raise) == true ifTrue:[ |
|
1422 | 197 |
Transcript showCR:'query says: ok'. |
1379 | 198 |
] ifFalse:[ |
1422 | 199 |
Transcript showCR:'query says: no' |
1379 | 200 |
] |
201 |
] value |
|
1316 | 202 |
] value |
203 |
] value |
|
1379 | 204 |
] value |
205 |
] value |
|
206 |
[exEnd] |
|
207 |
||
208 |
except, by handling the unhandled exception |
|
209 |
(but we think, that querySignals are easier to use and |
|
210 |
better document the intent): |
|
211 |
[exBegin] |
|
212 |
|signal| |
|
213 |
||
214 |
signal := Signal new. |
|
215 |
'nesting deeply'. |
|
216 |
[ |
|
217 |
[ |
|
218 |
[ |
|
219 |
[ |
|
220 |
[ |
|
221 |
Signal noHandlerSignal handle:[:ex | |
|
222 |
ex proceedWith:nil |
|
223 |
] do:[ |
|
224 |
(signal raise) == true ifTrue:[ |
|
1422 | 225 |
Transcript showCR:'query says: ok'. |
1379 | 226 |
] ifFalse:[ |
1422 | 227 |
Transcript showCR:'query says: no' |
1379 | 228 |
] |
229 |
] |
|
230 |
] value |
|
231 |
] value |
|
232 |
] value |
|
233 |
] value |
|
234 |
] value |
|
235 |
[exEnd] |
|
420 | 236 |
" |
237 |
! ! |
|
238 |
||
2893 | 239 |
!QuerySignal methodsFor:'answering queries'! |
240 |
||
241 |
answer:someAnswer do:aBlock |
|
242 |
"evaluate the argument, aBlock. |
|
243 |
If the receiver is queried during evaluation, answer with someAnswer. |
|
244 |
This is a wrapper for #handle:do: for lazy typists; no new functionality." |
|
245 |
||
246 |
^ self handle:[:ex | ex proceedWith:someAnswer] do:aBlock. |
|
247 |
||
248 |
" |
|
249 |
|q| |
|
250 |
||
251 |
q := QuerySignal new. |
|
252 |
||
253 |
q answer:true do:[ |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
254 |
Transcript showCR:'query answers: ' , (q query printString). |
2893 | 255 |
] |
256 |
" |
|
257 |
||
258 |
" |
|
259 |
|q| |
|
260 |
||
261 |
q := QuerySignal new. |
|
262 |
||
263 |
q answer:false do:[ |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
264 |
Transcript showCR:'first query answers: ' , (q query printString). |
2893 | 265 |
q answer:true do:[ |
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
266 |
Transcript showCR:'second query answers: ' , (q query printString). |
2893 | 267 |
] |
268 |
] |
|
269 |
" |
|
270 |
||
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
271 |
"Created: / 10.7.1996 / 15:08:20 / cg" |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
272 |
"Modified: / 14.10.1996 / 16:59:18 / cg" |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
273 |
"Modified: / 2.3.1998 / 10:41:45 / stefan" |
2893 | 274 |
! ! |
275 |
||
2037 | 276 |
!QuerySignal methodsFor:'initialization'! |
277 |
||
278 |
defaultAnswer:someValue |
|
279 |
"define the queries defaultAnswer to be someValue. |
|
280 |
This is the same as defining an appropriate handlerBlock." |
|
281 |
||
282 |
|handler| |
|
283 |
||
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
284 |
defaultAnswer := someValue. |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
285 |
hasDefault := true. |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
286 |
|
2037 | 287 |
"/ avoid creating a fullBlock, in the most common cases |
288 |
someValue == true ifTrue:[ |
|
289 |
handler := [:ex | ex proceedWith:true] |
|
290 |
] ifFalse:[ |
|
291 |
someValue == false ifTrue:[ |
|
292 |
handler := [:ex | ex proceedWith:false] |
|
293 |
] ifFalse:[ |
|
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
294 |
someValue isNil ifTrue:[ |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
295 |
handler := [:ex | ex proceedWith:nil] |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
296 |
] ifFalse:[ |
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
297 |
handler := [:ex | ex proceedWith:someValue]. |
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
298 |
] |
2037 | 299 |
] |
300 |
]. |
|
301 |
self handlerBlock:handler. |
|
302 |
||
303 |
" |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
304 |
QuerySignal new query |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
305 |
(QuerySignal new defaultAnswer:true) query |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
306 |
(QuerySignal new defaultAnswer:false) query |
2037 | 307 |
" |
308 |
||
309 |
" |
|
310 |
|sig rslt| |
|
311 |
||
312 |
sig := QuerySignal new. |
|
313 |
sig defaultAnswer:false. |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
314 |
rslt := sig query. |
2037 | 315 |
Transcript showCR:rslt. |
316 |
" |
|
317 |
||
318 |
" |
|
319 |
|sig rslt| |
|
320 |
||
321 |
sig := QuerySignal new. |
|
322 |
sig defaultAnswer:false. |
|
323 |
sig answer:true |
|
324 |
do:[ |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
325 |
rslt := sig query |
2037 | 326 |
]. |
327 |
Transcript showCR:rslt. |
|
328 |
" |
|
329 |
||
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
330 |
"Modified: / 3.1.1997 / 15:14:40 / cg" |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
331 |
"Modified: / 2.3.1998 / 10:42:14 / stefan" |
2037 | 332 |
! ! |
333 |
||
420 | 334 |
!QuerySignal methodsFor:'queries'! |
335 |
||
336 |
accepts:aSignal |
|
337 |
"return true, if the receiver accepts the argument, aSignal. |
|
338 |
(i.e. the receiver is aSignal or a parent of it). False otherwise." |
|
339 |
||
340 |
|s| |
|
341 |
||
421 | 342 |
aSignal isQuerySignal ifFalse:[^ false]. |
420 | 343 |
|
344 |
s := aSignal. |
|
345 |
[s notNil] whileTrue:[ |
|
346 |
self == s ifTrue:[^ true]. |
|
347 |
s := s parent |
|
348 |
]. |
|
349 |
^ false |
|
691 | 350 |
! |
351 |
||
352 |
isQuerySignal |
|
1249 | 353 |
"return true, if this is a querySignal - always return true here" |
354 |
||
691 | 355 |
^ true |
1249 | 356 |
|
357 |
"Modified: 22.4.1996 / 13:45:10 / cg" |
|
2893 | 358 |
! |
1534
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
359 |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
360 |
query |
2893 | 361 |
"raise the query - return the handlers value, or the default |
362 |
value, if there is no handler. |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
363 |
Invoking the handler is exactly the functionality of Signal>>raiseRequest, |
2893 | 364 |
but we can do it faster here." |
1534
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
365 |
|
2893 | 366 |
|con| |
1534
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
367 |
|
2893 | 368 |
con := thisContext sender. |
369 |
[con notNil] whileTrue:[ |
|
370 |
con := con findNextContextWithSelector:#doRaise |
|
371 |
or:#handle:do: |
|
372 |
or:#handle:from:do:. |
|
373 |
con notNil ifTrue:[ |
|
374 |
(con selector == #handle:do:) ifFalse:[ |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
375 |
^ super raiseRequest |
2893 | 376 |
]. |
377 |
(con receiver == self) ifTrue:[ |
|
378 |
"/ found a non-busy handler ... |
|
379 |
"/ if its sender is a #answer context, |
|
380 |
"/ fetch its value quickly from it. |
|
381 |
con := con sender. |
|
382 |
con selector == #answer:do: ifFalse:[ |
|
383 |
con receiver == self ifFalse:[ |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
384 |
^ super raiseRequest |
2893 | 385 |
] |
386 |
]. |
|
387 |
^ con argAt:1 |
|
388 |
] |
|
389 |
] |
|
390 |
]. |
|
391 |
"/ no handler found - return the default value |
|
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
392 |
hasDefault == true ifTrue:[ |
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
393 |
^ defaultAnswer |
2900
2153bcddc299
faster return of defaultValue
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
394 |
]. |
2893 | 395 |
handlerBlock isNil ifTrue:[ |
396 |
^ nil |
|
397 |
]. |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
398 |
^ super raiseRequest |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
399 |
|
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
400 |
"Modified: / 31.8.1997 / 08:05:32 / cg" |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
401 |
"Modified: / 2.3.1998 / 10:40:39 / stefan" |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
402 |
! |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
403 |
|
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
404 |
raise |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
405 |
"redefined to use #query" |
1534
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
406 |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
407 |
^ self query |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
408 |
|
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
409 |
"Modified: / 2.3.1998 / 10:39:05 / stefan" |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
410 |
! |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
411 |
|
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
412 |
raiseRequest |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
413 |
"redefined to use #query" |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
414 |
|
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
415 |
^ self query |
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
416 |
|
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
417 |
"Created: / 2.3.1998 / 10:41:03 / stefan" |
1534
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
418 |
! ! |
3aac2f9ef96c
added #answer:do: - easier to read
Claus Gittinger <cg@exept.de>
parents:
1422
diff
changeset
|
419 |
|
1954 | 420 |
!QuerySignal class methodsFor:'documentation'! |
691 | 421 |
|
422 |
version |
|
3307
08ad28464911
Use #raiseRequest to invoke the (inherently) proceedable QuerySignal.
Stefan Vogel <sv@exept.de>
parents:
2900
diff
changeset
|
423 |
^ '$Header: /cvs/stx/stx/libbasic/QuerySignal.st,v 1.22 1998-03-02 12:01:14 stefan Exp $' |
691 | 424 |
! ! |