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