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