author | Claus Gittinger <cg@exept.de> |
Tue, 25 Feb 1997 19:20:23 +0100 | |
changeset 2416 | 588d5d510c10 |
parent 2040 | 8ba8b1002902 |
child 2672 | dc3662188b2c |
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 |
||
13 |
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
|
14 |
instanceVariableNames:'' |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
15 |
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
|
16 |
poolDictionaries:'' |
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
17 |
category:'Kernel-Objects' |
1 | 18 |
! |
19 |
||
88 | 20 |
!UndefinedObject class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 25 |
All Rights Reserved |
1 | 26 |
|
88 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
1303 | 38 |
there is only one instance of this class: nil, |
39 |
representing an undefined or otherwise unspecified object. |
|
88 | 40 |
|
41 |
All instance variables, array elements and even method/block local |
|
42 |
variables are initially set to nil. |
|
1303 | 43 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
44 |
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
|
45 |
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
|
46 |
and no subclassing is possible. |
1303 | 47 |
(to be exact: subclassing UndefinedObject is technically possible, |
48 |
but instances of it would not be recognized as being nil |
|
49 |
- therefore, subclassing is blocked and an error is raised when it is tried) |
|
50 |
||
51 |
For advanced users: |
|
52 |
Beside the above role, nil can be subclassed (!!). |
|
53 |
This creates a class which inherits no protocol whatsoever - not even |
|
54 |
the basic interfaces as defined by the Object class. Subclasses of nil |
|
55 |
are useful if all messages send to instances should trap into the |
|
56 |
#doesNotUnderstand: method. For example, proxy objects are typically defined |
|
57 |
this way. |
|
1294 | 58 |
|
59 |
[author:] |
|
60 |
Claus Gittinger |
|
88 | 61 |
" |
62 |
! ! |
|
1 | 63 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
64 |
!UndefinedObject class methodsFor:'initialization'! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
65 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
66 |
initialize |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
67 |
CreateMinimumProtocolInNewSubclassQuery isNil ifTrue:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
68 |
CreateMinimumProtocolInNewSubclassQuery := QuerySignal new. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
69 |
CreateMinimumProtocolInNewSubclassQuery nameClass:self message:#createMinimumProtocolInNewSubclassQuery. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
70 |
CreateMinimumProtocolInNewSubclassQuery defaultAnswer:false. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
71 |
]. |
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 |
UndefinedObject initialize |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
75 |
" |
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 |
"Created: 3.1.1997 / 15:02:40 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
78 |
"Modified: 3.1.1997 / 15:18:33 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
79 |
! ! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
80 |
|
1 | 81 |
!UndefinedObject class methodsFor:'instance creation'! |
82 |
||
83 |
basicNew |
|
84 |
"catch new - there MUST be only one nil in the system" |
|
85 |
||
86 |
^ nil |
|
87 |
! |
|
88 |
||
89 |
basicNew:size |
|
90 |
"catch new - there MUST be only one nil in the system" |
|
91 |
||
92 |
^ nil |
|
93 |
! ! |
|
94 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
95 |
!UndefinedObject class methodsFor:'Signal constants'! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
96 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
97 |
createMinimumProtocolInNewSubclassQuery |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
98 |
"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
|
99 |
should be created for nil subclasses. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
100 |
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
|
101 |
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
|
102 |
some methods which the inspector needs." |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
103 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
104 |
^ CreateMinimumProtocolInNewSubclassQuery |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
105 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
106 |
"Created: 3.1.1997 / 15:05:48 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
107 |
"Modified: 3.1.1997 / 15:06:15 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
108 |
! ! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
109 |
|
51 | 110 |
!UndefinedObject class methodsFor:'queries'! |
111 |
||
112 |
canBeSubclassed |
|
113 |
"return true, if its allowed to create subclasses of the receiver. |
|
114 |
Return nil here - since it is NOT possible for UndefinedObject" |
|
115 |
||
116 |
^ false |
|
117 |
! ! |
|
118 |
||
2416 | 119 |
!UndefinedObject methodsFor:'converting'! |
120 |
||
121 |
decodeAsLiteralArray |
|
122 |
"given a literalEncoding in the receiver, |
|
123 |
create & return the corresponding object. |
|
124 |
The inverse operation to #literalArrayEncoding." |
|
125 |
||
126 |
^ self |
|
127 |
||
128 |
"Created: 25.2.1997 / 19:18:40 / cg" |
|
129 |
! |
|
130 |
||
131 |
literalArrayEncoding |
|
132 |
"encode myself as an array literal, from which a copy of the receiver |
|
133 |
can be reconstructed with #decodeAsLiteralArray." |
|
134 |
||
135 |
^ self |
|
136 |
||
137 |
"Created: 25.2.1997 / 19:18:47 / cg" |
|
138 |
! ! |
|
139 |
||
695 | 140 |
!UndefinedObject methodsFor:'copying'! |
141 |
||
142 |
copy |
|
143 |
"return a shallow copy of myself |
|
144 |
- since there is only one nil in the system return self" |
|
145 |
||
146 |
^ self |
|
147 |
! |
|
148 |
||
149 |
deepCopy |
|
150 |
"return a deep copy of myself |
|
151 |
- since there is only one nil in the system return self" |
|
152 |
||
153 |
^ self |
|
154 |
! |
|
155 |
||
156 |
deepCopyUsing:aDictionary |
|
157 |
"return a deep copy of myself |
|
158 |
- since there is only one nil in the system return self" |
|
159 |
||
160 |
^ self |
|
161 |
! |
|
162 |
||
163 |
shallowCopy |
|
164 |
"return a shallow copy of myself |
|
165 |
- since there is only one nil in the system return self" |
|
166 |
||
167 |
^ self |
|
168 |
! |
|
169 |
||
170 |
simpleDeepCopy |
|
171 |
"return a deep copy of myself |
|
172 |
- since there is only one nil in the system return self" |
|
173 |
||
174 |
^ self |
|
175 |
! ! |
|
176 |
||
1 | 177 |
!UndefinedObject methodsFor:'error catching'! |
178 |
||
179 |
basicAt:index |
|
180 |
"catch array access - its illegal |
|
181 |
defined here since basicAt: in Object ommits the nil-check" |
|
182 |
||
183 |
^ self notIndexed |
|
184 |
! |
|
185 |
||
186 |
basicAt:index put:anObject |
|
187 |
"catch array access - its illegal |
|
188 |
defined here since basicAt:put: in Object ommits the nil-check" |
|
189 |
||
190 |
^ self notIndexed |
|
191 |
! ! |
|
192 |
||
193 |
!UndefinedObject methodsFor:'printing & storing'! |
|
194 |
||
63 | 195 |
printOn:aStream |
196 |
"append a printed representation of the receiver to the |
|
197 |
argument, aStream" |
|
198 |
||
199 |
aStream nextPutAll:'nil' |
|
200 |
! |
|
201 |
||
695 | 202 |
printString |
203 |
"return a string for printing myself" |
|
204 |
||
205 |
^ 'nil' |
|
206 |
! |
|
207 |
||
63 | 208 |
storeOn:aStream |
209 |
"append a printed representation of the receiver to the |
|
210 |
argument, aStream, which allows reconstruction of it" |
|
211 |
||
212 |
^ self printOn:aStream |
|
695 | 213 |
! |
214 |
||
215 |
storeString |
|
216 |
"return a string for storing myself" |
|
217 |
||
218 |
^ 'nil' |
|
1 | 219 |
! ! |
2 | 220 |
|
77 | 221 |
!UndefinedObject methodsFor:'subclass creation'! |
222 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
223 |
nilSubclass:action |
356 | 224 |
"common helper for subclass creation. |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
225 |
Creates a nil-superclass class. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
226 |
If the CreateMinimumProtocolInNewSubclassQuery answers true, |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
227 |
entries for the minimum required protocol (#class, #isBehavior |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
228 |
and #doesNotUnderstand:) are also automatically created. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
229 |
(this query is typically answered by the browser) |
356 | 230 |
These are required to avoid getting into deep trouble when |
231 |
inspecting or debugging instances of this new class. |
|
232 |
The methods get a modified source code to remind you that these |
|
233 |
methods were automatically generated." |
|
234 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
235 |
|newClass methodDict method| |
202 | 236 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
237 |
Class withoutUpdatingChangesDo:[ |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
238 |
newClass := action value |
77 | 239 |
]. |
240 |
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
|
241 |
newClass setSuperclass:nil. |
1803
754f9205b651
meta's superclass should be class - not Object.
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
242 |
newClass class setSuperclass:Class. |
356 | 243 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
244 |
newClass methodDictionary size == 0 ifTrue:[ |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
245 |
Class addChangeRecordForClass:newClass. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
246 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
247 |
CreateMinimumProtocolInNewSubclassQuery raise |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
248 |
ifTrue:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
249 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
250 |
copy over method objects from Object |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
251 |
and modify the source code |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
252 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
253 |
methodDict := MethodDictionary new:3. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
254 |
#(#class #isBehavior #doesNotUnderstand:) do:[:sel| |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
255 |
method := (Object compiledMethodAt:sel) copy. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
256 |
method source: method source , ' |
356 | 257 |
" |
258 |
*** WARNING |
|
259 |
*** |
|
260 |
*** this method has been automatically created, |
|
261 |
*** since all nil-subclasses should respond to some minimum required |
|
262 |
*** protocol. |
|
263 |
*** |
|
264 |
*** Inspection and/or debugging of instances may not be possible, |
|
265 |
*** if you remove/change this method. |
|
266 |
" |
|
267 |
'. |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
268 |
methodDict at:sel put:method. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
269 |
"/ newClass addChangeRecordForMethod:method |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
270 |
]. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
271 |
newClass methodDictionary:methodDict. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
272 |
] |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
273 |
] |
77 | 274 |
]. |
275 |
^ newClass |
|
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
276 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
277 |
"Modified: 12.6.1996 / 10:46:15 / stefan" |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
278 |
"Modified: 3.1.1997 / 15:53:21 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
279 |
"Created: 3.1.1997 / 16:00:34 / cg" |
202 | 280 |
! |
281 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
282 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
202 | 283 |
"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
|
284 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
202 | 285 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
286 |
^ self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
287 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
288 |
Object class |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
289 |
name:nameSymbol |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
290 |
inEnvironment:(Class nameSpaceQuerySignal raise) |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
291 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
292 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
293 |
variable:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
294 |
words:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
295 |
pointers:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
296 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
297 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
298 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
299 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
300 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
301 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
302 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
303 |
"Modified: 3.1.1997 / 16:00:39 / cg" |
695 | 304 |
! |
305 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
306 |
variableByteSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
695 | 307 |
"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
|
308 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
695 | 309 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
310 |
^ self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
311 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
312 |
Object class |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
313 |
name:nameSymbol |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
314 |
inEnvironment:(Class nameSpaceQuerySignal raise) |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
315 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
316 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
317 |
variable:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
318 |
words:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
319 |
pointers:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
320 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
321 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
322 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
323 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
324 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
325 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
326 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
327 |
"Modified: 3.1.1997 / 16:00:42 / cg" |
695 | 328 |
! |
77 | 329 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
330 |
variableSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
159 | 331 |
"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
|
332 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
77 | 333 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
334 |
^ self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
335 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
336 |
Object class |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
337 |
name:nameSymbol |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
338 |
inEnvironment:(Class nameSpaceQuerySignal raise) |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
339 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
340 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
341 |
variable:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
342 |
words:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
343 |
pointers:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
344 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
345 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
346 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
347 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
348 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
349 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
350 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
351 |
"Modified: 3.1.1997 / 16:00:45 / cg" |
695 | 352 |
! ! |
353 |
||
354 |
!UndefinedObject methodsFor:'testing'! |
|
355 |
||
1868 | 356 |
? defaultValue |
357 |
"if the receiver is nil, return the defaultValue; |
|
358 |
otherwise, return the receiver. |
|
359 |
This method is redefined from Object; |
|
360 |
the argument is retuned unconditionally here. |
|
361 |
||
1958 | 362 |
Thus, if foo and bar are simple variables or constants, |
363 |
foo ? bar |
|
364 |
is the same as: |
|
365 |
(foo isNil ifTrue:[bar] ifFalse:[foo]) |
|
366 |
||
367 |
if they are message sends, the equivalent code is: |
|
368 |
[ |
|
369 |
|t1 t2| |
|
370 |
||
371 |
t1 := foo. |
|
372 |
t2 := bar. |
|
373 |
t1 isNil ifTrue:[t2] ifFalse:[t1] |
|
374 |
] value |
|
375 |
||
1868 | 376 |
Can be used to provide defaultValues to variables, |
377 |
as in: |
|
1958 | 378 |
foo := arg ? #defaultValue |
1868 | 379 |
" |
380 |
||
381 |
^ defaultValue |
|
382 |
||
383 |
" |
|
384 |
1 ? #default |
|
385 |
nil ? #default |
|
386 |
" |
|
387 |
||
388 |
"Created: 4.11.1996 / 20:37:09 / cg" |
|
1958 | 389 |
"Modified: 10.11.1996 / 18:37:13 / cg" |
1868 | 390 |
! |
391 |
||
695 | 392 |
basicSize |
393 |
"return the number of indexed instvars |
|
394 |
defined here since size in Object ommits the nil-check" |
|
395 |
||
396 |
^ 0 |
|
397 |
! |
|
398 |
||
399 |
hash |
|
400 |
"return an integer useful as a hash key" |
|
401 |
||
402 |
^ 0 |
|
403 |
! |
|
404 |
||
405 |
identityHash |
|
406 |
"return an integer useful as a hash key" |
|
407 |
||
408 |
^ 0 |
|
409 |
! |
|
410 |
||
411 |
isLiteral |
|
412 |
"return true, if the receiver can be used as a literal |
|
413 |
(i.e. can be used in constant arrays)" |
|
77 | 414 |
|
695 | 415 |
^ true |
416 |
! |
|
417 |
||
418 |
isNil |
|
419 |
"return true if I am nil - since I am, return true" |
|
420 |
||
421 |
^ true |
|
422 |
! |
|
423 |
||
424 |
notNil |
|
425 |
"return true if I am not nil - since I am nil, return false" |
|
77 | 426 |
|
695 | 427 |
^ false |
428 |
! |
|
429 |
||
430 |
size |
|
431 |
"return the number of indexed instvars |
|
432 |
defined here since size in Object ommits the nil-check" |
|
433 |
||
434 |
^ 0 |
|
77 | 435 |
! ! |
695 | 436 |
|
437 |
!UndefinedObject class methodsFor:'documentation'! |
|
438 |
||
439 |
version |
|
2416 | 440 |
^ '$Header: /cvs/stx/stx/libbasic/UndefinedObject.st,v 1.30 1997-02-25 18:19:01 cg Exp $' |
695 | 441 |
! ! |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
442 |
UndefinedObject initialize! |