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