author | Stefan Vogel <sv@exept.de> |
Wed, 27 Mar 1996 18:12:39 +0100 | |
changeset 1129 | 2734bcd503fe |
parent 1119 | 956d62a5656c |
child 1133 | 961f2b095c22 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
783 | 13 |
nil subclass:#Object |
14 |
instanceVariableNames:'' |
|
15 |
classVariableNames:'ErrorSignal HaltSignal MessageNotUnderstoodSignal |
|
16 |
UserInterruptSignal RecursionInterruptSignal |
|
17 |
ExceptionInterruptSignal SubscriptOutOfBoundsSignal |
|
18 |
NonIntegerIndexSignal NotFoundSignal KeyNotFoundSignal |
|
19 |
ElementOutOfBoundsSignal UserNotificationSignal InformationSignal |
|
20 |
WarningSignal PrimitiveFailureSignal DeepCopyErrorSignal |
|
21 |
AbortSignal ErrorRecursion Dependencies InfoPrinting |
|
22 |
ActivityNotificationSignal' |
|
23 |
poolDictionaries:'' |
|
24 |
category:'Kernel-Objects' |
|
1 | 25 |
! |
26 |
||
71 | 27 |
!Object class methodsFor:'documentation'! |
28 |
||
88 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 32 |
All Rights Reserved |
88 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
71 | 43 |
documentation |
44 |
" |
|
159 | 45 |
Object is the superclass of all other classes. Protocol common to |
46 |
every object is defined here. |
|
71 | 47 |
Also some utility stuff (like notify) and error handling is implemented here. |
48 |
||
49 |
Object has no instance variables (and may not get any added). One reason is, that |
|
159 | 50 |
UndefinedObject and SmallInteger are also inheriting from Object - these two cannot have instance |
143 | 51 |
variables (due to their implementation). The other reason is that the runtime system |
159 | 52 |
(VM) knows about the layout of some built-in classes (think of Class, Method, Block |
53 |
and also Integer or Float). If you where allowed to add instance variables to Object, |
|
54 |
the VM had to be recompiled (and also rewritten in some places). |
|
71 | 55 |
|
56 |
Class variables: |
|
57 |
||
159 | 58 |
ErrorSignal <Signal> Signal raised for error/error: messages |
59 |
also, parent of all other signals. |
|
60 |
||
61 |
HaltSignal <Signal> Signal raised for halt/halt: messages |
|
62 |
||
63 |
MessageNotUnderstoodSignal Signals raised for various error conditions |
|
64 |
UserInterruptSignal |
|
65 |
RecursionInterruptSignal |
|
66 |
ExceptionInterruptSignal |
|
67 |
SubscriptOutOfBoundsSignal |
|
68 |
NonIntegerIndexSignal |
|
69 |
NotFoundSignal |
|
70 |
KeyNotFoundSignal |
|
71 |
ElementOutOfBoundsSignal |
|
72 |
InformationSignal |
|
648
b70bfd63446a
made InformationSignal and WarningSignal a child of a common parent
Claus Gittinger <cg@exept.de>
parents:
643
diff
changeset
|
73 |
WarningSignal |
159 | 74 |
DeepCopyErrorSignal |
75 |
||
76 |
AbortSignal <Signal> Signal raised by debugger, to abort a computation |
|
77 |
BUT, the debugger will only raise it if it is handled. |
|
78 |
By handling the abortSignal, you can control where the |
|
79 |
debuggers abort-function resumes execution in case of |
|
80 |
an error. |
|
81 |
||
82 |
ErrorRecursion <Boolean> controls behavior when recursive errors occur (i.e. |
|
83 |
an error while handling an error). |
|
84 |
||
85 |
Dependencies <Dictionary> keeps track of object dependencies |
|
71 | 86 |
" |
87 |
! ! |
|
1 | 88 |
|
89 |
!Object class methodsFor:'initialization'! |
|
90 |
||
91 |
initialize |
|
92 |
"called only once - initialize signals" |
|
93 |
||
94 |
ErrorSignal isNil ifTrue:[ |
|
861 | 95 |
ErrorSignal := (Signal new) mayProceed:true. |
96 |
ErrorSignal nameClass:self message:#errorSignal. |
|
97 |
ErrorSignal notifierString:'error encountered'. |
|
98 |
||
99 |
HaltSignal := ErrorSignal newSignalMayProceed:true. |
|
100 |
HaltSignal nameClass:self message:#haltSignal. |
|
101 |
HaltSignal notifierString:'halt encountered'. |
|
102 |
||
103 |
MessageNotUnderstoodSignal := ErrorSignal newSignalMayProceed:true. |
|
104 |
MessageNotUnderstoodSignal nameClass:self message:#messageNotUnderstoodSignal. |
|
105 |
MessageNotUnderstoodSignal notifierString:'message not understood'. |
|
106 |
||
107 |
PrimitiveFailureSignal := ErrorSignal newSignalMayProceed:true. |
|
108 |
PrimitiveFailureSignal nameClass:self message:#primitiveFailureSignal. |
|
109 |
PrimitiveFailureSignal notifierString:'primitive failed'. |
|
159 | 110 |
|
362 | 111 |
"/ UserInterruptSignal := ErrorSignal newSignalMayProceed:true. |
861 | 112 |
UserInterruptSignal := (Signal new) newSignalMayProceed:true. |
113 |
UserInterruptSignal nameClass:self message:#userInterruptSignal. |
|
114 |
UserInterruptSignal notifierString:'user Interrupt'. |
|
159 | 115 |
|
362 | 116 |
"/ RecursionInterruptSignal := ErrorSignal newSignalMayProceed:false. |
861 | 117 |
RecursionInterruptSignal := (Signal new) mayProceed:true. |
118 |
RecursionInterruptSignal nameClass:self message:#recursionInterruptSignal. |
|
119 |
RecursionInterruptSignal notifierString:'recursion limit reached'. |
|
120 |
||
121 |
ExceptionInterruptSignal := ErrorSignal newSignalMayProceed:true. |
|
122 |
ExceptionInterruptSignal nameClass:self message:#exceptionInterruptSignal. |
|
123 |
ExceptionInterruptSignal notifierString:'exception Interrupt'. |
|
124 |
||
125 |
SubscriptOutOfBoundsSignal := ErrorSignal newSignalMayProceed:false. |
|
126 |
SubscriptOutOfBoundsSignal nameClass:self message:#subscriptOutOfBoundsSignal. |
|
127 |
SubscriptOutOfBoundsSignal notifierString:'subscript out of bounds'. |
|
128 |
||
129 |
ElementOutOfBoundsSignal := ErrorSignal newSignalMayProceed:false. |
|
130 |
ElementOutOfBoundsSignal nameClass:self message:#elementOutOfBoundsSignal. |
|
131 |
ElementOutOfBoundsSignal notifierString:'element not appropriate or out of bounds'. |
|
132 |
||
133 |
NotFoundSignal := ErrorSignal newSignalMayProceed:true. |
|
134 |
NotFoundSignal nameClass:self message:#notFoundSignal. |
|
135 |
NotFoundSignal notifierString:'no such element'. |
|
136 |
||
137 |
KeyNotFoundSignal := ErrorSignal newSignalMayProceed:true. |
|
138 |
KeyNotFoundSignal nameClass:self message:#keyNotFoundSignal. |
|
139 |
KeyNotFoundSignal notifierString:'no such key:'. |
|
140 |
||
141 |
NonIntegerIndexSignal := ErrorSignal newSignalMayProceed:false. |
|
142 |
NonIntegerIndexSignal nameClass:self message:#nonIntegerIndexSignal. |
|
143 |
NonIntegerIndexSignal notifierString:'index must be integer'. |
|
144 |
||
889 | 145 |
UserNotificationSignal := QuerySignal new newSignalMayProceed:true. |
861 | 146 |
UserNotificationSignal nameClass:self message:#userNotificationSignal. |
147 |
UserNotificationSignal notifierString:'user notifiaction'. |
|
148 |
||
149 |
InformationSignal := UserNotificationSignal newSignalMayProceed:true. |
|
150 |
InformationSignal nameClass:self message:#informationSignal. |
|
151 |
InformationSignal notifierString:'information'. |
|
152 |
||
153 |
WarningSignal := UserNotificationSignal newSignalMayProceed:true. |
|
154 |
WarningSignal nameClass:self message:#warnungSignal. |
|
155 |
WarningSignal notifierString:'warning'. |
|
156 |
||
157 |
ActivityNotificationSignal := UserNotificationSignal newSignalMayProceed:true. |
|
158 |
ActivityNotificationSignal nameClass:self message:#activityNotificationSignal. |
|
159 |
ActivityNotificationSignal notifierString:'activity'. |
|
160 |
||
161 |
DeepCopyErrorSignal := ErrorSignal newSignalMayProceed:true. |
|
162 |
DeepCopyErrorSignal nameClass:self message:#deepCopyErrorSignal. |
|
163 |
DeepCopyErrorSignal notifierString:'object cannot be deepCopy-ed'. |
|
164 |
||
165 |
" |
|
166 |
AbortSignal is not a child of ErrorSignal - |
|
167 |
this would complicate abort from within a signal handler |
|
168 |
" |
|
169 |
AbortSignal := Signal new mayProceed:true. |
|
170 |
AbortSignal nameClass:self message:#abortSignal. |
|
171 |
AbortSignal notifierString:'unhandled abort signal'. |
|
172 |
||
173 |
Dependencies isNil ifTrue:[ |
|
174 |
Dependencies := WeakIdentityDictionary new. |
|
175 |
] |
|
356 | 176 |
]. |
177 |
InfoPrinting := true |
|
1 | 178 |
|
179 |
"Object initialize" |
|
812
00db9c0646fe
notificationsignals are no longer children of ErrorSignal
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
180 |
|
00db9c0646fe
notificationsignals are no longer children of ErrorSignal
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
181 |
"Modified: 23.12.1995 / 12:45:57 / cg" |
1 | 182 |
! ! |
183 |
||
345 | 184 |
!Object class methodsFor:'Signal constants'! |
1 | 185 |
|
783 | 186 |
abortSignal |
187 |
"return the signal used to abort user actions. This signal is only |
|
188 |
raised if cought (by the debugger), and will lead way out of the |
|
189 |
currently active doIt/printIt or inspectIt. (also some others use |
|
190 |
this for a save abort)" |
|
191 |
||
192 |
^ AbortSignal |
|
579
2d26193415b5
allow catching of information: and warn: boxes
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
193 |
! |
2d26193415b5
allow catching of information: and warn: boxes
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
194 |
|
782 | 195 |
activityNotificationSignal |
196 |
"return the signal used for activity notifications. |
|
197 |
A handler for this signal gets all #activityNotification: sends" |
|
198 |
||
199 |
^ ActivityNotificationSignal |
|
200 |
! |
|
201 |
||
159 | 202 |
deepCopyErrorSignal |
203 |
"return the signal raised when a deepcopy is asked for |
|
204 |
an object which cannot do this (for example, BlockClosures |
|
205 |
or Contexts)." |
|
206 |
||
207 |
^ DeepCopyErrorSignal |
|
208 |
! |
|
209 |
||
783 | 210 |
elementOutOfBoundsSignal |
211 |
"return the signal used for element error reporting |
|
212 |
(this signal is used for example when a value not in 0..255 is to |
|
213 |
be put into a bytearray)" |
|
214 |
||
215 |
^ ElementOutOfBoundsSignal |
|
216 |
! |
|
217 |
||
218 |
errorSignal |
|
219 |
"return the signal used for error/error: - handling" |
|
220 |
||
221 |
^ ErrorSignal |
|
222 |
! |
|
223 |
||
224 |
exceptionInterruptSignal |
|
225 |
"return the signal used for exception (display errors) error handling" |
|
226 |
||
227 |
^ ExceptionInterruptSignal |
|
228 |
! |
|
229 |
||
230 |
haltSignal |
|
231 |
"return the signal used for halt/halt: - handling" |
|
232 |
||
233 |
^ HaltSignal |
|
234 |
! |
|
235 |
||
236 |
informationSignal |
|
237 |
"return the signal used for informations. |
|
238 |
A handler for this signal gets all #information: sends" |
|
239 |
||
240 |
^ InformationSignal |
|
241 |
! |
|
242 |
||
243 |
keyNotFoundSignal |
|
244 |
"return the signal used for no such key error reporting" |
|
245 |
||
246 |
^ KeyNotFoundSignal |
|
247 |
! |
|
248 |
||
249 |
messageNotUnderstoodSignal |
|
250 |
"return the signal used for doesNotUnderstand: - error handling" |
|
251 |
||
252 |
^ MessageNotUnderstoodSignal |
|
253 |
! |
|
254 |
||
255 |
nonIntegerIndexSignal |
|
256 |
"return the signal used for bad subscript error reporting" |
|
257 |
||
258 |
^ NonIntegerIndexSignal |
|
259 |
! |
|
260 |
||
261 |
notFoundSignal |
|
262 |
"return the signal used for no element found error reporting" |
|
263 |
||
264 |
^ NotFoundSignal |
|
265 |
! |
|
266 |
||
267 |
primitiveFailureSignal |
|
268 |
"return the signal used for primitiveFailed - error handling" |
|
269 |
||
270 |
^ PrimitiveFailureSignal |
|
271 |
! |
|
272 |
||
273 |
privateMethodSignal |
|
274 |
"return the signal used for privateMethod - error handling" |
|
275 |
||
276 |
^ MessageNotUnderstoodSignal |
|
277 |
! |
|
278 |
||
279 |
recursionInterruptSignal |
|
280 |
"return the signal used for recursion overflow error handling" |
|
281 |
||
282 |
^ RecursionInterruptSignal |
|
283 |
! |
|
284 |
||
285 |
subscriptOutOfBoundsSignal |
|
286 |
"return the signal used for subscript error reporting. |
|
287 |
(this signal is used for example when an array is accessed with an |
|
288 |
index less than 1 or greater than the array size)" |
|
289 |
||
290 |
^ SubscriptOutOfBoundsSignal |
|
291 |
! |
|
292 |
||
293 |
userInterruptSignal |
|
294 |
"return the signal used for ^C interrupts handling" |
|
295 |
||
296 |
^ UserInterruptSignal |
|
297 |
! |
|
298 |
||
299 |
userNotificationSignal |
|
300 |
"the parent signal used with information and warnings. |
|
301 |
Handling this allows handling of both information- and warning notifications." |
|
302 |
||
303 |
^ UserNotificationSignal |
|
304 |
! |
|
305 |
||
306 |
warningSignal |
|
307 |
"return the signal used for warnings. |
|
308 |
A handler for this signal gets all #warn: sends" |
|
309 |
||
310 |
^ WarningSignal |
|
1 | 311 |
! ! |
312 |
||
356 | 313 |
!Object class methodsFor:'info messages'! |
314 |
||
783 | 315 |
infoPrinting |
316 |
"return the flag which controls information messages." |
|
317 |
||
318 |
^ InfoPrinting |
|
319 |
! |
|
320 |
||
356 | 321 |
infoPrinting:aBoolean |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
322 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
323 |
|
356 | 324 |
"turn on/off printing of information messages. |
325 |
If the argument, aBoolean is false, infoPrint will not output |
|
326 |
messages. The default is true." |
|
327 |
||
328 |
InfoPrinting := aBoolean |
|
329 |
! ! |
|
330 |
||
3 | 331 |
!Object class methodsFor:'queries'! |
332 |
||
333 |
isBuiltInClass |
|
49 | 334 |
"return true, if this class is known by the run-time-system, |
335 |
i.e. you cannot add/remove instance variables without recompiling |
|
336 |
the VM." |
|
3 | 337 |
|
338 |
^ self == Object |
|
339 |
! ! |
|
340 |
||
1 | 341 |
!Object methodsFor:'accessing'! |
342 |
||
343 |
at:index |
|
344 |
"return the indexed instance variable with index, anInteger; |
|
345 |
this method can be redefined in subclasses." |
|
346 |
||
347 |
^ self basicAt:index |
|
348 |
! |
|
349 |
||
783 | 350 |
at:index put:anObject |
351 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
352 |
this method can be redefined in subclasses." |
|
353 |
||
354 |
^ self basicAt:index put:anObject |
|
355 |
! |
|
356 |
||
1 | 357 |
basicAt:index |
358 |
"return the indexed instance variable with index, anInteger. |
|
359 |
Trigger an error if the receiver has no indexed instance variables. |
|
360 |
This method should NOT be redefined in any subclass" |
|
361 |
||
362 |
%{ /* NOCONTEXT */ |
|
363 |
||
329 | 364 |
REGISTER int nbytes, indx; |
1 | 365 |
OBJ myClass; |
329 | 366 |
REGISTER char *pFirst; |
1 | 367 |
unsigned char *cp; |
368 |
unsigned short *sp; |
|
369 |
long *lp; |
|
370 |
OBJ *op; |
|
329 | 371 |
/* int nInstBytes, nInstVars, flags; */ |
372 |
REGISTER int n; |
|
1 | 373 |
|
374 |
||
375 |
/* |
|
56 | 376 |
* notice the missing test for self being a nonNilObject - |
1 | 377 |
* this can be done since basicAt: is defined both in UndefinedObject |
378 |
* and SmallInteger |
|
379 |
*/ |
|
253 | 380 |
if (__isSmallInteger(index)) { |
329 | 381 |
myClass = __qClass(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
382 |
indx = __intVal(index) - 1; |
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
383 |
n /* nInstVars */ = __intVal(_ClassInstPtr(myClass)->c_ninstvars); |
329 | 384 |
n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */); |
385 |
nbytes = __qSize(self) - n /* nInstBytes */; |
|
386 |
pFirst = (char *)(_InstPtr(self)) + n /* nInstBytes */; |
|
387 |
||
388 |
/* |
|
389 |
* replaced switch by open-coded if; this is slightly faster |
|
390 |
* since it avoids the range check and also handles the most common case first |
|
391 |
*/ |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
392 |
n = __intVal(_ClassInstPtr(myClass)->c_flags) & ARRAYMASK; |
329 | 393 |
if ((n == POINTERARRAY) || (n == WKPOINTERARRAY)) { |
394 |
if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) { |
|
395 |
op = (OBJ *)pFirst + indx; |
|
396 |
RETURN ( *op ); |
|
397 |
} |
|
398 |
} else if (n == BYTEARRAY) { |
|
399 |
if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) { |
|
400 |
cp = (unsigned char *)pFirst + indx; |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
401 |
RETURN ( __MKSMALLINT(*cp & 0xFF) ); |
329 | 402 |
} |
403 |
} else if (n == FLOATARRAY) { |
|
404 |
if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) { |
|
405 |
float *fp; |
|
406 |
||
407 |
fp = (float *)pFirst + indx; |
|
408 |
RETURN ( _MKFLOAT((double)(*fp)) COMMA_CON ); |
|
409 |
} |
|
410 |
} else if (n == DOUBLEARRAY) { |
|
411 |
if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) { |
|
412 |
double *dp; |
|
1 | 413 |
|
56 | 414 |
#ifdef NEED_DOUBLE_ALIGN |
329 | 415 |
/* |
416 |
* care for filler |
|
417 |
*/ |
|
418 |
pFirst += sizeof(FILLTYPE); |
|
56 | 419 |
#endif |
329 | 420 |
dp = (double *)pFirst + indx; |
421 |
RETURN ( _MKFLOAT(*dp) COMMA_CON ); |
|
422 |
} |
|
423 |
} else if (n == LONGARRAY) { |
|
424 |
if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) { |
|
425 |
lp = (long *)pFirst + indx; |
|
426 |
if ((*lp >= _MIN_INT) && (*lp <= _MAX_INT)) |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
427 |
RETURN ( __MKSMALLINT(*lp) ); |
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
428 |
RETURN ( __MKLARGEINT(*lp) ); |
329 | 429 |
} |
430 |
} else if (n == WORDARRAY) { |
|
431 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) { |
|
432 |
sp = (unsigned short *)pFirst + indx; |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
433 |
RETURN ( __MKSMALLINT(*sp & 0xFFFF) ); |
329 | 434 |
} |
159 | 435 |
} |
1 | 436 |
} |
437 |
%} |
|
438 |
. |
|
10 | 439 |
index isInteger ifFalse:[ |
159 | 440 |
^ self indexNotInteger |
1 | 441 |
]. |
159 | 442 |
^ self subscriptBoundsError:index |
1 | 443 |
! |
444 |
||
445 |
basicAt:index put:anObject |
|
446 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
447 |
Trigger an error if the receiver has no indexed instance variables. |
|
448 |
This method should NOT be redefined in any subclass" |
|
449 |
||
450 |
%{ /* NOCONTEXT */ |
|
451 |
||
452 |
register int nbytes, indx; |
|
453 |
OBJ myClass; |
|
454 |
register char *pFirst; |
|
455 |
char *cp; |
|
456 |
short *sp; |
|
457 |
long *lp; |
|
458 |
OBJ *op; |
|
329 | 459 |
/* int nInstBytes, ninstvars, flags; */ |
460 |
REGISTER int n; |
|
1 | 461 |
int val; |
462 |
||
56 | 463 |
/* notice the missing test for self being a nonNilObject - |
77 | 464 |
this can be done since basicAt: is defined both in UndefinedObject |
1 | 465 |
and SmallInteger */ |
466 |
||
253 | 467 |
if (__isSmallInteger(index)) { |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
468 |
indx = __intVal(index) - 1; |
329 | 469 |
myClass = __qClass(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
470 |
n /* ninstvars */ = __intVal(_ClassInstPtr(myClass)->c_ninstvars); |
329 | 471 |
n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* ninstvars */); |
472 |
nbytes = __qSize(self) - n /* nInstBytes */; |
|
473 |
pFirst = (char *)(_InstPtr(self)) + n /* nInstBytes */; |
|
474 |
||
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
475 |
n = __intVal(_ClassInstPtr(myClass)->c_flags) & ARRAYMASK; |
329 | 476 |
if ((n == POINTERARRAY) || (n == WKPOINTERARRAY)) { |
477 |
if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) { |
|
478 |
op = (OBJ *)pFirst + indx; |
|
479 |
*op = anObject; |
|
480 |
__STORE(self, anObject); |
|
481 |
RETURN ( anObject ); |
|
482 |
} |
|
483 |
} else if (n == BYTEARRAY) { |
|
484 |
if (__isSmallInteger(anObject)) { |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
485 |
val = __intVal(anObject); |
329 | 486 |
if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) { |
487 |
if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) { |
|
488 |
cp = pFirst + indx; |
|
489 |
*cp = val; |
|
159 | 490 |
RETURN ( anObject ); |
491 |
} |
|
492 |
} |
|
329 | 493 |
} |
494 |
} else if (n == FLOATARRAY) { |
|
495 |
if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) { |
|
496 |
float *fp; |
|
497 |
||
498 |
fp = (float *)pFirst + indx; |
|
499 |
if (__isFloatLike(anObject)) { |
|
500 |
*fp = _floatVal(anObject); |
|
501 |
RETURN ( anObject ); |
|
159 | 502 |
} |
329 | 503 |
if (__isSmallInteger(anObject)) { |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
504 |
*fp = (float) __intVal(anObject); |
329 | 505 |
RETURN ( anObject ); |
506 |
} |
|
507 |
} |
|
508 |
} else if (n == DOUBLEARRAY) { |
|
509 |
if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) { |
|
510 |
double *dp; |
|
13 | 511 |
|
56 | 512 |
#ifdef NEED_DOUBLE_ALIGN |
329 | 513 |
/* |
514 |
* care for filler |
|
515 |
*/ |
|
516 |
pFirst += sizeof(FILLTYPE); |
|
56 | 517 |
#endif |
329 | 518 |
dp = (double *)pFirst + indx; |
519 |
if (__isFloatLike(anObject)) { |
|
520 |
*dp = _floatVal(anObject); |
|
521 |
RETURN ( anObject ); |
|
522 |
} |
|
523 |
if (__isSmallInteger(anObject)) { |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
524 |
*dp = (double) __intVal(anObject); |
329 | 525 |
RETURN ( anObject ); |
526 |
} |
|
527 |
} |
|
528 |
} else if (n == LONGARRAY) { |
|
529 |
if (__isSmallInteger(anObject)) { |
|
530 |
if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) { |
|
531 |
lp = (long *)pFirst + indx; |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
532 |
*lp = __intVal(anObject); |
329 | 533 |
RETURN ( anObject ); |
534 |
} |
|
535 |
} |
|
536 |
/* XXX |
|
537 |
* XXX must add possibility to put in a large number here |
|
538 |
* XXX |
|
539 |
*/ |
|
540 |
} else if (n == WORDARRAY) { |
|
541 |
if (__isSmallInteger(anObject)) { |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
542 |
val = __intVal(anObject); |
329 | 543 |
if ((val >= 0) && (val <= 0xFFFF)) { |
544 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) { |
|
339 | 545 |
sp = (short *)pFirst + indx; |
546 |
*sp = val; |
|
547 |
RETURN ( anObject ); |
|
159 | 548 |
} |
549 |
} |
|
329 | 550 |
} |
159 | 551 |
} |
1 | 552 |
} |
553 |
%} |
|
554 |
. |
|
10 | 555 |
index isInteger ifFalse:[ |
159 | 556 |
" |
557 |
the index should be an integer number |
|
558 |
" |
|
559 |
^ self indexNotInteger |
|
1 | 560 |
]. |
561 |
(index between:1 and:self size) ifFalse:[ |
|
159 | 562 |
" |
563 |
the index is less than 1 or greater than the size of the |
|
213 | 564 |
receiver collection |
159 | 565 |
" |
566 |
^ self subscriptBoundsError:index |
|
1 | 567 |
]. |
643 | 568 |
(self class isFloatsOrDoubles) ifTrue:[ |
159 | 569 |
anObject isNumber ifTrue:[ |
570 |
^ self basicAt:index put:(anObject asFloat) |
|
571 |
] |
|
13 | 572 |
]. |
10 | 573 |
anObject isInteger ifFalse:[ |
159 | 574 |
" |
213 | 575 |
the object to put into the receiver collection |
159 | 576 |
should be an integer number |
577 |
" |
|
578 |
^ self elementNotInteger |
|
2 | 579 |
]. |
159 | 580 |
" |
213 | 581 |
the object to put into the receiver collection |
362 | 582 |
is not an instance of the expected element class, |
583 |
or the value is not within the elements valid range. |
|
159 | 584 |
" |
2 | 585 |
^ self elementBoundsError |
1 | 586 |
! |
587 |
||
588 |
instVarAt:index |
|
589 |
"return a non-indexed instance variable; |
|
13 | 590 |
peeking into an object this way is not very object oriented |
591 |
- use with care (needed for copy, inspector etc.)" |
|
1 | 592 |
|
593 |
%{ /* NOCONTEXT */ |
|
594 |
||
595 |
OBJ myClass; |
|
596 |
int idx, ninstvars; |
|
597 |
||
253 | 598 |
if (__isSmallInteger(index)) { |
329 | 599 |
myClass = __Class(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
600 |
idx = __intVal(index) - 1; |
357 | 601 |
/* |
602 |
* do not allow return of non-object fields. |
|
603 |
* if subclass did not make privisions for that, |
|
604 |
* we wont do so here ... |
|
605 |
*/ |
|
606 |
if (((INT)(_ClassInstPtr(myClass)->c_flags) & _MASKSMALLINT(NONOBJECT_INSTS))) { |
|
607 |
if (idx == 0) { |
|
608 |
RETURN ( nil ) |
|
609 |
} |
|
610 |
} |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
611 |
ninstvars = __intVal(_ClassInstPtr(myClass)->c_ninstvars); |
159 | 612 |
if ((idx >= 0) && (idx < ninstvars)) { |
613 |
RETURN ( _InstPtr(self)->i_instvars[idx] ); |
|
614 |
} |
|
1 | 615 |
} |
616 |
%} |
|
617 |
. |
|
618 |
index isInteger ifFalse:[ |
|
159 | 619 |
^ self indexNotInteger |
1 | 620 |
]. |
159 | 621 |
^ self subscriptBoundsError:index |
1 | 622 |
! |
623 |
||
624 |
instVarAt:index put:value |
|
625 |
"change a non-indexed instance variable; |
|
13 | 626 |
peeking into an object this way is not very object oriented |
627 |
- use with care (needed for copy, inspector etc.)" |
|
1 | 628 |
|
629 |
%{ /* NOCONTEXT */ |
|
630 |
||
631 |
OBJ myClass; |
|
632 |
int idx, ninstvars; |
|
633 |
||
253 | 634 |
if (__isSmallInteger(index)) { |
329 | 635 |
myClass = __Class(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
636 |
idx = __intVal(index) - 1; |
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
637 |
ninstvars = __intVal(_ClassInstPtr(myClass)->c_ninstvars); |
357 | 638 |
/* |
639 |
* do not allow setting of non-object fields. |
|
640 |
* if subclass did not make privisions for that, |
|
641 |
* we wont do so here ... |
|
642 |
*/ |
|
643 |
if (((INT)(_ClassInstPtr(myClass)->c_flags) & _MASKSMALLINT(NONOBJECT_INSTS))) { |
|
644 |
if (idx == 0) { |
|
645 |
RETURN ( nil ) |
|
646 |
} |
|
647 |
} |
|
159 | 648 |
if ((idx >= 0) && (idx < ninstvars)) { |
649 |
_InstPtr(self)->i_instvars[idx] = value; |
|
650 |
__STORE(self, value); |
|
651 |
RETURN ( value ); |
|
652 |
} |
|
1 | 653 |
} |
654 |
%} |
|
655 |
. |
|
656 |
index isInteger ifFalse:[ |
|
159 | 657 |
^ self indexNotInteger |
1 | 658 |
]. |
159 | 659 |
^ self subscriptBoundsError:index |
359 | 660 |
! |
661 |
||
662 |
instVarNamed:name |
|
663 |
"return a non-indexed instance variables value by name; |
|
664 |
peeking into an object this way is not very object oriented |
|
665 |
- use with care (provided for inspectors)" |
|
666 |
||
667 |
^ self instVarAt:(self class instVarOffsetOf:name) |
|
668 |
! |
|
669 |
||
670 |
instVarNamed:name put:value |
|
671 |
"set a non-indexed instance variable by name; |
|
672 |
peeking into an object this way is not very object oriented |
|
673 |
- use with care (provided for inspectors)" |
|
674 |
||
675 |
^ self instVarAt:(self class instVarOffsetOf:name) put:value |
|
1 | 676 |
! ! |
677 |
||
783 | 678 |
!Object methodsFor:'binary storage'! |
679 |
||
680 |
hasSpecialBinaryRepresentation |
|
681 |
"return true, if the receiver has a special binary representation; |
|
682 |
default here is false, but can be redefined in class which provide |
|
683 |
their own storeBinary/readBinary methods. |
|
684 |
||
685 |
Normal user classes should not use this, it is meant as a hook for |
|
686 |
special classes such as True, False, UndefinedObject or SmallInteger. |
|
687 |
||
688 |
If your instances should be stored in a special way, see |
|
689 |
#representBinaryOn: and #readBinaryContentsFromdata:manager:." |
|
690 |
||
691 |
^ false |
|
1 | 692 |
! |
693 |
||
783 | 694 |
readBinaryContentsFrom:stream manager:manager |
695 |
"reconstruct the receivers instance variables by reading a binary |
|
696 |
binary representation from stream. |
|
697 |
This is a general implementation, walking over instances |
|
698 |
and loading each recursively using manager. |
|
699 |
Redefined by some classes to read a more compact representations |
|
700 |
(see String, SmallInteger etc). |
|
701 |
||
702 |
Notice, that the object is already recreated as an empty corps |
|
703 |
with instance variables all nil and bit-instances (bytes, words etc.) |
|
704 |
already read and restored. |
|
705 |
||
706 |
Also notice: this method is not called for if a private representation |
|
707 |
has been stored (see representBinaryOn:). |
|
708 |
In that case, #readBinaryContentsFromData:manager: is called, which |
|
709 |
has to be reimplemented in the objects class." |
|
710 |
||
711 |
|size "{ Class: SmallInteger }" |
|
712 |
instvarArray| |
|
713 |
||
714 |
stream next == 1 ifTrue:[ |
|
715 |
"/ |
|
716 |
"/ special representation ... |
|
717 |
"/ |
|
718 |
instvarArray := Array new:(size := stream nextNumber:3). |
|
719 |
1 to:size do:[:i | |
|
720 |
instvarArray basicAt:i put:(manager nextObject) |
|
721 |
]. |
|
722 |
self readBinaryContentsFromData:instvarArray manager:manager. |
|
723 |
^ self |
|
724 |
]. |
|
725 |
||
726 |
"/ |
|
727 |
"/ standard representation |
|
728 |
"/ |
|
729 |
size := self basicSize. |
|
730 |
size ~~ 0 ifTrue:[ |
|
731 |
self class isPointers ifTrue:[ |
|
732 |
1 to:size do:[:i | |
|
733 |
self basicAt:i put:(manager nextObject) |
|
734 |
] |
|
735 |
] |
|
736 |
]. |
|
737 |
size := self class instSize. |
|
738 |
1 to:size do:[:i | |
|
739 |
self instVarAt:i put:(manager nextObject) |
|
740 |
]. |
|
741 |
! |
|
742 |
||
743 |
readBinaryContentsFromData:instvarArray manager:manager |
|
744 |
"reconstruct the receivers instance variables by filling instance |
|
745 |
variables with values from instvarArray. This array contains the instvars |
|
746 |
as specified in #representBinaryOn: when the object was stored. |
|
747 |
It is the receivers responsibility to set its instance variables in the |
|
748 |
same order from that array." |
|
749 |
||
750 |
^ self subclassResponsibility |
|
751 |
||
752 |
"typical implementation (see also comment in #representBinaryOn:) |
|
753 |
(for an object with foo, bar and baz as instance variables, |
|
754 |
which did not store baz and wants baz to be reinitialized to |
|
755 |
some constant string) |
|
756 |
||
757 |
foo := instvarArray at:1. |
|
758 |
bar := instvarArray at:2. |
|
759 |
baz := 'aConstant'. |
|
760 |
" |
|
761 |
! |
|
762 |
||
763 |
representBinaryOn:manager |
|
764 |
"this method is called by the storage manager to ask objects |
|
765 |
if they wish to provide their own binary representation. |
|
766 |
||
767 |
If they want to do so, they should return an array containing all |
|
768 |
instance variables (named & indexed pointer) to be stored. |
|
769 |
If not redefined, this method returns nil which means that all |
|
770 |
instance variables are to be stored. |
|
771 |
||
772 |
It should be redefined in objects which do not want all instance variables |
|
773 |
to be stored (for example: objects which keep references to a view etc.). |
|
774 |
||
775 |
If this is redefined returning non-nil, the corresponding class needs |
|
776 |
a redefined instance method named #readBinaryContentsFromData:manager: |
|
777 |
which has to fill the receivers named (and optionally indexed pointer) |
|
778 |
instance variables with corresponding values from a data array." |
|
779 |
||
780 |
^ nil |
|
781 |
||
782 |
"typical implementation: |
|
783 |
(see also comment in #readBinaryContentsFromData:manager:) |
|
784 |
for an object with foo, bar and baz as instance variables, |
|
785 |
which does not want to store baz: |
|
786 |
||
787 |
representBinaryOn:manager |
|
788 |
|data| |
|
789 |
||
790 |
data := Array new:2. |
|
791 |
data at:1 put:foo. |
|
792 |
data at:2 put:bar. |
|
793 |
^ data |
|
794 |
" |
|
159 | 795 |
! |
796 |
||
783 | 797 |
storeBinaryContentsFromData:instvarArray on:stream manager:manager |
798 |
"store the instvars (both named & indexed pointer) |
|
799 |
as returned by #representBinaryOn:." |
|
800 |
||
801 |
|size "{ Class: SmallInteger }"| |
|
802 |
||
803 |
size := instvarArray size. |
|
804 |
1 to:size do:[:i | |
|
805 |
manager putIdOf:(instvarArray at:i) on:stream |
|
806 |
]. |
|
807 |
! |
|
808 |
||
809 |
storeBinaryContentsOn:stream manager:manager |
|
810 |
"store the receivers instance variables in a binary representation |
|
811 |
on a stream using manager. |
|
812 |
This is a general implementation, walking over instances |
|
813 |
and storing each recursively using manager. |
|
814 |
||
815 |
Notice, that the objects definition and bit-instances (bytes, words etc.) |
|
816 |
are already stored. |
|
817 |
Here, we only have to deal with indexed-pointer and named instance variables. |
|
818 |
||
819 |
Also notice: this method is not called for if a private representation |
|
820 |
has been stored (see representBinaryOn:). |
|
821 |
In that case, #storeBinaryContentsFromData:manager: is called." |
|
822 |
||
823 |
|size "{ Class: SmallInteger }"| |
|
824 |
||
825 |
size := self basicSize. |
|
826 |
size ~~ 0 ifTrue:[ |
|
827 |
self class isPointers ifTrue:[ |
|
828 |
1 to:size do:[:i | |
|
829 |
manager putIdOf:(self basicAt:i) on:stream |
|
830 |
]. |
|
831 |
]. |
|
832 |
]. |
|
833 |
size := self class instSize. |
|
834 |
1 to:size do:[:i | |
|
835 |
manager putIdOf:(self instVarAt:i) on:stream |
|
836 |
]. |
|
1 | 837 |
! |
838 |
||
783 | 839 |
storeBinaryDefinitionBodyOn:stream manager:manager |
840 |
"append a binary representation of the receivers body onto stream. |
|
841 |
This is a general implementation walking over instances storing |
|
842 |
each recursively as an ID using manager. |
|
843 |
Can be redefined in subclasses." |
|
844 |
||
845 |
|basicSize "{ Class: SmallInteger }" |
|
846 |
instSize "{ Class: SmallInteger }" |
|
847 |
myClass specialRep pointers| |
|
848 |
||
849 |
myClass := self class. |
|
850 |
instSize := myClass instSize. |
|
851 |
||
852 |
(pointers := myClass isPointers) ifTrue:[ |
|
853 |
"/ |
|
854 |
"/ inst size not needed - if you uncomment the line below, |
|
855 |
"/ also uncomment the corresponding line in |
|
856 |
"/ Object>>binaryDefinitionFrom:manager: |
|
857 |
"/ |
|
858 |
"/ stream nextPut:instSize. "mhmh this limits us to 255 named instvars" |
|
859 |
||
860 |
myClass isVariable ifTrue:[ |
|
861 |
stream nextNumber:3 put:(basicSize := self basicSize) |
|
862 |
] ifFalse:[ |
|
863 |
basicSize := 0 |
|
864 |
]. |
|
865 |
] ifFalse: [ |
|
866 |
stream nextNumber:4 put:(basicSize := self basicSize). |
|
867 |
myClass isBytes ifTrue:[ |
|
868 |
1 to:basicSize do:[:i | |
|
869 |
stream nextPut:(self basicAt:i) |
|
870 |
] |
|
871 |
] ifFalse:[ |
|
872 |
myClass isWords ifTrue:[ |
|
873 |
1 to:basicSize do:[:i | |
|
874 |
stream nextNumber:2 put:(self basicAt: i) |
|
875 |
] |
|
876 |
] ifFalse:[ |
|
877 |
myClass isLongs ifTrue:[ |
|
878 |
1 to:basicSize do:[:i | |
|
879 |
stream nextNumber:4 put:(self basicAt: i) |
|
880 |
] |
|
881 |
] ifFalse:[ |
|
882 |
myClass isFloats ifTrue:[ |
|
883 |
"could do it in one big write on machines which use IEEE floats ..." |
|
884 |
1 to:basicSize do:[:i | |
|
885 |
Float storeBinaryIEEESingle:(self basicAt:i) on:stream |
|
886 |
] |
|
887 |
] ifFalse:[ |
|
888 |
myClass isDoubles ifTrue:[ |
|
889 |
"could do it in one big write on machines which use IEEE doubles ..." |
|
890 |
1 to:basicSize do:[:i | |
|
891 |
Float storeBinaryIEEEDouble:(self basicAt:i) on:stream |
|
892 |
] |
|
893 |
] ifFalse:[ |
|
894 |
"/ should never be reached ... |
|
895 |
1 to:basicSize do:[:i | |
|
896 |
manager putIdOf:(self basicAt:i) on:stream |
|
897 |
] |
|
898 |
] |
|
899 |
] |
|
900 |
] |
|
901 |
] |
|
902 |
]. |
|
903 |
]. |
|
904 |
||
905 |
(pointers or:[instSize ~~ 0]) ifTrue:[ |
|
906 |
specialRep := self representBinaryOn:manager. |
|
907 |
specialRep notNil ifTrue:[ |
|
908 |
stream nextPut:1. "/ means: private representation follows |
|
909 |
stream nextNumber:3 put:(specialRep basicSize). |
|
910 |
self storeBinaryContentsFromData:specialRep on:stream manager:manager |
|
911 |
] ifFalse:[ |
|
912 |
stream nextPut:0. "/ means: full representation follows |
|
913 |
self storeBinaryContentsOn:stream manager:manager |
|
159 | 914 |
] |
1 | 915 |
] |
783 | 916 |
|
917 |
"Modified: 25.10.1995 / 14:00:51 / cg" |
|
1 | 918 |
! |
919 |
||
783 | 920 |
storeBinaryDefinitionOn:stream manager:manager |
921 |
"append a binary representation of the receiver onto stream. |
|
922 |
This method first stores the class, then the body, which is done |
|
923 |
in a separate method to allow redefinition of the bodies format. |
|
924 |
Can be redefined in subclasses to write more compact representations |
|
925 |
(see String, SmallInteger etc)." |
|
926 |
||
927 |
manager putIdOfClass:(self class) on:stream. |
|
928 |
self storeBinaryDefinitionBodyOn:stream manager:manager |
|
929 |
! |
|
930 |
||
931 |
storeBinaryOn:aStream |
|
932 |
"Writes a description of the receiver onto aStream, in a way that allows |
|
933 |
the object's structure to be reconstructed from the stream's contents" |
|
934 |
||
935 |
BinaryOutputManager store:self on:aStream |
|
899 | 936 |
|
937 |
" |
|
938 |
|a s1 s2| |
|
939 |
||
940 |
s1 := 'hello'. |
|
941 |
s2 := 'world'. |
|
942 |
a := Array new:5. |
|
943 |
a at:1 put:s1. |
|
944 |
a at:2 put:s2. |
|
945 |
a at:3 put:s1. |
|
946 |
a at:4 put:s2. |
|
947 |
a storeBinaryOn:'test.boss' |
|
948 |
" |
|
949 |
||
950 |
" |
|
951 |
(BinaryObjectStorage onOld:'test.boss' asFilename readStream) |
|
952 |
next |
|
953 |
inspect |
|
954 |
" |
|
783 | 955 |
! |
956 |
||
957 |
storeBinaryOn:stream manager:manager |
|
958 |
"append a binary representation of the receiver onto stream." |
|
959 |
||
960 |
manager putIdOf:self on:stream |
|
1 | 961 |
! ! |
962 |
||
963 |
!Object methodsFor:'change and update'! |
|
964 |
||
783 | 965 |
broadcast:aSelectorSymbol |
966 |
"send a message with selector aSelectorSymbol to all my dependents" |
|
967 |
||
968 |
self dependentsDo:[:dependent | |
|
969 |
dependent perform:aSelectorSymbol |
|
970 |
] |
|
971 |
! |
|
972 |
||
973 |
broadcast:aSelectorSymbol with:anArgument |
|
974 |
"send a message with selector aSelectorSymbol with an additional |
|
975 |
argument anArgument to all my dependents." |
|
976 |
||
977 |
self dependentsDo:[:dependent | |
|
978 |
dependent perform:aSelectorSymbol with:anArgument |
|
979 |
] |
|
980 |
! |
|
981 |
||
159 | 982 |
changeRequest |
983 |
"the receiver wants to change - check if all dependents |
|
984 |
grant the request, and return true if so" |
|
985 |
||
986 |
self dependentsDo:[:dependent | |
|
987 |
dependent updateRequest ifFalse:[^ false]. |
|
988 |
]. |
|
989 |
^ true |
|
990 |
! |
|
991 |
||
992 |
changeRequest:aParameter |
|
993 |
"the receiver wants to change - check if all dependents |
|
994 |
grant the request, and return true if so" |
|
995 |
||
996 |
self dependentsDo:[:dependent | |
|
997 |
(dependent updateRequest:aParameter) ifFalse:[^ false]. |
|
998 |
]. |
|
999 |
^ true |
|
1000 |
! |
|
1001 |
||
783 | 1002 |
changeRequest:aParameter from:anObject |
1003 |
"the receiver wants to change - check if all dependents |
|
1004 |
except anObject grant the request, and return true if so. |
|
1005 |
The argument anObject is typically going to be the one who is |
|
1006 |
about to send the change request." |
|
1007 |
||
1008 |
self dependentsDo:[:dependent | |
|
1009 |
dependent == anObject ifFalse:[ |
|
1010 |
(dependent updateRequest:aParameter) ifFalse:[^ false]. |
|
1011 |
] |
|
1012 |
]. |
|
1013 |
^ true |
|
1014 |
! |
|
1015 |
||
159 | 1016 |
changeRequestFrom:anObject |
1017 |
"the receiver wants to change - check if all dependents |
|
202 | 1018 |
except anObject grant the request, and return true if so. |
1019 |
The argument anObject is typically going to be the one who is |
|
1020 |
about to send the change request." |
|
159 | 1021 |
|
1022 |
self dependentsDo:[:dependent | |
|
1023 |
dependent == anObject ifFalse:[ |
|
1024 |
(dependent updateRequest) ifFalse:[^ false]. |
|
1025 |
] |
|
1026 |
]. |
|
1027 |
^ true |
|
1028 |
! |
|
1029 |
||
1 | 1030 |
changed |
1031 |
"notify all dependents that the receiver has changed. |
|
71 | 1032 |
Each dependent gets a '#update:'-message with the original |
1033 |
receiver as argument." |
|
1 | 1034 |
|
159 | 1035 |
self changed:nil |
1 | 1036 |
! |
1037 |
||
1038 |
changed:aParameter |
|
1039 |
"notify all dependents that the receiver has changed somehow. |
|
71 | 1040 |
Each dependent gets a '#update:'-message with aParameter |
1041 |
as argument." |
|
1 | 1042 |
|
159 | 1043 |
self changed:aParameter with:nil |
1 | 1044 |
! |
1045 |
||
71 | 1046 |
changed:aParameter with:anArgument |
1 | 1047 |
"notify all dependents that the receiver has changed somehow. |
159 | 1048 |
Each dependent gets a '#update:with:from:'-message, with aParameter |
71 | 1049 |
and anArgument as arguments." |
1 | 1050 |
|
159 | 1051 |
self dependentsDo:[:dependent | |
1052 |
dependent update:aParameter with:anArgument from:self |
|
1 | 1053 |
] |
1054 |
! |
|
1055 |
||
1056 |
update:aParameter |
|
71 | 1057 |
"the message is sent to a dependent, when one of the objects |
1058 |
on whom the receiver depends, has changed. The argument aParameter |
|
1059 |
is either the changed object or the argument to the #changed: message. |
|
1060 |
||
1061 |
Default behavior here is to do nothing" |
|
1 | 1062 |
|
1063 |
^ self |
|
1064 |
! |
|
1065 |
||
1066 |
update:aParameter with:anArgument |
|
1067 |
"dependent is notified of some change - |
|
159 | 1068 |
Default is to try update:" |
1 | 1069 |
|
1070 |
^ self update:aParameter |
|
1071 |
! |
|
1072 |
||
1073 |
update:aParameter with:anArgument from:sender |
|
1074 |
"dependent is notified of some change - |
|
159 | 1075 |
Default is to try update:with:" |
1 | 1076 |
|
1077 |
^ self update:aParameter with:anArgument |
|
159 | 1078 |
! |
1079 |
||
1080 |
updateRequest |
|
1081 |
"return true, if an update request is granted. |
|
1082 |
Default here is to grant updates - may be used |
|
1083 |
to lock updates if someone is making other changes |
|
202 | 1084 |
from within an update. Or if someone has locked its |
1085 |
state and does not want others to change things. |
|
1086 |
However, these dependents must all honor the |
|
1087 |
changeRequest - ifTrue - change protocol. I.e. they |
|
1088 |
must first ask all others via changeRequest, and only do the change |
|
1089 |
it returns true. The others must decide in updateRequest and |
|
1090 |
return true if they think a change is ok." |
|
159 | 1091 |
|
1092 |
^ true |
|
1093 |
! |
|
1094 |
||
1095 |
updateRequest:aSymbol |
|
1096 |
"return true, if an update request is granted. |
|
1097 |
Default here a simple updateRequest" |
|
1098 |
||
1099 |
^ self updateRequest |
|
1 | 1100 |
! ! |
1101 |
||
783 | 1102 |
!Object methodsFor:'cleanup'! |
1103 |
||
1104 |
lowSpaceCleanup |
|
1105 |
"ignored here - redefined in some classes to |
|
1106 |
cleanup in low-memory situations" |
|
1107 |
||
1108 |
^ self |
|
1109 |
! ! |
|
1110 |
||
1111 |
!Object methodsFor:'comparing'! |
|
1112 |
||
1113 |
= anObject |
|
1114 |
"return true, if the receiver and the arg have the same structure" |
|
1115 |
||
1116 |
^ self == anObject |
|
1117 |
! |
|
1118 |
||
1119 |
== anObject |
|
1120 |
"return true, if the receiver and the arg are the same object" |
|
1121 |
||
1122 |
%{ /* NOCONTEXT */ |
|
1123 |
||
1124 |
RETURN ( (self == anObject) ? true : false ); |
|
1125 |
%} |
|
1126 |
! |
|
1127 |
||
1128 |
hash |
|
1129 |
"return an Integer useful as a hash key for the receiver. |
|
1130 |
This hash should return same values for objects with same |
|
1131 |
contents (i.e. use this to hash on structure)" |
|
1132 |
||
1133 |
^ self identityHash |
|
1134 |
! |
|
1135 |
||
1136 |
identityHash |
|
1137 |
"return an Integer useful as a hash key for the receiver. |
|
1138 |
This hash should return same values for the same object (i.e. use |
|
1139 |
this to hash on identity of objects). |
|
1140 |
||
1141 |
We cannot use the Objects address (as other smalltalks do) since |
|
1142 |
no object-table exists and the hashval must not change when objects |
|
1143 |
are moved by the collector. Therefore we assign each object a unique |
|
1144 |
Id in the object header itself as its hashed upon. |
|
1145 |
(luckily we have 11 bits spare to do this - unluckily its only 11 bits). |
|
1146 |
Time will show, if 11 bits are enough; if not, another entry in the |
|
1147 |
object header will be needed, adding 4 bytes to every object. Alternatively, |
|
1148 |
hashed-upon objects could add an instvar containing the hash value." |
|
1149 |
||
1150 |
%{ /* NOCONTEXT */ |
|
1151 |
||
1152 |
REGISTER unsigned hash; |
|
1153 |
static unsigned nextHash = 0; |
|
1154 |
OBJ cls; |
|
1155 |
||
1156 |
if (__isNonNilObject(self)) { |
|
1157 |
hash = __GET_HASH(self); |
|
1158 |
if (hash == 0) { |
|
1159 |
hash = nextHash++; |
|
1160 |
__SET_HASH(self, hash); |
|
1161 |
hash = __GET_HASH(self); |
|
1162 |
if (hash == 0) { |
|
1163 |
hash = nextHash++; |
|
1164 |
__SET_HASH(self, hash); |
|
1165 |
hash = __GET_HASH(self); |
|
1166 |
} |
|
1167 |
} |
|
1168 |
||
1169 |
/* |
|
1170 |
* now, we got 11 bits for hashing; |
|
1171 |
* make it as large as possible; since most hashers use the returned |
|
1172 |
* key and take it modulu some prime number, this will allow for |
|
1173 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
|
1174 |
* we could shift it up to the 30 bit limit - not making it negative. |
|
1175 |
*/ |
|
1176 |
RETURN ( __MKSMALLINT(hash << __HASH_SHIFT__) ); |
|
1177 |
} |
|
1178 |
%}. |
|
1179 |
^ 0 "never reached, since redefined in UndefinedObject and SmallInteger" |
|
1180 |
! |
|
1181 |
||
1182 |
isNil |
|
1183 |
"return true, if the receiver is nil" |
|
1184 |
||
1185 |
^ false |
|
1186 |
! |
|
1187 |
||
1188 |
notNil |
|
1189 |
"return true, if the receiver is not nil" |
|
1190 |
||
1191 |
^ true |
|
1192 |
! |
|
1193 |
||
1194 |
~= anObject |
|
1195 |
"return true, if the receiver and the arg do not have the same structure" |
|
1196 |
||
1197 |
^ (self = anObject) not |
|
1198 |
! |
|
1199 |
||
1200 |
~~ anObject |
|
1201 |
"return true, if the receiver and the arg are not the same object" |
|
1202 |
||
1203 |
%{ /* NOCONTEXT */ |
|
1204 |
||
1205 |
RETURN ( (self == anObject) ? false : true ); |
|
1206 |
%} |
|
1207 |
! ! |
|
1208 |
||
1209 |
!Object methodsFor:'converting'! |
|
1210 |
||
1211 |
asValue |
|
1212 |
"return a valueHolder for for the receiver" |
|
1213 |
||
1214 |
^ ValueHolder with:self |
|
1215 |
! ! |
|
1216 |
||
1217 |
!Object methodsFor:'copying'! |
|
1218 |
||
1219 |
copy |
|
1220 |
"return a copy of the receiver - defaults to shallowcopy here. |
|
1221 |
Notice, that copy does not copy dependents." |
|
1222 |
||
1223 |
^ self shallowCopy postCopy |
|
1224 |
! |
|
1225 |
||
1226 |
deepCopy |
|
1227 |
"return a copy of the object with all subobjects also copied. |
|
1228 |
This method DOES handle cycles/self-refs; however the receivers |
|
1229 |
class is not copied (to avoid the 'total' copy). |
|
1230 |
This deepCopy is a bit slower than the old (unsecure) one, since it |
|
1231 |
keeps track of already copied objects. If you are sure, that your |
|
1129 | 1232 |
copied object does not include duplicates (or you do not care) and |
783 | 1233 |
no cycles, you can use the old simpleDeepCopy, which avoids this overhead, |
1234 |
but may run into trouble. |
|
1235 |
Notice, that copy does not copy dependents." |
|
1236 |
||
1237 |
^ self deepCopyUsing:(IdentityDictionary new) |
|
1238 |
||
1239 |
"an example which is not handled by the old deepCopy: |
|
1240 |
||
1241 |
|a| |
|
1242 |
a := Array new:3. |
|
1243 |
a at:3 put:a. |
|
1244 |
a deepCopy inspect |
|
1245 |
" |
|
1129 | 1246 |
|
1247 |
"Modified: 27.3.1996 / 16:31:20 / stefan" |
|
783 | 1248 |
! |
1249 |
||
1250 |
deepCopyError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1251 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1252 |
|
783 | 1253 |
"raise a signal, that deepCopy is not allowed for this object" |
1254 |
||
1255 |
^ DeepCopyErrorSignal raise |
|
1256 |
! |
|
1257 |
||
1258 |
deepCopyUsing:aDictionary |
|
1259 |
"a helper for deepCopy; return a copy of the object with |
|
1260 |
all subobjects also copied. If the to-be-copied object is in the dictionary, |
|
1261 |
use the value found there. The class of the receiver is not copied. |
|
1262 |
This method DOES handle cycles/self references." |
|
1263 |
||
1264 |
|myClass aCopy |
|
1265 |
sz "{ Class: SmallInteger }" |
|
1266 |
iOrig iCopy| |
|
1267 |
||
1268 |
myClass := self class. |
|
1269 |
myClass isVariable ifTrue:[ |
|
1270 |
sz := self basicSize. |
|
1271 |
aCopy := myClass basicNew:sz. |
|
1272 |
] ifFalse:[ |
|
1273 |
sz := 0. |
|
1274 |
aCopy := myClass basicNew |
|
1275 |
]. |
|
1276 |
aCopy setHashFrom:self. |
|
1277 |
||
1278 |
aDictionary at:self put:aCopy. |
|
143 | 1279 |
|
1280 |
" |
|
783 | 1281 |
copy indexed instvars - if any |
1282 |
" |
|
1283 |
sz ~~ 0 ifTrue:[ |
|
1284 |
myClass isBits ifTrue:[ |
|
1285 |
"block-copy indexed instvars" |
|
1286 |
aCopy replaceFrom:1 to:sz with:self startingAt:1 |
|
1287 |
] ifFalse:[ |
|
1288 |
"individual deep copy the indexed variables" |
|
1289 |
1 to:sz do:[:i | |
|
1290 |
iOrig := self basicAt:i. |
|
1291 |
iOrig notNil ifTrue:[ |
|
1292 |
(aDictionary includesKey:iOrig) ifTrue:[ |
|
1293 |
iCopy := aDictionary at:iOrig |
|
1294 |
] ifFalse:[ |
|
1295 |
iCopy := iOrig deepCopyUsing:aDictionary. |
|
1296 |
]. |
|
1297 |
aCopy basicAt:i put:iCopy |
|
1298 |
] |
|
1299 |
] |
|
1300 |
] |
|
1301 |
]. |
|
1302 |
||
1303 |
" |
|
1304 |
copy the instance variables |
|
1305 |
" |
|
1306 |
sz := myClass instSize. |
|
1307 |
sz ~~ 0 ifTrue:[ |
|
1308 |
1 to:sz do:[:i | |
|
1309 |
iOrig := self instVarAt:i. |
|
1310 |
iOrig notNil ifTrue:[ |
|
1311 |
(aDictionary includesKey:iOrig) ifTrue:[ |
|
1312 |
iCopy := aDictionary at:iOrig |
|
1313 |
] ifFalse:[ |
|
1314 |
iCopy := iOrig deepCopyUsing:aDictionary. |
|
1315 |
]. |
|
1316 |
aCopy instVarAt:i put:iCopy |
|
1317 |
] |
|
1318 |
]. |
|
1319 |
]. |
|
1320 |
||
1321 |
^ aCopy |
|
1322 |
! |
|
1323 |
||
1324 |
postCopy |
|
1325 |
"this is for compatibility with ST-80 code, which uses postCopy for |
|
1326 |
cleanup after copying, while ST/X passes the original in postCopyFrom: |
|
1327 |
(see there)" |
|
1328 |
||
1329 |
^ self |
|
1330 |
! |
|
1331 |
||
1332 |
postCopyFrom:original |
|
1333 |
"sent to a freshly deep-copied object to give it a chance to adjust things. |
|
1334 |
(a font could flush its device-handle for example). |
|
1335 |
Notice, that for Sets/Dicts etc. a rehash is not needed, since the deepCopy |
|
1336 |
will have the same hash key as the receiver (as long as ST/X provides the |
|
1337 |
setHash: functionality)." |
|
1338 |
||
1339 |
"for ST-80 compatibility, we try postCopy here ..." |
|
1340 |
^ self postCopy |
|
1341 |
! |
|
1342 |
||
1343 |
setHashFrom:anObject |
|
1344 |
"set my identity-hash key to be the same as anObjects hash key. |
|
1345 |
This is an ST/X speciality, which is NOT available in other (especially OT based) |
|
1346 |
Smalltalks, and may not be available in future ST/X versions. |
|
1347 |
DO NEVER use this for normal application code." |
|
1348 |
||
1349 |
%{ /* NOCONTEXT */ |
|
1350 |
||
1351 |
REGISTER unsigned h; |
|
1352 |
||
1353 |
if (__isNonNilObject(self) && __isNonNilObject(anObject)) { |
|
1354 |
h = __GET_HASH(anObject); |
|
1355 |
__SET_HASH(self, h); |
|
1356 |
RETURN (self); |
|
1357 |
} |
|
1358 |
%} |
|
1359 |
. |
|
1360 |
self primitiveFailed "neither receiver not arg may be nil or SmallInteger" |
|
1361 |
! |
|
1362 |
||
1363 |
shallowCopy |
|
1364 |
"return a copy of the object with shared subobjects (a shallow copy) |
|
1365 |
i.e. the copy shares referenced instvars with its original." |
|
1366 |
||
1367 |
|myClass aCopy |
|
1368 |
sz "{ Class: SmallInteger }" | |
|
1369 |
||
1370 |
myClass := self class. |
|
1371 |
myClass isVariable ifTrue:[ |
|
1372 |
sz := self basicSize. |
|
1373 |
aCopy := myClass basicNew:sz. |
|
1374 |
||
1375 |
"copy the indexed variables" |
|
1376 |
1 to:sz do:[:i | |
|
1377 |
aCopy basicAt:i put:(self basicAt:i) |
|
1378 |
] |
|
1379 |
] ifFalse:[ |
|
1380 |
aCopy := myClass basicNew |
|
1381 |
]. |
|
1382 |
||
1383 |
"copy the instance variables" |
|
1384 |
sz := myClass instSize. |
|
1385 |
1 to:sz do:[:i | |
|
1386 |
aCopy instVarAt:i put:(self instVarAt:i) |
|
1387 |
]. |
|
1388 |
||
1389 |
^ aCopy |
|
1390 |
! |
|
1391 |
||
1392 |
shallowCopyForFinalization |
|
1393 |
"this is used to aquire a copy to be used for finalization - |
|
1394 |
(the copy will get a dispose-notification; see the documentation in the Registry class) |
|
1395 |
This method can be redefined for more efficient copying - especially for large objects." |
|
1396 |
||
1397 |
^ self shallowCopy |
|
1398 |
! |
|
1399 |
||
1400 |
simpleDeepCopy |
|
1401 |
"return a copy of the object with all subobjects also copied. |
|
1402 |
This method does NOT handle cycles - but is included to allow this |
|
1403 |
slightly faster copy in situations where it is known that |
|
1404 |
no recursive references occur (LargeIntegers for example). |
|
1405 |
NOTICE: you will run into trouble, when trying this with recursive |
|
1406 |
objects (usually recursionInterrupt or memory-alert). |
|
1407 |
This method corresponds to the 'traditional' deepCopy found in |
|
1408 |
the Blue book." |
|
1409 |
||
1410 |
|myClass aCopy |
|
1411 |
sz "{ Class: SmallInteger }" | |
|
1412 |
||
1413 |
myClass := self class. |
|
1414 |
myClass isVariable ifTrue:[ |
|
1415 |
sz := self basicSize. |
|
1416 |
aCopy := myClass basicNew:sz. |
|
1417 |
||
1418 |
"copy the indexed variables" |
|
1419 |
1 to:sz do:[:i | |
|
1420 |
aCopy basicAt:i put:((self basicAt:i) simpleDeepCopy) |
|
1421 |
] |
|
1422 |
] ifFalse:[ |
|
1423 |
aCopy := myClass basicNew |
|
1424 |
]. |
|
1425 |
||
1426 |
"copy the instance variables" |
|
1427 |
sz := myClass instSize. |
|
1428 |
1 to:sz do:[:i | |
|
1429 |
aCopy instVarAt:i put:((self instVarAt:i) simpleDeepCopy) |
|
1430 |
]. |
|
1431 |
||
1432 |
^ aCopy |
|
1433 |
||
1434 |
"a bad example (but ST/X should survive ...)" |
|
1435 |
" |
|
1436 |
|a| |
|
1437 |
a := Array new:3. |
|
1438 |
a at:3 put:a. |
|
1439 |
a simpleDeepCopy |
|
1440 |
" |
|
1441 |
! ! |
|
1442 |
||
1443 |
!Object methodsFor:'debugging'! |
|
1444 |
||
1445 |
basicInspect |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1446 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1447 |
|
783 | 1448 |
"launch an inspector on the receiver. |
1449 |
this method should NOT be redefined in subclasses." |
|
1450 |
||
1451 |
Inspector isNil ifTrue:[ |
|
1452 |
" |
|
1453 |
for systems without GUI |
|
1454 |
" |
|
1455 |
Transcript showCr:'no Inspector' |
|
1456 |
] ifFalse:[ |
|
1457 |
Inspector openOn:self |
|
1458 |
] |
|
1459 |
! |
|
1460 |
||
1461 |
inspect |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1462 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1463 |
|
783 | 1464 |
"launch an inspector on the receiver. |
1465 |
this method (or better: inspectorClass) can be redefined in subclasses |
|
1466 |
to start special inspectors." |
|
1467 |
||
1468 |
|cls| |
|
1469 |
||
1470 |
cls := self inspectorClass. |
|
1471 |
cls isNil ifTrue:[ |
|
1472 |
^ self basicInspect |
|
1473 |
]. |
|
1474 |
cls openOn:self |
|
1475 |
||
1476 |
" |
|
1477 |
Object new inspect |
|
1478 |
(1 @ 2) inspect |
|
1479 |
Smalltalk inspect |
|
1480 |
#(1 2 3) asOrderedCollection inspect |
|
1481 |
(Color red) inspect |
|
1482 |
(Image fromFile:'bitmaps/garfield.gif') inspect |
|
143 | 1483 |
" |
71 | 1484 |
! |
1485 |
||
783 | 1486 |
inspectorClass |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1487 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1488 |
|
783 | 1489 |
"return the class to use for inspect. |
1490 |
Can (should) be redefined in classes for which a better inspector is available" |
|
1491 |
||
1492 |
^ Inspector |
|
1493 |
! |
|
1494 |
||
1495 |
mustBeKindOf:aClass |
|
1496 |
"for compatibility & debugging support: |
|
1497 |
check if the receiver isKindOf:aClass and raise an error if not. |
|
1498 |
Notice: |
|
1499 |
it is VERY questionable, if it makes sense to add manual |
|
1500 |
type checks to a dynamically typed language like smalltalk. |
|
1501 |
It will, at least, slow down performance, |
|
1502 |
make your code less reusable and clutter your code with stupid sends |
|
1503 |
of this selector. Also, read the comment in isKindOf:, regarding the |
|
1504 |
use of isXXX check methods. |
|
1505 |
You see: The author does not like this at all ..." |
|
1506 |
||
1507 |
(self isKindOf:aClass) ifFalse:[ |
|
1508 |
self error:'argument is not of expected type' |
|
1509 |
] |
|
1510 |
! |
|
1511 |
||
1512 |
obsoleteMethodWarning |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1513 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1514 |
|
783 | 1515 |
"in methods which are going to be obsoleted, a self send to |
1516 |
this method is used to tell programmers that a method is |
|
1517 |
used which is going to be removed in later ST/X versions. |
|
1518 |
Find all methods which will be obsolete soon by looking at senders |
|
1519 |
of this message. |
|
1520 |
Hopefully, this warning message is annoying enough for you to |
|
1521 |
change the code ... ;-)" |
|
1522 |
||
1523 |
self obsoleteMethodWarning:nil from:thisContext sender |
|
1524 |
! |
|
1525 |
||
1526 |
obsoleteMethodWarning:message |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1527 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1528 |
|
783 | 1529 |
"in methods which are going to be obsoleted, a self send to |
1530 |
this method is used to tell programmers that a method is |
|
1531 |
used which is going to be removed in later ST/X versions. |
|
1532 |
Find all methods which will be obsolete soon by looking at senders |
|
1533 |
of this message. |
|
1534 |
Hopefully, this warning message is annoying enough for you to |
|
1535 |
change the code ... ;-)" |
|
1536 |
||
1537 |
self obsoleteMethodWarning:message from:thisContext sender |
|
1538 |
! |
|
1539 |
||
1540 |
obsoleteMethodWarning:message from:aContext |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1541 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1542 |
|
783 | 1543 |
"in methods which are going to be obsoleted, a self-send to |
1544 |
this method is used to tell programmers that a method is |
|
1545 |
used which is going to be removed in later ST/X versions. |
|
1546 |
Find all methods which will be obsolete soon by looking at senders |
|
1547 |
of this message. |
|
1548 |
Hopefully, this warning message is annoying enough for you to |
|
1549 |
change the code ... ;-)" |
|
1550 |
||
1551 |
|spec| |
|
1552 |
||
1553 |
spec := aContext methodPrintString. |
|
1554 |
('WARNING: the ''' , spec , ''' method is obsolete.') errorPrintNL. |
|
1555 |
(' And may not be present in future ST/X versions.') errorPrintNL. |
|
1556 |
(' called from ' , aContext sender printString) errorPrintNL. |
|
1557 |
message notNil ifTrue:[ |
|
1558 |
'------> ' errorPrint. message errorPrintNL |
|
1559 |
] |
|
1560 |
||
1561 |
" |
|
1562 |
Object obsoleteMethodWarning:'foo' from:thisContext sender sender |
|
1563 |
" |
|
1564 |
! ! |
|
1565 |
||
1566 |
!Object methodsFor:'dependents access'! |
|
1567 |
||
1568 |
addDependent:anObject |
|
1569 |
"make the argument, anObject be a dependent of the receiver" |
|
1570 |
||
1571 |
|deps| |
|
1572 |
||
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1573 |
[ |
891 | 1574 |
deps := self dependents. |
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1575 |
|
1043 | 1576 |
"/ to save a fair amount of memory in case of |
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1577 |
"/ many dependencies, we store a single dependent in |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1578 |
"/ a WeakArray, and switch to a WeakSet if more dependents are |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1579 |
"/ added. |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1580 |
|
891 | 1581 |
deps isNil ifTrue:[ |
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1582 |
self dependents:(WeakArray with:anObject) |
891 | 1583 |
] ifFalse:[ |
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1584 |
deps class == WeakArray ifTrue:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1585 |
self dependents:(WeakIdentitySet with:(deps at:1) with:anObject) |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1586 |
] ifFalse:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1587 |
deps add:anObject |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1588 |
] |
891 | 1589 |
] |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1590 |
] valueUninterruptably |
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1591 |
|
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1592 |
"Modified: 2.2.1996 / 11:04:31 / cg" |
783 | 1593 |
! |
1594 |
||
1595 |
dependents |
|
1596 |
"return a Collection of dependents - nil if there is none. |
|
1597 |
The default implementation here uses a global Dictionary to store |
|
1598 |
dependents which may be too slow for high frequency change&update. |
|
1599 |
Therefore, some classes (Model) redefine this for better performance." |
|
1600 |
||
1601 |
^ Dependencies at:self ifAbsent:[nil] |
|
1602 |
! |
|
1603 |
||
1604 |
dependents:aCollection |
|
1605 |
"set the collection of dependents. |
|
1606 |
The default implementation here uses a global Dictionary to store |
|
1607 |
dependents which may be too slow for high frequency change&update. |
|
1608 |
Therefore, some classes (Model) redefine this for better performance." |
|
1609 |
||
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1610 |
[ |
891 | 1611 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1612 |
Dependencies removeKey:self ifAbsent:[] |
891 | 1613 |
] ifFalse:[ |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1614 |
Dependencies at:self put:aCollection |
891 | 1615 |
] |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1616 |
] valueUninterruptably |
783 | 1617 |
! |
1618 |
||
1619 |
dependentsDo:aBlock |
|
1620 |
"evaluate aBlock for all of my dependents" |
|
1621 |
||
1622 |
|deps| |
|
1623 |
||
1624 |
deps := self dependents. |
|
1625 |
deps notNil ifTrue:[ |
|
1626 |
deps do:aBlock |
|
1627 |
] |
|
1628 |
! |
|
1629 |
||
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1630 |
expressInterestIn:aspect for:anObject sendBack:aSelector |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1631 |
"arrange for aSelector to be sent to anObject whenever the receiver |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1632 |
changes aspect. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1633 |
This is redefined in the ValueModel class for a more efficient implementation." |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1634 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1635 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1636 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1637 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1638 |
self addDependent:(InterestConverter destination:anObject selector:aSelector aspect:aspect) |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1639 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1640 |
" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1641 |
|p b| |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1642 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1643 |
b := [Transcript showCr:'the point changed']. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1644 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1645 |
p := Point new. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1646 |
Transcript showCr:'interest in #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1647 |
p expressInterestIn:#foo for:b sendBack:#value. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1648 |
p x:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1649 |
Transcript showCr:'now changing #bar'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1650 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1651 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1652 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1653 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1654 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1655 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1656 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1657 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1658 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1659 |
Transcript showCr:'no more interest in #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1660 |
p retractInterestIn:#foo for:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1661 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1662 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1663 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1664 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1665 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1666 |
Transcript showCr:'interest in #bar now'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1667 |
p expressInterestIn:#bar for:b sendBack:#value. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1668 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1669 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1670 |
Transcript showCr:'now changing #bar'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1671 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1672 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1673 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1674 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1675 |
Transcript showCr:'interest in #foo now'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1676 |
p expressInterestIn:#foo for:b sendBack:#value. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1677 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1678 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1679 |
Transcript showCr:'now changing #bar'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1680 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1681 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1682 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1683 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1684 |
Transcript showCr:'no more interests'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1685 |
p retractInterestsFor:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1686 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1687 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1688 |
Transcript showCr:'now changing #bar'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1689 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1690 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1691 |
" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1692 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1693 |
"Created: 8.3.1996 / 22:57:10 / cg" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1694 |
"Modified: 8.3.1996 / 23:00:52 / cg" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1695 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1696 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1697 |
onChangeSend:aSelector to:anObject |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1698 |
"arrange for aSelector to be sent to anObject whenever the receiver |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1699 |
changes. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1700 |
This is redefined in the ValueModel class for a more efficient implementation." |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1701 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1702 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1703 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1704 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1705 |
self addDependent:(InterestConverter destination:anObject selector:aSelector) |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1706 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1707 |
" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1708 |
|p b| |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1709 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1710 |
b := [Transcript showCr:'the point changed']. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1711 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1712 |
p := Point new. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1713 |
p onChangeSend:#value to:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1714 |
p x:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1715 |
Transcript showCr:'now changing'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1716 |
p changed. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1717 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1718 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1719 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1720 |
Transcript showCr:'now changing'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1721 |
p changed. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1722 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1723 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1724 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1725 |
Transcript showCr:'no more interest'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1726 |
p retractInterestsFor:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1727 |
Transcript showCr:'now changing again'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1728 |
p changed. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1729 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1730 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1731 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1732 |
Transcript showCr:'interest again'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1733 |
p onChangeSend:#value to:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1734 |
Transcript showCr:'now changing again'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1735 |
p changed. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1736 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1737 |
" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1738 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1739 |
"Modified: 8.3.1996 / 22:53:17 / cg" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1740 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1741 |
|
783 | 1742 |
release |
1743 |
"remove all dependencies from the receiver" |
|
1744 |
||
1745 |
self dependents:nil |
|
1746 |
! |
|
1747 |
||
1748 |
removeDependent:anObject |
|
1749 |
"make the argument, anObject be independent of the receiver" |
|
1750 |
||
1751 |
|deps| |
|
1752 |
||
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1753 |
[ |
891 | 1754 |
deps := self dependents. |
1755 |
deps notNil ifTrue:[ |
|
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1756 |
|
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1757 |
"/ to save a fair amount of memeory in case of |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1758 |
"/ many dependencies, we store a single dependent in |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1759 |
"/ a WeakArray, and switch to a WeakSet if more dependents are |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1760 |
"/ added. |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1761 |
|
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1762 |
deps class == WeakArray ifTrue:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1763 |
(deps at:1) == anObject ifTrue:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1764 |
self dependents:nil |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1765 |
] |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1766 |
] ifFalse:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1767 |
deps remove:anObject ifAbsent:[]. |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1768 |
deps isEmpty ifTrue:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1769 |
self dependents:nil |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1770 |
] ifFalse:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1771 |
deps class == WeakArray ifTrue:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1772 |
self dependents:(WeakArray with:(deps first)) |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1773 |
] |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
1774 |
] |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1775 |
] |
891 | 1776 |
] |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1777 |
] valueUninterruptably |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1778 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1779 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1780 |
retractInterestIn:aspect for:someOne |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1781 |
"remove the interest of someOne in the receiver changing aspect |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1782 |
(as installed with #expressInterestIn:for:sendBack:). |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1783 |
This is redefined in the ValueModel class for a more efficient implementation." |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1784 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1785 |
"/ for now, remove the interestConverter. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1786 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1787 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1788 |
self dependentsDo:[:dep | |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1789 |
(dep isMemberOf:InterestConverter) ifTrue:[ |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1790 |
dep destination == someOne ifTrue:[ |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1791 |
dep aspect == aspect ifTrue:[ |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1792 |
self removeDependent:dep. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1793 |
^ self |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1794 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1795 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1796 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1797 |
]. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1798 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1799 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1800 |
" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1801 |
|p b| |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1802 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1803 |
b := [Transcript showCr:'the point changed']. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1804 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1805 |
p := Point new. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1806 |
Transcript showCr:'interest in #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1807 |
p expressInterestIn:#foo for:b sendBack:#value. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1808 |
p x:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1809 |
Transcript showCr:'now changing #bar'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1810 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1811 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1812 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1813 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1814 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1815 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1816 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1817 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1818 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1819 |
Transcript showCr:'no more interest in #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1820 |
p retractInterestIn:#foo for:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1821 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1822 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1823 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1824 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1825 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1826 |
Transcript showCr:'interest in #bar now'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1827 |
p expressInterestIn:#bar for:b sendBack:#value. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1828 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1829 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1830 |
Transcript showCr:'now changing #bar'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1831 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1832 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1833 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1834 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1835 |
Transcript showCr:'interest in #foo now'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1836 |
p expressInterestIn:#foo for:b sendBack:#value. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1837 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1838 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1839 |
Transcript showCr:'now changing #bar'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1840 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1841 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1842 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1843 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1844 |
Transcript showCr:'no more interests'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1845 |
p retractInterestsFor:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1846 |
Transcript showCr:'now changing #foo'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1847 |
p changed:#foo. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1848 |
Transcript showCr:'now changing #bar'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1849 |
p changed:#bar. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1850 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1851 |
" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1852 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1853 |
"Created: 8.3.1996 / 22:59:59 / cg" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1854 |
"Modified: 8.3.1996 / 23:01:52 / cg" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1855 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1856 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1857 |
retractInterestsFor:someOne |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1858 |
"remove the interest of someOne in the receiver |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1859 |
(as installed with #onChangeSend:to:). |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1860 |
This is redefined in the ValueModel class for a more efficient implementation." |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1861 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1862 |
"/ for now, remove the interestConverter. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1863 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1864 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1865 |
|coll| |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1866 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1867 |
"/ cannot removeDependent within the loop - the collection rehashes |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1868 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1869 |
coll := IdentitySet new. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1870 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1871 |
self dependentsDo:[:dep | |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1872 |
(dep isMemberOf:InterestConverter) ifTrue:[ |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1873 |
dep destination == someOne ifTrue:[ |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1874 |
coll add:dep. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1875 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1876 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1877 |
]. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1878 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1879 |
coll do:[:dep | |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1880 |
self removeDependent:dep. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1881 |
]. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1882 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1883 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1884 |
" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1885 |
|p b| |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1886 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1887 |
b := [Transcript showCr:'the point changed']. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1888 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1889 |
p := Point new. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1890 |
p onChangeSend:#value to:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1891 |
p x:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1892 |
Transcript showCr:'now changing'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1893 |
p changed. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1894 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1895 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1896 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1897 |
Transcript showCr:'now changing'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1898 |
p changed. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1899 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1900 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1901 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1902 |
Transcript showCr:'no more interest'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1903 |
p retractInterestsFor:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1904 |
Transcript showCr:'now changing again'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1905 |
p changed. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1906 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1907 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1908 |
Delay waitForSeconds:1. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1909 |
Transcript showCr:'interest again'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1910 |
p onChangeSend:#value to:b. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1911 |
Transcript showCr:'now changing again'. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1912 |
p changed. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1913 |
Transcript cr. |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1914 |
" |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1915 |
|
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1916 |
"Modified: 8.3.1996 / 22:58:30 / cg" |
783 | 1917 |
! ! |
1918 |
||
1919 |
!Object methodsFor:'error handling'! |
|
1920 |
||
1921 |
appropriateDebugger:aSelector |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1922 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1923 |
|
783 | 1924 |
"return an appropriate debugger to use. |
1925 |
If there is already a debugger active on the stack, and it is |
|
1926 |
the DebugView, return MiniDebugger (as a last chance) otherwise abort." |
|
1927 |
||
1928 |
|context| |
|
1929 |
||
1930 |
context := thisContext. |
|
1931 |
context := context sender. |
|
1932 |
[context notNil] whileTrue:[ |
|
1933 |
((context receiver class == Debugger) |
|
1934 |
and:[context selector == aSelector]) ifTrue:[ |
|
1935 |
"we are already in some Debugger" |
|
1936 |
(Debugger == MiniDebugger) ifTrue:[ |
|
1937 |
"we are already in the MiniDebugger" |
|
1938 |
ErrorRecursion ifFalse:[ |
|
1939 |
Smalltalk fatalAbort:'recursive error ...' |
|
1940 |
] |
|
1941 |
]. |
|
1942 |
MiniDebugger isNil ifTrue:[ |
|
1943 |
Smalltalk fatalAbort:'no debugger' |
|
1944 |
]. |
|
1945 |
||
1946 |
"ok, an error occured while in the graphical debugger; |
|
1947 |
lets try MiniDebugger" |
|
1948 |
^ MiniDebugger |
|
1949 |
]. |
|
1950 |
context := context sender |
|
71 | 1951 |
]. |
783 | 1952 |
"not within Debugger - no problem" |
1953 |
^ Debugger |
|
1954 |
! |
|
1955 |
||
1956 |
doesNotUnderstand:aMessage |
|
1957 |
"this message is sent by the runtime system (VM) when |
|
1958 |
a message is not understood by some object (i.e. there |
|
1959 |
is no method for that selector). The original message has |
|
1960 |
been packed into aMessage (i.e. the receiver, selector and |
|
1961 |
any arguments) and the original receiver is then sent the |
|
1962 |
#doesNotUnderstand: message. |
|
1963 |
Here, we raise another signal which usually enters the debugger. |
|
1964 |
You can of course redefine #doesNotUnderstand: in your classes |
|
1965 |
to implement message delegation." |
|
1966 |
||
1967 |
|sel errorString cls sender| |
|
1968 |
||
1969 |
"/ handle the case of an error during early startup |
|
1970 |
"/ (output streams not yet initialized) |
|
1971 |
"/ |
|
1972 |
Stdout isNil ifTrue:[ |
|
1101 | 1973 |
Smalltalk fatalAbort:'error during init: ' , aMessage selector , ' not understood'. |
783 | 1974 |
]. |
1975 |
||
1976 |
(sel := aMessage selector) isNil ifTrue:[ |
|
1977 |
"/ |
|
1978 |
"/ happens when things go mad, or a method has been |
|
1979 |
"/ called by valueWithReceiver: with a wrong receiver |
|
1980 |
"/ to avoud later trouble (when concatenating strings), |
|
1981 |
"/ replace the selector by some (nonNil) string |
|
1982 |
"/ |
|
1983 |
sel := '(nil)' |
|
1984 |
]. |
|
1985 |
||
1986 |
"/ |
|
1987 |
"/ extract the class that should have implemented the message. |
|
1988 |
"/ (in case of a super-send, this is not the receivers class) |
|
1989 |
"/ |
|
1990 |
sender := thisContext sender. |
|
1991 |
cls := sender searchClass. |
|
1992 |
cls isNil ifTrue:[ |
|
1993 |
"it was NOT a super or directed send ..." |
|
1994 |
cls := self class |
|
1995 |
]. |
|
1996 |
||
1997 |
cls notNil ifTrue:[ |
|
1998 |
"/ |
|
1999 |
"/ displayString is better than 'cls name', |
|
2000 |
"/ since it appends (obsolete) for outdated classes. |
|
2001 |
"/ (this happens if you send messages to old instances |
|
2002 |
"/ after changing a classes definition) |
|
2003 |
"/ |
|
2004 |
errorString := cls displayString. |
|
2005 |
] ifFalse:[ |
|
2006 |
errorString := '(** nil-class **)' |
|
2007 |
]. |
|
2008 |
errorString := errorString , ' does not understand: ' , sel. |
|
2009 |
||
2010 |
"/ |
|
2011 |
"/ this only happens, when YOU play around with my classvars ... |
|
2012 |
"/ (or an error occurs during early startup, when signals are not yet set) |
|
2013 |
"/ |
|
2014 |
MessageNotUnderstoodSignal isNil ifTrue:[ |
|
2015 |
^ self enterDebuggerWith:nil |
|
2016 |
message:'oops - MessageNotUnderstoodSignal is gone'. |
|
2017 |
]. |
|
2018 |
||
2019 |
"/ |
|
2020 |
"/ thats where we end up normally - raise a signal which (if unhandled) opens a debugger |
|
2021 |
"/ |
|
2022 |
^ MessageNotUnderstoodSignal |
|
2023 |
raiseRequestWith:aMessage |
|
2024 |
errorString:errorString |
|
2025 |
in:sender |
|
2026 |
||
2027 |
"Modified: 9.12.1995 / 17:25:37 / cg" |
|
2028 |
! |
|
2029 |
||
2030 |
elementBoundsError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2031 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2032 |
|
783 | 2033 |
"report error that badElement is out of bounds |
2034 |
(i.e. cannot be put into that collection)" |
|
2035 |
||
2036 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
2037 |
! |
|
2038 |
||
2039 |
elementNotCharacter |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2040 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2041 |
|
783 | 2042 |
"report error that object to be stored is no Character. |
2043 |
(usually when storing into Strings)" |
|
2044 |
||
2045 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
2046 |
! |
|
2047 |
||
2048 |
elementNotInteger |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2049 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2050 |
|
783 | 2051 |
"report error that object to be stored is not Integer. |
2052 |
(in collections that store integers only)" |
|
2053 |
||
2054 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
2055 |
! |
|
2056 |
||
2057 |
enterDebuggerWith:anException message:aString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2058 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2059 |
|
783 | 2060 |
"enter the debugger with error-message aString" |
2061 |
||
2062 |
^ self enterDebuggerWith:anException |
|
2063 |
message:aString |
|
2064 |
on:anException suspendedContext |
|
2065 |
! |
|
2066 |
||
2067 |
enterDebuggerWith:anException message:aString on:aContext |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2068 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2069 |
|
783 | 2070 |
"enter the debugger with error-message aString. |
2071 |
The first visible context shown there is aContext |
|
2072 |
(this allows intermediate helpers to hide themselfes from what is |
|
2073 |
presented to the user)" |
|
2074 |
||
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2075 |
|debugger msg| |
71 | 2076 |
|
2077 |
" |
|
783 | 2078 |
if there is no debugger, exit smalltalk |
2079 |
" |
|
2080 |
Debugger isNil ifTrue:[ |
|
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2081 |
msg := 'error: ' , aString. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2082 |
|
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2083 |
Smalltalk isStandAloneApp ifTrue:[ |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2084 |
Dialog notNil ifTrue:[ |
1097 | 2085 |
(Dialog |
2086 |
confirm:msg title:(Smalltalk commandName) |
|
2087 |
yesLabel:'ignore' noLabel:'exit' |
|
2088 |
) ifTrue:[ |
|
1095 | 2089 |
^ AbortSignal raise |
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2090 |
] |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2091 |
]. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2092 |
msg errorPrintNL. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2093 |
OperatingSystem exit:1 |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2094 |
]. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2095 |
msg errorPrintNL. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2096 |
Smalltalk fatalAbort:'no Debugger defined' |
783 | 2097 |
]. |
983 | 2098 |
|
783 | 2099 |
" |
2100 |
find an appropriate debugger to use |
|
71 | 2101 |
" |
783 | 2102 |
debugger := self appropriateDebugger:#'enter:withMessage:'. |
2103 |
^ debugger enter:aContext withMessage:aString. |
|
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2104 |
|
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2105 |
"Modified: 8.3.1996 / 20:40:48 / cg" |
783 | 2106 |
! |
2107 |
||
2108 |
error |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2109 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2110 |
|
783 | 2111 |
"report error that an error occured" |
2112 |
||
2113 |
^ ErrorSignal raiseIn:thisContext sender |
|
2114 |
! |
|
2115 |
||
2116 |
error:aString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2117 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2118 |
|
783 | 2119 |
"enter debugger with error-message aString" |
2120 |
||
2121 |
^ ErrorSignal raiseRequestWith:#error: |
|
2122 |
errorString:aString |
|
2123 |
in:thisContext sender |
|
2124 |
! |
|
2125 |
||
2126 |
errorKeyNotFound:aKey |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2127 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2128 |
|
783 | 2129 |
"report error that a key was not found in a collection" |
2130 |
||
2131 |
^ KeyNotFoundSignal raiseRequestWith:aKey in:thisContext sender |
|
2132 |
! |
|
2133 |
||
2134 |
errorNotFound |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2135 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2136 |
|
783 | 2137 |
"report error that no element was found in a collection" |
2138 |
||
2139 |
^ NotFoundSignal raiseIn:thisContext sender |
|
2140 |
! |
|
2141 |
||
2142 |
halt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2143 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2144 |
|
783 | 2145 |
"enter debugger with halt-message" |
2146 |
||
2147 |
^ HaltSignal raiseIn:thisContext sender. |
|
2148 |
! |
|
2149 |
||
2150 |
halt:aString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2151 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2152 |
|
783 | 2153 |
"enter debugger with halt-message" |
2154 |
||
2155 |
^ HaltSignal raiseRequestWith:#halt: |
|
2156 |
errorString:aString |
|
2157 |
in:thisContext sender |
|
2158 |
! |
|
2159 |
||
2160 |
implementedBySubclass |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2161 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2162 |
|
783 | 2163 |
"this is sent by ST/V code - its the same as #subclassResponsibility" |
2164 |
||
2165 |
^ self subclassResponsibility |
|
2166 |
! |
|
2167 |
||
2168 |
indexNotInteger |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2169 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2170 |
|
783 | 2171 |
"report error that index is not an Integer. |
2172 |
(when accessing collections indexed by an integer key)" |
|
2173 |
||
2174 |
^ NonIntegerIndexSignal raiseIn:thisContext sender |
|
2175 |
! |
|
2176 |
||
2177 |
integerCheckError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2178 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2179 |
|
783 | 2180 |
"generated when a variable declared with an integer type gets a bad |
2181 |
value assigned" |
|
2182 |
||
2183 |
^ self error:'bad assign of ' , self printString , |
|
2184 |
' (' , self class name , ') to integer-typed variable' |
|
71 | 2185 |
! |
2186 |
||
783 | 2187 |
invalidMessage |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2188 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2189 |
|
783 | 2190 |
"this is sent by ST/V code - its the same as #shouldNotImplement" |
2191 |
||
2192 |
^ self shouldNotImplement |
|
2193 |
! |
|
2194 |
||
2195 |
mustBeRectangle |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2196 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2197 |
|
783 | 2198 |
"report an argument-not-rectangle-error" |
2199 |
||
2200 |
^ self error:'argument must be a Rectangle' |
|
2201 |
! |
|
2202 |
||
2203 |
mustBeString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2204 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2205 |
|
783 | 2206 |
"report an argument-not-string-error" |
2207 |
||
2208 |
^ self error:'argument must be a String' |
|
2209 |
! |
|
2210 |
||
2211 |
notIndexed |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2212 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2213 |
|
783 | 2214 |
"report error that receiver has no indexed instance variables" |
2215 |
||
2216 |
^ self error:'receiver has no indexed variables' |
|
2217 |
! |
|
2218 |
||
2219 |
primitiveFailed |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2220 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2221 |
|
783 | 2222 |
"report error that primitive code failed" |
2223 |
||
2224 |
^ PrimitiveFailureSignal raiseIn:(thisContext sender) |
|
2225 |
! |
|
2226 |
||
2227 |
shouldNotImplement |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2228 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2229 |
|
783 | 2230 |
"report error that this message should not be implemented" |
2231 |
||
2232 |
^ self error:'method not appropriate for this class' |
|
2233 |
! |
|
2234 |
||
2235 |
subclassResponsibility |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2236 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2237 |
|
783 | 2238 |
"report error that this message should have been reimplemented in a |
2239 |
subclass" |
|
2240 |
||
2241 |
^ self error:'method must be reimplemented in subclass' |
|
2242 |
! |
|
2243 |
||
2244 |
subscriptBoundsError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2245 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2246 |
|
783 | 2247 |
"report error that some index is out of bounds. |
2248 |
(when accessing indexable collections)" |
|
2249 |
||
2250 |
^ SubscriptOutOfBoundsSignal raiseIn:thisContext sender |
|
2251 |
! |
|
2252 |
||
2253 |
subscriptBoundsError:anIndex |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2254 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2255 |
|
783 | 2256 |
"report error that anIndex is out of bounds. |
2257 |
(when accessing indexable collections)" |
|
2258 |
||
1021
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2259 |
^ SubscriptOutOfBoundsSignal |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2260 |
raiseRequestWith:anIndex |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2261 |
errorString:('subscript (' , anIndex printString , ') out of bounds') |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2262 |
in:thisContext sender |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2263 |
|
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2264 |
"Modified: 26.2.1996 / 14:38:26 / cg" |
783 | 2265 |
! |
2266 |
||
2267 |
typeCheckError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2268 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2269 |
|
783 | 2270 |
"generated when a variable declared with a type hint gets a bad |
2271 |
value assigned" |
|
2272 |
||
2273 |
^ self error:'bad assign of ' , self printString , |
|
2274 |
' (' , self class name , ') to typed variable' |
|
2275 |
! ! |
|
2276 |
||
2277 |
!Object methodsFor:'evaluation'! |
|
2278 |
||
2279 |
value |
|
2280 |
"this allows every object to be used where blocks are typically used. |
|
2281 |
Time will show, if this is a good idea or leads to sloppy programming |
|
2282 |
style ... (the idea was borrowed from the Self language). |
|
2283 |
WARNING: dont 'optimize' away ifXXX: blocks - the compilers will |
|
2284 |
only generate inline code for the if, if the argument(s) are blocks. |
|
2285 |
It will work, but run slower instead." |
|
2286 |
||
2287 |
^ self |
|
71 | 2288 |
|
2289 |
" |
|
783 | 2290 |
#(1 2 3 4) indexOf:5 ifAbsent:0 |
2291 |
" |
|
2292 |
||
2293 |
"DO NOT DO THIS (its slower) |
|
2294 |
(1 > 4) ifTrue:'oops' ifFalse:'ok' |
|
2295 |
||
2296 |
USE (the compiler optimizes blocks in if/while): |
|
2297 |
(1 > 4) ifTrue:['oops'] ifFalse:['ok'] |
|
2298 |
" |
|
2299 |
! ! |
|
2300 |
||
2301 |
!Object methodsFor:'initialization'! |
|
2302 |
||
2303 |
initialize |
|
2304 |
"just to ignore initialize to objects which do not need it" |
|
2305 |
||
2306 |
^ self |
|
2307 |
! ! |
|
2308 |
||
2309 |
!Object methodsFor:'interrupt handling'! |
|
2310 |
||
2311 |
childSignalInterrupt |
|
2312 |
"death of a child process (unix process) - do nothing" |
|
2313 |
||
2314 |
^ self |
|
2315 |
! |
|
2316 |
||
2317 |
customInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2318 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2319 |
|
783 | 2320 |
"a custom interrupt" |
2321 |
||
2322 |
^ self error:'custom interrupt' |
|
2323 |
! |
|
2324 |
||
2325 |
errorInterrupt:errorID with:aParameter |
|
2326 |
"subsystem error. The arguments errorID and aParameter are the values passed |
|
2327 |
to the 'errorInterruptWithIDAndParameter(id, param)' function, |
|
2328 |
which can be called from C subsystems to raise an (asynchronous) |
|
2329 |
error exception. |
|
2330 |
||
2331 |
Currently, this is used to map XErrors to smalltalk errors, but can be |
|
2332 |
used from other C subsystems too, to upcast errors. |
|
2333 |
Especially, for subsystems which call errorHandler functions asynchronously. |
|
2334 |
IDs (currently) used: |
|
2335 |
#DisplayError ..... x-error interrupt |
|
2336 |
#XtError ..... xt-error interrupt (Xt interface is not yet published) |
|
71 | 2337 |
" |
783 | 2338 |
|
2339 |
|handler| |
|
2340 |
||
2341 |
handler := ObjectMemory registeredErrorInterruptHandlers at:errorID ifAbsent:nil. |
|
2342 |
handler notNil ifTrue:[ |
|
2343 |
"/ |
|
2344 |
"/ handler found; let it do whatever it wants ... |
|
2345 |
"/ |
|
2346 |
handler errorInterrupt:errorID with:aParameter. |
|
2347 |
^ self |
|
2348 |
]. |
|
2349 |
||
2350 |
"/ |
|
2351 |
"/ no handler - raise errorSignal passing the errorId as parameter |
|
2352 |
"/ |
|
2353 |
^ ErrorSignal |
|
2354 |
raiseRequestWith:errorID |
|
2355 |
errorString:('Subsystem error. ErrorID = ' , errorID printString) |
|
2356 |
! |
|
2357 |
||
2358 |
exceptionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2359 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2360 |
|
783 | 2361 |
"exception interrupt - enter debugger" |
2362 |
||
2363 |
self error:'exception Interrupt' |
|
2364 |
! |
|
2365 |
||
2366 |
fpExceptionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2367 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2368 |
|
783 | 2369 |
"a floating point exception occured - this one |
2370 |
has to be handled differently since it comes asynchronous |
|
2371 |
on some machines (for example, on machines with a separate FPU |
|
2372 |
or superscalar architectures. Also, errors from within primitive code |
|
2373 |
(or library functions such as GL) are sent via the Unix-signal |
|
2374 |
mechanism this way." |
|
2375 |
||
2376 |
^ Float domainErrorSignal raise |
|
2377 |
! |
|
2378 |
||
2379 |
internalError:msg |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2380 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2381 |
|
783 | 2382 |
"this is triggered, when system hits some bad error, |
2383 |
such as corrupted class, corrupted method/selector array |
|
2384 |
etc. The argument string gives some more information on what happened. |
|
2385 |
(for example, if you set an objects class to a smallInteger, nil etc). |
|
2386 |
Its not guaranteed, that the system is in a working condition once |
|
2387 |
this error occurred ...." |
|
2388 |
||
2389 |
^ self error:msg |
|
2390 |
! |
|
2391 |
||
2392 |
ioInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2393 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2394 |
|
783 | 2395 |
"I/O (SIGIO/SIGPOLL) interrupt (supposed to be sent to Processor). |
2396 |
If we arrive here, there is either no handler (ObjMem>>ioInterruptHandler) |
|
2397 |
or it does not understand the ioInterrupt message. |
|
2398 |
In any case, this is a sign of some big trouble. Enter debugger." |
|
2399 |
||
2400 |
self error:'I/O Interrupt - but no handler' |
|
2401 |
! |
|
2402 |
||
2403 |
memoryInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2404 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2405 |
|
783 | 2406 |
"out-of-memory interrupt and no handler - enter debugger" |
2407 |
||
2408 |
^ self error:'almost out of memory' |
|
2409 |
! |
|
2410 |
||
2411 |
recursionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2412 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2413 |
|
783 | 2414 |
"recursion limit (actually: stack overflow) interrupt. |
2415 |
This interrupt is triggered, when a process stack grows above |
|
2416 |
its stackLimit - usually, this leads into the debugger, but |
|
2417 |
could be cought and the stackLimit increased in the handler. |
|
2418 |
At the time we arrive here, the system has still some stack |
|
2419 |
as a reserve so we can continue to do some useful work or cleanup or |
|
2420 |
debugging for a while. |
|
2421 |
If the signal is ignored, and the stack continues to grow, there |
|
2422 |
will be a few more chances (and more interrupts) before the VM |
|
2423 |
hard-terminates the process." |
|
2424 |
||
2425 |
thisContext isRecursive ifFalse:[ |
|
2426 |
^ RecursionInterruptSignal raise |
|
2427 |
] |
|
2428 |
! |
|
2429 |
||
2430 |
schedulerInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2431 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2432 |
|
783 | 2433 |
"scheduler interrupt (supposed to be sent to Processor). |
2434 |
If we arrive here, either the Processor does not understand it, |
|
2435 |
or it has been set to nil. In any case, this is a sign of some |
|
2436 |
big trouble. Enter debugger." |
|
2437 |
||
2438 |
self error:'schedulerInterrupt - but no Processor' |
|
2439 |
! |
|
2440 |
||
2441 |
signalInterrupt:signalNumber |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2442 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2443 |
|
783 | 2444 |
"unix signal occured - some signals are handled as Smalltalk Exceptions |
2445 |
(SIGPIPE), others (SIGBUS) are rather fatal ... |
|
2446 |
In any case, if a smalltalk-signal has been connected to the OS signal, |
|
2447 |
that one is raised. |
|
2448 |
TODO: add another argument, giving more detailed signal info (PC, VADDR, |
|
2449 |
exact cause etc.). This helps if segvs occur in primitive code. |
|
2450 |
Currently (temporary kludge), these are passed as global variables." |
|
2451 |
||
2452 |
|box name here sig ignorable titles actions badContext msg pc addr| |
|
2453 |
||
2454 |
" |
|
2455 |
special case - since SIGPIPE has an ST-signal associated |
|
2456 |
" |
|
2457 |
(signalNumber == 13) ifTrue:[ |
|
2458 |
"SIGPIPE - write on a pipe with no one to read" |
|
2459 |
||
2460 |
^ PipeStream brokenPipeSignal raise. |
|
2461 |
]. |
|
2462 |
||
2463 |
"if there has been an ST-signal installed, use it ..." |
|
2464 |
||
2465 |
sig := OperatingSystem operatingSystemSignal:signalNumber. |
|
2466 |
sig notNil ifTrue:[ |
|
2467 |
^ sig raise |
|
2468 |
]. |
|
2469 |
||
2470 |
" |
|
2471 |
... otherwise , bring up a box asking for what to do ... |
|
2472 |
" |
|
2473 |
name := OperatingSystem nameForSignal:signalNumber. |
|
2474 |
here := thisContext. |
|
2475 |
||
2476 |
" |
|
2477 |
the context, in which the signal occurred: |
|
2478 |
" |
|
2479 |
badContext := here sender. |
|
2480 |
||
2481 |
" |
|
2482 |
ungrab - in case it happened in a box/popupview |
|
2483 |
otherwise display stays locked |
|
2484 |
" |
|
2485 |
Display notNil ifTrue:[ |
|
2486 |
Display ungrabPointer. |
|
2487 |
]. |
|
2488 |
||
2489 |
" |
|
2490 |
SIGBUS, SIGSEGV and SIGILL do not make sense to ignore (i.e. continue) |
|
2491 |
since the system will retry the faulty instruction, which leads to |
|
2492 |
another signal - to avoid frustration, better not offer this option. |
|
2493 |
" |
|
2494 |
ignorable := (signalNumber ~~ OperatingSystem sigBUS) |
|
2495 |
and:[signalNumber ~~ OperatingSystem sigILL |
|
2496 |
and:[signalNumber ~~ OperatingSystem sigSEGV]]. |
|
2497 |
||
2498 |
ignorable ifFalse:[ |
|
2499 |
here isRecursive ifTrue:[ |
|
2500 |
'fatal: signal ' errorPrint. signalNumber errorPrintNL. |
|
2501 |
MiniDebugger enterWithMessage:'recursive signal'. |
|
2502 |
^ self |
|
2503 |
]. |
|
2504 |
" |
|
2505 |
a hard signal - go into debugger immediately |
|
2506 |
" |
|
2507 |
msg := 'Signal ', name. |
|
2508 |
InterruptPcLow notNil ifTrue:[ |
|
2509 |
pc := InterruptPcLow + (InterruptPcHi bitShift:16). |
|
2510 |
pc ~~ 0 ifTrue:[ |
|
2511 |
msg := msg , ' PC=' , (pc printStringRadix:16) |
|
2512 |
]. |
|
2513 |
]. |
|
2514 |
InterruptAddrLow notNil ifTrue:[ |
|
2515 |
addr := InterruptAddrLow + (InterruptAddrHi bitShift:16). |
|
2516 |
addr ~~ 0 ifTrue:[ |
|
2517 |
msg := msg , ' ADDR=' , (addr printStringRadix:16) |
|
2518 |
]. |
|
2519 |
]. |
|
2520 |
Debugger enter:here withMessage:msg. |
|
2521 |
badContext return. |
|
2522 |
^ nil. |
|
2523 |
]. |
|
2524 |
||
2525 |
OptionBox isNil ifTrue:[ |
|
2526 |
" |
|
2527 |
a system without GUI ... |
|
2528 |
go into minidebugger (if there is one) |
|
2529 |
" |
|
2530 |
MiniDebugger isNil ifTrue:[ |
|
2531 |
" |
|
2532 |
a system without debugging facilities |
|
2533 |
(i.e. a standalone system) |
|
2534 |
output a message and exit. |
|
2535 |
" |
|
2536 |
('exit due to Signal ' , name) errorPrintNL. |
|
2537 |
Smalltalk exit. |
|
2538 |
]. |
|
2539 |
MiniDebugger enterWithMessage:'Signal cought (' , name, ')'. |
|
2540 |
^ self |
|
2541 |
]. |
|
2542 |
||
2543 |
box := OptionBox |
|
2544 |
title:'Signal cought (' , name, ')' |
|
2545 |
numberOfOptions:(ignorable ifTrue:[5] ifFalse:[4]). |
|
2546 |
||
2547 |
titles := #('return' 'debug' 'dump' 'exit'). |
|
2548 |
actions := Array |
|
2549 |
with:[badContext return] |
|
2550 |
with:[Debugger enter:here withMessage:('Signal ', name). ^nil] |
|
2551 |
with:[Smalltalk fatalAbort] |
|
2552 |
with:[Smalltalk exit]. |
|
2553 |
||
2554 |
ignorable ifTrue:[ |
|
2555 |
titles := #('ignore') , titles. |
|
2556 |
actions := (Array with:[^ nil]) , actions. |
|
2557 |
]. |
|
2558 |
box buttonTitles:titles. |
|
2559 |
box actions:actions. |
|
2560 |
box showAtPointer |
|
2561 |
! |
|
2562 |
||
2563 |
spyInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2564 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2565 |
|
783 | 2566 |
"spy interrupt and no handler - enter debugger" |
2567 |
||
2568 |
self error:'spy Interrupt - but no handler' |
|
2569 |
! |
|
2570 |
||
2571 |
timerInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2572 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2573 |
|
783 | 2574 |
"timer interrupt and no handler - enter debugger" |
2575 |
||
2576 |
self error:'timer Interrupt - but no handler' |
|
2577 |
! |
|
2578 |
||
2579 |
userInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2580 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2581 |
|
783 | 2582 |
"user (^c) interrupt - enter debugger" |
2583 |
||
2584 |
UserInterruptSignal raise |
|
71 | 2585 |
! ! |
2586 |
||
1 | 2587 |
!Object methodsFor:'message sending'! |
2588 |
||
2589 |
perform:aSelector |
|
2590 |
"send the message aSelector to the receiver" |
|
2591 |
||
2592 |
%{ /* NOCONTEXT */ |
|
2593 |
||
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2594 |
OBJ l; |
93 | 2595 |
#ifdef PRE_2_11 |
1 | 2596 |
static struct inlineCache ilc = _ILC0; |
93 | 2597 |
struct inlineCache lilc = _DUMMYILC0; |
2598 |
#else |
|
2599 |
static struct inlineCache ilc = _DUMMYILC0; |
|
2600 |
struct inlineCache lilc; |
|
2601 |
#endif |
|
1 | 2602 |
static OBJ lastSelector = nil; |
2603 |
||
71 | 2604 |
#if defined(THIS_CONTEXT) |
1 | 2605 |
/* |
93 | 2606 |
* must set lineno in sender by hand here ... (because of NOCONTEXT) |
1 | 2607 |
*/ |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2608 |
if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2609 |
_ContextInstPtr(__thisContext)->c_lineno = l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2610 |
} |
1 | 2611 |
#endif |
2612 |
||
93 | 2613 |
#ifdef PRE_2_11 |
1 | 2614 |
if (aSelector != lastSelector) { |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2615 |
ilc.ilc_func = __SEND0ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2616 |
lastSelector = aSelector; |
1 | 2617 |
} |
93 | 2618 |
#else |
2619 |
lilc = ilc; |
|
2620 |
#endif |
|
2621 |
||
329 | 2622 |
#if !defined(TRADITIONAL_STACK_FRAME) |
2623 |
lilc.ilc_lineNo = __pilc->ilc_lineNo; |
|
2624 |
#endif |
|
2625 |
||
85 | 2626 |
#ifdef PRE_2_11 |
1 | 2627 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc) ); |
85 | 2628 |
#else |
2629 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &lilc) ); |
|
2630 |
#endif |
|
1 | 2631 |
%} |
2632 |
! |
|
2633 |
||
783 | 2634 |
perform:aSelector inClass:aClass withArguments:argArray |
2635 |
"send the message aSelector with all args taken from argArray |
|
2636 |
to the receiver as a super-send message. |
|
2637 |
This is actually more flexible than the normal super-send, since it allows |
|
2638 |
to execute a method in ANY superclass of the receiver (not just the |
|
2639 |
immediate superclass). |
|
2640 |
Thus, it is (theoretically) possible to do |
|
2641 |
'5 perform:#< inClass:Magnitude withArguments:#(6)' |
|
2642 |
and evaluate Magnitudes compare method even if there was one in Number. |
|
2643 |
This method is used by the interpreter to evaluate super sends |
|
2644 |
and could be used for very special behavior (language extension ?). |
|
2645 |
||
2646 |
WARNING: this is an ST/X feature - probably not found in other smalltalks." |
|
2647 |
||
2648 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
|
2649 |
||
2650 |
" |
|
2651 |
check, if aClass is really a superclass of the receiver |
|
2652 |
" |
|
2653 |
(self class isSubclassOf:aClass) ifFalse:[ |
|
2654 |
self error:'class argument is not a superclass of the receiver'. |
|
2655 |
^ nil |
|
2656 |
]. |
|
2657 |
numberOfArgs := argArray size. |
|
2658 |
%{ |
|
2659 |
REGISTER OBJ *argP; |
|
2660 |
int nargs, i; |
|
2661 |
static struct inlineCache ilc0 = _DUMMYILC0; |
|
2662 |
static struct inlineCache ilc1 = _DUMMYILC1; |
|
2663 |
static struct inlineCache ilc2 = _DUMMYILC2; |
|
2664 |
static struct inlineCache ilc3 = _DUMMYILC3; |
|
2665 |
static struct inlineCache ilc4 = _DUMMYILC4; |
|
2666 |
static struct inlineCache ilc5 = _DUMMYILC5; |
|
2667 |
static struct inlineCache ilc6 = _DUMMYILC6; |
|
2668 |
static struct inlineCache ilc7 = _DUMMYILC7; |
|
2669 |
static struct inlineCache ilc8 = _DUMMYILC8; |
|
2670 |
static struct inlineCache ilc9 = _DUMMYILC9; |
|
2671 |
static struct inlineCache ilc10 = _DUMMYILC10; |
|
2672 |
static struct inlineCache ilc11 = _DUMMYILC11; |
|
2673 |
static struct inlineCache ilc12 = _DUMMYILC12; |
|
2674 |
static struct inlineCache ilc13 = _DUMMYILC13; |
|
2675 |
static struct inlineCache ilc14 = _DUMMYILC14; |
|
2676 |
static struct inlineCache ilc15 = _DUMMYILC15; |
|
2677 |
||
2678 |
if (__isSmallInteger(numberOfArgs)) { |
|
2679 |
nargs = __intVal(numberOfArgs); |
|
2680 |
if (nargs == 0) { |
|
2681 |
RETURN (_SEND0(self, aSelector, CON_COMMA aClass, &ilc0)); |
|
2682 |
} |
|
2683 |
||
2684 |
argP = (OBJ *)(&a1); |
|
2685 |
if (__Class(argArray) == Array) { |
|
2686 |
for (i=0; i < nargs; i++) { |
|
2687 |
*argP++ = _ArrayInstPtr(argArray)->a_element[i]; |
|
2688 |
} |
|
2689 |
} else { |
|
2690 |
for (i=1; i <= nargs; i++) { |
|
2691 |
*argP++ = __AT_(argArray, CON_COMMA __MKSMALLINT(i)); |
|
2692 |
} |
|
2693 |
} |
|
2694 |
switch (nargs) { |
|
2695 |
case 1: |
|
2696 |
RETURN ( _SEND1(self, aSelector, CON_COMMA aClass, &ilc1, a1)); |
|
2697 |
||
2698 |
case 2: |
|
2699 |
RETURN ( _SEND2(self, aSelector, CON_COMMA aClass, &ilc2, a1, a2)); |
|
2700 |
||
2701 |
case 3: |
|
2702 |
RETURN ( _SEND3(self, aSelector, CON_COMMA aClass, &ilc3, a1, a2, a3)); |
|
2703 |
||
2704 |
case 4: |
|
2705 |
RETURN ( _SEND4(self, aSelector, CON_COMMA aClass, &ilc4, a1, a2, a3, a4)); |
|
2706 |
||
2707 |
case 5: |
|
2708 |
RETURN ( _SEND5(self, aSelector, CON_COMMA aClass, &ilc5, |
|
2709 |
a1, a2, a3, a4, a5)); |
|
2710 |
||
2711 |
case 6: |
|
2712 |
RETURN ( _SEND6(self, aSelector, CON_COMMA aClass, &ilc6, |
|
2713 |
a1, a2, a3, a4, a5, a6)); |
|
2714 |
||
2715 |
case 7: |
|
2716 |
RETURN ( _SEND7(self, aSelector, CON_COMMA aClass, &ilc7, |
|
2717 |
a1, a2, a3, a4, a5, a6, a7)); |
|
2718 |
||
2719 |
case 8: |
|
2720 |
RETURN ( _SEND8(self, aSelector, CON_COMMA aClass, &ilc8, |
|
2721 |
a1, a2, a3, a4, a5, a6, a7, a8)); |
|
2722 |
||
2723 |
case 9: |
|
2724 |
RETURN ( _SEND9(self, aSelector, CON_COMMA aClass, &ilc9, |
|
2725 |
a1, a2, a3, a4, a5, a6, a7, a8, a9)); |
|
2726 |
||
2727 |
case 10: |
|
2728 |
RETURN ( _SEND10(self, aSelector, CON_COMMA aClass, &ilc10, |
|
2729 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)); |
|
2730 |
||
2731 |
case 11: |
|
2732 |
RETURN ( _SEND11(self, aSelector, CON_COMMA aClass, &ilc11, |
|
2733 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)); |
|
2734 |
||
2735 |
case 12: |
|
2736 |
RETURN ( _SEND12(self, aSelector, CON_COMMA aClass, &ilc12, |
|
2737 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)); |
|
2738 |
||
2739 |
case 13: |
|
2740 |
RETURN ( _SEND13(self, aSelector, CON_COMMA aClass, &ilc13, |
|
2741 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
|
2742 |
a13)); |
|
2743 |
||
2744 |
case 14: |
|
2745 |
RETURN ( _SEND14(self, aSelector, CON_COMMA aClass, &ilc14, |
|
2746 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
|
2747 |
a13, a14)); |
|
2748 |
||
2749 |
case 15: |
|
2750 |
RETURN ( _SEND15(self, aSelector, CON_COMMA aClass, &ilc15, |
|
2751 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
|
2752 |
a13, a14, a15)); |
|
2753 |
} |
|
2754 |
} |
|
2755 |
%} |
|
2756 |
. |
|
2757 |
^ self primitiveFailed |
|
2758 |
! |
|
2759 |
||
1 | 2760 |
perform:aSelector with:anObject |
2761 |
"send the one-arg-message aSelector to the receiver" |
|
2762 |
||
2763 |
%{ /* NOCONTEXT */ |
|
2764 |
||
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2765 |
OBJ l; |
93 | 2766 |
#ifdef PRE_2_11 |
1 | 2767 |
static struct inlineCache ilc = _ILC1; |
93 | 2768 |
struct inlineCache lilc = _DUMMYILC1; |
1 | 2769 |
static OBJ lastSelector = nil; |
2770 |
||
159 | 2771 |
# if defined(THIS_CONTEXT) |
1 | 2772 |
/* |
93 | 2773 |
* must set lineno in sender by hand here ... (because of NOCONTEXT) |
1 | 2774 |
*/ |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2775 |
if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2776 |
_ContextInstPtr(__thisContext)->c_lineno = l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2777 |
} |
159 | 2778 |
# endif |
2779 |
||
1 | 2780 |
if (aSelector != lastSelector) { |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2781 |
ilc.ilc_func = __SEND1ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2782 |
lastSelector = aSelector; |
1 | 2783 |
} |
2784 |
ilc.ilc_lineNo = __pilc->ilc_lineNo; |
|
2785 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, anObject) ); |
|
85 | 2786 |
#else |
159 | 2787 |
static struct inlineCache ilc = _DUMMYILC1; |
2788 |
struct inlineCache lilc; |
|
2789 |
||
2790 |
# if defined(THIS_CONTEXT) |
|
2791 |
/* |
|
2792 |
* must set lineno in sender by hand here ... (because of NOCONTEXT) |
|
2793 |
*/ |
|
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2794 |
if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2795 |
_ContextInstPtr(__thisContext)->c_lineno = l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2796 |
} |
159 | 2797 |
# endif |
2798 |
||
2799 |
lilc = ilc; |
|
2800 |
lilc.ilc_lineNo = __pilc->ilc_lineNo; |
|
85 | 2801 |
RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &lilc, anObject) ); |
2802 |
#endif |
|
1 | 2803 |
%} |
2804 |
! |
|
2805 |
||
2806 |
perform:aSelector with:firstObject with:secondObject |
|
2807 |
"send the two-arg-message aSelector to the receiver" |
|
2808 |
||
2809 |
%{ /* NOCONTEXT */ |
|
2810 |
||
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2811 |
OBJ l; |
93 | 2812 |
#ifdef PRE_2_11 |
1 | 2813 |
static struct inlineCache ilc = _ILC2; |
93 | 2814 |
struct inlineCache lilc = _DUMMYILC2; |
2815 |
#else |
|
2816 |
static struct inlineCache ilc = _DUMMYILC2; |
|
2817 |
struct inlineCache lilc; |
|
2818 |
#endif |
|
1 | 2819 |
static OBJ lastSelector = nil; |
2820 |
||
71 | 2821 |
#if defined(THIS_CONTEXT) |
1 | 2822 |
/* |
93 | 2823 |
* must set lineno in sender by hand here ... (because of NOCONTEXT) |
1 | 2824 |
*/ |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2825 |
if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2826 |
_ContextInstPtr(__thisContext)->c_lineno = l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2827 |
} |
1 | 2828 |
#endif |
93 | 2829 |
|
2830 |
#ifdef PRE_2_11 |
|
1 | 2831 |
if (aSelector != lastSelector) { |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2832 |
ilc.ilc_func = __SEND2ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2833 |
lastSelector = aSelector; |
1 | 2834 |
} |
93 | 2835 |
#else |
2836 |
lilc = ilc; |
|
2837 |
#endif |
|
2838 |
||
329 | 2839 |
#if !defined(TRADITIONAL_STACK_FRAME) |
2840 |
lilc.ilc_lineNo = __pilc->ilc_lineNo; |
|
2841 |
#endif |
|
2842 |
||
93 | 2843 |
#if defined(xxTHIS_CONTEXT) |
85 | 2844 |
# ifdef PRE_2_11 |
1 | 2845 |
ilc.ilc_lineNo = __pilc->ilc_lineNo; |
85 | 2846 |
# else |
2847 |
lilc.ilc_lineNo = __pilc->ilc_lineNo; |
|
2848 |
# endif |
|
1 | 2849 |
#endif |
2850 |
||
85 | 2851 |
# ifdef PRE_2_11 |
2852 |
RETURN ((*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, firstObject, secondObject)); |
|
2853 |
# else |
|
2854 |
RETURN ((*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &lilc, firstObject, secondObject)); |
|
2855 |
# endif |
|
1 | 2856 |
%} |
2857 |
! |
|
2858 |
||
2859 |
perform:aSelector with:firstObject with:secondObject with:thirdObject |
|
2860 |
"send the three-arg-message aSelector to the receiver" |
|
2861 |
||
2862 |
%{ /* NOCONTEXT */ |
|
2863 |
||
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2864 |
OBJ l; |
93 | 2865 |
#ifdef PRE_2_11 |
1 | 2866 |
static struct inlineCache ilc = _ILC3; |
93 | 2867 |
struct inlineCache lilc = _DUMMYILC3; |
2868 |
#else |
|
2869 |
static struct inlineCache ilc = _DUMMYILC3; |
|
2870 |
struct inlineCache lilc; |
|
2871 |
#endif |
|
1 | 2872 |
static OBJ lastSelector = nil; |
2873 |
||
71 | 2874 |
#if defined(THIS_CONTEXT) |
1 | 2875 |
/* |
93 | 2876 |
* must set lineno in sender by hand here ... (because of NOCONTEXT) |
1 | 2877 |
*/ |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2878 |
if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2879 |
_ContextInstPtr(__thisContext)->c_lineno = l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2880 |
} |
1 | 2881 |
#endif |
93 | 2882 |
|
2883 |
#ifdef PRE_2_11 |
|
1 | 2884 |
if (aSelector != lastSelector) { |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2885 |
ilc.ilc_func = __SEND3ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2886 |
lastSelector = aSelector; |
1 | 2887 |
} |
93 | 2888 |
#else |
2889 |
lilc = ilc; |
|
329 | 2890 |
# if !defined(TRADITIONAL_STACK_FRAME) |
2891 |
lilc.ilc_lineNo = __pilc->ilc_lineNo; |
|
2892 |
# endif |
|
1 | 2893 |
#endif |
2894 |
||
93 | 2895 |
#if defined(xxTHIS_CONTEXT) |
2896 |
# ifdef PRE_2_11 |
|
2897 |
ilc.ilc_lineNo = __pilc->ilc_lineNo; |
|
2898 |
# else |
|
2899 |
lilc.ilc_lineNo = __pilc->ilc_lineNo; |
|
2900 |
# endif |
|
2901 |
#endif |
|
2902 |
||
2903 |
# ifdef PRE_2_11 |
|
2904 |
RETURN ((*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, firstObject, secondObject, thirdObject)); |
|
2905 |
# else |
|
2906 |
RETURN ((*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &lilc, firstObject, secondObject, thirdObject)); |
|
2907 |
# endif |
|
1 | 2908 |
%} |
2909 |
! |
|
2910 |
||
2911 |
perform:aSelector withArguments:argArray |
|
2912 |
"send the message aSelector with all args taken from argArray |
|
44 | 2913 |
to the receiver." |
1 | 2914 |
|
77 | 2915 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
1 | 2916 |
|
2917 |
numberOfArgs := argArray size. |
|
2918 |
%{ |
|
2919 |
REGISTER OBJ *argP; |
|
2920 |
int nargs, i; |
|
2921 |
static OBJ last0 = nil; static struct inlineCache ilc0 = _ILC0; |
|
2922 |
static OBJ last1 = nil; static struct inlineCache ilc1 = _ILC1; |
|
2923 |
static OBJ last2 = nil; static struct inlineCache ilc2 = _ILC2; |
|
2924 |
static OBJ last3 = nil; static struct inlineCache ilc3 = _ILC3; |
|
2925 |
static OBJ last4 = nil; static struct inlineCache ilc4 = _ILC4; |
|
2926 |
static OBJ last5 = nil; static struct inlineCache ilc5 = _ILC5; |
|
2927 |
static OBJ last6 = nil; static struct inlineCache ilc6 = _ILC6; |
|
2928 |
static OBJ last7 = nil; static struct inlineCache ilc7 = _ILC7; |
|
2929 |
static OBJ last8 = nil; static struct inlineCache ilc8 = _ILC8; |
|
2930 |
static OBJ last9 = nil; static struct inlineCache ilc9 = _ILC9; |
|
2931 |
static OBJ last10 = nil; static struct inlineCache ilc10 = _ILC10; |
|
2932 |
static OBJ last11 = nil; static struct inlineCache ilc11 = _ILC11; |
|
2933 |
static OBJ last12 = nil; static struct inlineCache ilc12 = _ILC12; |
|
71 | 2934 |
static OBJ last13 = nil; static struct inlineCache ilc13 = _ILC13; |
2935 |
static OBJ last14 = nil; static struct inlineCache ilc14 = _ILC14; |
|
2936 |
static OBJ last15 = nil; static struct inlineCache ilc15 = _ILC15; |
|
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2937 |
OBJ l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2938 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2939 |
#if defined(xxxTHIS_CONTEXT) /* not because this has a context */ |
71 | 2940 |
/* |
93 | 2941 |
* must set lineno in sender by hand here ... (because of NOCONTEXT) |
71 | 2942 |
*/ |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2943 |
if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2944 |
_ContextInstPtr(__thisContext)->c_lineno = l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2945 |
} |
71 | 2946 |
#endif |
1 | 2947 |
|
253 | 2948 |
if (__isSmallInteger(numberOfArgs)) { |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2949 |
nargs = __intVal(numberOfArgs); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2950 |
if (nargs == 0) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2951 |
if (aSelector != last0) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2952 |
ilc0.ilc_func = __SEND0ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2953 |
if (ilc0.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2954 |
__flushPolyCache(ilc0.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2955 |
ilc0.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2956 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2957 |
last0 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2958 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2959 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2960 |
ilc0.ilc_lineNo = __pilc->ilc_lineNo; |
44 | 2961 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2962 |
RETURN ((*ilc0.ilc_func)(self, aSelector, CON_COMMA nil, &ilc0)); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2963 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2964 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2965 |
if (__isArray(argArray)) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2966 |
argP = _ArrayInstPtr(argArray)->a_element; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2967 |
} else { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2968 |
argP = (OBJ *)(&a1); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2969 |
for (i=1; i <= nargs; i++) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2970 |
*argP++ = __AT_(argArray, CON_COMMA __MKSMALLINT(i)); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2971 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2972 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2973 |
switch (nargs) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2974 |
case 1: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2975 |
if (aSelector != last1) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2976 |
ilc1.ilc_func = __SEND1ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2977 |
if (ilc1.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2978 |
__flushPolyCache(ilc1.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2979 |
ilc1.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2980 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2981 |
last1 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2982 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2983 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2984 |
ilc1.ilc_lineNo = __pilc->ilc_lineNo; |
44 | 2985 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2986 |
RETURN ( (*ilc1.ilc_func)(self, aSelector, CON_COMMA nil, &ilc1, argP[0])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2987 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2988 |
case 2: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2989 |
if (aSelector != last2) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2990 |
ilc2.ilc_func = __SEND2ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2991 |
if (ilc2.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2992 |
__flushPolyCache(ilc2.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2993 |
ilc2.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2994 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2995 |
last2 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2996 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2997 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
2998 |
ilc2.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 2999 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3000 |
RETURN ( (*ilc2.ilc_func)(self, aSelector, CON_COMMA nil, &ilc2, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3001 |
argP[0], argP[1])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3002 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3003 |
case 3: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3004 |
if (aSelector != last3) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3005 |
ilc3.ilc_func = __SEND3ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3006 |
if (ilc3.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3007 |
__flushPolyCache(ilc3.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3008 |
ilc3.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3009 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3010 |
last3 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3011 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3012 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3013 |
ilc3.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3014 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3015 |
RETURN ( (*ilc3.ilc_func)(self, aSelector, CON_COMMA nil, &ilc3, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3016 |
argP[0], argP[1], argP[2])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3017 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3018 |
case 4: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3019 |
if (aSelector != last4) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3020 |
ilc4.ilc_func = __SEND4ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3021 |
if (ilc4.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3022 |
__flushPolyCache(ilc4.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3023 |
ilc4.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3024 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3025 |
last4 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3026 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3027 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3028 |
ilc4.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3029 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3030 |
RETURN ( (*ilc4.ilc_func)(self, aSelector, CON_COMMA nil, &ilc4, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3031 |
argP[0], argP[1], argP[2], argP[3])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3032 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3033 |
case 5: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3034 |
if (aSelector != last5) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3035 |
ilc5.ilc_func = __SEND5ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3036 |
if (ilc5.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3037 |
__flushPolyCache(ilc5.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3038 |
ilc5.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3039 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3040 |
last5 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3041 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3042 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3043 |
ilc5.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3044 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3045 |
RETURN ( (*ilc5.ilc_func)(self, aSelector, CON_COMMA nil, &ilc5, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3046 |
argP[0], argP[1], argP[2], argP[3], argP[4])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3047 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3048 |
case 6: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3049 |
if (aSelector != last6) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3050 |
ilc6.ilc_func = __SEND6ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3051 |
if (ilc6.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3052 |
__flushPolyCache(ilc6.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3053 |
ilc6.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3054 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3055 |
last6 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3056 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3057 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3058 |
ilc6.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3059 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3060 |
RETURN ( (*ilc6.ilc_func)(self, aSelector, CON_COMMA nil, &ilc6, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3061 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3062 |
argP[5])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3063 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3064 |
case 7: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3065 |
if (aSelector != last7) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3066 |
ilc7.ilc_func = __SEND7ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3067 |
if (ilc7.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3068 |
__flushPolyCache(ilc7.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3069 |
ilc7.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3070 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3071 |
last7 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3072 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3073 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3074 |
ilc7.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3075 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3076 |
RETURN ( (*ilc7.ilc_func)(self, aSelector, CON_COMMA nil, &ilc7, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3077 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3078 |
argP[5], argP[6])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3079 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3080 |
case 8: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3081 |
if (aSelector != last8) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3082 |
ilc8.ilc_func = __SEND8ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3083 |
last8 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3084 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3085 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3086 |
ilc8.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3087 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3088 |
RETURN ( (*ilc8.ilc_func)(self, aSelector, CON_COMMA nil, &ilc8, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3089 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3090 |
argP[5], argP[6], argP[7])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3091 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3092 |
case 9: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3093 |
if (aSelector != last9) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3094 |
ilc9.ilc_func = __SEND9ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3095 |
last9 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3096 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3097 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3098 |
ilc9.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3099 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3100 |
RETURN ( (*ilc9.ilc_func)(self, aSelector, CON_COMMA nil, &ilc9, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3101 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3102 |
argP[5], argP[6], argP[7], argP[8])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3103 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3104 |
case 10: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3105 |
if (aSelector != last10) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3106 |
ilc10.ilc_func = __SEND10ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3107 |
last10 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3108 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3109 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3110 |
ilc10.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3111 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3112 |
RETURN ( (*ilc10.ilc_func)(self, aSelector, CON_COMMA nil, &ilc10, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3113 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3114 |
argP[5], argP[6], argP[7], argP[8], argP[9])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3115 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3116 |
case 11: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3117 |
if (aSelector != last11) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3118 |
ilc11.ilc_func = __SEND11ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3119 |
last11 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3120 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3121 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3122 |
ilc11.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3123 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3124 |
RETURN ( (*ilc11.ilc_func)(self, aSelector, CON_COMMA nil, &ilc11, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3125 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3126 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3127 |
argP[10])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3128 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3129 |
case 12: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3130 |
if (aSelector != last12) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3131 |
ilc12.ilc_func = __SEND12ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3132 |
last12 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3133 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3134 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3135 |
ilc12.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3136 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3137 |
RETURN ( (*ilc12.ilc_func)(self, aSelector, CON_COMMA nil, &ilc12, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3138 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3139 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3140 |
argP[10], argP[11])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3141 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3142 |
case 13: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3143 |
if (aSelector != last13) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3144 |
ilc13.ilc_func = __SEND13ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3145 |
last13 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3146 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3147 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3148 |
ilc13.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3149 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3150 |
RETURN ( (*ilc13.ilc_func)(self, aSelector, CON_COMMA nil, &ilc13, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3151 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3152 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3153 |
argP[10], argP[11], argP[12])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3154 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3155 |
case 14: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3156 |
if (aSelector != last14) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3157 |
ilc14.ilc_func = __SEND14ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3158 |
last14 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3159 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3160 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3161 |
ilc14.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3162 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3163 |
RETURN ( (*ilc14.ilc_func)(self, aSelector, CON_COMMA nil, &ilc14, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3164 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3165 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3166 |
argP[10], argP[11], argP[12], argP[13])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3167 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3168 |
case 15: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3169 |
if (aSelector != last15) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3170 |
ilc15.ilc_func = __SEND15ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3171 |
last15 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3172 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3173 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3174 |
ilc15.ilc_lineNo = __pilc->ilc_lineNo; |
77 | 3175 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3176 |
RETURN ( (*ilc15.ilc_func)(self, aSelector, CON_COMMA nil, &ilc15, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3177 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3178 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3179 |
argP[10], argP[11], argP[12], argP[13], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3180 |
argP[14])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3181 |
} |
1 | 3182 |
} |
3183 |
%} |
|
3184 |
. |
|
3185 |
^ self primitiveFailed |
|
3186 |
! ! |
|
3187 |
||
783 | 3188 |
!Object methodsFor:'misc'! |
3189 |
||
3190 |
-> anObject |
|
3191 |
"return an association with the receiver as key and |
|
3192 |
the argument as value" |
|
3193 |
||
3194 |
^ Association key:self value:anObject |
|
2 | 3195 |
! ! |
3196 |
||
1 | 3197 |
!Object methodsFor:'printing & storing'! |
3198 |
||
3199 |
className |
|
3200 |
"return the classname of the receivers class" |
|
3201 |
||
3202 |
^ self class name |
|
56 | 3203 |
|
293 | 3204 |
" |
3205 |
1 className |
|
3206 |
1 class className 'this may change ...' |
|
3207 |
$a className |
|
3208 |
$a class className 'this may change ...' |
|
3209 |
" |
|
1 | 3210 |
! |
3211 |
||
3212 |
classNameWithArticle |
|
71 | 3213 |
"return a string consisting of classname preceeded by an article. |
3214 |
(dont expect me to write national variants for this ... :-) |
|
3215 |
If you have special preferences, redefine it ..." |
|
1 | 3216 |
|
85 | 3217 |
|classname| |
1 | 3218 |
|
293 | 3219 |
classname := self class displayString. |
85 | 3220 |
^ classname article , ' ' , classname |
56 | 3221 |
|
293 | 3222 |
" |
3223 |
1 classNameWithArticle |
|
3224 |
(1->2) classNameWithArticle |
|
3225 |
XWorkstation basicNew classNameWithArticle |
|
3226 |
" |
|
1 | 3227 |
! |
3228 |
||
783 | 3229 |
displayOn:aGc at:aPoint |
3230 |
"ST-80 Compatibility |
|
3231 |
display the receiver in a graphicsContext - this method allows |
|
3232 |
for any object to be displayed in a ListView - for example." |
|
3233 |
||
3234 |
^ self displayOn:aGc x:(aPoint x) y:(aPoint y). |
|
56 | 3235 |
! |
3236 |
||
783 | 3237 |
displayOn:aGc x:x y:y |
3238 |
"display the receiver in a graphicsContext - this method allows |
|
3239 |
for any object to be displayed in a ListView - for example." |
|
3240 |
||
3241 |
^ aGc displayString:(self displayString) x:x y:y. |
|
56 | 3242 |
! |
3243 |
||
783 | 3244 |
displayString |
3245 |
"return a string used when displaying the receiver in a view; |
|
3246 |
for example an Inspector. This is usually the same as printString, |
|
3247 |
but sometimes redefined for a better look." |
|
3248 |
||
3249 |
^ self printString |
|
3250 |
||
3251 |
" |
|
3252 |
#(1 2 3) printString |
|
3253 |
#(1 2 3) displayString |
|
3254 |
#(1 2 3) storeString |
|
3255 |
" |
|
1 | 3256 |
! |
3257 |
||
783 | 3258 |
errorPrint |
3259 |
"print the receiver on the standard error stream." |
|
3260 |
||
1089
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3261 |
Stream streamErrorSignal catch:[ |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3262 |
self printOn:Stderr |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3263 |
] |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3264 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3265 |
"Modified: 7.3.1996 / 19:11:29 / cg" |
783 | 3266 |
! |
3267 |
||
3268 |
errorPrintNL |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3269 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3270 |
|
1089
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3271 |
"print the receiver followed by a cr on the standard error stream." |
783 | 3272 |
|
3273 |
^ self errorPrintNewline |
|
1089
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3274 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3275 |
"Modified: 7.3.1996 / 19:12:56 / cg" |
783 | 3276 |
! |
3277 |
||
3278 |
errorPrintNewline |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3279 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3280 |
|
1089
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3281 |
"print the receiver followed by a cr on the standard error stream." |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3282 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3283 |
Stream streamErrorSignal catch:[ |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3284 |
self printOn:Stderr. |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3285 |
Stderr cr |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3286 |
] |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3287 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3288 |
"Modified: 7.3.1996 / 19:13:01 / cg" |
71 | 3289 |
! |
3290 |
||
356 | 3291 |
infoPrint |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3292 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3293 |
|
356 | 3294 |
"print the receiver on the standard error stream. |
3295 |
This is meant for information messages which are not warnings |
|
3296 |
or fatal messages. |
|
3297 |
These messages can be turned on/off by 'Object infoPrinting:true/false'" |
|
3298 |
||
3299 |
InfoPrinting ifTrue:[ |
|
3300 |
self printOn:Stderr |
|
3301 |
] |
|
3302 |
! |
|
3303 |
||
3304 |
infoPrintNL |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3305 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3306 |
|
356 | 3307 |
"print the receiver followed by a cr on the standard error stream. |
3308 |
This is meant for information messages which are not warnings |
|
3309 |
or fatal messages. |
|
3310 |
These messages can be turned on/off by 'Object infoPrinting:true/false'" |
|
3311 |
||
3312 |
InfoPrinting ifTrue:[ |
|
3313 |
self errorPrintNewline |
|
3314 |
] |
|
3315 |
! |
|
3316 |
||
783 | 3317 |
|
3318 |
"print the receiver on the standard output stream" |
|
3319 |
||
3320 |
self printOn:Stdout |
|
3321 |
! |
|
3322 |
||
3323 |
printNL |
|
3324 |
"print the receiver followed by a cr on the standard output stream |
|
3325 |
- for GNU Smalltalk compatibility" |
|
3326 |
||
3327 |
^ self printNewline |
|
3328 |
! |
|
3329 |
||
3330 |
printNewline |
|
3331 |
"print the receiver followed by a cr on the standard output stream" |
|
3332 |
||
3333 |
self printOn:Stdout. |
|
3334 |
Stdout cr |
|
3335 |
! |
|
3336 |
||
3337 |
printOn:aStream |
|
3338 |
"print the receiver on the argument-stream. |
|
3339 |
The default here is to output the receivers class name. |
|
3340 |
BUT: this method is heavily redefined for objects which |
|
3341 |
can print prettier." |
|
3342 |
||
3343 |
aStream nextPutAll:self classNameWithArticle |
|
3344 |
! |
|
3345 |
||
3346 |
printOn:aStream leftPaddedTo:size |
|
3347 |
"print the receiver on aStream, padding with spaces up to size. |
|
3348 |
padding is done on the left." |
|
3349 |
||
3350 |
self printOn:aStream leftPaddedTo:size with:(Character space) |
|
3351 |
||
3352 |
" |
|
3353 |
123 printOn:Transcript leftPaddedTo:10. Transcript cr |
|
3354 |
123 printOn:Transcript leftPaddedTo:2. Transcript cr |
|
3355 |
" |
|
71 | 3356 |
! |
3357 |
||
783 | 3358 |
printOn:aStream leftPaddedTo:size with:padCharacter |
3359 |
"print the receiver on aStream, padding with padCharacters up to size. |
|
3360 |
padding is done on the left." |
|
3361 |
||
3362 |
aStream nextPutAll:(self printStringLeftPaddedTo:size with:padCharacter) |
|
3363 |
||
3364 |
" |
|
3365 |
123 printOn:Transcript leftPaddedTo:10 with:$_ . Transcript cr |
|
3366 |
123 printOn:Transcript leftPaddedTo:10 with:$. . Transcript cr |
|
3367 |
" |
|
3368 |
! |
|
3369 |
||
3370 |
printOn:aStream paddedTo:size |
|
3371 |
"print the receiver on aStream, padding with spaces up to size." |
|
3372 |
||
3373 |
self printOn:aStream paddedTo:size with:(Character space) |
|
3374 |
||
3375 |
" |
|
3376 |
123.0 printOn:Transcript paddedTo:10. Transcript nextPut:$|. Transcript cr |
|
3377 |
" |
|
71 | 3378 |
! |
3379 |
||
783 | 3380 |
printOn:aStream paddedTo:size with:padCharacter |
3381 |
"print the receiver on aStream, padding with padCharacter up to size" |
|
3382 |
||
3383 |
aStream nextPutAll:(self printStringPaddedTo:size with:padCharacter). |
|
3384 |
||
3385 |
" |
|
3386 |
123 printOn:Transcript paddedTo:10 with:$_ . Transcript cr |
|
3387 |
123 printOn:Transcript paddedTo:10 with:$. . Transcript cr |
|
3388 |
" |
|
3389 |
! |
|
3390 |
||
3391 |
printOn:aStream zeroPaddedTo:size |
|
3392 |
"print the receiver on aStream, padding with zeros up to size. |
|
3393 |
Usually used with float numbers." |
|
3394 |
||
3395 |
self printOn:aStream paddedTo:size with:$0. |
|
3396 |
||
3397 |
" |
|
3398 |
123.0 printOn:Transcript zeroPaddedTo:10 |
|
3399 |
" |
|
3400 |
! |
|
3401 |
||
3402 |
printRightAdjustLen:size |
|
3403 |
"obsolete - just a name confusion. |
|
3404 |
This method will go away ..." |
|
3405 |
||
3406 |
(self printStringLeftPaddedTo:size) printOn:Stdout |
|
71 | 3407 |
! |
3408 |
||
3409 |
printString |
|
3410 |
"return a string for printing the receiver. |
|
3411 |
Since we now use printOn: as the basic print mechanism, |
|
3412 |
we have to create a stream and print into it." |
|
3413 |
||
3414 |
|s| |
|
3415 |
||
3416 |
s := WriteStream on:(String new:30). |
|
3417 |
self printOn:s. |
|
3418 |
^ s contents |
|
3419 |
! |
|
3420 |
||
783 | 3421 |
printStringLeftPaddedTo:size |
3422 |
"return my printString as a right-adjusted string of length size; |
|
3423 |
characters on the left are filled with spaces. |
|
3424 |
If the printString is longer than size, |
|
3425 |
it is returned unchanged (i.e. not truncated)" |
|
3426 |
||
3427 |
^ self printStringLeftPaddedTo:size with:(Character space) |
|
3428 |
||
3429 |
" |
|
3430 |
10 printStringLeftPaddedTo:10 |
|
3431 |
1 printStringLeftPaddedTo:10 |
|
3432 |
" |
|
3433 |
! |
|
3434 |
||
3435 |
printStringLeftPaddedTo:size ifLarger:alternative |
|
3436 |
"return my printString as a right-adjusted string of length size; |
|
3437 |
characters on the left are filled with spaces. |
|
3438 |
If the printString is larger than size, |
|
3439 |
return the result from evaluating alternative." |
|
3440 |
||
3441 |
^ self printStringLeftPaddedTo:size with:(Character space) ifLarger:alternative |
|
3442 |
||
3443 |
" |
|
3444 |
12 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
3445 |
123 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
3446 |
1234 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
3447 |
" |
|
3448 |
! |
|
3449 |
||
3450 |
printStringLeftPaddedTo:size with:padCharacter |
|
3451 |
"return my printString as a right-adjusted string of length size; |
|
3452 |
characters on the left are filled with padCharacter. |
|
3453 |
If the printString is longer than size, |
|
3454 |
it is returned unchanged (i.e. not truncated)" |
|
3455 |
||
3456 |
^ (self printString) leftPaddedTo:size with:padCharacter |
|
3457 |
||
3458 |
" |
|
3459 |
123 printStringLeftPaddedTo:10 with:$. |
|
3460 |
1 printStringLeftPaddedTo:10 with:$. |
|
3461 |
(Float pi) printStringLeftPaddedTo:20 with:$* |
|
3462 |
" |
|
3463 |
! |
|
3464 |
||
3465 |
printStringLeftPaddedTo:size with:padCharacter ifLarger:alternative |
|
3466 |
"return my printString as a right-adjusted string of length size; |
|
3467 |
characters on the left are filled with padCharacter. |
|
3468 |
If the printString is larger than size, |
|
369 | 3469 |
return the result from evaluating alternative." |
3470 |
||
3471 |
|s| |
|
3472 |
||
3473 |
s := self printString. |
|
3474 |
s size > size ifTrue:[^ alternative value]. |
|
783 | 3475 |
^ s leftPaddedTo:size with:padCharacter |
369 | 3476 |
|
3477 |
" |
|
783 | 3478 |
12 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
3479 |
123 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
|
3480 |
1234 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
|
293 | 3481 |
" |
13 | 3482 |
! |
3483 |
||
3484 |
printStringPaddedTo:size |
|
56 | 3485 |
"return a printed representation of the receiver, |
369 | 3486 |
padded with spaces (at the right) up to size. |
293 | 3487 |
If the printString is longer than size, |
3488 |
it is returned unchanged (i.e. not truncated)" |
|
13 | 3489 |
|
3490 |
^ self printStringPaddedTo:size with:(Character space) |
|
3491 |
||
293 | 3492 |
" |
3493 |
123 printStringPaddedTo:10 |
|
3494 |
1234567890123456 printStringPaddedTo:10 |
|
3495 |
'hello' printStringPaddedTo:10 |
|
3496 |
" |
|
2 | 3497 |
! |
3498 |
||
369 | 3499 |
printStringPaddedTo:size ifLarger:alternative |
3500 |
"return a printed representation of the receiver, |
|
3501 |
padded with spaces (at the right) up to size. |
|
3502 |
If the resulting printString is too large, |
|
3503 |
return the result from evaluating alternative." |
|
3504 |
||
3505 |
^ self printStringPaddedTo:size with:(Character space) ifLarger:alternative |
|
3506 |
||
3507 |
" |
|
3508 |
12 printStringPaddedTo:3 ifLarger:['***'] |
|
3509 |
123 printStringPaddedTo:3 ifLarger:['***'] |
|
3510 |
1234 printStringPaddedTo:3 ifLarger:['***'] |
|
3511 |
" |
|
3512 |
! |
|
3513 |
||
783 | 3514 |
printStringPaddedTo:size with:padCharacter |
3515 |
"return a printed representation of the receiver, |
|
3516 |
padded with padCharacter (at the right) up to size. |
|
3517 |
If the printString is longer than size, |
|
3518 |
it is returned unchanged (i.e. not truncated)" |
|
3519 |
||
3520 |
^ (self printString) paddedTo:size with:padCharacter |
|
3521 |
||
3522 |
" |
|
3523 |
123 printStringPaddedTo:10 with:$. |
|
3524 |
123 printStringPaddedTo:10 with:$* |
|
3525 |
123 printStringPaddedTo:3 with:$* |
|
3526 |
1234 printStringPaddedTo:3 with:$* |
|
3527 |
" |
|
3528 |
! |
|
3529 |
||
3530 |
printStringPaddedTo:size with:padCharacter ifLarger:alternative |
|
3531 |
"return a printed representation of the receiver, |
|
3532 |
padded with padCharacter (at the right) up to size. |
|
3533 |
If the resulting printString is too large, |
|
3534 |
return the result from evaluating alternative." |
|
3535 |
||
3536 |
|s| |
|
3537 |
||
3538 |
s := self printString. |
|
3539 |
s size > size ifTrue:[^ alternative value]. |
|
3540 |
^ s paddedTo:size with:padCharacter |
|
3541 |
||
3542 |
" |
|
3543 |
123 printStringPaddedTo:3 with:$. ifLarger:['***'] |
|
3544 |
12345 printStringPaddedTo:3 with:$. ifLarger:['***'] |
|
3545 |
" |
|
3546 |
! |
|
3547 |
||
3548 |
printStringRightAdjustLen:size |
|
3549 |
"obsolete - just a name confusion. |
|
3550 |
This method will go away ..." |
|
3551 |
||
3552 |
^ self printStringLeftPaddedTo:size |
|
3553 |
! |
|
3554 |
||
2 | 3555 |
printStringZeroPaddedTo:size |
71 | 3556 |
"return a printed representation of the receiver, |
369 | 3557 |
padded with zero (at the right) characters up to size. |
13 | 3558 |
Usually used with float numbers." |
2 | 3559 |
|
3560 |
^ self printStringPaddedTo:size with:$0 |
|
13 | 3561 |
|
293 | 3562 |
" |
3563 |
123.0 printStringZeroPaddedTo:10 |
|
3564 |
" |
|
2 | 3565 |
! |
3566 |
||
783 | 3567 |
store |
3568 |
"store the receiver on standard output. |
|
3569 |
this method is useless, but included for compatibility." |
|
3570 |
||
3571 |
self storeOn:Stdout |
|
71 | 3572 |
! |
3573 |
||
783 | 3574 |
storeNl |
3575 |
"store the receiver on standard output; append a newline. |
|
3576 |
this method is useless, but included for compatibility." |
|
3577 |
||
3578 |
self store. |
|
3579 |
Character nl print |
|
460
7e058858cc3b
New Method: displayOn:aGc at:aPoint (ST80-compatibility).
Stefan Vogel <sv@exept.de>
parents:
446
diff
changeset
|
3580 |
! |
7e058858cc3b
New Method: displayOn:aGc at:aPoint (ST80-compatibility).
Stefan Vogel <sv@exept.de>
parents:
446
diff
changeset
|
3581 |
|
56 | 3582 |
storeOn:aStream |
3583 |
"store the receiver on aStream; i.e. print an expression which will |
|
293 | 3584 |
reconstruct the receiver. |
3585 |
Notice, that no self referencing or cyclic objects can be represented |
|
3586 |
in this format. |
|
3587 |
Use storeBinaryOn:, which handles these cases correctly." |
|
56 | 3588 |
|
3589 |
|myClass hasSemi sz "{ Class: SmallInteger }" | |
|
1 | 3590 |
|
25 | 3591 |
thisContext isRecursive ifTrue:[ |
159 | 3592 |
Transcript showCr:'Error: storeString of self referencing object.'. |
3593 |
aStream nextPutAll:'#("recursive")'. |
|
3594 |
^ self |
|
25 | 3595 |
]. |
56 | 3596 |
|
1 | 3597 |
myClass := self class. |
56 | 3598 |
aStream nextPut:$(. |
3599 |
aStream nextPutAll:self class name. |
|
3600 |
||
1 | 3601 |
hasSemi := false. |
3602 |
myClass isVariable ifTrue:[ |
|
159 | 3603 |
aStream nextPutAll:' basicNew:'. |
3604 |
self basicSize printOn:aStream |
|
1 | 3605 |
] ifFalse:[ |
159 | 3606 |
aStream nextPutAll:' basicNew' |
1 | 3607 |
]. |
56 | 3608 |
|
1 | 3609 |
sz := myClass instSize. |
3610 |
1 to:sz do:[:i | |
|
159 | 3611 |
aStream nextPutAll:' instVarAt:'. |
3612 |
i printOn:aStream. |
|
3613 |
aStream nextPutAll:' put:'. |
|
3614 |
(self instVarAt:i) storeOn:aStream. |
|
3615 |
aStream nextPut:$;. |
|
3616 |
hasSemi := true |
|
1 | 3617 |
]. |
3618 |
myClass isVariable ifTrue:[ |
|
159 | 3619 |
sz := self basicSize. |
3620 |
1 to:sz do:[:i | |
|
3621 |
aStream nextPutAll:' basicAt:'. |
|
3622 |
i printOn:aStream. |
|
3623 |
aStream nextPutAll:' put:'. |
|
3624 |
(self basicAt:i) storeOn:aStream. |
|
3625 |
aStream nextPut:$;. |
|
3626 |
hasSemi := true |
|
3627 |
] |
|
1 | 3628 |
]. |
3629 |
hasSemi ifTrue:[ |
|
159 | 3630 |
aStream nextPutAll:' yourself' |
1 | 3631 |
]. |
56 | 3632 |
aStream nextPut:$). |
293 | 3633 |
|
3634 |
" |
|
3635 |
|s| |
|
3636 |
||
3637 |
s := WriteStream on:(String new). |
|
3638 |
('hello' -> 'world') storeOn:s. |
|
3639 |
s := ReadStream on:(s contents). |
|
3640 |
(Object readFrom:s) inspect |
|
3641 |
" |
|
3642 |
" |
|
3643 |
|s| |
|
3644 |
||
3645 |
s := 'data' asFilename writeStream. |
|
3646 |
('hello' -> 'world') storeOn:s. |
|
3647 |
s close. |
|
3648 |
||
3649 |
s := 'data' asFilename readStream. |
|
3650 |
(Object readFrom:s) inspect |
|
3651 |
" |
|
3652 |
||
3653 |
"does not work example:" |
|
3654 |
" |
|
3655 |
|s a| |
|
3656 |
||
3657 |
a := Array new:2. |
|
3658 |
a at:1 put:a. |
|
3659 |
||
3660 |
s := 'data' asFilename writeStream. |
|
3661 |
a storeOn:s. |
|
3662 |
s close. |
|
3663 |
||
3664 |
s := 'data' asFilename readStream. |
|
3665 |
(Object readFrom:s) inspect |
|
3666 |
" |
|
1 | 3667 |
! |
3668 |
||
56 | 3669 |
storeString |
293 | 3670 |
"return a string representing an expression to reconstruct the receiver. |
3671 |
Notice, that no self referencing or cyclic objects can be represented |
|
3672 |
in this format. |
|
3673 |
Use storeBinaryOn:, which handles these cases correctly." |
|
56 | 3674 |
|
3675 |
|s| |
|
3676 |
||
3677 |
s := WriteStream on:(String new:50). |
|
3678 |
self storeOn:s. |
|
3679 |
^ s contents |
|
783 | 3680 |
! ! |
3681 |
||
3682 |
!Object methodsFor:'queries'! |
|
3683 |
||
3684 |
basicSize |
|
3685 |
"return the number of the receivers indexed instance variables, |
|
3686 |
0 if it has none. |
|
3687 |
||
3688 |
This method should NOT be redefined in any subclass" |
|
3689 |
||
3690 |
%{ /* NOCONTEXT */ |
|
3691 |
||
3692 |
REGISTER int nbytes; |
|
3693 |
REGISTER OBJ myClass; |
|
3694 |
REGISTER int flags; |
|
3695 |
||
3696 |
/* |
|
3697 |
* notice the missing test for self being a nonNilObject - |
|
3698 |
* this can be done since basicSize is defined both in UndefinedObject |
|
3699 |
* and SmallInteger |
|
3700 |
*/ |
|
3701 |
myClass = __qClass(self); |
|
3702 |
nbytes = __qSize(self) |
|
3703 |
- OHDR_SIZE |
|
3704 |
- __OBJS2BYTES__(__intVal(_ClassInstPtr(myClass)->c_ninstvars)); |
|
3705 |
||
3706 |
flags = __intVal(_ClassInstPtr(myClass)->c_flags) & ARRAYMASK; |
|
3707 |
/* |
|
3708 |
* replaced switch by open-if; this is slightly faster since |
|
3709 |
* it avoids the range check and also checks the most common case first |
|
3710 |
*/ |
|
3711 |
if ((flags == POINTERARRAY) |
|
3712 |
|| (flags == WKPOINTERARRAY)) { |
|
3713 |
RETURN ( __MKSMALLINT(__BYTES2OBJS__(nbytes)) ); |
|
3714 |
} |
|
3715 |
if (flags == BYTEARRAY) { |
|
3716 |
RETURN ( __MKSMALLINT(nbytes / sizeof(char)) ); |
|
3717 |
} |
|
3718 |
if (flags == FLOATARRAY) { |
|
3719 |
RETURN ( __MKSMALLINT(nbytes / sizeof(float)) ); |
|
3720 |
} |
|
3721 |
if (flags == DOUBLEARRAY) { |
|
3722 |
#ifdef NEED_DOUBLE_ALIGN |
|
3723 |
/* |
|
3724 |
* care for filler |
|
3725 |
*/ |
|
3726 |
nbytes -= sizeof(FILLTYPE); |
|
3727 |
#endif |
|
3728 |
RETURN ( __MKSMALLINT(nbytes / sizeof(double)) ); |
|
3729 |
} |
|
3730 |
if (flags == LONGARRAY) { |
|
3731 |
RETURN ( __MKSMALLINT(nbytes / sizeof(long)) ); |
|
3732 |
} |
|
3733 |
if (flags == WORDARRAY) { |
|
3734 |
RETURN ( __MKSMALLINT(nbytes / sizeof(short)) ); |
|
3735 |
} |
|
3736 |
%}. |
|
3737 |
^ 0 |
|
1 | 3738 |
! |
3739 |
||
783 | 3740 |
class |
3741 |
"return the receivers class" |
|
3742 |
||
3743 |
%{ /* NOCONTEXT */ |
|
3744 |
||
3745 |
RETURN ( __Class(self) ); |
|
3746 |
%} |
|
3747 |
! |
|
3748 |
||
3749 |
isArray |
|
3750 |
"return true, if the receiver is some kind of array (or weakArray etc); |
|
3751 |
false is returned here - the method is only redefined in Array." |
|
3752 |
||
3753 |
^ false |
|
3754 |
! |
|
3755 |
||
3756 |
isBehavior |
|
3757 |
"return true, if the receiver is some kind of class (i.e. behavior); |
|
3758 |
false is returned here - the method is only redefined in Behavior." |
|
3759 |
||
3760 |
^ false |
|
3761 |
! |
|
3762 |
||
3763 |
isBlock |
|
3764 |
"return true, if the receiver is some kind of block; |
|
3765 |
false returned here - the method is only redefined in Block." |
|
3766 |
||
3767 |
^ false |
|
3768 |
! |
|
3769 |
||
3770 |
isCharacter |
|
3771 |
"return true, if the receiver is some kind of character; |
|
3772 |
false is returned here - the method is only redefined in Character." |
|
3773 |
||
3774 |
^ false |
|
3775 |
! |
|
3776 |
||
3777 |
isClass |
|
3778 |
"return true, if the receiver is some kind of class (real class, |
|
3779 |
not just behavior); |
|
3780 |
false is returned here - the method is only redefined in Class." |
|
3781 |
||
3782 |
^ false |
|
3783 |
! |
|
3784 |
||
3785 |
isCollection |
|
3786 |
"return true, if the receiver is some kind of collection; |
|
3787 |
false is returned here - the method is only redefined in Collection." |
|
3788 |
||
3789 |
^ false |
|
3790 |
! |
|
3791 |
||
3792 |
isColor |
|
3793 |
"return true, if the receiver is some kind of color; |
|
3794 |
false is returned here - the method is only redefined in Color." |
|
3795 |
||
3796 |
^ false |
|
3797 |
! |
|
3798 |
||
3799 |
isContext |
|
3800 |
"return true, if the receiver is some kind of context; |
|
3801 |
false returned here - the method is only redefined in Context." |
|
3802 |
||
3803 |
^ false |
|
3804 |
! |
|
3805 |
||
3806 |
isExternalStream |
|
3807 |
"return true, if the receiver is some kind of externalStream; |
|
3808 |
false is returned here - the method is only redefined in ExternalStream." |
|
3809 |
||
3810 |
^false |
|
3811 |
! |
|
3812 |
||
3813 |
isFileStream |
|
3814 |
"return true, if the receiver is some kind of fileStream; |
|
3815 |
false is returned here - the method is only redefined in FileStream." |
|
3816 |
||
3817 |
^false |
|
3818 |
! |
|
3819 |
||
3820 |
isFixedSize |
|
3821 |
"return true if the receiver cannot grow easily |
|
3822 |
(i.e. a grow may be expensive, since it involves a become:)" |
|
3823 |
||
3824 |
^ true |
|
3825 |
! |
|
3826 |
||
3827 |
isForm |
|
3828 |
"return true, if the receiver is some kind of form; |
|
3829 |
false is returned here - the method is only redefined in Form." |
|
3830 |
||
3831 |
^ false |
|
3832 |
! |
|
3833 |
||
3834 |
isFraction |
|
3835 |
"return true, if the receiver is some kind of fraction; |
|
3836 |
false is returned here - the method is only redefined in Fraction." |
|
3837 |
||
3838 |
^ false |
|
3839 |
! |
|
3840 |
||
3841 |
isImage |
|
3842 |
"return true, if the receiver is some kind of image; |
|
3843 |
false is returned here - the method is only redefined in Image." |
|
3844 |
||
3845 |
^ false |
|
3846 |
! |
|
3847 |
||
3848 |
isImageOrForm |
|
3849 |
"return true, if the receiver is some kind of image or form; |
|
3850 |
false is returned here - the method is only redefined in Image and Form." |
|
3851 |
||
3852 |
^ false |
|
3853 |
! |
|
3854 |
||
3855 |
isInteger |
|
3856 |
"return true, if the receiver is some kind of integer number; |
|
3857 |
false is returned here - the method is only redefined in Integer." |
|
3858 |
||
3859 |
^ false |
|
3860 |
! |
|
3861 |
||
3862 |
isKindOf:aClass |
|
3863 |
"return true, if the receiver is an instance of aClass or one of its |
|
3864 |
subclasses, false otherwise. |
|
3865 |
Advice: |
|
3866 |
use of this to check objects for certain attributes/protocoll should |
|
3867 |
be avoided; it limits the reusability of your classes by limiting use |
|
3868 |
to instances of certain classes and fences you into a specific inheritance |
|
3869 |
hierarchy. |
|
3870 |
Use check-methods to check an object for a certain attributes/protocol |
|
3871 |
(such as #isXXXX, #respondsTo: or #isNumber). |
|
3872 |
||
3873 |
Using #isKindOf: is considered BAD STYLE. |
|
3874 |
||
3875 |
Advice2: |
|
3876 |
Be aware, that using an #isXXX method is usually much faster than |
|
3877 |
using #isKindOf:; because isKindOf: has to walk up all the superclass |
|
3878 |
hierarchy, comparing every class on the way. |
|
3879 |
Due to caching in the VM, a call to #isXXX is normally reached via |
|
3880 |
a single function call. |
|
3881 |
" |
|
3882 |
||
3883 |
%{ /* NOCONTEXT */ |
|
3884 |
register OBJ thisClass; |
|
3885 |
||
3886 |
thisClass = __Class(self); |
|
3887 |
while (thisClass != nil) { |
|
3888 |
if (thisClass == aClass) { |
|
3889 |
RETURN ( true ); |
|
3890 |
} |
|
3891 |
thisClass = _ClassInstPtr(thisClass)->c_superclass; |
|
3892 |
} |
|
3893 |
%} |
|
3894 |
. |
|
3895 |
"/ |
|
3896 |
"/ the above code is equivalent to: |
|
3897 |
"/ |
|
3898 |
"/ thisClass := self class. |
|
3899 |
"/ [thisClass notNil] whileTrue:[ |
|
3900 |
"/ thisClass == aClass ifTrue:[^ true]. |
|
3901 |
"/ thisClass := thisClass superclass |
|
3902 |
"/ ] |
|
3903 |
"/ |
|
3904 |
^ false |
|
3905 |
! |
|
3906 |
||
3907 |
isLayout |
|
3908 |
"return true, if the receiver is some kind of layout; |
|
3909 |
false is returned here - the method is only redefined in Layout." |
|
3910 |
||
3911 |
^ false |
|
3912 |
! |
|
3913 |
||
3914 |
isLiteral |
|
3915 |
"return true, if the receiver can be represented as a constant in ST syntax; |
|
3916 |
false is returned here - the method is redefined in some classes." |
|
3917 |
||
3918 |
^ false |
|
3919 |
! |
|
3920 |
||
3921 |
isMemberOf:aClass |
|
3922 |
"return true, if the receiver is an instance of aClass, false otherwise. |
|
3923 |
Advice: |
|
3924 |
use of this to check objects for certain attributes/protocoll should |
|
3925 |
be avoided; it limits the reusability of your classes by limiting use |
|
3926 |
to instances of a certain class. |
|
3927 |
Use check-methods to check an object for a certain attributes/protocol |
|
3928 |
(such as #isXXX, #respondsTo: or #isNumber); |
|
3929 |
||
3930 |
Using #isMemberOf: is considered BAD STYLE." |
|
3931 |
||
3932 |
^ (self class) == aClass |
|
3933 |
! |
|
3934 |
||
3935 |
isMeta |
|
3936 |
"return true, if the receiver is some kind of metaclass; |
|
3937 |
false is returned here - the method is only redefined in Metaclass." |
|
3938 |
||
3939 |
^ false |
|
3940 |
! |
|
3941 |
||
3942 |
isMethod |
|
3943 |
"return true, if the receiver is some kind of method; |
|
3944 |
false returned here - the method is only redefined in Method." |
|
3945 |
||
3946 |
^ false |
|
3947 |
! |
|
3948 |
||
3949 |
isNumber |
|
3950 |
"return true, if the receiver is some kind of number; |
|
3951 |
false is returned here - the method is only redefined in Number." |
|
3952 |
||
3953 |
^ false |
|
3954 |
! |
|
3955 |
||
3956 |
isPoint |
|
3957 |
"return true, if the receiver is some kind of point; |
|
3958 |
false is returned here - the method is only redefined in Point." |
|
3959 |
||
3960 |
^ false |
|
3961 |
! |
|
3962 |
||
3963 |
isReal |
|
3964 |
"return true, if the receiver is some kind of real number; |
|
3965 |
false is returned here - the method is only redefined in LimitedPrecisionReal." |
|
3966 |
||
3967 |
^ false |
|
3968 |
! |
|
3969 |
||
3970 |
isRectangle |
|
3971 |
"return true, if the receiver is some kind of rectangle; |
|
3972 |
false is returned here - the method is only redefined in Rectangle." |
|
3973 |
||
3974 |
^ false |
|
3975 |
! |
|
3976 |
||
3977 |
isSequenceable |
|
3978 |
"return true, if the receiver is some kind of sequenceable collection; |
|
3979 |
false is returned here - the method is only redefined in SequenceableCollection." |
|
3980 |
||
3981 |
^ false |
|
3982 |
! |
|
3983 |
||
3984 |
isSequenceableCollection |
|
3985 |
"OBSOLETE: use isSequenceable for ST-80 compatibility. |
|
3986 |
This method is a historic leftover and will be removed soon ..." |
|
3987 |
||
3988 |
self obsoleteMethodWarning:'use #isSequenceable'. |
|
3989 |
^ false |
|
3990 |
! |
|
3991 |
||
3992 |
isSignal |
|
3993 |
"return true, if the receiver is some kind of signal; |
|
3994 |
false returned here - the method is only redefined in Signal." |
|
3995 |
||
3996 |
^ false |
|
3997 |
! |
|
3998 |
||
3999 |
isStream |
|
4000 |
"return true, if the receiver is some kind of stream; |
|
4001 |
false is returned here - the method is only redefined in Stream." |
|
4002 |
||
4003 |
^ false |
|
4004 |
! |
|
4005 |
||
4006 |
isString |
|
4007 |
"return true, if the receiver is some kind of string; |
|
4008 |
false is returned here - the method is only redefined in String." |
|
4009 |
||
4010 |
^ false |
|
4011 |
! |
|
4012 |
||
4013 |
isSymbol |
|
4014 |
"return true, if the receiver is some kind of symbol; |
|
4015 |
false is returned here - the method is only redefined in Symbol." |
|
4016 |
||
4017 |
^ false |
|
4018 |
! |
|
4019 |
||
4020 |
isVariable |
|
4021 |
"return true if the receiver has indexed instance variables, |
|
4022 |
false otherwise." |
|
4023 |
||
4024 |
^ self class isVariable |
|
4025 |
! |
|
4026 |
||
4027 |
isView |
|
4028 |
"return true, if the receiver is some kind of view; |
|
4029 |
false is returned here - the method is only redefined in View." |
|
4030 |
||
4031 |
^ false |
|
4032 |
! |
|
4033 |
||
4034 |
respondsTo:aSelector |
|
4035 |
"return true, if the receiver implements a method with selector equal |
|
4036 |
to aSelector; i.e. if there is a method for aSelector in either the |
|
4037 |
receivers class or one of its superclasses. |
|
4038 |
||
4039 |
Notice, that this does not imply, that such a message can be sent without |
|
4040 |
an error being raised. For example, an implementation could send |
|
4041 |
#shouldNotImplement or #subclassResponsibility." |
|
4042 |
||
4043 |
" |
|
4044 |
should we go via the cache, or search (by class) ? |
|
4045 |
The first is faster, most of the time; while the 2nd fills |
|
4046 |
the cache with useless data if this is sent in a loop over all objects. |
|
4047 |
For now, use the cache ... |
|
4048 |
" |
|
4049 |
%{ /* NOCONTEXT */ |
|
4050 |
||
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
4051 |
if (__lookup(__Class(self), aSelector) == nil) { |
783 | 4052 |
RETURN ( false ); |
4053 |
} |
|
4054 |
RETURN ( true ); |
|
4055 |
%} |
|
4056 |
. |
|
4057 |
" |
|
4058 |
^ self class canUnderstand:aSelector |
|
4059 |
" |
|
4060 |
||
4061 |
"'aString' respondsTo:#+" |
|
4062 |
"'aString' respondsTo:#," |
|
4063 |
"'aString' respondsTo:#collect:" |
|
4064 |
! |
|
4065 |
||
4066 |
respondsToArithmetic |
|
4067 |
"return true, if the receiver responds to arithmetic messages. |
|
4068 |
false is returned here - the method is redefined in ArithmeticValue." |
|
4069 |
||
4070 |
^ false |
|
4071 |
! |
|
4072 |
||
4073 |
size |
|
4074 |
"return the number of the receivers indexed instance variables; |
|
4075 |
this method may be redefined in subclasses" |
|
4076 |
||
4077 |
^ self basicSize |
|
4078 |
! |
|
4079 |
||
4080 |
species |
|
4081 |
"return a class which is similar to (or the same as) the receivers class. |
|
4082 |
This is used to create an appropriate object when creating derived |
|
4083 |
copies in the collection classes (sometimes redefined)." |
|
4084 |
||
4085 |
^ self class |
|
4086 |
! |
|
4087 |
||
4088 |
yourself |
|
4089 |
"return the receiver - used for cascades to return self at the end" |
|
4090 |
||
4091 |
^ self |
|
4092 |
! ! |
|
4093 |
||
4094 |
!Object methodsFor:'secure message sending'! |
|
4095 |
||
4096 |
askFor:aSelector |
|
4097 |
"try to send the receiver the message, aSelector. |
|
4098 |
If it does not understand it, return false. Otherwise |
|
4099 |
the real value returned. |
|
4100 |
Useful to send messages such as: 'isColor' to unknown |
|
4101 |
receivers." |
|
4102 |
||
4103 |
^ self perform:aSelector ifNotUnderstood:[false] |
|
4104 |
||
4105 |
" |
|
4106 |
1 askFor:#isColor |
|
4107 |
" |
|
4108 |
! |
|
4109 |
||
4110 |
perform:aSelector ifNotUnderstood:exceptionBlock |
|
4111 |
"try to send message aSelector to the receiver. |
|
4112 |
If its understood, return the methods returned value, |
|
4113 |
otherwise return the value of the exceptionBlock" |
|
4114 |
||
4115 |
|val| |
|
4116 |
||
4117 |
MessageNotUnderstoodSignal handle:[:ex | |
|
4118 |
^ exceptionBlock value |
|
4119 |
] do:[ |
|
4120 |
val := self perform:aSelector |
|
4121 |
]. |
|
4122 |
^ val |
|
4123 |
||
4124 |
" |
|
4125 |
1.2345 perform:#foo ifNotUnderstood:['sorry'] |
|
4126 |
" |
|
1 | 4127 |
! |
4128 |
||
783 | 4129 |
perform:aSelector with:argument ifNotUnderstood:exceptionBlock |
4130 |
"try to send message aSelector to the receiver. |
|
4131 |
If its understood, return the methods returned value, |
|
4132 |
otherwise return the value of the exceptionBlock" |
|
4133 |
||
4134 |
|val| |
|
4135 |
||
4136 |
MessageNotUnderstoodSignal handle:[:ex | |
|
4137 |
^ exceptionBlock value |
|
4138 |
] do:[ |
|
4139 |
val := self perform:aSelector with:argument |
|
4140 |
]. |
|
4141 |
^ val |
|
4142 |
||
4143 |
" |
|
4144 |
|unknown| |
|
4145 |
||
4146 |
unknown := 1. |
|
4147 |
(unknown perform:#+ with:2 ifNotUnderstood:['sorry']) printNewline. |
|
4148 |
unknown := 'high there'. |
|
4149 |
(unknown perform:#+ with:2 ifNotUnderstood:['sorry']) printNewline. |
|
4150 |
" |
|
4151 |
! ! |
|
4152 |
||
4153 |
!Object methodsFor:'special queries'! |
|
4154 |
||
4155 |
allOwners |
|
4156 |
"return a collection of all objects referencing the receiver" |
|
4157 |
||
4158 |
^ ObjectMemory whoReferences:self |
|
4159 |
! |
|
4160 |
||
4161 |
references:anObject |
|
4162 |
"return true, if the receiver refers to the argument, anObject. |
|
4163 |
- for debugging only" |
|
4164 |
||
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4165 |
"/ |myClass |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4166 |
"/ numInst "{ Class: SmallInteger }" | |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4167 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4168 |
%{ /* NOCONTEXT */ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4169 |
OBJ cls, flags; |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4170 |
int nInsts, i; |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4171 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4172 |
if (! __isNonNilObject(self)) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4173 |
RETURN (false); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4174 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4175 |
|
783 | 4176 |
/* |
4177 |
* a little optimization: use the fact that all old objects |
|
4178 |
* refering to a new object are on the remSet; if I am not, |
|
4179 |
* a trivial reject is possible, if anObject is a newbee |
|
4180 |
*/ |
|
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4181 |
if (__isNonNilObject(anObject)) { |
783 | 4182 |
if ((__qSpace(self) <= OLDSPACE) && !__isRemembered(self)) { |
4183 |
int spc; |
|
4184 |
||
4185 |
if (((spc = __qSpace(anObject)) == NEWSPACE) || (spc == SURVSPACE)) { |
|
4186 |
RETURN (false); |
|
4187 |
} |
|
4188 |
} |
|
4189 |
} |
|
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4190 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4191 |
cls = __qClass(self); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4192 |
if (cls == anObject) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4193 |
RETURN (true); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4194 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4195 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4196 |
flags = __ClassInstPtr(cls)->c_flags; |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4197 |
if (((INT)flags & _MASKSMALLINT(ARRAYMASK)) == _MASKSMALLINT(POINTERARRAY)) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4198 |
nInsts = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4199 |
} else { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4200 |
nInsts = __intVal(__ClassInstPtr(cls)->c_ninstvars); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4201 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4202 |
if (! nInsts) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4203 |
RETURN (false); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4204 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4205 |
for (i=0; i<nInsts; i++) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4206 |
if (_InstPtr(self)->i_instvars[i] == anObject) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4207 |
RETURN (true); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4208 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4209 |
} |
783 | 4210 |
%}. |
4211 |
||
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4212 |
"/ myClass := self class. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4213 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4214 |
"/ "check the class" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4215 |
"/ (myClass == anObject) ifTrue:[^ true]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4216 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4217 |
"/ "check the instance variables" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4218 |
"/ numInst := myClass instSize. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4219 |
"/ 1 to:numInst do:[:i | |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4220 |
"/ ((self instVarAt:i) == anObject) ifTrue:[^ true] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4221 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4222 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4223 |
"/ "check the indexed variables" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4224 |
"/ myClass isVariable ifTrue:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4225 |
"/ myClass isPointers ifFalse:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4226 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4227 |
"/ "/ we could argue about the following unconditional return: |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4228 |
"/ "/ it says that a non pointer array never has a reference to the |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4229 |
"/ "/ corresponding object - not mimicing a reference to a copy of the |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4230 |
"/ "/ integer. However, it avoids useless searches in huge byteArray |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4231 |
"/ "/ like objects when searching for owners. If in doubt, remove it. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4232 |
"/ "/ A consequence of the return below is that #[1 2 3] will say that it |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4233 |
"/ "/ does not refer to the number 2 (think of keeping a copy instead) |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4234 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4235 |
"/ ^ false. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4236 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4237 |
"/ "/ alternative: |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4238 |
"/ "/ anObject isNumber ifFalse:[^ false]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4239 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4240 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4241 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4242 |
"/ "/ because arrays are so common, and those have a highly tuned |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4243 |
"/ "/ idenitytIndex method, use it |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4244 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4245 |
"/ myClass == Array ifTrue:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4246 |
"/ ^ (self identityIndexOf:anObject) ~~ 0 |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4247 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4248 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4249 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4250 |
"/ "/ otherwise, do it the slow way |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4251 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4252 |
"/ numInst := self basicSize. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4253 |
"/ 1 to:numInst do:[:i | |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4254 |
"/ ((self basicAt:i) == anObject) ifTrue:[^ true] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4255 |
"/ ] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4256 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4257 |
|
783 | 4258 |
^ false |
4259 |
||
4260 |
" |
|
4261 |
|v| |
|
4262 |
||
4263 |
v := View new initialize. |
|
4264 |
v references:Display. |
|
4265 |
" |
|
4266 |
! |
|
4267 |
||
4268 |
referencesDerivedInstanceOf:aClass |
|
4269 |
"return true, if the receiver refers to an instance of |
|
4270 |
the argument, aClass or its subclass. This method exists |
|
4271 |
to support searching for users of a class." |
|
4272 |
||
4273 |
|myClass |
|
4274 |
numInst "{ Class: SmallInteger }" | |
|
4275 |
||
4276 |
myClass := self class. |
|
4277 |
||
4278 |
"check the class" |
|
4279 |
(myClass isKindOf:aClass) ifTrue:[^ true]. |
|
4280 |
||
4281 |
"check the instance variables" |
|
4282 |
numInst := myClass instSize. |
|
4283 |
1 to:numInst do:[:i | |
|
4284 |
((self instVarAt:i) isKindOf:aClass) ifTrue:[^ true] |
|
4285 |
]. |
|
4286 |
||
4287 |
"check the indexed variables" |
|
4288 |
myClass isVariable ifTrue:[ |
|
4289 |
myClass isPointers ifFalse:[ |
|
4290 |
"no need to search in non pointer fields" |
|
4291 |
((aClass == Number) or:[aClass isSubclassOf:Number]) ifFalse:[^ false]. |
|
4292 |
]. |
|
4293 |
numInst := self basicSize. |
|
4294 |
1 to:numInst do:[:i | |
|
4295 |
((self basicAt:i) isKindOf:aClass) ifTrue:[^ true] |
|
4296 |
] |
|
4297 |
]. |
|
4298 |
^ false |
|
4299 |
||
4300 |
" |
|
4301 |
(1 @ 3.4) referencesDerivedInstanceOf:Number |
|
4302 |
(1 @ 3.4) referencesDerivedInstanceOf:Array |
|
4303 |
View new initialize referencesDerivedInstanceOf:DeviceWorkstation |
|
4304 |
" |
|
4305 |
! |
|
4306 |
||
4307 |
referencesInstanceOf:aClass |
|
4308 |
"return true, if the receiver refers to an instance of |
|
4309 |
the argument, aClass.This method exists |
|
4310 |
to support searching for users of a class." |
|
4311 |
||
4312 |
|myClass |
|
4313 |
numInst "{ Class: SmallInteger }" | |
|
4314 |
||
4315 |
myClass := self class. |
|
4316 |
||
4317 |
"check the class" |
|
4318 |
(myClass isMemberOf:aClass) ifTrue:[^ true]. |
|
4319 |
||
4320 |
"check the instance variables" |
|
4321 |
numInst := myClass instSize. |
|
4322 |
1 to:numInst do:[:i | |
|
4323 |
((self instVarAt:i) isMemberOf:aClass) ifTrue:[^ true] |
|
4324 |
]. |
|
4325 |
||
4326 |
"check the indexed variables" |
|
4327 |
myClass isVariable ifTrue:[ |
|
4328 |
myClass isPointers ifFalse:[ |
|
4329 |
"no need to search in non-pointer indexed fields" |
|
4330 |
myClass isLongs ifTrue:[ |
|
4331 |
(aClass == SmallInteger or:[aClass == LargeInteger]) ifFalse:[^ false]. |
|
4332 |
] ifFalse:[ |
|
4333 |
myClass isFloatsOrDoubles ifTrue:[^ aClass == Float]. |
|
4334 |
^ aClass == SmallInteger |
|
4335 |
] |
|
4336 |
]. |
|
4337 |
numInst := self basicSize. |
|
4338 |
1 to:numInst do:[:i | |
|
4339 |
((self basicAt:i) isMemberOf:aClass) ifTrue:[^ true] |
|
4340 |
] |
|
4341 |
]. |
|
4342 |
^ false |
|
4343 |
||
4344 |
" |
|
4345 |
(1 @ 3.4) referencesInstanceOf:Float |
|
4346 |
(1 @ 3.4) referencesInstanceOf:Fraction |
|
4347 |
View new initialize referencesInstanceOf:(Display class) |
|
4348 |
" |
|
1 | 4349 |
! ! |
783 | 4350 |
|
4351 |
!Object methodsFor:'system primitives'! |
|
4352 |
||
4353 |
become:anotherObject |
|
4354 |
"make all references to the receiver become references to anotherObject |
|
859 | 4355 |
and vice-versa. Notice the vice-versa; see #becomeSameAs: for a one-way become. |
4356 |
This can be a very dangerous operation - be warned. |
|
861 | 4357 |
In general, using #become: should be avoided if possible, since it may |
4358 |
produce many strange effects (think of hashing in Sets, Dictionaries etc.). |
|
4359 |
||
4360 |
This may also be an expensive (i.e. slow) operation, |
|
783 | 4361 |
since in the worst case, the whole memory has to be searched for |
4362 |
references to the two objects (although the primitive tries hard to |
|
4363 |
limit the search, for acceptable performance in most cases). |
|
4364 |
This method fails, if the receiver or the argument is a SmallInteger |
|
4365 |
or nil, or is a context of a living method (i.e. one that has not already |
|
4366 |
returned). |
|
859 | 4367 |
(notice that #become: is not used heavily by the system |
783 | 4368 |
- the Collection-classes have been rewritten to not use it.)" |
4369 |
%{ |
|
859 | 4370 |
if (__primBecome(self, anotherObject COMMA_CON)) { |
783 | 4371 |
RETURN ( self ); |
859 | 4372 |
} |
4373 |
%}. |
|
783 | 4374 |
self primitiveFailed |
4375 |
! |
|
4376 |
||
4377 |
becomeNil |
|
4378 |
"make all references to the receiver become nil - effectively getting |
|
859 | 4379 |
rid of the receiver. |
4380 |
This can be a very dangerous operation - be warned. |
|
4381 |
||
4382 |
This may be an expensive (i.e. slow) operation. |
|
783 | 4383 |
The receiver may not be a SmallInteger or a context of a living method." |
4384 |
||
4385 |
%{ |
|
859 | 4386 |
if (__primBecomeNil(self COMMA_CON )) { |
783 | 4387 |
RETURN ( nil ); |
859 | 4388 |
} |
4389 |
%}. |
|
4390 |
self primitiveFailed |
|
4391 |
! |
|
4392 |
||
4393 |
becomeSameAs:anotherObject |
|
4394 |
"make all references to the receiver become references to anotherObject |
|
861 | 4395 |
but NOT vice versa (as done in #become:). |
859 | 4396 |
This can be a very dangerous operation - be warned. |
861 | 4397 |
In general, using #become: should be avoided if possible, since it may |
4398 |
produce many strange effects (think of hashing in Sets, Dictionaries etc.). |
|
4399 |
||
4400 |
This may also be an expensive (i.e. slow) operation, |
|
859 | 4401 |
since in the worst case, the whole memory has to be searched for |
4402 |
references to the two objects (although the primitive tries hard to |
|
4403 |
limit the search, for acceptable performance in most cases). |
|
4404 |
This method fails, if the receiver or the argument is a SmallInteger |
|
4405 |
or nil, or is a context of a living method (i.e. one that has not already returned)." |
|
4406 |
%{ |
|
4407 |
if (__primBecomeSameAs(self, anotherObject COMMA_CON)) { |
|
4408 |
RETURN ( self ); |
|
4409 |
} |
|
4410 |
%}. |
|
783 | 4411 |
self primitiveFailed |
4412 |
! |
|
4413 |
||
4414 |
changeClassTo:otherClass |
|
4415 |
"changes the class of the receiver to the argument, otherClass. |
|
4416 |
This is only allowed (possible), if the receivers class and the argument |
|
4417 |
have the same structure (i.e. number of named instance variables and |
|
4418 |
type of indexed instance variables). |
|
4419 |
If the structures do not match, or any of the original class or new class |
|
4420 |
is UndefinedObject or a Smallinteger, a primitive error is triggered." |
|
4421 |
||
4422 |
|myClass ok| |
|
4423 |
||
4424 |
"check for UndefinedObject/SmallInteger receiver or newClass" |
|
4425 |
%{ |
|
4426 |
if (__isNonNilObject(self) |
|
4427 |
&& __isNonNilObject(otherClass) |
|
4428 |
&& (otherClass != UndefinedObject) |
|
4429 |
&& (otherClass != SmallInteger)) { |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4430 |
ok = true; |
783 | 4431 |
} else { |
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4432 |
ok = false; |
783 | 4433 |
} |
4434 |
%}. |
|
4435 |
ok ifTrue:[ |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4436 |
ok := false. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4437 |
myClass := self class. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4438 |
myClass flags == otherClass flags ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4439 |
myClass instSize == otherClass instSize ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4440 |
"same instance layout and types: its ok to do it" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4441 |
ok := true. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4442 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4443 |
myClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4444 |
myClass isVariable ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4445 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4446 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4447 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4448 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4449 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4450 |
myClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4451 |
"if newClass is a variable class, with instSize <= my instsize, |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4452 |
we can do it (effectively mapping additional instvars into the |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4453 |
variable part) - usefulness is questionable, though" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4454 |
|
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4455 |
otherClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4456 |
otherClass isVariable ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4457 |
otherClass instSize <= (myClass instSize + self basicSize) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4458 |
ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4459 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4460 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4461 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4462 |
otherClass instSize == (myClass instSize + self basicSize) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4463 |
ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4464 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4465 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4466 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4467 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4468 |
"it does not make sense to convert pointers to bytes ..." |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4469 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4470 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4471 |
"does it make sense, to convert bits ?" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4472 |
"could allow byteArray->wordArray->longArray->floatArray->doubleArray here ..." |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4473 |
(myClass isBits and:[otherClass isBits]) ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4474 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4475 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4476 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4477 |
] |
783 | 4478 |
]. |
4479 |
ok ifTrue:[ |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4480 |
"now, change the receivers class ..." |
783 | 4481 |
%{ |
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4482 |
__qClass(self) = otherClass; |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4483 |
__STORE(self, otherClass); |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4484 |
RETURN ( self ); |
783 | 4485 |
%}. |
4486 |
]. |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4487 |
|
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4488 |
" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4489 |
the receiver cannot be represented as a instance of |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4490 |
the desired class. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4491 |
For example, you cannot change a bitInstance (byteArray etc.) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4492 |
into a pointer object and vice versa. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4493 |
" |
783 | 4494 |
self primitiveFailed |
4495 |
! |
|
4496 |
||
4497 |
changeClassToThatOf:anObject |
|
4498 |
"changes the class of the receiver to that of the argument, anObject. |
|
4499 |
This is only allowed (possible), if the receivers class and the arguments |
|
4500 |
class have the same structure (i.e. number of named instance variables and |
|
4501 |
type of indexed instance variables). If the structures do not match, or any |
|
4502 |
of the objects is nil or a Smallinteger, a primitive error is triggered." |
|
4503 |
||
4504 |
self changeClassTo:(anObject class) |
|
4505 |
! ! |
|
4506 |
||
4507 |
!Object methodsFor:'user interaction & notifications'! |
|
4508 |
||
4509 |
activityNotification:aString |
|
4510 |
"this can be sent from deeply nested methods, which are going to perform |
|
4511 |
some long-time activity. |
|
4512 |
If there is a handler for the ActivityNotificationSignal signal, that one is raised, |
|
4513 |
passing the argument. The handler should show this message whereever it likes, |
|
4514 |
and proceed. If there is no handler, this is simply ignored. |
|
4515 |
||
4516 |
This is very useful to pass busy messages up to some higher level (typically a view) |
|
4517 |
which likes to display that message in its label or a busy-box. |
|
4518 |
It could also be put into some logfile or printed on the standard output/error." |
|
4519 |
||
4520 |
ActivityNotificationSignal isHandled ifTrue:[ |
|
861 | 4521 |
^ ActivityNotificationSignal raiseRequestWith:self errorString:aString |
783 | 4522 |
]. |
4523 |
||
4524 |
" |
|
4525 |
nil activityNotification:'hello there' |
|
4526 |
self activityNotification:'hello there' |
|
4527 |
" |
|
4528 |
||
4529 |
" |
|
4530 |
ActivityNotificationSignal handle:[:ex | |
|
861 | 4531 |
ex errorString printNL. |
4532 |
ex proceed. |
|
783 | 4533 |
] do:[ |
861 | 4534 |
'hello' printNL. |
4535 |
self activityNotification:'doing some long time computation'. |
|
4536 |
'world' printNL. |
|
783 | 4537 |
] |
4538 |
" |
|
4539 |
||
4540 |
"Modified: 16.12.1995 / 18:23:42 / cg" |
|
4541 |
! |
|
4542 |
||
4543 |
confirm:aString |
|
4544 |
"launch a confirmer, which allows user to enter yes or no. |
|
4545 |
return true for yes, false for no" |
|
4546 |
||
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4547 |
" |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4548 |
on systems without GUI, or during startup, output a message |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4549 |
and return true (as if yes was answered) |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4550 |
Q: should we ask user by reading Stdin ? |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4551 |
" |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4552 |
Smalltalk isInitialized ifFalse:[ |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4553 |
'confirmation: ' print. aString print. |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4554 |
'continue, assuming <yes>' printNL. |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4555 |
^ true |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4556 |
]. |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
4557 |
|
783 | 4558 |
Dialog isNil ifTrue:[ |
4559 |
Transcript showCr:aString. |
|
4560 |
Transcript showCr:'continue, assuming <yes>'. |
|
4561 |
^ true |
|
4562 |
]. |
|
4563 |
Dialog autoload. "in case its autoloaded" |
|
4564 |
^ Dialog confirm:aString |
|
4565 |
||
4566 |
" |
|
4567 |
nil confirm:'hello' |
|
4568 |
self confirm:'hello' |
|
4569 |
" |
|
4570 |
! |
|
4571 |
||
4572 |
errorNotify:aString |
|
4573 |
"launch a Notifier, showing top stack, telling user something |
|
4574 |
and give a chance to enter debugger." |
|
4575 |
||
4576 |
|info con sender| |
|
4577 |
||
891 | 4578 |
Smalltalk isInitialized ifFalse:[ |
4579 |
'errorNotification: ' print. aString printNL. |
|
4580 |
^ self |
|
4581 |
]. |
|
4582 |
||
783 | 4583 |
Dialog isNil ifTrue:[ |
4584 |
" |
|
4585 |
on systems without GUI, simply show |
|
4586 |
the message on the Transcript. |
|
4587 |
" |
|
4588 |
Transcript showCr:aString. |
|
4589 |
^ self |
|
4590 |
]. |
|
4591 |
Dialog autoload. "in case its autoloaded" |
|
4592 |
||
4593 |
con := sender := thisContext sender. |
|
4594 |
info := aString , Character cr asString , Character cr asString. |
|
4595 |
1 to:5 do:[:n | |
|
4596 |
con notNil ifTrue:[ |
|
4597 |
info := info , con printString , Character cr asString. |
|
4598 |
con := con sender |
|
4599 |
] |
|
4600 |
]. |
|
4601 |
||
4602 |
(Dialog choose:info |
|
4603 |
labels:#('proceed' 'debug') |
|
4604 |
values:#(#proceed #debug) |
|
4605 |
default:#debug) == #debug |
|
4606 |
ifTrue:[ |
|
4607 |
Debugger enter:sender withMessage:aString |
|
4608 |
] |
|
4609 |
||
4610 |
" |
|
4611 |
nil errorNotify:'hello there' |
|
4612 |
self errorNotify:'hello there' |
|
4613 |
" |
|
4614 |
! |
|
4615 |
||
4616 |
information:aString |
|
4617 |
"launch an InfoBox, telling user something. |
|
4618 |
These info-boxes can be suppressed by handling the |
|
4619 |
UserNotification- or InformationSignal and proceeding in the handler." |
|
4620 |
||
4621 |
InformationSignal isHandled ifTrue:[ |
|
4622 |
^ InformationSignal raiseRequestWith:self errorString:aString |
|
4623 |
]. |
|
4624 |
self notify:aString |
|
4625 |
||
4626 |
" |
|
4627 |
nil information:'hello there' |
|
4628 |
self information:'hello there' |
|
4629 |
" |
|
4630 |
||
4631 |
" |
|
4632 |
InformationSignal handle:[:ex | |
|
4633 |
'no box popped' printNL. |
|
4634 |
ex proceed. |
|
4635 |
] do:[ |
|
4636 |
'hello' printNL. |
|
4637 |
self information:'some info'. |
|
4638 |
'world' printNL. |
|
4639 |
] |
|
4640 |
" |
|
4641 |
||
4642 |
"Modified: 24.11.1995 / 22:29:49 / cg" |
|
4643 |
! |
|
4644 |
||
4645 |
notify:aString |
|
4646 |
"launch a Notifier, telling user something. |
|
4647 |
Use #information: for ignorable messages." |
|
4648 |
||
891 | 4649 |
Smalltalk isInitialized ifFalse:[ |
4650 |
'information: ' print. aString printNL. |
|
4651 |
^ self |
|
4652 |
]. |
|
4653 |
||
783 | 4654 |
Dialog isNil ifTrue:[ |
4655 |
" |
|
4656 |
on systems without GUI, simply show |
|
4657 |
the message on the Transcript. |
|
4658 |
" |
|
4659 |
Transcript showCr:aString. |
|
4660 |
^ self |
|
4661 |
]. |
|
4662 |
Dialog autoload. "in case its autoloaded" |
|
4663 |
Dialog information:aString |
|
4664 |
||
4665 |
" |
|
4666 |
nil notify:'hello there' |
|
4667 |
self notify:'hello there' |
|
4668 |
" |
|
4669 |
! |
|
4670 |
||
4671 |
warn:aString |
|
4672 |
"launch a WarningBox, telling user something. |
|
4673 |
These warn-boxes can be suppressed by handling the |
|
4674 |
UserNotification- or WarningSignal and proceeding in the handler." |
|
4675 |
||
4676 |
WarningSignal isHandled ifTrue:[ |
|
4677 |
^ WarningSignal raiseRequestWith:self errorString:aString |
|
4678 |
]. |
|
4679 |
||
891 | 4680 |
Smalltalk isInitialized ifFalse:[ |
4681 |
'warning: ' print. aString printNL. |
|
4682 |
^ self |
|
4683 |
]. |
|
4684 |
||
783 | 4685 |
Dialog isNil ifTrue:[ |
4686 |
" |
|
4687 |
on systems without GUI, simply show |
|
4688 |
the message on the Transcript. |
|
4689 |
" |
|
4690 |
Transcript showCr:aString. |
|
4691 |
^ self |
|
4692 |
]. |
|
4693 |
Dialog autoload. "in case its autoloaded" |
|
4694 |
Dialog warn:aString |
|
4695 |
||
4696 |
" |
|
4697 |
nil warn:'hello there' |
|
4698 |
self warn:'hello there' |
|
4699 |
" |
|
4700 |
||
4701 |
" |
|
4702 |
WarningSignal handle:[:ex | |
|
4703 |
ex proceed. |
|
4704 |
] do:[ |
|
4705 |
'hello' printNL. |
|
4706 |
self warn:'some info'. |
|
4707 |
'world' printNL. |
|
4708 |
] |
|
4709 |
" |
|
4710 |
! ! |
|
4711 |
||
4712 |
!Object class methodsFor:'documentation'! |
|
4713 |
||
4714 |
version |
|
1129 | 4715 |
^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.108 1996-03-27 17:12:39 stefan Exp $' |
783 | 4716 |
! ! |
4717 |
Object initialize! |