author | Stefan Vogel <sv@exept.de> |
Tue, 17 Mar 2009 17:00:12 +0100 | |
changeset 11635 | 04be8c0e7a03 |
parent 10945 | 2d0596240727 |
child 11821 | df8c99edbf45 |
child 17711 | 39faaaf888b4 |
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 |
" |
|
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
13 |
|
1 | 14 |
Object subclass:#UndefinedObject |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
15 |
instanceVariableNames:'' |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
16 |
classVariableNames:'CreateMinimumProtocolInNewSubclassQuery' |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
17 |
poolDictionaries:'' |
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
18 |
category:'Kernel-Objects' |
1 | 19 |
! |
20 |
||
88 | 21 |
!UndefinedObject class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 26 |
All Rights Reserved |
1 | 27 |
|
88 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
1303 | 39 |
there is only one instance of this class: nil, |
40 |
representing an undefined or otherwise unspecified object. |
|
88 | 41 |
|
42 |
All instance variables, array elements and even method/block local |
|
43 |
variables are initially set to nil. |
|
1303 | 44 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
45 |
Since in Smalltalk/X (and in other smalltalks), nil is represented by |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
46 |
a special pointer value (NULL), there can be only one instance of UndefinedObject, |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
47 |
and no subclassing is possible. |
1303 | 48 |
(to be exact: subclassing UndefinedObject is technically possible, |
49 |
but instances of it would not be recognized as being nil |
|
50 |
- therefore, subclassing is blocked and an error is raised when it is tried) |
|
51 |
||
52 |
For advanced users: |
|
53 |
Beside the above role, nil can be subclassed (!!). |
|
54 |
This creates a class which inherits no protocol whatsoever - not even |
|
55 |
the basic interfaces as defined by the Object class. Subclasses of nil |
|
56 |
are useful if all messages send to instances should trap into the |
|
57 |
#doesNotUnderstand: method. For example, proxy objects are typically defined |
|
58 |
this way. |
|
1294 | 59 |
|
60 |
[author:] |
|
61 |
Claus Gittinger |
|
88 | 62 |
" |
63 |
! ! |
|
1 | 64 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
65 |
!UndefinedObject class methodsFor:'initialization'! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
66 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
67 |
initialize |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
68 |
CreateMinimumProtocolInNewSubclassQuery isNil ifTrue:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
69 |
CreateMinimumProtocolInNewSubclassQuery := QuerySignal new. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
70 |
CreateMinimumProtocolInNewSubclassQuery nameClass:self message:#createMinimumProtocolInNewSubclassQuery. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
71 |
CreateMinimumProtocolInNewSubclassQuery defaultAnswer:false. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
72 |
]. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
73 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
74 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
75 |
UndefinedObject initialize |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
76 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
77 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
78 |
"Created: 3.1.1997 / 15:02:40 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
79 |
"Modified: 3.1.1997 / 15:18:33 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
80 |
! ! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
81 |
|
1 | 82 |
!UndefinedObject class methodsFor:'instance creation'! |
83 |
||
84 |
basicNew |
|
85 |
"catch new - there MUST be only one nil in the system" |
|
86 |
||
87 |
^ nil |
|
88 |
! |
|
89 |
||
90 |
basicNew:size |
|
91 |
"catch new - there MUST be only one nil in the system" |
|
92 |
||
93 |
^ nil |
|
94 |
! ! |
|
95 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
96 |
!UndefinedObject class methodsFor:'Signal constants'! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
97 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
98 |
createMinimumProtocolInNewSubclassQuery |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
99 |
"return the signal used to ask if the minimum required protocol |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
100 |
should be created for nil subclasses. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
101 |
By default, this is not done, however, the browser answers true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
102 |
here, to avoid big trouble with nil subclasses which do not define |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
103 |
some methods which the inspector needs." |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
104 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
105 |
^ CreateMinimumProtocolInNewSubclassQuery |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
106 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
107 |
"Created: 3.1.1997 / 15:05:48 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
108 |
"Modified: 3.1.1997 / 15:06:15 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
109 |
! ! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
110 |
|
51 | 111 |
!UndefinedObject class methodsFor:'queries'! |
112 |
||
113 |
canBeSubclassed |
|
114 |
"return true, if its allowed to create subclasses of the receiver. |
|
3914 | 115 |
Return false here - since it is NOT possible for UndefinedObject. |
116 |
(due to the representation of nil as a 0-pointer)" |
|
51 | 117 |
|
118 |
^ false |
|
3914 | 119 |
|
120 |
"Modified: / 5.11.1998 / 16:11:43 / cg" |
|
2672
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
121 |
! |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
122 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
123 |
hasImmediateInstances |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
124 |
"return true if this class has immediate instances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
125 |
i.e. if the instances are represented in the pointer itself and |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
126 |
no real object header/storage is used for the object. |
2672
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
127 |
Redefined from Behavior" |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
128 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
129 |
^ true |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
130 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
131 |
"Created: 3.6.1997 / 12:01:39 / cg" |
4321 | 132 |
! |
133 |
||
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
134 |
hasSharedInstances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
135 |
"return true if this class has shared instances, that is, instances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
136 |
with the same value are identical. |
4654 | 137 |
True returned here - there is only one nil." |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
138 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
139 |
^ true |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
140 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
141 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
142 |
! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
143 |
|
4321 | 144 |
isBuiltInClass |
145 |
"return true, if this class is known by the run-time-system, |
|
146 |
i.e. you cannot add/remove instance variables without recompiling |
|
147 |
the VM. |
|
148 |
Here, true is returned for myself, false for subclasses." |
|
149 |
||
150 |
^ self == UndefinedObject |
|
151 |
||
51 | 152 |
! ! |
153 |
||
5699 | 154 |
|
2416 | 155 |
!UndefinedObject methodsFor:'converting'! |
156 |
||
8305 | 157 |
asBoolean |
158 |
^ false |
|
159 |
! |
|
160 |
||
2416 | 161 |
literalArrayEncoding |
162 |
"encode myself as an array literal, from which a copy of the receiver |
|
163 |
can be reconstructed with #decodeAsLiteralArray." |
|
164 |
||
165 |
^ self |
|
166 |
||
167 |
"Created: 25.2.1997 / 19:18:47 / cg" |
|
168 |
! ! |
|
169 |
||
695 | 170 |
!UndefinedObject methodsFor:'copying'! |
171 |
||
172 |
copy |
|
173 |
"return a shallow copy of myself |
|
174 |
- since there is only one nil in the system return self" |
|
175 |
||
176 |
^ self |
|
177 |
! |
|
178 |
||
179 |
deepCopy |
|
180 |
"return a deep copy of myself |
|
181 |
- since there is only one nil in the system return self" |
|
182 |
||
183 |
^ self |
|
184 |
! |
|
185 |
||
10945 | 186 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
695 | 187 |
"return a deep copy of myself |
8383 | 188 |
- since there is only one nil in the system, return self" |
695 | 189 |
|
190 |
^ self |
|
191 |
! |
|
192 |
||
193 |
shallowCopy |
|
194 |
"return a shallow copy of myself |
|
195 |
- since there is only one nil in the system return self" |
|
196 |
||
197 |
^ self |
|
198 |
! |
|
199 |
||
200 |
simpleDeepCopy |
|
201 |
"return a deep copy of myself |
|
202 |
- since there is only one nil in the system return self" |
|
203 |
||
204 |
^ self |
|
205 |
! ! |
|
206 |
||
3166 | 207 |
!UndefinedObject methodsFor:'dependents access'! |
208 |
||
209 |
addDependent:someObject |
|
210 |
"raise an error here - nil may not have dependents" |
|
211 |
||
4530
793b116fef3e
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
4339
diff
changeset
|
212 |
self error:'nil may not have dependents' mayProceed:true |
793b116fef3e
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
4339
diff
changeset
|
213 |
|
3166 | 214 |
! |
215 |
||
3183 | 216 |
dependents |
217 |
"nil has no dependents" |
|
218 |
||
219 |
^#() |
|
220 |
! |
|
221 |
||
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
222 |
release |
3166 | 223 |
"ignored here - nil has no dependents" |
3183 | 224 |
! |
3166 | 225 |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
226 |
removeDependent:someObject |
3183 | 227 |
"ignored here - nil has no dependents" |
3166 | 228 |
! ! |
229 |
||
1 | 230 |
!UndefinedObject methodsFor:'error catching'! |
231 |
||
232 |
basicAt:index |
|
233 |
"catch array access - its illegal |
|
234 |
defined here since basicAt: in Object ommits the nil-check" |
|
235 |
||
236 |
^ self notIndexed |
|
237 |
! |
|
238 |
||
239 |
basicAt:index put:anObject |
|
240 |
"catch array access - its illegal |
|
241 |
defined here since basicAt:put: in Object ommits the nil-check" |
|
242 |
||
243 |
^ self notIndexed |
|
244 |
! ! |
|
245 |
||
246 |
!UndefinedObject methodsFor:'printing & storing'! |
|
247 |
||
63 | 248 |
printOn:aStream |
249 |
"append a printed representation of the receiver to the |
|
250 |
argument, aStream" |
|
251 |
||
252 |
aStream nextPutAll:'nil' |
|
253 |
! |
|
254 |
||
695 | 255 |
printString |
256 |
"return a string for printing myself" |
|
257 |
||
258 |
^ 'nil' |
|
259 |
! |
|
260 |
||
63 | 261 |
storeOn:aStream |
262 |
"append a printed representation of the receiver to the |
|
263 |
argument, aStream, which allows reconstruction of it" |
|
264 |
||
265 |
^ self printOn:aStream |
|
695 | 266 |
! |
267 |
||
268 |
storeString |
|
269 |
"return a string for storing myself" |
|
270 |
||
271 |
^ 'nil' |
|
1 | 272 |
! ! |
2 | 273 |
|
5557 | 274 |
!UndefinedObject methodsFor:'queries'! |
275 |
||
276 |
basicSize |
|
277 |
"return the number of indexed instvars |
|
278 |
defined here since size in Object ommits the nil-check" |
|
279 |
||
280 |
^ 0 |
|
281 |
! |
|
282 |
||
283 |
size |
|
284 |
"return the number of indexed instvars |
|
285 |
defined here since size in Object ommits the nil-check" |
|
286 |
||
287 |
^ 0 |
|
288 |
! ! |
|
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
289 |
|
77 | 290 |
!UndefinedObject methodsFor:'subclass creation'! |
291 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
292 |
nilSubclass:action |
356 | 293 |
"common helper for subclass creation. |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
294 |
Creates a nil-superclass class. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
295 |
If the CreateMinimumProtocolInNewSubclassQuery answers true, |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
296 |
entries for the minimum required protocol (#class, #isBehavior |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
297 |
and #doesNotUnderstand:) are also automatically created. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
298 |
(this query is typically answered by the browser) |
356 | 299 |
These are required to avoid getting into deep trouble when |
300 |
inspecting or debugging instances of this new class. |
|
301 |
The methods get a modified source code to remind you that these |
|
302 |
methods were automatically generated." |
|
303 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
304 |
|newClass methodDict method| |
202 | 305 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
306 |
Class withoutUpdatingChangesDo:[ |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
307 |
newClass := action value |
77 | 308 |
]. |
309 |
newClass notNil ifTrue:[ |
|
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
310 |
newClass setSuperclass:nil. |
1803
754f9205b651
meta's superclass should be class - not Object.
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
311 |
newClass class setSuperclass:Class. |
356 | 312 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
313 |
newClass methodDictionary size == 0 ifTrue:[ |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
314 |
Class addChangeRecordForClass:newClass. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
315 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
316 |
CreateMinimumProtocolInNewSubclassQuery query |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
317 |
ifTrue:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
318 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
319 |
copy over method objects from Object |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
320 |
and modify the source code |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
321 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
322 |
methodDict := MethodDictionary new:3. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
323 |
#(#class #isBehavior #doesNotUnderstand:) do:[:sel| |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
324 |
method := (Object compiledMethodAt:sel) copy. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
325 |
method source: method source , ' |
356 | 326 |
" |
327 |
*** WARNING |
|
328 |
*** |
|
329 |
*** this method has been automatically created, |
|
330 |
*** since all nil-subclasses should respond to some minimum required |
|
331 |
*** protocol. |
|
332 |
*** |
|
333 |
*** Inspection and/or debugging of instances may not be possible, |
|
334 |
*** if you remove/change this method. |
|
335 |
" |
|
336 |
'. |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
337 |
methodDict at:sel put:method. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
338 |
"/ newClass addChangeRecordForMethod:method |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
339 |
]. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
340 |
newClass methodDictionary:methodDict. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
341 |
] |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
342 |
] |
77 | 343 |
]. |
344 |
^ newClass |
|
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
345 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
346 |
"Modified: / 3.1.1997 / 15:53:21 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
347 |
"Created: / 3.1.1997 / 16:00:34 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
348 |
"Modified: / 18.3.1999 / 18:29:58 / stefan" |
202 | 349 |
! |
350 |
||
9256 | 351 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool |
352 |
"create a new class which has nil as superclass |
|
353 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
|
354 |
||
355 |
^ self |
|
356 |
subclass:nameSymbol |
|
357 |
instanceVariableNames:instVarNameString |
|
358 |
classVariableNames:classVarString |
|
359 |
poolDictionaries:pool |
|
360 |
category:(Class defaultCategoryForSTVorVAGEClasses). |
|
361 |
! |
|
362 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
363 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
202 | 364 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
365 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
202 | 366 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
367 |
^ self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
368 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
369 |
Object class |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
370 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
371 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
372 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
373 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
374 |
variable:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
375 |
words:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
376 |
pointers:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
377 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
378 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
379 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
380 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
381 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
382 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
383 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
384 |
"Modified: / 3.1.1997 / 16:00:39 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
385 |
"Modified: / 18.3.1999 / 18:30:07 / stefan" |
695 | 386 |
! |
387 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
388 |
variableByteSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
695 | 389 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
390 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
695 | 391 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
392 |
^ self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
393 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
394 |
Object class |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
395 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
396 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
397 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
398 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
399 |
variable:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
400 |
words:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
401 |
pointers:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
402 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
403 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
404 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
405 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
406 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
407 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
408 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
409 |
"Modified: / 3.1.1997 / 16:00:42 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
410 |
"Modified: / 18.3.1999 / 18:30:11 / stefan" |
695 | 411 |
! |
77 | 412 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
413 |
variableSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
159 | 414 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
415 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
77 | 416 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
417 |
^ self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
418 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
419 |
Object class |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
420 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
421 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
422 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
423 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
424 |
variable:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
425 |
words:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
426 |
pointers:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
427 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
428 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
429 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
430 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
431 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
432 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
433 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
434 |
"Modified: / 3.1.1997 / 16:00:45 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
435 |
"Modified: / 18.3.1999 / 18:30:16 / stefan" |
695 | 436 |
! ! |
437 |
||
7262 | 438 |
!UndefinedObject methodsFor:'subclass creation-private'! |
5745 | 439 |
|
440 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:ownerClass |
|
441 |
"create a new private class which has nil as superclass |
|
442 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
|
443 |
||
444 |
^ self |
|
445 |
nilSubclass:[ |
|
446 |
Object class |
|
447 |
name:nameSymbol |
|
448 |
inEnvironment:ownerClass |
|
449 |
subclassOf:self |
|
450 |
instanceVariableNames:instVarNameString |
|
451 |
variable:false |
|
452 |
words:true |
|
453 |
pointers:true |
|
454 |
classVariableNames:classVarString |
|
455 |
poolDictionaries:pool |
|
456 |
category:ownerClass category |
|
457 |
comment:nil |
|
458 |
changed:true |
|
459 |
] |
|
460 |
||
461 |
"Modified: / 3.1.1997 / 16:00:39 / cg" |
|
462 |
"Modified: / 18.3.1999 / 18:30:07 / stefan" |
|
463 |
! ! |
|
464 |
||
695 | 465 |
!UndefinedObject methodsFor:'testing'! |
466 |
||
1868 | 467 |
? defaultValue |
3466 | 468 |
"a syntactic shugar-piece: |
469 |
if the receiver is nil, return the defaultValue; |
|
1868 | 470 |
otherwise, return the receiver. |
471 |
This method is redefined from Object; |
|
472 |
the argument is retuned unconditionally here. |
|
473 |
||
1958 | 474 |
Thus, if foo and bar are simple variables or constants, |
475 |
foo ? bar |
|
476 |
is the same as: |
|
477 |
(foo isNil ifTrue:[bar] ifFalse:[foo]) |
|
478 |
||
479 |
if they are message sends, the equivalent code is: |
|
480 |
[ |
|
481 |
|t1 t2| |
|
482 |
||
483 |
t1 := foo. |
|
484 |
t2 := bar. |
|
485 |
t1 isNil ifTrue:[t2] ifFalse:[t1] |
|
486 |
] value |
|
487 |
||
1868 | 488 |
Can be used to provide defaultValues to variables, |
489 |
as in: |
|
1958 | 490 |
foo := arg ? #defaultValue |
1868 | 491 |
" |
492 |
||
493 |
^ defaultValue |
|
494 |
||
495 |
" |
|
496 |
1 ? #default |
|
497 |
nil ? #default |
|
498 |
" |
|
499 |
||
3466 | 500 |
"Created: / 4.11.1996 / 20:37:09 / cg" |
501 |
"Modified: / 19.5.1998 / 17:39:36 / cg" |
|
1868 | 502 |
! |
503 |
||
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
504 |
?? defaultValue |
11635 | 505 |
"a syntactic sugar-piece: |
3466 | 506 |
much like ?, but sends value to the argument if required. |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
507 |
If the receiver is nil, return the defaultValues value; |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
508 |
otherwise, return the receiver. |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
509 |
This method is redefined from Object. |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
510 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
511 |
Thus, if foo and bar are simple variables or constants, |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
512 |
foo ?? bar |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
513 |
is the same as: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
514 |
(foo isNil ifTrue:[bar value] ifFalse:[foo]) |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
515 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
516 |
if they are message sends, the equivalent code is: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
517 |
[ |
3466 | 518 |
|t| |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
519 |
|
3466 | 520 |
t := foo. |
521 |
t isNil ifTrue:[bar value] ifFalse:[t] |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
522 |
] value |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
523 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
524 |
Can be used to provide defaultValues to variables, |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
525 |
as in: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
526 |
foo := arg ?? [something] |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
527 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
528 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
529 |
^ defaultValue value |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
530 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
531 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
532 |
1 ?? #default |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
533 |
nil ?? #default |
6069 | 534 |
1 ?? [Date today] |
535 |
nil ?? [Date today] |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
536 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
537 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
538 |
"Created: / 4.11.1996 / 20:37:09 / cg" |
3466 | 539 |
"Modified: / 19.5.1998 / 17:42:10 / cg" |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
540 |
! |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
541 |
|
7108
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
542 |
checkNilFileStream |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
543 |
"Do nothing if this is a valid FileStream |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
544 |
(i.e. the previous open operation was successful). |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
545 |
Also implemented in UndefinedObject, to raise an Error there. |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
546 |
|
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
547 |
This is an aid for converting from the old error reporting (returning nil) |
11635 | 548 |
to the new error reporting (with real Exceptions). |
7108
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
549 |
|
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
550 |
It will vanish as soon as the conversion has been done" |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
551 |
|
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
552 |
^ ExternalStream openErrorSignal raise |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
553 |
! |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
554 |
|
695 | 555 |
hash |
556 |
"return an integer useful as a hash key" |
|
557 |
||
558 |
^ 0 |
|
559 |
! |
|
560 |
||
561 |
identityHash |
|
562 |
"return an integer useful as a hash key" |
|
563 |
||
564 |
^ 0 |
|
565 |
! |
|
566 |
||
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
567 |
ifNil:aBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
568 |
"return myself, or the result from evaluating the argument, if I am nil. |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
569 |
This is much like #?, but sends #value to the argument in case of a nil |
5796 | 570 |
receiver. |
571 |
Notice: |
|
572 |
This method is open coded (inlined) by the compiler(s) |
|
573 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
574 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
575 |
^ aBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
576 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
577 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
578 |
ifNil:nilBlockOrValue ifNotNil:notNilBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
579 |
"return the value of the first arg, if I am nil, |
5796 | 580 |
the result from evaluating the 2nd argument, if I am not nil. |
581 |
Notice: |
|
582 |
This method is open coded (inlined) by the compiler(s) |
|
583 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
584 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
585 |
^ nilBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
586 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
587 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
588 |
ifNotNil:aBlockOrValue |
5796 | 589 |
"return myself if nil, or the result from evaluating the argument, if I am not nil. |
590 |
Notice: |
|
591 |
This method is open coded (inlined) by the compiler(s) |
|
592 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
593 |
|
8574 | 594 |
^ nil |
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
595 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
596 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
597 |
ifNotNil:notNilBlockOrValue ifNil:nilBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
598 |
"return the value of the 2nd arg, if I am nil, |
5796 | 599 |
the result from evaluating the 1st argument, if I am not nil. |
600 |
Notice: |
|
601 |
This method is open coded (inlined) by the compiler(s) |
|
602 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
603 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
604 |
^ nilBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
605 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
606 |
|
8574 | 607 |
ifNotNilDo:aBlock |
608 |
"if the reciever is non-nil, return the value of aBlock, passing myself as argument. |
|
609 |
Otherwise do nothing and return nil." |
|
610 |
||
611 |
^ nil |
|
612 |
! |
|
613 |
||
6181 | 614 |
isEmptyOrNil |
8833 | 615 |
"return true if I am nil or an empty collection - since I am nil, return true. |
616 |
(from Sqeak)" |
|
6181 | 617 |
|
618 |
^ true |
|
619 |
||
620 |
"Created: / 13.11.2001 / 13:16:40 / cg" |
|
6182 | 621 |
"Modified: / 13.11.2001 / 13:28:47 / cg" |
6181 | 622 |
! |
623 |
||
695 | 624 |
isLiteral |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
625 |
"return true, if the receiver can be used as a literal constant in ST syntax |
695 | 626 |
(i.e. can be used in constant arrays)" |
77 | 627 |
|
695 | 628 |
^ true |
629 |
! |
|
630 |
||
631 |
isNil |
|
9223 | 632 |
"Return true, if the receiver is nil. |
633 |
Since I am definitely nil, unconditionally return true here. |
|
3044 | 634 |
Notice: |
9223 | 635 |
This method is open coded (inlined) by the compiler(s) |
636 |
- redefining it may not work as expected." |
|
695 | 637 |
|
638 |
^ true |
|
639 |
! |
|
640 |
||
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
641 |
isNilOrEmptyCollection |
8833 | 642 |
"return true if I am nil or an empty collection - false here. |
643 |
Obsolete, use isEmptyOrNil." |
|
644 |
||
645 |
<resource:#obsolete> |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
646 |
|
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
647 |
^ true |
6182 | 648 |
|
649 |
"Modified: / 13.11.2001 / 13:28:15 / cg" |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
650 |
! |
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
651 |
|
6932 | 652 |
notEmptyOrNil |
653 |
"Squeak compatibility: |
|
654 |
return true if I am neither nil nor an empty collection." |
|
655 |
||
656 |
^ false |
|
657 |
! |
|
658 |
||
695 | 659 |
notNil |
9223 | 660 |
"Return true, if the receiver is not nil. |
661 |
Since I am definitely nil, unconditionally return false here. |
|
3044 | 662 |
Notice: |
9223 | 663 |
This method is open coded (inlined) by the compiler(s) |
664 |
- redefining it may not work as expected." |
|
77 | 665 |
|
695 | 666 |
^ false |
77 | 667 |
! ! |
695 | 668 |
|
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
669 |
!UndefinedObject methodsFor:'tracing'! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
670 |
|
4682 | 671 |
traceInto:aRequestor level:level from:referrer |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
672 |
"double dispatch into tracer, passing my type implicitely in the selector" |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
673 |
|
4682 | 674 |
^ aRequestor traceUndefinedObject:self level:level from:referrer |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
675 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
676 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
677 |
! ! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
678 |
|
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
679 |
!UndefinedObject methodsFor:'visiting'! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
680 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
681 |
acceptVisitor:aVisitor with:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
682 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
683 |
^ aVisitor visitNilWith:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
684 |
! ! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
685 |
|
695 | 686 |
!UndefinedObject class methodsFor:'documentation'! |
687 |
||
688 |
version |
|
11635 | 689 |
^ '$Header: /cvs/stx/stx/libbasic/UndefinedObject.st,v 1.69 2009-03-17 16:00:12 stefan Exp $' |
695 | 690 |
! ! |
6932 | 691 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
692 |
UndefinedObject initialize! |